idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
5,700 | public Collection < BrowserApplication > list ( List < String > queryParams ) { return HTTP . GET ( "/v2/browser_applications.json" , null , queryParams , BROWSER_APPLICATIONS ) . get ( ) ; } | Returns the set of Browser applications with the given query parameters . |
5,701 | public Collection < BrowserApplication > list ( String name ) { List < BrowserApplication > ret = new ArrayList < BrowserApplication > ( ) ; Collection < BrowserApplication > applications = list ( ) ; for ( BrowserApplication application : applications ) { if ( name == null || application . getName ( ) . equals ( name ... | Returns the set of Browser applications for the given name . |
5,702 | public Optional < BrowserApplication > show ( long applicationId ) { QueryParameterList queryParams = new QueryParameterList ( ) ; queryParams . add ( "filter[ids]" , new Long ( applicationId ) ) ; return Optional . of ( HTTP . GET ( "/v2/browser_applications.json" , null , queryParams , BROWSER_APPLICATIONS ) . get ( ... | Returns the Browser application for the given application id . |
5,703 | public Collection < PartnerAccount > list ( long partnerId ) { return HTTP . GET ( String . format ( "/v2/partners/%d/accounts" , partnerId ) , PARTNER_ACCOUNTS ) . get ( ) ; } | Returns the set of accounts . |
5,704 | public Optional < PartnerAccount > show ( long partnerId , long accountId ) { return HTTP . GET ( String . format ( "/v2/partners/%d/accounts/%d" , partnerId , accountId ) , PARTNER_ACCOUNT ) ; } | Returns the account with the given id . |
5,705 | public Optional < PartnerAccount > create ( long partnerId , PartnerAccount account ) { return HTTP . POST ( String . format ( "/v2/partners/%d/accounts" , partnerId ) , account , PARTNER_ACCOUNT ) ; } | Creates the given account . |
5,706 | public Optional < PartnerAccount > update ( long partnerId , PartnerAccount account ) { return HTTP . PUT ( String . format ( "/v2/partners/%d/accounts/%d" , partnerId , account . getId ( ) ) , account , PARTNER_ACCOUNT ) ; } | Updates the given account . |
5,707 | public PartnerAccountService delete ( long partnerId , long accountId ) { HTTP . DELETE ( String . format ( "/v2/partners/%d/accounts/%d" , partnerId , accountId ) ) ; return this ; } | Deletes the account with the given id . |
5,708 | public void writeTo ( Object object , Class < ? > type , Type genericType , Annotation [ ] annotations , MediaType mediaType , MultivaluedMap < String , Object > httpHeaders , OutputStream entityStream ) throws IOException , WebApplicationException { OutputStreamWriter outputStreamWriter = null ; try { outputStreamWrit... | Write a type to a HTTP message . |
5,709 | public Object readFrom ( Class < Object > type , Type genericType , Annotation [ ] annotations , MediaType mediaType , MultivaluedMap < String , String > httpHeaders , InputStream inputStream ) throws IOException , WebApplicationException { String json = null ; Object result = null ; InputStreamReader inputStreamReader... | Read a type from the InputStream . |
5,710 | private Type getAppropriateType ( Class < ? > type , Type genericType ) { return type . equals ( genericType ) ? type : genericType ; } | Returns the type of the given class . |
5,711 | private static String getStringFromInputStream ( InputStream is ) { BufferedReader br = null ; StringBuilder sb = new StringBuilder ( ) ; String line ; try { br = new BufferedReader ( new InputStreamReader ( is ) ) ; while ( ( line = br . readLine ( ) ) != null ) { sb . append ( line ) ; } } catch ( IOException e ) { l... | Extracts the string from the given input stream . |
5,712 | public void filter ( ClientRequestContext request ) throws IOException { if ( ! request . getHeaders ( ) . containsKey ( "X-License-Key" ) ) request . getHeaders ( ) . add ( "X-License-Key" , this . licensekey ) ; } | Adds the License key to the client request . |
5,713 | public long [ ] getEntitiesArray ( ) { long [ ] ret = new long [ entities . size ( ) ] ; for ( int i = 0 ; i < entities . size ( ) ; i ++ ) ret [ i ] = entities . get ( i ) ; return ret ; } | Returns the array of entities for the condition . |
5,714 | public void addEventType ( String eventType ) { if ( this . eventTypes == null ) this . eventTypes = new ArrayList < String > ( ) ; this . eventTypes . add ( eventType ) ; } | Adds an event type to the dashboard filter . |
5,715 | public void addAttribute ( String attribute ) { if ( this . attributes == null ) this . attributes = new ArrayList < String > ( ) ; this . attributes . add ( attribute ) ; } | Adds an attribute to the dashboard filter . |
5,716 | public boolean getAttributeBoolean ( ScoreAttribute sa ) { if ( ! ( sa . getDefaultValue ( ) instanceof Boolean ) ) throw new RuntimeException ( sa . toString ( ) + " is not a boolean attribute" ) ; return ( Boolean ) getAttributeObject ( sa ) ; } | Returns the boolean value associated to an attribute |
5,717 | public double getAttributeNumber ( ScoreAttribute sa ) { if ( ! ( sa . getDefaultValue ( ) instanceof Number ) ) throw new RuntimeException ( sa . toString ( ) + " is not a number attribute" ) ; return ( ( Number ) getAttributeObject ( sa ) ) . doubleValue ( ) ; } | Returns the number value associated to an attribute as a double . |
5,718 | public Object getAttributeObject ( ScoreAttribute sa ) { Object ret = m_attributes . get ( sa . getName ( ) ) ; if ( ret == null ) ret = sa . getDefaultValue ( ) ; return ret ; } | Returns the object associated to an attribute |
5,719 | public float getAttributeSize ( ScoreAttribute sa ) throws AttributeNotDefinedException , RuntimeException { if ( ! ( sa . getDefaultValue ( ) instanceof ScoreAttribute . Size ) ) throw new RuntimeException ( sa . toString ( ) + " is not a size attribute" ) ; ScoreAttribute . Size s = ( ScoreAttribute . Size ) getAttri... | Gets the size of an attribute calculated from score metrics if needed . |
5,720 | public float getDefaultTextSize ( ) { ScoreAttribute . Size s = ( ScoreAttribute . Size ) getAttributeObject ( ScoreAttribute . TEXT_DEFAULT_SIZE ) ; if ( s . getUnit ( ) . equals ( SizeUnit . PT ) ) return s . getSize ( ) ; else { return ( s . getSize ( ) / 100f ) * getAttributeSize ( ScoreAttribute . NOTATION_SIZE ) ... | Returns the default text size in pt . |
5,721 | public Color getElementColor ( byte scoreElement ) { Object ret = m_attributes . get ( "COLOR_" + Byte . toString ( scoreElement ) ) ; if ( ret == null ) { ret = m_attributes . get ( "COLOR_" + Byte . toString ( ScoreElements . _DEFAULT ) ) ; if ( ret == null ) return null ; } return ( Color ) ret ; } | Returns the color of the given element |
5,722 | public byte [ ] getFieldsAtPosition ( byte vert , byte horiz ) { Position p = new Position ( vert , horiz ) ; if ( m_fieldsPosition . get ( p ) != null ) { Vector v = ( Vector ) m_fieldsPosition . get ( p ) ; Vector ret = new Vector ( v . size ( ) ) ; for ( Object aV : v ) { byte field = ( Byte ) aV ; if ( isVisible ( ... | Returns the list of visible fields at the given position |
5,723 | public byte [ ] getPosition ( byte field ) { Iterator it = m_fieldsPosition . keySet ( ) . iterator ( ) ; Byte B = field ; while ( it . hasNext ( ) ) { Position p = ( Position ) it . next ( ) ; if ( ( ( Vector ) m_fieldsPosition . get ( p ) ) . contains ( B ) ) { return new byte [ ] { p . m_vertical , p . m_horizontal ... | Returns position of a field |
5,724 | public Font getTextFont ( byte field ) { FieldInfos fi = getFieldInfos ( field ) ; Vector v = new Vector ( m_defaultTextFontFamilyNames . length + fi . m_fontFamilyNames . length ) ; Collections . addAll ( v , fi . m_fontFamilyNames ) ; Collections . addAll ( v , m_defaultTextFontFamilyNames ) ; Iterator it = v . itera... | Returns the styled and sized font for a field . |
5,725 | public float getTextSize ( byte field ) { FieldInfos fi = getFieldInfos ( field ) ; if ( fi . m_fontSizeUnit . equals ( SizeUnit . PT ) ) return fi . m_fontSize ; else return getDefaultTextSize ( ) * ( fi . m_fontSize / 100f ) ; } | Returns the font size of a field in pt |
5,726 | public void setAttribute ( ScoreAttribute sa , Object value ) { if ( value == null ) m_attributes . remove ( sa . getName ( ) ) ; else m_attributes . put ( sa . getName ( ) , value ) ; notifyListeners ( ) ; } | Sets the object associated to an attribute |
5,727 | public void setAttributeSize ( ScoreAttribute sa , float size ) { m_attributes . put ( sa . getName ( ) , new ScoreAttribute . Size ( size , ( ( ScoreAttribute . Size ) sa . getDefaultValue ( ) ) . getUnit ( ) ) ) ; notifyListeners ( ) ; } | Sets the size associated to an attribute using the attribute s default unit |
5,728 | public void setAttributeSize ( ScoreAttribute sa , float size , SizeUnit unit ) { if ( ! ( sa . getDefaultValue ( ) instanceof ScoreAttribute . Size ) ) throw new RuntimeException ( sa . toString ( ) + " is not a size attribute" ) ; m_attributes . put ( sa . getName ( ) , new ScoreAttribute . Size ( size , unit ) ) ; n... | Sets the size associated to an attribute |
5,729 | public void setDefaultTextFontFamilyName ( String [ ] faces ) { if ( ( faces != null ) && ( faces . length > 0 ) ) m_defaultTextFontFamilyNames = faces ; else m_defaultTextFontFamilyNames = new String [ ] { "Dialog" } ; notifyListeners ( ) ; } | Set the default font faces in order of preference . |
5,730 | public void setElementColor ( byte scoreElement , Color color ) { String name = "COLOR_" + Byte . toString ( scoreElement ) ; if ( color == null ) m_attributes . remove ( name ) ; else m_attributes . put ( name , color ) ; notifyListeners ( ) ; } | Sets the color of the given element type |
5,731 | public void setPosition ( byte [ ] fields , byte vert , byte horiz ) { for ( byte field : fields ) { setVisible ( field , true ) ; Position p = new Position ( vert , horiz ) ; byte [ ] p1f = getPosition ( field ) ; Position p1 = p1f == null ? null : new Position ( p1f [ 0 ] , p1f [ 1 ] ) ; if ( ! p . equals ( p1 ) ) { ... | Sets the position of several fields |
5,732 | public void setTextAttributes ( byte [ ] fields , Hashtable attrib ) { for ( byte field : fields ) { getFieldInfos ( field ) . m_textAttributes = attrib ; } notifyListeners ( ) ; } | Sets the text attributes of several fields |
5,733 | public void setTextFontFamilyName ( byte [ ] fields , String [ ] fontFamilies ) { if ( fontFamilies == null ) fontFamilies = new String [ 0 ] ; for ( byte field : fields ) { getFieldInfos ( field ) . m_fontFamilyNames = fontFamilies ; } notifyListeners ( ) ; } | Sets the font family of several fields |
5,734 | public void setTextSize ( byte field , float size , SizeUnit unit ) { FieldInfos fi = getFieldInfos ( field ) ; fi . m_fontSize = size ; fi . m_fontSizeUnit = unit ; notifyListeners ( ) ; } | Sets the font size of a field |
5,735 | public void setTextStyle ( byte [ ] fields , int style ) { for ( byte field : fields ) { getFieldInfos ( field ) . m_fontStyle = style ; } notifyListeners ( ) ; } | Sets the font style of several fields |
5,736 | public void setVisible ( byte [ ] fields , boolean visible ) { for ( byte field : fields ) { getFieldInfos ( field ) . m_visible = visible ; } notifyListeners ( ) ; } | Sets the visibility of several fields |
5,737 | public Collection < AlertEvent > list ( List < String > queryParams ) { return HTTP . GET ( "/v2/alerts_events.json" , null , queryParams , ALERT_EVENTS ) . get ( ) ; } | Returns the set of alert events with the given query parameters . |
5,738 | public Collection < Monitor > list ( Label label ) { return HTTP . GET ( String . format ( "/v1/monitors/labels/%s" , label . getKey ( ) ) , MONITORS ) . get ( ) ; } | Returns the set of monitors for the given label . |
5,739 | public Optional < Monitor > show ( String monitorId ) { return HTTP . GET ( String . format ( "/v3/monitors/%s" , monitorId ) , MONITOR ) ; } | Returns the monitor for the given monitor id . |
5,740 | public Optional < Script > showScript ( String monitorId ) { return HTTP . GET ( String . format ( "/v3/monitors/%s/script" , monitorId ) , SCRIPT ) ; } | Returns the script for the given monitor id . |
5,741 | public Optional < Monitor > create ( Monitor monitor ) { Response obj = HTTP . POST ( "/v3/monitors" , monitor ) . get ( ) ; String location = obj . getStringHeaders ( ) . getFirst ( "location" ) ; if ( location != null ) monitor . setId ( location . substring ( location . lastIndexOf ( "/" ) + 1 ) ) ; return Optional ... | Creates the given monitor . |
5,742 | public Optional < Monitor > update ( Monitor monitor ) { HTTP . PUT ( String . format ( "/v3/monitors/%s" , monitor . getId ( ) ) , monitor ) ; return Optional . of ( monitor ) ; } | Updates the given monitor . |
5,743 | public Optional < Script > updateScript ( String monitorId , Script script ) { HTTP . PUT ( String . format ( "/v3/monitors/%s/script" , monitorId ) , script ) ; return Optional . of ( script ) ; } | Updates the given monitor to add a script . |
5,744 | public Optional < Monitor > patch ( Monitor monitor ) { HTTP . PATCH ( String . format ( "/v3/monitors/%s" , monitor . getId ( ) ) , monitor ) ; return Optional . of ( monitor ) ; } | Patches the given monitor . |
5,745 | public Optional < Label > createLabel ( String monitorId , Label label ) { HTTP . POST ( String . format ( "/v1/monitors/%s/labels" , monitorId ) , label . getKey ( ) ) ; return Optional . of ( label ) ; } | Adds the given label to the monitor with the given id . |
5,746 | public MonitorService deleteLabel ( String monitorId , Label label ) { HTTP . DELETE ( String . format ( "/v1/monitors/%s/labels/%s" , monitorId , label . getKey ( ) ) ) ; return this ; } | Deletes the given label from the monitor with the given id . |
5,747 | public void append ( Music music ) { if ( ! music . m_partLabel . equals ( " " ) ) { for ( Object m_voice : m_voices ) { ( ( Voice ) m_voice ) . addElement ( new PartLabel ( music . m_partLabel ) ) ; } } for ( Object o : music . getVoices ( ) ) { Voice v = ( Voice ) o ; if ( ! voiceExists ( v . getVoiceName ( ) ) ) { V... | Concatene the given music object to current one |
5,748 | public Voice getVoice ( String voiceName ) { for ( Object m_voice : m_voices ) { Voice v = ( Voice ) m_voice ; if ( v . getVoiceName ( ) . equals ( voiceName ) ) return v ; } Voice v = new Voice ( voiceName , m_firstBarNumber ) ; v . setPartLabel ( m_partLabel ) ; m_voices . add ( v ) ; return v ; } | Returns the asked voice create it if needed . |
5,749 | public void addToAllVoices ( MusicElement element ) { for ( Object m_voice : m_voices ) { Voice v = ( Voice ) m_voice ; v . addElement ( element ) ; } } | Maybe could be used ... ? add an element to all voices be sure to add it first in the voice are last when all elements have been added ... |
5,750 | public MusicElement getElementAtStreamPosition ( int offset ) { Iterator it = m_voices . iterator ( ) ; CharStreamPosition pos ; while ( it . hasNext ( ) ) { Voice v = ( Voice ) it . next ( ) ; int size = v . size ( ) ; MusicElement current = null ; for ( int i = 0 ; i < size ; i ++ ) { current = ( MusicElement ) v . e... | Returns the score element location at the specified offset . |
5,751 | public byte [ ] encodeAsBytes ( long time , int sequence ) { byte [ ] buffer = new byte [ 16 ] ; buffer [ 0 ] = ( byte ) ( time >>> 56 ) ; buffer [ 1 ] = ( byte ) ( time >>> 48 ) ; buffer [ 2 ] = ( byte ) ( time >>> 40 ) ; buffer [ 3 ] = ( byte ) ( time >>> 32 ) ; buffer [ 4 ] = ( byte ) ( time >>> 24 ) ; buffer [ 5 ] ... | Return a 128 - bit version of the given time and sequence numbers according to the Flake specification . |
5,752 | public String encodeAsString ( long time , int sequence ) { StringBuilder s = new StringBuilder ( 32 ) ; ByteBuffer bb = ByteBuffer . wrap ( encodeAsBytes ( time , sequence ) ) ; s . append ( leftPad ( toHexString ( bb . getLong ( ) ) , 16 , '0' ) ) ; s . append ( leftPad ( toHexString ( bb . getLong ( ) ) , 16 , '0' )... | Return the 32 character left padded hex version of the given id . These can be lexicographically sorted . |
5,753 | public static Date decodeDate ( byte [ ] flakeBytes ) { ByteBuffer buffer = ByteBuffer . allocate ( 16 ) ; buffer . put ( flakeBytes ) ; buffer . flip ( ) ; return new Date ( buffer . getLong ( ) ) ; } | Return the Date from the given encoded Flake id . |
5,754 | public static long decodeMachineId ( byte [ ] flakeBytes ) { ByteBuffer buffer = ByteBuffer . allocate ( 16 ) ; buffer . put ( flakeBytes ) ; buffer . flip ( ) ; buffer . getLong ( ) ; return buffer . getLong ( ) >>> 16 ; } | Return the machine id from the given encoded Snowflake id . |
5,755 | public static int decodeSequence ( byte [ ] flakeBytes ) { ByteBuffer buffer = ByteBuffer . allocate ( 16 ) ; buffer . put ( flakeBytes ) ; buffer . flip ( ) ; buffer . getLong ( ) ; return ( int ) ( buffer . getLong ( ) & 0x000000000000FFFF ) ; } | Return the sequence number from the given encoded Snowflake id . |
5,756 | public String encodeAsString ( long time , int sequence ) { return leftPad ( toHexString ( encodeAsLong ( time , sequence ) ) , 16 , '0' ) ; } | Return the 16 character left padded hex version of the given id . These can be lexicographically sorted . |
5,757 | public static byte [ ] getOverride ( ) { String overrideMac = System . getProperty ( OVERRIDE_MAC_PROP ) ; byte [ ] macBytes = null ; if ( overrideMac != null ) { ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; String [ ] rawBytes = overrideMac . split ( ":" ) ; if ( rawBytes . length == 6 ) { try { for ( S... | Return the overridden MAC address if the system property OVERRIDE_MAC_PROP has been set . If the value of the property isn t a valid MAC address or it was not set then null is returned . |
5,758 | private Object cloneArray ( Object array ) { Class < ? > type = array . getClass ( ) ; if ( type == byte [ ] . class ) { byte [ ] byteArray = ( byte [ ] ) array ; return byteArray . clone ( ) ; } if ( type == char [ ] . class ) { char [ ] charArray = ( char [ ] ) array ; return charArray . clone ( ) ; } if ( type == do... | This method which clones its array argument would not be necessary if Cloneable had a public clone method . |
5,759 | private XAnnotationInvocationHandler asOneOfUs ( Object o ) { if ( Proxy . isProxyClass ( o . getClass ( ) ) ) { InvocationHandler handler = Proxy . getInvocationHandler ( o ) ; if ( handler instanceof XAnnotationInvocationHandler ) return ( XAnnotationInvocationHandler ) handler ; } return null ; } | Returns an object s invocation handler if that object is a dynamic proxy with a handler of type AnnotationInvocationHandler . Returns null otherwise . |
5,760 | private static boolean memberValueEquals ( Object v1 , Object v2 ) { Class < ? > type = v1 . getClass ( ) ; if ( ! type . isArray ( ) ) return v1 . equals ( v2 ) ; if ( v1 instanceof Object [ ] && v2 instanceof Object [ ] ) return Arrays . equals ( ( Object [ ] ) v1 , ( Object [ ] ) v2 ) ; if ( v2 . getClass ( ) != typ... | Returns true iff the two member values in dynamic proxy return form are equal using the appropriate equality function depending on the member type . The two values will be of the same type unless one of the containing annotations is ill - formed . If one of the containing annotations is ill - formed this method will re... |
5,761 | private void verifyCustomOptionNameUnique ( final CustomOptionContext ctx ) { if ( ctx . customOptionName ( ) . customOptionNamePart ( ) . size ( ) == 1 ) { final CustomOptionNamePartContext namePart = ctx . customOptionName ( ) . customOptionNamePart ( 0 ) ; verifyOptionNameUnique ( namePart . getText ( ) , namePart .... | Verifies uniqueness for custom options with a single NamePart . The multipart custom options should be validated during UninterpetedOption resolution in OptionsBuilder not here! |
5,762 | public static String [ ] tokenize ( String input , boolean lowercase ) { String [ ] tokens = input . split ( "\\W" ) ; for ( int i = 0 ; i < tokens . length && lowercase ; i ++ ) { tokens [ i ] = tokens [ i ] . toLowerCase ( ) ; } return tokens ; } | tokenize based on simple regular expression |
5,763 | public static String canonicalize ( String target ) { if ( target . startsWith ( Files . HOME_ALIAS ) ) { String homePath = OperatingSystemUtils . getUserHomePath ( ) ; target = homePath + target . substring ( 1 , target . length ( ) ) ; } return target ; } | Replace instances of internal tokens with actual file equivalents . |
5,764 | public String getStringSerialization ( int [ ] fieldToKeep ) { if ( fieldToKeep == null || fieldToKeep . length == 0 ) return getStringSerialization ( ) ; StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( this . getClass ( ) . getSimpleName ( ) ) . append ( "\t" ) ; buffer . append ( this . label ) ; buffe... | but limiting it to a subset of its fields |
5,765 | public Vector getFeatureVector ( Lexicon lexicon ) { Parameters . WeightingMethod method = lexicon . getMethod ( ) ; return getFeatureVector ( lexicon , method , null ) ; } | Returns a Vector representation of the document . This Vector object is weighted and used by the instances of Learner or TextClassifier |
5,766 | private double getScore ( int pos , Lexicon lexicon , double numdocs ) { double score = 0 ; int indexTerm = this . indices [ pos ] ; double occurences = ( double ) this . freqs [ pos ] ; int fieldNum = this . indexToField [ pos ] ; double frequency = occurences / tokensPerField [ fieldNum ] ; String fieldName = lexicon... | Returns the score of an attribute given the weighting scheme specified in the lexicon or for a specific field |
5,767 | private void normalizeL2 ( double [ ] scores ) { double square_sum = 0.0 ; for ( int i = 0 ; i < scores . length ; i ++ ) { square_sum += ( scores [ i ] * scores [ i ] ) ; } double norm = Math . sqrt ( square_sum ) ; if ( norm != 0 ) for ( int i = 0 ; i < scores . length ; i ++ ) { scores [ i ] = scores [ i ] / norm ; ... | Returns the L2 norm factor of this vector s values . |
5,768 | public static ExtensionInfo findExtensionByName ( final ExtensionRegistry registry , final Descriptor containingType , final String name ) { final int index = name . lastIndexOf ( "." ) ; final String nameLastPart = index == - 1 ? name : name . substring ( index + 1 ) ; return registry . findImmutableExtensionByName ( ... | Finds extension by its containing type and the dot separated multi - part name . |
5,769 | public static ExtensionRegistry addWithDependeciesToRegistry ( final FileDescriptor file , final ExtensionRegistry registry ) { for ( final FileDescriptor dependency : getFileWithAllDependencies ( file ) ) { addToRegistry ( dependency , registry ) ; } return registry ; } | Adds all extensions including dependencies for the given FileDescriptor to the registry . |
5,770 | public static ExtensionRegistry addToRegistry ( final FileDescriptor file , final ExtensionRegistry registry ) { for ( final FieldDescriptor extension : file . getExtensions ( ) ) { addToRegistry ( extension , registry ) ; } for ( final Descriptor descriptor : file . getMessageTypes ( ) ) { addToRegistry ( descriptor ,... | Adds all extensions without dependencies for the given FileDescriptor to the registry . |
5,771 | public static ExtensionRegistry addToRegistry ( final Descriptor descriptor , final ExtensionRegistry registry ) { for ( final FieldDescriptor extension : descriptor . getExtensions ( ) ) { addToRegistry ( extension , registry ) ; } for ( final Descriptor child : descriptor . getNestedTypes ( ) ) { addToRegistry ( chil... | Adds all extensions for the given Descriptor to the registry . |
5,772 | public static ExtensionRegistry addToRegistry ( final FieldDescriptor extension , final ExtensionRegistry registry ) { if ( extension . getJavaType ( ) == JavaType . MESSAGE ) { registry . add ( extension , DynamicMessage . getDefaultInstance ( extension . getMessageType ( ) ) ) ; } else { registry . add ( extension ) ... | Adds extension to the registry making a default DynamicMessage if its type is a Message . |
5,773 | private void onChanged ( ) { if ( builder != null ) { message = null ; } if ( isClean && parent != null ) { parent . markDirty ( ) ; isClean = false ; } } | Called when a the builder or one of its nested children has changed and any parent should be notified of its invalidation . |
5,774 | public Object invoke ( final ELContext context , final Object base , final Object method , Class < ? > [ ] paramTypes , final Object [ ] params ) { if ( ( base == null ) || ( method == null ) ) { return null ; } final MethodDescriptor [ ] methodDescriptors = getMethodDescriptors ( context , base ) ; if ( methodDescript... | Invokes the method considering the base s BeanInfo class MethodDescriptors . Resolves method overloads by looking at the MethodDescriptors first and only then the base s class itself choosing the most specific candidate . |
5,775 | public static File unzip ( File inputZip ) { File rootDir = null ; try { BufferedOutputStream dest = null ; BufferedInputStream is = null ; ZipEntry entry ; ZipFile zipfile = new ZipFile ( inputZip ) ; File test = File . createTempFile ( "aaa" , "aaa" ) ; String tempDir = test . getParent ( ) ; test . delete ( ) ; Enum... | Unzips the argument into the temp directory and returns the unzipped location . The zip must have a root dir element and not just a flat list of files |
5,776 | private void checkMembers ( XMember < ? > [ ] members ) { for ( int index = 0 ; index < members . length ; index ++ ) { final XMember < ? > member = members [ index ] ; if ( ! member . getMember ( ) . getDeclaringClass ( ) . isAssignableFrom ( getTargetClass ( ) ) ) { throw new IllegalArgumentException ( "Member [" + m... | Checks if all the passed members belong to the given target class . |
5,777 | public static String getSafeFilename ( String filename ) { String result = filename ; if ( result != null ) { result = result . replaceAll ( "[^a-zA-Z0-9]+" , "-" ) . replaceAll ( "^-+" , "" ) ; } return result ; } | Generate a string that is usable as a single file name or directory path segment on any operating system . Replaces unsafe characters with the underscore _ character |
5,778 | public static int getLineCount ( final String text ) { final Matcher matcher = LINE_FINDER . matcher ( text ) ; int i = 0 ; while ( matcher . find ( ) ) { i ++ ; } return i ; } | Gets a zero - based line count of text . |
5,779 | protected static List < FieldDescriptor > getChildFieldDescriptors ( final Descriptor type ) { final List < FieldDescriptor > fields = new ArrayList < FieldDescriptor > ( ) ; for ( final FieldDescriptor field : type . getFields ( ) ) { if ( field . getJavaType ( ) == JavaType . MESSAGE ) { fields . add ( field ) ; } } ... | Gets all child MessageOrBuilder descriptors for the type . |
5,780 | public Annotation [ ] getAnnotations ( ) { final XAnnotation < ? > [ ] xannotations = getXAnnotations ( ) ; final Annotation [ ] annotations = new Annotation [ xannotations . length ] ; for ( int index = 0 ; index < xannotations . length ; index ++ ) { annotations [ index ] = xannotations [ index ] . getResult ( ) ; } ... | Returns annotations for this annotated item . |
5,781 | private File generateDOTFile ( AddonDependencyResolver addonResolver , AddonId id , String fileName ) { File parent = new File ( outputDirectory ) ; parent . mkdirs ( ) ; File file = new File ( parent , fileName ) ; getLog ( ) . info ( "Generating " + file ) ; AddonInfo addonInfo = addonResolver . resolveAddonDependenc... | Generates the DOT file for a given addonId |
5,782 | public final Module loadAddonModule ( Addon addon ) throws ModuleLoadException { try { this . currentAddon . set ( addon ) ; ModuleIdentifier moduleId = moduleCache . getModuleId ( addon ) ; Module result = loadModule ( moduleId ) ; return result ; } catch ( ModuleLoadException e ) { throw e ; } finally { this . curren... | Loads a module for the given Addon . |
5,783 | private void installModuleMBeanServer ( ) { try { Method method = ModuleLoader . class . getDeclaredMethod ( "installMBeanServer" ) ; method . setAccessible ( true ) ; method . invoke ( null ) ; } catch ( Exception e ) { throw new ContainerException ( "Could not install Modules MBean server" , e ) ; } } | Installs the MBeanServer . |
5,784 | public A getResult ( ) { final InvocationHandler handler = new XAnnotationInvocationHandler ( this ) ; @ SuppressWarnings ( "unchecked" ) final A annotation = ( A ) Proxy . newProxyInstance ( annotationClass . getClassLoader ( ) , new Class [ ] { annotationClass } , handler ) ; return annotation ; } | Returns the instance of the annotation for this xannotation . |
5,785 | public static void filterFields ( File trainingCorpus , File newRawFile , int [ ] fieldsToKeep ) throws IOException { FileTrainingCorpus ftc = new FileTrainingCorpus ( trainingCorpus ) ; Writer writer = new BufferedWriter ( new FileWriter ( newRawFile ) ) ; Iterator < Document > iterator = ftc . iterator ( ) ; while ( ... | rewrite a raw file so that only a subset of the fields are kept |
5,786 | public static void randomSelection ( File input , int expected_number , boolean noTest ) throws IOException { BitSet biset = new BitSet ( ) ; Random random = new java . util . Random ( ) ; int maxNumLines = 0 ; BufferedReader reader = new BufferedReader ( new FileReader ( input ) ) ; while ( ( reader . readLine ( ) ) !... | Generates a random sample of lines from an input file and stores the selection in a file named like the original but with the suffix _ + number of lines . |
5,787 | public static String unwrapProxyClassName ( Class < ? > type ) { String typeName = null ; if ( type != null ) { if ( type . getName ( ) . contains ( "$$EnhancerByCGLIB$$" ) ) { typeName = CGLIB_CLASSNAME_REGEXP . matcher ( type . getName ( ) ) . replaceAll ( "$1" ) ; } else if ( type . getName ( ) . contains ( "_jvst" ... | Unwraps the proxy type if javassist or CGLib is used |
5,788 | public static boolean areEquivalent ( Object proxiedObj , Object anotherProxiedObj ) { if ( proxiedObj == null && anotherProxiedObj == null ) { return true ; } else if ( proxiedObj == null || anotherProxiedObj == null ) { return false ; } else { Object unproxiedObj = unwrap ( proxiedObj ) ; Object anotherUnproxiedObj =... | This method tests if two proxied objects are equivalent . |
5,789 | @ SuppressWarnings ( "unchecked" ) public static final List < Map < String , Object > > getDocuments ( Map < String , Object > result ) { if ( MapUtils . isNotEmpty ( result ) && result . containsKey ( RESPONSE_KEY ) ) { Map < String , Object > response = ( Map < String , Object > ) result . get ( RESPONSE_KEY ) ; if (... | Extract the documents from the specified result . |
5,790 | public Document createDocument ( String [ ] tokenstring ) { this . lexicon . incrementDocCount ( ) ; return new SimpleDocument ( tokenstring , this . lexicon , true ) ; } | Create a Document from an array of Strings |
5,791 | public Document createDocument ( String [ ] tokenstring , String label ) { this . lexicon . incrementDocCount ( ) ; SimpleDocument doc = new SimpleDocument ( tokenstring , this . lexicon , true ) ; doc . setLabel ( this . lexicon . getLabelIndex ( label ) ) ; return doc ; } | Create a Document from an array of Strings and specify the label |
5,792 | public static Learner getLearner ( String workdirectory , String implementationName , boolean overwrite ) throws Exception { File directory = new File ( workdirectory ) ; if ( directory . exists ( ) == false ) throw new Exception ( workdirectory + " must exist" ) ; if ( directory . isDirectory ( ) == false ) throw new ... | Generate an instance of Learner from an existing directory . |
5,793 | public static int count ( final String string , final String substring ) { int count = 0 ; int idx = 0 ; while ( ( idx = string . indexOf ( substring , idx ) ) != - 1 ) { idx ++ ; count ++ ; } return count ; } | Count the number of instances of substring within a string . |
5,794 | public static String pad ( final StringBuffer buff , final String string , final int count ) { for ( int i = 0 ; i < count ; i ++ ) { buff . append ( string ) ; } return buff . toString ( ) ; } | Return a string padded with the given string for the given count . |
5,795 | public static String pad ( final Object obj , final int count ) { return pad ( new StringBuffer ( ) , String . valueOf ( obj ) , count ) ; } | Return a string padded with the given string value of an object for the given count . |
5,796 | public static String capitalize ( final String string ) { if ( string == null ) throw new IllegalArgumentException ( "string" ) ; if ( string . equals ( "" ) ) throw new IllegalArgumentException ( "string" ) ; return Character . toUpperCase ( string . charAt ( 0 ) ) + string . substring ( 1 ) ; } | Capitalize the first character of the given string . |
5,797 | public final static boolean isJavaKeyword ( String s ) { if ( s == null || s . length ( ) == 0 ) { return false ; } for ( int i = 0 ; i < keywords . length ; i ++ ) { if ( keywords [ i ] . equals ( s ) ) { return true ; } } return false ; } | Check whether the given String is a reserved Java Keyword according to the Java Language Specifications . |
5,798 | public final static boolean isEjbQlIdentifier ( String s ) { if ( s == null || s . length ( ) == 0 ) { return false ; } for ( int i = 0 ; i < ejbQlIdentifiers . length ; i ++ ) { if ( ejbQlIdentifiers [ i ] . equalsIgnoreCase ( s ) ) { return true ; } } return false ; } | Check whether the given String is an identifier according to the EJB - QL definition . See The EJB 2 . 0 Documentation Section 11 . 2 . 6 . 1 . |
5,799 | public static String removeWhiteSpace ( String s ) { String retn = null ; if ( s != null ) { int len = s . length ( ) ; StringBuffer sbuf = new StringBuffer ( len ) ; for ( int i = 0 ; i < len ; i ++ ) { char c = s . charAt ( i ) ; if ( ! Character . isWhitespace ( c ) ) sbuf . append ( c ) ; } retn = sbuf . toString (... | Returns a new string with all the whitespace removed |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.