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 ) ) ret . add ( application ) ; } return ret ; }
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 ( ) . iterator ( ) . next ( ) ) ; }
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 { outputStreamWriter = new OutputStreamWriter ( entityStream , CHARSET ) ; Type jsonType = getAppropriateType ( type , genericType ) ; String json = getGson ( ) . toJson ( object , jsonType ) ; if ( logger . isLoggable ( Level . FINE ) ) logger . fine ( "Outgoing JSON Entity: " + json ) ; getGson ( ) . toJson ( object , jsonType , outputStreamWriter ) ; } finally { if ( outputStreamWriter != null ) outputStreamWriter . close ( ) ; } }
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 = null ; try { inputStreamReader = new InputStreamReader ( inputStream , CHARSET ) ; Type jsonType = getAppropriateType ( type , genericType ) ; json = getStringFromInputStream ( inputStream ) ; if ( logger . isLoggable ( Level . FINE ) ) logger . fine ( "Incoming JSON Entity: " + json ) ; result = getGson ( ) . fromJson ( json , jsonType ) ; } catch ( JsonSyntaxException e ) { logger . severe ( "Error in Incoming JSON Entity: " + json ) ; } finally { if ( inputStreamReader != null ) inputStreamReader . close ( ) ; } return result ; }
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 ) { logger . severe ( "Unable to get string from stream: " + e . getClass ( ) . getName ( ) + ": " + e . getMessage ( ) ) ; } finally { try { if ( br != null ) br . close ( ) ; } catch ( IOException e ) { } } return sb . toString ( ) ; }
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 ) getAttributeObject ( sa ) ; if ( s == null ) throw new AttributeNotDefinedException ( sa ) ; SizeUnit u = s . getUnit ( ) ; float size = s . getSize ( ) ; if ( ( u . equals ( SizeUnit . PX ) ) || ( u . equals ( SizeUnit . PT ) ) ) { return size ; } else if ( u . equals ( SizeUnit . NOTE_HEIGHT ) ) { return ( float ) ( size * getMetrics ( ) . getNoteHeight ( ) ) ; } else if ( u . equals ( SizeUnit . NOTE_WIDTH ) ) { return ( float ) ( size * getMetrics ( ) . getNoteWidth ( ) ) ; } else if ( u . equals ( SizeUnit . GRACENOTE_HEIGHT ) ) { return ( float ) ( size * getMetrics ( ) . getGraceNoteHeight ( ) ) ; } else if ( u . equals ( SizeUnit . GRACENOTE_WIDTH ) ) { return ( float ) ( size * getMetrics ( ) . getGraceNoteWidth ( ) ) ; } else if ( u . equals ( SizeUnit . STAFF_HEIGHT ) ) { return ( float ) ( size * getMetrics ( ) . getStaffCharBounds ( ) . getHeight ( ) ) ; } else if ( u . equals ( SizeUnit . STAFF_WIDTH ) ) { return ( float ) ( size * getMetrics ( ) . getStaffCharBounds ( ) . getWidth ( ) ) ; } else if ( u . equals ( SizeUnit . PERCENT ) ) { return size / 100 * getAttributeSize ( ScoreAttribute . NOTATION_SIZE ) ; } else throw new RuntimeException ( "unknown size unit for attribute: " + sa . toString ( ) ) ; }
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 ( field ) ) ret . add ( field ) ; } byte [ ] ret2 = new byte [ ret . size ( ) ] ; for ( int i = 0 ; i < ret2 . length ; i ++ ) { ret2 [ i ] = ( Byte ) ret . get ( i ) ; } return ret2 ; } return new byte [ 0 ] ; }
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 } ; } } if ( field != ScoreElements . _DEFAULT ) { return getPosition ( ScoreElements . _DEFAULT ) ; } return null ; }
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 . iterator ( ) ; Font font = null ; String s = "" ; int style = getTextStyle ( field ) ; int size = ( int ) getTextSize ( field ) ; while ( it . hasNext ( ) ) { String fontName = ( String ) it . next ( ) ; if ( s . length ( ) > 0 ) s += ", " ; s += fontName ; if ( isFontAvailable ( fontName ) ) { font = new Font ( fontName , style , size ) ; break ; } } if ( font == null ) { System . err . println ( "None of these fonts are available: " + s ) ; font = new Font ( "Dialog" , style , size ) ; } if ( fi . m_textAttributes != null ) { font = font . deriveFont ( fi . m_textAttributes ) ; } return font ; }
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 ) ) ; notifyListeners ( ) ; }
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 ) ) { Iterator it = m_fieldsPosition . values ( ) . iterator ( ) ; Byte B = field ; while ( it . hasNext ( ) ) { Vector v = ( Vector ) it . next ( ) ; if ( v . contains ( B ) ) v . remove ( B ) ; } if ( m_fieldsPosition . get ( p ) == null ) m_fieldsPosition . put ( p , new Vector ( ) ) ; Vector v = ( Vector ) m_fieldsPosition . get ( p ) ; v . add ( B ) ; } } notifyListeners ( ) ; }
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 . of ( monitor ) ; }
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 ( ) ) ) { Voice vCopy = getVoice ( v . getVoiceName ( ) ) ; vCopy . setTablature ( v . getTablature ( ) ) ; vCopy . setVolume ( v . getVolume ( ) ) ; vCopy . setInstrument ( v . getInstrument ( ) ) ; } getVoice ( v . getVoiceName ( ) ) . addAll ( 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 . elementAt ( i ) ; if ( current != null ) { pos = current . getCharStreamPosition ( ) ; if ( pos != null ) { if ( ( pos . getStartIndex ( ) <= offset ) && ( pos . getEndIndex ( ) > offset ) ) return current ; } } } } return null ; }
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 ] = ( byte ) ( time >>> 16 ) ; buffer [ 6 ] = ( byte ) ( time >>> 8 ) ; buffer [ 7 ] = ( byte ) ( time ) ; long rest = shiftedMachineId | ( 0x0000FFFF & sequence ) ; buffer [ 8 ] = ( byte ) ( rest >>> 56 ) ; buffer [ 9 ] = ( byte ) ( rest >>> 48 ) ; buffer [ 10 ] = ( byte ) ( rest >>> 40 ) ; buffer [ 11 ] = ( byte ) ( rest >>> 32 ) ; buffer [ 12 ] = ( byte ) ( rest >>> 24 ) ; buffer [ 13 ] = ( byte ) ( rest >>> 16 ) ; buffer [ 14 ] = ( byte ) ( rest >>> 8 ) ; buffer [ 15 ] = ( byte ) ( rest ) ; return buffer ; }
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 s . toString ( ) ; }
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 ( String b : rawBytes ) { out . write ( Integer . parseInt ( b , 16 ) ) ; } macBytes = out . toByteArray ( ) ; } catch ( NumberFormatException e ) { } } } return macBytes ; }
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 == double [ ] . class ) { double [ ] doubleArray = ( double [ ] ) array ; return doubleArray . clone ( ) ; } if ( type == float [ ] . class ) { float [ ] floatArray = ( float [ ] ) array ; return floatArray . clone ( ) ; } if ( type == int [ ] . class ) { int [ ] intArray = ( int [ ] ) array ; return intArray . clone ( ) ; } if ( type == long [ ] . class ) { long [ ] longArray = ( long [ ] ) array ; return longArray . clone ( ) ; } if ( type == short [ ] . class ) { short [ ] shortArray = ( short [ ] ) array ; return shortArray . clone ( ) ; } if ( type == boolean [ ] . class ) { boolean [ ] booleanArray = ( boolean [ ] ) array ; return booleanArray . clone ( ) ; } Object [ ] objectArray = ( Object [ ] ) array ; return objectArray . clone ( ) ; }
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 ( ) != type ) return false ; if ( type == byte [ ] . class ) return Arrays . equals ( ( byte [ ] ) v1 , ( byte [ ] ) v2 ) ; if ( type == char [ ] . class ) return Arrays . equals ( ( char [ ] ) v1 , ( char [ ] ) v2 ) ; if ( type == double [ ] . class ) return Arrays . equals ( ( double [ ] ) v1 , ( double [ ] ) v2 ) ; if ( type == float [ ] . class ) return Arrays . equals ( ( float [ ] ) v1 , ( float [ ] ) v2 ) ; if ( type == int [ ] . class ) return Arrays . equals ( ( int [ ] ) v1 , ( int [ ] ) v2 ) ; if ( type == long [ ] . class ) return Arrays . equals ( ( long [ ] ) v1 , ( long [ ] ) v2 ) ; if ( type == short [ ] . class ) return Arrays . equals ( ( short [ ] ) v1 , ( short [ ] ) v2 ) ; assert type == boolean [ ] . class ; return Arrays . equals ( ( boolean [ ] ) v1 , ( boolean [ ] ) v2 ) ; }
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 return false unless the two members are identical object references .
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 . getStart ( ) ) ; } }
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 ) ; buffer . append ( "\t" ) . append ( tokensPerField . length ) ; for ( int fieldNum = 0 ; fieldNum < tokensPerField . length ; fieldNum ++ ) { double tokperf = tokensPerField [ fieldNum ] ; if ( java . util . Arrays . binarySearch ( fieldToKeep , fieldNum ) != - 1 ) buffer . append ( "\t" ) . append ( tokperf ) ; else buffer . append ( "\t" ) . append ( "0.0" ) ; } for ( int i = 0 ; i < indices . length ; i ++ ) { int fieldNum = this . indexToField [ i ] ; if ( java . util . Arrays . binarySearch ( fieldToKeep , fieldNum ) != - 1 ) buffer . append ( "\t" ) . append ( indices [ i ] ) . append ( ":" ) . append ( freqs [ i ] ) . append ( ":" ) . append ( this . indexToField [ i ] ) ; } buffer . append ( "\n" ) ; return buffer . toString ( ) ; }
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 . getFields ( ) [ fieldNum ] ; WeightingMethod method = lexicon . getMethod ( fieldName ) ; if ( method . equals ( Parameters . WeightingMethod . BOOLEAN ) ) { score = 1 ; } else if ( method . equals ( Parameters . WeightingMethod . OCCURRENCES ) ) { score = occurences ; } else if ( method . equals ( Parameters . WeightingMethod . FREQUENCY ) ) { score = frequency ; } else if ( method . equals ( Parameters . WeightingMethod . TFIDF ) ) { int df = lexicon . getDocFreq ( indexTerm ) ; double idf = numdocs / ( double ) df ; score = frequency * Math . log ( idf ) ; if ( idf == 1 ) score = frequency ; } return score ; }
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 ( containingType . getFullName ( ) + "." + nameLastPart ) ; }
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 , registry ) ; } return registry ; }
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 ( child , registry ) ; } return registry ; }
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 ) ; } return registry ; }
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 ( methodDescriptors != null ) { final Method m = findMethodOrThrow ( method . toString ( ) , paramTypes , params , false , methodDescriptors ) ; paramTypes = m . getParameterTypes ( ) ; } return super . invoke ( context , base , method , paramTypes , params ) ; }
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 ( ) ; Enumeration e = zipfile . entries ( ) ; while ( e . hasMoreElements ( ) ) { entry = ( ZipEntry ) e . nextElement ( ) ; is = new BufferedInputStream ( zipfile . getInputStream ( entry ) ) ; int count ; byte data [ ] = new byte [ BUFFER ] ; File target = new File ( tempDir , entry . getName ( ) ) ; if ( entry . getName ( ) . endsWith ( "/" ) ) { target . mkdir ( ) ; if ( rootDir == null ) rootDir = target ; continue ; } FileOutputStream fos = new FileOutputStream ( target ) ; dest = new BufferedOutputStream ( fos , BUFFER ) ; while ( ( count = is . read ( data , 0 , BUFFER ) ) != - 1 ) { dest . write ( data , 0 , count ) ; } dest . flush ( ) ; dest . close ( ) ; is . close ( ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; } return rootDir ; }
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 [" + member + "] does not belong to the target class [" + targetClass + "]." ) ; } } }
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 ) ; } } for ( final FieldDescriptor field : type . getExtensions ( ) ) { if ( field . getJavaType ( ) == JavaType . MESSAGE ) { fields . add ( field ) ; } } return Collections . unmodifiableList ( fields ) ; }
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 ( ) ; } return annotations ; }
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 . resolveAddonDependencyHierarchy ( id ) ; toDOT ( file , toGraph ( addonResolver , addonInfo ) ) ; return file ; }
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 . currentAddon . remove ( ) ; } }
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 ( iterator . hasNext ( ) ) { MultiFieldDocument doc = ( MultiFieldDocument ) iterator . next ( ) ; String representation = doc . getStringSerialization ( fieldsToKeep ) ; writer . write ( representation ) ; } writer . close ( ) ; }
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 ( ) ) != null ) { maxNumLines ++ ; } System . out . println ( "Original file : " + maxNumLines + " lines" ) ; boolean dumpAll = maxNumLines <= expected_number ; int added = 0 ; while ( added <= expected_number ) { int randomInt = random . nextInt ( maxNumLines + 1 ) ; if ( biset . get ( randomInt ) == false ) { biset . set ( randomInt , true ) ; added ++ ; } } File output = new File ( input . getParentFile ( ) , input . getName ( ) + "_" + expected_number ) ; File eval = new File ( input . getParentFile ( ) , input . getName ( ) + "_" + expected_number + ".test" ) ; reader . close ( ) ; reader = new BufferedReader ( new FileReader ( input ) ) ; BufferedWriter writer = new BufferedWriter ( new FileWriter ( output ) ) ; BufferedWriter writer2 = null ; if ( noTest == false ) writer2 = new BufferedWriter ( new FileWriter ( eval ) ) ; int count = 0 ; int kept = 0 ; String line = null ; while ( ( line = reader . readLine ( ) ) != null ) { if ( biset . get ( count ) || dumpAll ) { writer . append ( line + "\n" ) ; kept ++ ; } else if ( noTest == false ) { writer2 . append ( line + "\n" ) ; } count ++ ; } System . out . println ( "New file : " + kept + " lines" ) ; if ( noTest == false ) writer2 . close ( ) ; writer . close ( ) ; reader . close ( ) ; }
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" ) ) { typeName = JAVASSIST_CLASSNAME_REGEXP . matcher ( type . getName ( ) ) . replaceAll ( "$1" ) ; } else { typeName = type . getName ( ) ; } } return typeName ; }
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 = unwrap ( anotherProxiedObj ) ; boolean sameClassName = unwrapProxyClassName ( unproxiedObj . getClass ( ) ) . equals ( unwrapProxyClassName ( anotherUnproxiedObj . getClass ( ) ) ) ; if ( sameClassName ) { if ( unproxiedObj . getClass ( ) . isEnum ( ) ) { Enum < ? > enumLeft = Enum . class . cast ( unproxiedObj ) ; Enum < ? > enumRight = Enum . class . cast ( anotherUnproxiedObj ) ; return ( enumLeft . name ( ) . equals ( enumRight . name ( ) ) ) && ( enumLeft . ordinal ( ) == enumRight . ordinal ( ) ) ; } else { return ( unproxiedObj . hashCode ( ) == anotherUnproxiedObj . hashCode ( ) ) ; } } else { return false ; } } }
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 ( MapUtils . isNotEmpty ( response ) && response . containsKey ( DOCUMENTS_KEY ) ) { return ( List < Map < String , Object > > ) response . get ( DOCUMENTS_KEY ) ; } } return null ; }
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 Exception ( workdirectory + " must be a directory" ) ; String model_file_name = workdirectory + File . separator + Parameters . modelName ; String lexicon_file_name = workdirectory + File . separator + Parameters . lexiconName ; String vector_file_name = workdirectory + File . separator + Parameters . vectorName ; String raw_file_name = workdirectory + File . separator + Parameters . rawName ; Learner learner = null ; if ( overwrite ) { removeExistingFile ( model_file_name ) ; removeExistingFile ( lexicon_file_name ) ; removeExistingFile ( vector_file_name ) ; removeExistingFile ( raw_file_name ) ; } if ( LibSVMModelCreator . equals ( implementationName ) ) learner = new LibSVMModelCreator ( lexicon_file_name , model_file_name , vector_file_name ) ; else if ( LibLinearModelCreator . equals ( implementationName ) ) learner = new LibLinearModelCreator ( lexicon_file_name , model_file_name , vector_file_name ) ; else throw new Exception ( implementationName + " is unknown" ) ; if ( ! overwrite ) { Lexicon oldlexicon = new Lexicon ( lexicon_file_name ) ; if ( oldlexicon != null ) learner . lexicon = oldlexicon ; } learner . workdirectory = directory ; return learner ; }
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 ( ) ; } return retn ; }
Returns a new string with all the whitespace removed