idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
10,600
public void addZone ( String id , Component zone , String constraints ) { Component previousZone = getZone ( id ) ; if ( previousZone != null ) { remove ( previousZone ) ; idToZones . remove ( id ) ; } if ( zone instanceof JComponent ) { JComponent jc = ( JComponent ) zone ; if ( jc . getBorder ( ) == null || jc . getBorder ( ) instanceof UIResource ) { if ( jc instanceof JLabel ) { jc . setBorder ( new CompoundBorder ( zoneBorder , new EmptyBorder ( 0 , 2 , 0 , 2 ) ) ) ; ( ( JLabel ) jc ) . setText ( " " ) ; } else { jc . setBorder ( zoneBorder ) ; } } } add ( zone , constraints ) ; idToZones . put ( id , zone ) ; }
Adds a new zone in the StatusBar .
10,601
public IContext loadContext ( String function ) throws ContextLoaderException { IContext result = new Context ( ) ; parse ( function , result , null ) ; createIds ( result ) ; log . info ( "Parsed nodes: " + nodesParsed ) ; return result ; }
Converts the string with a function into a tree .
10,602
static void parse ( String inString , IContext context , INode parent ) { List < String > tokens = getCommaTokens ( inString ) ; for ( String token : tokens ) { int isFunction = token . indexOf ( OPEN_PARENTHESIS ) ; if ( isFunction >= 0 ) { String funcName = token . substring ( 0 , isFunction ) ; INode newParent = addChild ( parent , context , funcName ) ; String arguments = token . substring ( isFunction + 1 , token . length ( ) - 1 ) ; parse ( arguments , context , newParent ) ; } else { addChild ( parent , context , token ) ; } } }
Parses the string to get the children of the given node .
10,603
static List < String > getCommaTokens ( String inString ) { String input = inString . trim ( ) ; List < String > tokens = new ArrayList < String > ( ) ; String token ; while ( 0 < input . length ( ) ) { if ( COMMA == input . charAt ( 0 ) ) { input = input . substring ( 1 ) ; } token = getNextCommaToken ( input ) ; input = input . substring ( token . length ( ) ) ; tokens . add ( token . trim ( ) ) ; } return tokens ; }
Tokenizes the string into siblings .
10,604
static String getNextCommaToken ( String inString ) { String token = "" ; int parenthesis = 0 ; for ( int i = 0 ; i < inString . length ( ) ; i ++ ) { if ( OPEN_PARENTHESIS == inString . charAt ( i ) ) { parenthesis ++ ; token += inString . charAt ( i ) ; } else if ( CLOSE_PARENTHESIS == inString . charAt ( i ) ) { parenthesis -- ; token += inString . charAt ( i ) ; } else if ( COMMA == inString . charAt ( i ) ) { if ( parenthesis == 0 ) { break ; } else { token += inString . charAt ( i ) ; } } else { token += inString . charAt ( i ) ; } } return token ; }
Computes the first argument from a list of arguments
10,605
public String get ( String key ) { if ( "dn" . equals ( key ) ) { return this . dn ; } else if ( key != null && attributes != null && getKeys ( ) . contains ( key ) && attributes . get ( key ) != null ) { return attributes . get ( key ) . toString ( ) . replace ( key + ":" , "" ) . trim ( ) ; } return null ; }
Returns an entry for a given key .
10,606
public void set ( String key , String value ) { if ( "dn" . equals ( key ) ) { this . dn = value ; } else if ( value != null && ! value . isEmpty ( ) && key != null && ! key . isEmpty ( ) ) { addAttribute ( new BasicAttribute ( key , value , true ) ) ; } }
Sets the value of an entry .
10,607
public synchronized void deleteAtExit ( FileNode node ) { if ( delete == null ) { tryDelete ( node ) ; } else { delete . add ( node ) ; } }
Use this instead of File . deleteAtExist because it can delete none - empty directories
10,608
public AutoComplete union ( AutoComplete other ) { if ( possibilities . isEmpty ( ) ) { return other ; } if ( other . possibilities . isEmpty ( ) ) { return this ; } if ( ! this . prefix . equals ( other . prefix ) ) { throw new IllegalArgumentException ( "Trying to perform union on different prefixes: prefix1='" + this . prefix + "', prefix2='" + other . prefix + '\'' ) ; } final Trie < CliValueType > unifiedPossibilities = this . possibilities . union ( other . possibilities ) ; return new AutoComplete ( prefix , unifiedPossibilities ) ; }
Create a new auto - complete by merging this auto - complete with the given auto - complete . The resulting auto - complete will contain possibilities from both this and the given auto - complete .
10,609
public TrieBuilder < T > add ( String word , T value ) { assertNotEmptyWord ( word ) ; if ( map . containsKey ( word ) ) { throw new IllegalArgumentException ( "Trie already contains a value for '" + word + "': " + map . get ( word ) ) ; } map . put ( word , value ) ; return this ; }
Add a word - value mapping to the Trie . Expects there not to be a previous mapping for the word .
10,610
public TrieBuilder < T > addAll ( Map < String , T > map ) { for ( Entry < String , T > entry : map . entrySet ( ) ) { add ( entry . getKey ( ) , entry . getValue ( ) ) ; } return this ; }
Add all word - value pairs from the given map to the Trie . Expects there not to be any previous mappings for any of the words .
10,611
public TrieBuilder < T > set ( String word , T value ) { assertNotEmptyWord ( word ) ; map . put ( word , value ) ; return this ; }
Set a word - value mapping on the Trie . If a previous mapping exists it will be overwritten . Otherwise will create a new word - value mapping .
10,612
public TrieBuilder < T > setAll ( Map < String , T > map ) { for ( Entry < String , T > entry : map . entrySet ( ) ) { set ( entry . getKey ( ) , entry . getValue ( ) ) ; } return this ; }
Set all word - value pairs in the given map to the Trie . If any previous mapping exists it will be overwritten .
10,613
public final void setTable ( PropertySheetTable table ) { if ( table == null ) { throw new IllegalArgumentException ( "table must not be null" ) ; } if ( model != null ) { model . removePropertyChangeListener ( this ) ; } model = ( PropertySheetTableModel ) table . getModel ( ) ; model . addPropertyChangeListener ( this ) ; if ( this . table != null ) { this . table . getSelectionModel ( ) . removeListSelectionListener ( selectionListener ) ; } table . getSelectionModel ( ) . addListSelectionListener ( selectionListener ) ; tableScroll . getViewport ( ) . setView ( table ) ; this . table = table ; }
Sets the table used by this panel .
10,614
public void setDescriptionVisible ( boolean visible ) { if ( visible ) { add ( "Center" , split ) ; split . setTopComponent ( tableScroll ) ; split . setBottomComponent ( descriptionScrollPane ) ; split . setDividerLocation ( split . getHeight ( ) - lastDescriptionHeight ) ; } else { lastDescriptionHeight = split . getHeight ( ) - split . getDividerLocation ( ) ; remove ( split ) ; add ( "Center" , tableScroll ) ; } descriptionButton . setSelected ( visible ) ; PropertySheetPanel . this . revalidate ( ) ; }
Toggles the visibility of the description panel .
10,615
public void readFromObject ( Object data ) { getTable ( ) . cancelEditing ( ) ; Property [ ] properties = model . getProperties ( ) ; for ( int i = 0 , c = properties . length ; i < c ; i ++ ) { properties [ i ] . readFromObject ( data ) ; } repaint ( ) ; }
Initializes the PropertySheet from the given object . If any it cancels pending edit before proceeding with properties .
10,616
public void writeToObject ( Object data ) { getTable ( ) . commitEditing ( ) ; Property [ ] properties = getProperties ( ) ; for ( int i = 0 , c = properties . length ; i < c ; i ++ ) { properties [ i ] . writeToObject ( data ) ; } }
Writes the PropertySheet to the given object . If any it commits pending edit before proceeding with properties .
10,617
public void setSorting ( boolean value ) { model . setSortingCategories ( value ) ; model . setSortingProperties ( value ) ; sortButton . setSelected ( value ) ; }
Sets sorting properties and categories enabled or disabled .
10,618
public void writeMessage ( final int fieldNumber , final MessageLite value ) throws IOException { writeTag ( fieldNumber , WireFormat . WIRETYPE_LENGTH_DELIMITED ) ; writeMessageNoTag ( value ) ; }
Write an embedded message field including tag to the stream .
10,619
public void writeEnum ( final int fieldNumber , final int value ) throws IOException { writeTag ( fieldNumber , WireFormat . WIRETYPE_VARINT ) ; writeEnumNoTag ( value ) ; }
Write an enum field including tag to the stream . Caller is responsible for converting the enum value to its numeric value .
10,620
public void writeMessageSetExtension ( final int fieldNumber , final MessageLite value ) throws IOException { writeTag ( WireFormat . MESSAGE_SET_ITEM , WireFormat . WIRETYPE_START_GROUP ) ; writeUInt32 ( WireFormat . MESSAGE_SET_TYPE_ID , fieldNumber ) ; writeMessage ( WireFormat . MESSAGE_SET_MESSAGE , value ) ; writeTag ( WireFormat . MESSAGE_SET_ITEM , WireFormat . WIRETYPE_END_GROUP ) ; }
Write a MessageSet extension field to the stream . For historical reasons the wire format differs from normal fields .
10,621
public void writeRawMessageSetExtension ( final int fieldNumber , final ByteString value ) throws IOException { writeTag ( WireFormat . MESSAGE_SET_ITEM , WireFormat . WIRETYPE_START_GROUP ) ; writeUInt32 ( WireFormat . MESSAGE_SET_TYPE_ID , fieldNumber ) ; writeBytes ( WireFormat . MESSAGE_SET_MESSAGE , value ) ; writeTag ( WireFormat . MESSAGE_SET_ITEM , WireFormat . WIRETYPE_END_GROUP ) ; }
Write an unparsed MessageSet extension field to the stream . For historical reasons the wire format differs from normal fields .
10,622
public static int computeMessageSetExtensionSize ( final int fieldNumber , final MessageLite value ) { return computeTagSize ( WireFormat . MESSAGE_SET_ITEM ) * 2 + computeUInt32Size ( WireFormat . MESSAGE_SET_TYPE_ID , fieldNumber ) + computeMessageSize ( WireFormat . MESSAGE_SET_MESSAGE , value ) ; }
Compute the number of bytes that would be needed to encode a MessageSet extension to the stream . For historical reasons the wire format differs from normal fields .
10,623
public static int computeRawMessageSetExtensionSize ( final int fieldNumber , final ByteString value ) { return computeTagSize ( WireFormat . MESSAGE_SET_ITEM ) * 2 + computeUInt32Size ( WireFormat . MESSAGE_SET_TYPE_ID , fieldNumber ) + computeBytesSize ( WireFormat . MESSAGE_SET_MESSAGE , value ) ; }
Compute the number of bytes that would be needed to encode an unparsed MessageSet extension field to the stream . For historical reasons the wire format differs from normal fields .
10,624
public static int computeLazyFieldMessageSetExtensionSize ( final int fieldNumber , final LazyField value ) { return computeTagSize ( WireFormat . MESSAGE_SET_ITEM ) * 2 + computeUInt32Size ( WireFormat . MESSAGE_SET_TYPE_ID , fieldNumber ) + computeLazyFieldSize ( WireFormat . MESSAGE_SET_MESSAGE , value ) ; }
Compute the number of bytes that would be needed to encode an lazily parsed MessageSet extension field to the stream . For historical reasons the wire format differs from normal fields .
10,625
private void refreshBuffer ( ) throws IOException { if ( output == null ) { throw new OutOfSpaceException ( ) ; } output . write ( buffer , 0 , position ) ; position = 0 ; }
Internal helper that writes the current buffer to the output . The buffer position is reset to its initial value when this returns .
10,626
public void writeRawBytes ( final byte [ ] value , int offset , int length ) throws IOException { if ( limit - position >= length ) { System . arraycopy ( value , offset , buffer , position , length ) ; position += length ; } else { final int bytesWritten = limit - position ; System . arraycopy ( value , offset , buffer , position , bytesWritten ) ; offset += bytesWritten ; length -= bytesWritten ; position = limit ; refreshBuffer ( ) ; if ( length <= limit ) { System . arraycopy ( value , offset , buffer , 0 , length ) ; position = length ; } else { output . write ( value , offset , length ) ; } } }
Write part of an array of bytes .
10,627
public void writeRawBytes ( final ByteString value , int offset , int length ) throws IOException { if ( limit - position >= length ) { value . copyTo ( buffer , offset , position , length ) ; position += length ; } else { final int bytesWritten = limit - position ; value . copyTo ( buffer , offset , position , bytesWritten ) ; offset += bytesWritten ; length -= bytesWritten ; position = limit ; refreshBuffer ( ) ; if ( length <= limit ) { value . copyTo ( buffer , offset , 0 , length ) ; position = length ; } else { InputStream inputStreamFrom = value . newInput ( ) ; if ( offset != inputStreamFrom . skip ( offset ) ) { throw new IllegalStateException ( "Skip failed? Should never happen." ) ; } while ( length > 0 ) { int bytesToRead = Math . min ( length , limit ) ; int bytesRead = inputStreamFrom . read ( buffer , 0 , bytesToRead ) ; if ( bytesRead != bytesToRead ) { throw new IllegalStateException ( "Read failed? Should never happen" ) ; } output . write ( buffer , 0 , bytesRead ) ; length -= bytesRead ; } } } }
Write part of a byte string .
10,628
public void writeRawLittleEndian32 ( final int value ) throws IOException { writeRawByte ( ( value ) & 0xFF ) ; writeRawByte ( ( value >> 8 ) & 0xFF ) ; writeRawByte ( ( value >> 16 ) & 0xFF ) ; writeRawByte ( ( value >> 24 ) & 0xFF ) ; }
Write a little - endian 32 - bit integer .
10,629
public void writeRawLittleEndian64 ( final long value ) throws IOException { writeRawByte ( ( int ) ( value ) & 0xFF ) ; writeRawByte ( ( int ) ( value >> 8 ) & 0xFF ) ; writeRawByte ( ( int ) ( value >> 16 ) & 0xFF ) ; writeRawByte ( ( int ) ( value >> 24 ) & 0xFF ) ; writeRawByte ( ( int ) ( value >> 32 ) & 0xFF ) ; writeRawByte ( ( int ) ( value >> 40 ) & 0xFF ) ; writeRawByte ( ( int ) ( value >> 48 ) & 0xFF ) ; writeRawByte ( ( int ) ( value >> 56 ) & 0xFF ) ; }
Write a little - endian 64 - bit integer .
10,630
public static < T extends MatchResult , S extends MatchType > Predicate < T > greaterThan ( S matchType ) { return new GreaterThanPredicate < T , S > ( matchType ) ; }
Generates a Predicate that only accepts the Match Results that have a Match Type greater than matchType
10,631
public static < T extends MatchResult , S extends MatchType > Predicate < T > lowerThan ( S matchType ) { return new LowerThanPredicate < T , S > ( matchType ) ; }
Generates a Predicate that only accepts the Match Results that have a Match Type lower than matchType
10,632
public static < T extends MatchResult , S extends MatchType > Predicate < T > equalTo ( S matchType ) { return new EqualToPredicate < T , S > ( matchType ) ; }
Generates a Predicate that only accepts the Match Results that have a Match Type equal to matchType
10,633
public static < T extends MatchResult , S extends MatchType > Predicate < T > greaterOrEqualTo ( S matchType ) { return Predicates . or ( greaterThan ( matchType ) , equalTo ( matchType ) ) ; }
Generates a Predicate that only accepts the Match Results that have a Match Type greater or equal to matchType
10,634
public static < T extends MatchResult , S extends MatchType > Predicate < T > lowerOrEqualTo ( S matchType ) { return Predicates . or ( lowerThan ( matchType ) , equalTo ( matchType ) ) ; }
Generates a Predicate that only accepts the Match Results that have a Match Type lower or equal to matchType
10,635
public LoopInfo < R > setValues ( int currentIndex , int effectiveIndex , R lastRes ) { this . currentIndex = currentIndex ; this . effectiveIndex = effectiveIndex ; this . lastRes = lastRes ; return this ; }
set all fields of the loop info
10,636
public java . lang . Iterable < ? > getIterable ( KProcess process ) { java . lang . Iterable < ? > iterable = null ; try { iterable = ( java . lang . Iterable < ? > ) this . field . get ( process . getContext ( ) ) ; } catch ( IllegalArgumentException e ) { e . printStackTrace ( ) ; } catch ( IllegalAccessException e ) { e . printStackTrace ( ) ; } return iterable ; }
This will return Iterable to Calling method as parameter .
10,637
private String getItemKey ( int position ) { if ( mMap != null ) { return new ArrayList < > ( mMap . entrySet ( ) ) . get ( position ) . getKey ( ) ; } else if ( mJsonArray != null ) { return String . valueOf ( position ) ; } return null ; }
Provides the item key name . Number for array property for object .
10,638
private Object getItem ( int position ) { if ( mMap != null ) { return new ArrayList < > ( mMap . entrySet ( ) ) . get ( position ) . getValue ( ) ; } else if ( mJsonArray != null ) { return mJsonArray . opt ( position ) ; } return null ; }
Provides the item in a given position .
10,639
public static ConceptId getInstance ( String propId , String propertyName , Metadata metadata ) { return getInstance ( propId , propertyName , null , metadata ) ; }
Returns a concept propId with the given proposition propId and property name .
10,640
public static PropDefConceptId getInstance ( String propId , String propertyName , Value value , Metadata metadata ) { List < Object > key = new ArrayList < > ( 4 ) ; key . add ( propId ) ; key . add ( propertyName ) ; key . add ( value ) ; key . add ( Boolean . TRUE ) ; PropDefConceptId conceptId = ( PropDefConceptId ) metadata . getFromConceptIdCache ( key ) ; if ( conceptId == null ) { conceptId = new PropDefConceptId ( propId , propertyName , value , metadata ) ; metadata . putInConceptIdCache ( key , conceptId ) ; } return conceptId ; }
Returns a concept propId with the given proposition propId property name and value .
10,641
public static < T > ClassSup < T > cls ( Class < T > cls ) { return mapper . get ( cls . getName ( ) , ( ) -> new ClassSup < > ( cls ) ) ; }
create a class supporter with given class
10,642
@ SuppressWarnings ( "unchecked" ) public static < T > ClassSup < T > cls ( T obj ) { return mapper . get ( obj . getClass ( ) . getName ( ) , ( ) -> ( ClassSup < T > ) cls ( obj . getClass ( ) ) ) ; }
create a class supporter with given object
10,643
@ SuppressWarnings ( "unchecked" ) public static < T > T proxy ( InvocationHandler handler , T toProxy ) { return ( T ) Proxy . newProxyInstance ( toProxy . getClass ( ) . getClassLoader ( ) , toProxy . getClass ( ) . getInterfaces ( ) , handler ) ; }
generate proxy object with given InvocationHandler and the object to do proxy
10,644
private static boolean translate ( String glob , StringBuilder result ) { int i ; int max ; char c ; int j ; String stuff ; int escaped ; escaped = 0 ; max = glob . length ( ) ; for ( i = 0 ; i < max ; ) { c = glob . charAt ( i ++ ) ; if ( c == '*' ) { result . append ( ".*" ) ; } else if ( c == '?' ) { result . append ( '.' ) ; } else if ( c == '[' ) { j = i ; if ( j < max && glob . charAt ( j ) == '!' ) { j ++ ; } if ( j < max && glob . charAt ( j ) == ']' ) { j ++ ; } while ( j < max && glob . charAt ( j ) != ']' ) { j ++ ; } if ( j >= max ) { result . append ( "\\[" ) ; } else { stuff = glob . substring ( i , j ) ; stuff = Strings . replace ( stuff , "\\" , "\\\\" ) ; i = j + 1 ; if ( stuff . charAt ( 0 ) == '!' ) { stuff = '^' + stuff . substring ( 1 ) ; } else if ( stuff . charAt ( 0 ) == '^' ) { stuff = '\\' + stuff ; } result . append ( '[' ) ; result . append ( stuff ) ; result . append ( ']' ) ; } } else { escaped ++ ; result . append ( escape ( c ) ) ; } } result . append ( '$' ) ; return escaped == max ; }
Translate a glob PATTERN to a regular expression .
10,645
InputStream getContent ( String url ) throws IOException , NsApiException { Request request = new Request . Builder ( ) . url ( url ) . get ( ) . build ( ) ; try { Response response = client . newCall ( request ) . execute ( ) ; if ( response . body ( ) == null ) { log . error ( "Error while calling the webservice, entity is null" ) ; throw new NsApiException ( "Error while calling the webservice, entity is null" ) ; } return response . body ( ) . byteStream ( ) ; } catch ( RuntimeException e ) { log . error ( "Error while calling the webservice, entity is null" ) ; throw new NsApiException ( "Error while calling the webservice, entity is null" , e ) ; } }
Handling the webservice call
10,646
public final void add ( final GeneratedMessageLite . GeneratedExtension < ? , ? > extension ) { extensionsByNumber . put ( new ObjectIntPair ( extension . getContainingTypeDefaultInstance ( ) , extension . getNumber ( ) ) , extension ) ; }
Add an extension from a lite generated file to the registry .
10,647
public String value ( Object context ) { return this . property != null ? this . property . get ( context ) : null ; }
Return the value of the attribute
10,648
@ SuppressWarnings ( "unchecked" ) protected void set ( String property , Object value , boolean notify ) { uninstallListener ( property ) ; JsonEntity entity = null ; if ( value instanceof JsonValue ) { entity = getEntity ( ( JsonValue ) value ) ; } else if ( value instanceof JsonEntity ) { entity = ( JsonEntity ) value ; } if ( entity != null && ! listeners . containsKey ( property ) ) { installListener ( property , entity ) ; } V oldValue = properties . get ( property ) ; properties . put ( property , ( V ) value ) ; appendSortOrder ( property ) ; if ( notify ) { firePropertyChange ( property , oldValue , ( V ) value ) ; } }
Sets a new value for the given property .
10,649
public void remove ( String property ) { uninstallListener ( property ) ; Object oldValue = get ( property ) ; properties . remove ( property ) ; firePropertyChange ( property , oldValue , null ) ; }
Removes the given property .
10,650
public static String [ ] toArray ( Collection < String > coll ) { String [ ] ar ; ar = new String [ coll . size ( ) ] ; coll . toArray ( ar ) ; return ar ; }
Turns a list of Strings into an array .
10,651
public static String escape ( String str ) { int i , max ; StringBuilder result ; char c ; max = str . length ( ) ; for ( i = 0 ; i < max ; i ++ ) { if ( str . charAt ( i ) < 32 ) { break ; } } if ( i == max ) { return str ; } result = new StringBuilder ( max + 10 ) ; for ( i = 0 ; i < max ; i ++ ) { c = str . charAt ( i ) ; switch ( c ) { case '\n' : result . append ( "\\n" ) ; break ; case '\r' : result . append ( "\\r" ) ; break ; case '\t' : result . append ( "\\t" ) ; break ; case '\\' : result . append ( "\\\\" ) ; break ; default : if ( c < 32 ) { result . append ( "\\u" ) . append ( Strings . padLeft ( Integer . toHexString ( c ) , 4 , '0' ) ) ; } else { result . append ( c ) ; } } } return result . toString ( ) ; }
escape Strings as in Java String literals
10,652
protected static Properties getComponentProperties ( String componentPrefix , Properties properties ) { Properties result = new Properties ( ) ; if ( null != componentPrefix ) { int componentPrefixLength = componentPrefix . length ( ) ; for ( String propertyName : properties . stringPropertyNames ( ) ) { if ( propertyName . startsWith ( componentPrefix ) ) { result . put ( propertyName . substring ( componentPrefixLength ) , properties . getProperty ( propertyName ) ) ; } } } return result ; }
Returns only properties that start with componentPrefix removing this prefix .
10,653
protected static String makeComponentPrefix ( String tokenName , String className ) { String simpleClassName = className ; if ( null != className ) { int lastDotIdx = className . lastIndexOf ( "." ) ; if ( lastDotIdx > - 1 ) { simpleClassName = className . substring ( lastDotIdx + 1 , className . length ( ) ) ; } } return tokenName + "." + simpleClassName + "." ; }
Creates a prefix for component to search for its properties in properties .
10,654
public static Properties loadProperties ( String filename ) throws ConfigurableException { log . info ( "Loading properties from " + filename ) ; Properties properties = new Properties ( ) ; FileInputStream input = null ; try { input = new FileInputStream ( filename ) ; properties . load ( input ) ; } catch ( IOException e ) { final String errMessage = e . getClass ( ) . getSimpleName ( ) + ": " + e . getMessage ( ) ; log . error ( errMessage , e ) ; throw new ConfigurableException ( errMessage , e ) ; } finally { if ( null != input ) { try { input . close ( ) ; } catch ( IOException e ) { final String errMessage = e . getClass ( ) . getSimpleName ( ) + ": " + e . getMessage ( ) ; log . error ( errMessage , e ) ; } } } return properties ; }
Loads the properties from the properties file .
10,655
public char match ( ISense source , ISense target ) throws MatcherLibraryException { int Equals = 0 ; int moreGeneral = 0 ; int lessGeneral = 0 ; int Opposite = 0 ; String sSynset = source . getGloss ( ) ; String tSynset = target . getGloss ( ) ; StringTokenizer stSource = new StringTokenizer ( sSynset , " ,.\"'()" ) ; String lemmaS , lemmaT ; while ( stSource . hasMoreTokens ( ) ) { StringTokenizer stTarget = new StringTokenizer ( tSynset , " ,.\"'()" ) ; lemmaS = stSource . nextToken ( ) ; if ( ! meaninglessWords . contains ( lemmaS ) ) while ( stTarget . hasMoreTokens ( ) ) { lemmaT = stTarget . nextToken ( ) ; if ( ! meaninglessWords . contains ( lemmaT ) ) { if ( isWordLessGeneral ( lemmaS , lemmaT ) ) lessGeneral ++ ; else if ( isWordMoreGeneral ( lemmaS , lemmaT ) ) moreGeneral ++ ; else if ( isWordSynonym ( lemmaS , lemmaT ) ) Equals ++ ; else if ( isWordOpposite ( lemmaS , lemmaT ) ) Opposite ++ ; } } } return getRelationFromInts ( lessGeneral , moreGeneral , Equals , Opposite ) ; }
Computes the relations with WordNet semantic gloss matcher .
10,656
public char match ( String str1 , String str2 ) { invocationCount ++ ; char rel = IMappingElement . IDK ; if ( str1 == null || str2 == null ) { rel = IMappingElement . IDK ; } else { if ( ( str1 . length ( ) > 3 ) && ( str2 . length ( ) > 3 ) ) { if ( str1 . startsWith ( str2 ) ) { if ( str1 . contains ( " " ) ) { rel = IMappingElement . LESS_GENERAL ; } else { rel = IMappingElement . EQUIVALENCE ; } } else { if ( str2 . startsWith ( str1 ) ) { if ( str2 . contains ( " " ) ) { rel = IMappingElement . MORE_GENERAL ; } else { rel = IMappingElement . EQUIVALENCE ; } } } } } if ( rel != IMappingElement . IDK ) { relCount ++ ; addCase ( str1 , str2 , rel ) ; } return rel ; }
Computes the relation with prefix matcher .
10,657
public static CouchbaseOperation getOperation ( Configuration hadoopConfiguration ) throws ArgsException { String strCouchbaseOperation = hadoopConfiguration . get ( ARG_OPERATION . getPropertyName ( ) ) ; if ( strCouchbaseOperation == null ) { return CouchbaseOperation . SET ; } try { return CouchbaseOperation . valueOf ( strCouchbaseOperation ) ; } catch ( IllegalArgumentException e ) { throw new ArgsException ( "Unrecognized store type '" + strCouchbaseOperation + "'. Please provide one of the following: SET, ADD, REPLACE, APPEND, PREPEND and DELETE." , e ) ; } }
Reads Couchbase store operation from the Hadoop configuration type .
10,658
public static Map < String , String > attributes ( Object executable ) { if ( executable == null || ! Aspects . hasAspect ( PerExecutable . class , executable . getClass ( ) ) ) { return empty ; } PerExecutable perExecutable = Aspects . aspectOf ( PerExecutable . class , executable . getClass ( ) ) ; if ( perExecutable . executable != null ) { return perExecutable . executable . values ( executable ) ; } else { return empty ; } }
Return the values of the attributes
10,659
protected Map < String , Object > buildJobDataMap ( final JmxCommand jmxCommand , final Object [ ] params ) throws MBeanException { final Map < String , Object > jobDataMap = new HashMap < String , Object > ( ) ; try { int ind = 0 ; for ( JmxOption option : JmxOptions . getOptions ( ) ) { option . process ( jobDataMap , String . valueOf ( params [ ind ++ ] ) ) ; } for ( Argument arg : this . remoteProgram . getArguments ( ) ) { arg . setValueUsingParser ( String . valueOf ( params [ ind ++ ] ) ) ; } } catch ( Exception e ) { throw new MBeanException ( e ) ; } return jobDataMap ; }
Initialize the JobDataMap with the Program arguments
10,660
public Optional < BioCNode > getNode ( String role ) { return getNodes ( ) . stream ( ) . filter ( n -> n . getRole ( ) . equals ( role ) ) . findFirst ( ) ; }
Gets the first node based on the role .
10,661
public Matcher getMatcher ( String str ) { Matcher m ; if ( matchers . containsKey ( str ) ) { m = matchers . get ( str ) ; } else { m = p . matcher ( str ) ; matchers . put ( str , m ) ; } return m ; }
get matcher of the given string
10,662
public String [ ] exec ( String toExec ) { Matcher m = getMatcher ( toExec ) ; if ( m . find ( ) ) { List < String > list = new ArrayList < > ( ) ; int count = m . groupCount ( ) ; For ( 1 ) . to ( count ) . loop ( i -> { list . add ( m . group ( i ) ) ; } ) ; return list . toArray ( new String [ list . size ( ) ] ) ; } else { return null ; } }
same as JavaScript exec
10,663
public static Trie < String > toStringTrie ( List < String > words ) { final TrieBuilder < String > builder = new TrieBuilder < > ( ) ; for ( String word : words ) { builder . add ( word , "" ) ; } return builder . build ( ) ; }
Sometimes a Trie s values aren t important only the words matter . Convenience method that associates each word with an empty value .
10,664
private void flushBuffer ( byte [ ] append , int ofs , int len ) throws IOException { int count ; count = pos + len ; if ( count > 0 ) { dest . writeAsciiLn ( Integer . toHexString ( count ) ) ; dest . write ( buffer , 0 , pos ) ; dest . write ( append , ofs , len ) ; dest . writeAsciiLn ( ) ; pos = 0 ; } }
flush buffer and bytes in append
10,665
public int download ( ) { try { if ( url . startsWith ( "https://" ) ) { registerSSLContext ( client . getBackend ( ) ) ; } final HttpGet httpGet = new HttpGet ( url ) ; if ( httpGet . isAborted ( ) ) { httpGet . abort ( ) ; } client . execute ( httpGet , new FutureCallback < HttpResponse > ( ) { public void failed ( Exception e ) { for ( DownloadListenerInterface listener : listeners ) { listener . errorOccured ( e ) ; } } public void completed ( HttpResponse response ) { for ( DownloadListenerInterface listener : listeners ) { try { listener . dataReceived ( response . getEntity ( ) . getContent ( ) , httpGet . getURI ( ) . toString ( ) ) ; } catch ( Exception e ) { listener . errorOccured ( e ) ; } } } public void cancelled ( ) { for ( DownloadListenerInterface listener : listeners ) { listener . aborted ( httpGet . getURI ( ) . toString ( ) ) ; } } } ) ; httpGets . add ( httpGet ) ; lastSlot = httpGets . size ( ) - 1 ; return lastSlot ; } catch ( Exception e ) { for ( DownloadListenerInterface listener : listeners ) { listener . errorOccured ( e ) ; } } return - 1 ; }
Starts the async download . The returned number is the internal slot for this download transfer which can be used as parameter in abort to stop this specific transfer .
10,666
public void abort ( int slot ) { try { HttpGet httpGet = httpGets . get ( slot ) ; httpGet . abort ( ) ; abortListeners ( httpGet . getURI ( ) . toString ( ) ) ; } catch ( Exception e ) { log . error ( e . getMessage ( ) ) ; } }
Aborts a transfer at the given slot
10,667
public static ElementBuilder [ ] newBuilders ( Class < ? > type ) { List < ElementBuilder > builders = new ArrayList < ElementBuilder > ( ) ; for ( ElementBuilderFactory factory : loader ) { ElementBuilder b = factory . newBuilder ( type ) ; if ( b != null ) { builders . add ( b ) ; } } return builders . toArray ( new ElementBuilder [ 0 ] ) ; }
Return an array of builders that will build one part of the program .
10,668
private void convertWordNetToFlat ( Properties properties ) throws SMatchException { InMemoryWordNetBinaryArray . createWordNetCaches ( GLOBAL_PREFIX + SENSE_MATCHER_KEY , properties ) ; WordNet . createWordNetCaches ( GLOBAL_PREFIX + LINGUISTIC_ORACLE_KEY , properties ) ; }
Converts WordNet dictionary to binary format for fast searching .
10,669
@ SuppressWarnings ( "unchecked" ) public < Coll extends CollectionFuncSup < T > > Coll add ( T t ) { Collection < T > coll = ( Collection < T > ) iterable ; coll . add ( t ) ; return ( Coll ) this ; }
a chain to simplify add process
10,670
public boolean assist ( ) { final String commandLine = commandLineManager . getCommandLine ( ) ; final int caret = commandLineManager . getCaret ( ) ; final String commandLineToAssist = commandLine . substring ( 0 , caret ) ; final Opt < String > autoCompletedSuffix = shell . assist ( commandLineToAssist ) ; if ( ! autoCompletedSuffix . isPresent ( ) ) { return false ; } final String extraCommandLine = commandLine . substring ( caret ) ; final String autoCompletedCommandLine = commandLineToAssist + autoCompletedSuffix . get ( ) ; commandLineManager . setCommandLine ( autoCompletedCommandLine + extraCommandLine ) ; commandLineManager . setCaret ( autoCompletedCommandLine . length ( ) ) ; return true ; }
Provide assistance for the command line .
10,671
public Set < URI > listOutputs ( URI operationUri ) { if ( operationUri == null ) { return ImmutableSet . of ( ) ; } return ImmutableSet . copyOf ( this . opOutputMap . get ( operationUri ) ) ; }
Obtains the list of output URIs for a given Operation
10,672
public Set < URI > listOptionalParts ( URI messageContent ) { if ( messageContent == null ) { return ImmutableSet . of ( ) ; } return ImmutableSet . copyOf ( this . messageOptionalPartsMap . get ( messageContent ) ) ; }
Obtains the list of optional parts for a given Message Content
10,673
private void initialise ( ) { Stopwatch stopwatch = new Stopwatch ( ) ; stopwatch . start ( ) ; populateCache ( ) ; stopwatch . stop ( ) ; log . info ( "Cache populated. Time taken {}" , stopwatch ) ; }
This method will be called when the server is initialised . If necessary it should take care of updating any indexes on boot time .
10,674
public synchronized void handleOntologyCreated ( OntologyCreatedEvent event ) { log . info ( "Processing Ontology Created Event - {}" , event . getOntologyUri ( ) ) ; Set < URI > conceptUris = this . manager . getKnowledgeBaseManager ( ) . listConcepts ( event . getOntologyUri ( ) ) ; log . info ( "Fetching matches for all the {} concepts present in the ontology - {}" , conceptUris . size ( ) , event . getOntologyUri ( ) ) ; for ( URI c : conceptUris ) { indexedMatches . put ( c , new ConcurrentHashMap < URI , MatchResult > ( sparqlMatcher . listMatchesAtLeastOfType ( c , LogicConceptMatchType . Subsume ) ) ) ; } }
A new ontology has been uploaded to the server and we need to update the indexes
10,675
public synchronized void handleOntologyDeleted ( OntologyDeletedEvent event ) { log . info ( "Processing Ontology Deleted Event - {}" , event . getOntologyUri ( ) ) ; Set < URI > conceptUris = this . manager . getKnowledgeBaseManager ( ) . listConcepts ( null ) ; Set < URI > difference = Sets . difference ( conceptUris , this . indexedMatches . keySet ( ) ) ; for ( URI conceptUri : difference ) { this . indexedMatches . remove ( conceptUri ) ; } for ( URI indexedConcept : indexedMatches . keySet ( ) ) { Map < URI , MatchResult > matchResultMap = indexedMatches . get ( indexedConcept ) ; for ( URI conceptUri : difference ) { matchResultMap . remove ( conceptUri ) ; } indexedMatches . put ( indexedConcept , new ConcurrentHashMap < URI , MatchResult > ( matchResultMap ) ) ; } }
An ontology has been deleted from the KB and we should thus update the indexes . By the time we want to process this event we won t know any longer which concepts need to be removed unless we keep this somewhere .
10,676
public Icon get ( String url ) { StackTraceElement [ ] stacks = new Exception ( ) . getStackTrace ( ) ; try { Class callerClazz = Class . forName ( stacks [ 1 ] . getClassName ( ) ) ; return get ( callerClazz . getResource ( url ) ) ; } catch ( ClassNotFoundException e ) { throw new RuntimeException ( e ) ; } }
Gets the icon denoted by url . If url is relative it is relative to the caller .
10,677
public void closeAssociated ( ) throws XAException { Xid associatedXid = cpoXaStateMap . getXaResourceMap ( ) . get ( this ) ; if ( associatedXid != null ) { close ( associatedXid ) ; } }
Closes the resource associated with this instance
10,678
public void close ( Xid xid ) throws XAException { synchronized ( cpoXaStateMap ) { CpoXaState < T > cpoXaState = cpoXaStateMap . getXidStateMap ( ) . get ( xid ) ; if ( cpoXaState == null ) throw CpoXaError . createXAException ( CpoXaError . XAER_NOTA , "Unknown XID" ) ; closeResource ( cpoXaState . getResource ( ) ) ; cpoXaStateMap . getXaResourceMap ( ) . remove ( cpoXaState . getAssignedResourceManager ( ) ) ; cpoXaStateMap . getXidStateMap ( ) . remove ( xid ) ; } }
Closes the resource for the specified xid
10,679
public void execute ( org . parallelj . mirror . Process process ) { if ( ! ( process instanceof KProcess ) ) { return ; } this . execute ( ( KProcess ) process ) ; }
Execute a process .
10,680
public static ConceptId getInstance ( String id , Metadata metadata ) { List < Object > key = new ArrayList < > ( 1 ) ; key . add ( id ) ; ConceptId result = metadata . getFromConceptIdCache ( key ) ; if ( result != null ) { return result ; } else { result = new SimpleConceptId ( id , metadata ) ; metadata . putInConceptIdCache ( key , result ) ; return result ; } }
Returns a concept propId with the given string identifier .
10,681
public static < T > Spplr < T > reflectionSupplier ( Object instance , String methodName , Class < T > suppliedClass ) { final ReflectionMethod method = ReflectionUtils . getNoArgsMethod ( instance . getClass ( ) , methodName ) ; ReflectionUtils . assertReturnValue ( method , suppliedClass ) ; return new ReflectionSupplier < > ( instance , method ) ; }
Create a supplier that will invoke the method specified by the give method name on the given object instance through reflection . The method must be no - args and must return a value of the specified type . The method may be private in which case it will be made accessible outside it s class .
10,682
public void write ( String key , String document ) throws IOException { try { outputStream . write ( key . getBytes ( "UTF-8" ) ) ; outputStream . write ( keyDocumentDelimiter . getBytes ( "UTF-8" ) ) ; outputStream . write ( document . getBytes ( "UTF-8" ) ) ; outputStream . write ( rowDelimiter . getBytes ( "UTF-8" ) ) ; } catch ( UnsupportedEncodingException e ) { LOGGER . error ( "Shouldn't happen." ) ; } }
Write a Couchbase document
10,683
protected char getRelation ( IAtomicConceptOfLabel sourceACoL , IAtomicConceptOfLabel targetACoL ) throws MatcherLibraryException { try { char relation = senseMatcher . getRelation ( sourceACoL . getSenseList ( ) , targetACoL . getSenseList ( ) ) ; if ( IMappingElement . IDK == relation ) { if ( useWeakSemanticsElementLevelMatchersLibrary ) { relation = getRelationFromStringMatchers ( sourceACoL . getLemma ( ) , targetACoL . getLemma ( ) ) ; if ( IMappingElement . IDK == relation ) { relation = getRelationFromSenseGlossMatchers ( sourceACoL . getSenseList ( ) , targetACoL . getSenseList ( ) ) ; } } } return relation ; } catch ( SenseMatcherException e ) { final String errMessage = e . getClass ( ) . getSimpleName ( ) + ": " + e . getMessage ( ) ; log . error ( errMessage , e ) ; throw new MatcherLibraryException ( errMessage , e ) ; } }
Returns a semantic relation between two atomic concepts .
10,684
private char getRelationFromStringMatchers ( String sourceLabel , String targetLabel ) { char relation = IMappingElement . IDK ; int i = 0 ; while ( ( relation == IMappingElement . IDK ) && ( i < stringMatchers . size ( ) ) ) { relation = stringMatchers . get ( i ) . match ( sourceLabel , targetLabel ) ; i ++ ; } return relation ; }
Returns semantic relation holding between two labels as computed by string based matchers .
10,685
private char getRelationFromSenseGlossMatchers ( List < ISense > sourceSenses , List < ISense > targetSenses ) throws MatcherLibraryException { char relation = IMappingElement . IDK ; if ( 0 < senseGlossMatchers . size ( ) ) { for ( ISense sourceSense : sourceSenses ) { for ( ISense targetSense : targetSenses ) { int k = 0 ; while ( ( relation == IMappingElement . IDK ) && ( k < senseGlossMatchers . size ( ) ) ) { relation = senseGlossMatchers . get ( k ) . match ( sourceSense , targetSense ) ; k ++ ; } return relation ; } } } return relation ; }
Returns semantic relation between two sets of senses by WordNet sense - based matchers .
10,686
public static List < Element > getChildElements ( Element root , String ... steps ) { List < Element > lst ; lst = new ArrayList < > ( ) ; doGetChildElements ( root , steps , 0 , lst ) ; return lst ; }
Steps may be empty strings
10,687
private ILabel processNode ( INode currentNode , ArrayList < ILabel > pathToRootPhrases ) throws ContextPreprocessorException { if ( debugLabels ) { log . debug ( "preprocessing node: " + currentNode . getNodeData ( ) . getId ( ) + ", label: " + currentNode . getNodeData ( ) . getName ( ) ) ; } currentNode . getNodeData ( ) . setcLabFormula ( "" ) ; currentNode . getNodeData ( ) . setcNodeFormula ( "" ) ; while ( 0 < currentNode . getNodeData ( ) . getACoLCount ( ) ) { currentNode . getNodeData ( ) . removeACoL ( 0 ) ; } String label = currentNode . getNodeData ( ) . getName ( ) ; ILabel result = new Label ( label ) ; result . setContext ( pathToRootPhrases ) ; try { pipeline . process ( result ) ; String formula = result . getFormula ( ) ; currentNode . getNodeData ( ) . setIsPreprocessed ( true ) ; String [ ] tokenIndexes = formula . split ( "[ ()&|~]" ) ; Set < String > indexes = new HashSet < String > ( Arrays . asList ( tokenIndexes ) ) ; List < IToken > tokens = result . getTokens ( ) ; for ( int i = 0 ; i < tokens . size ( ) ; i ++ ) { IToken token = tokens . get ( i ) ; String tokenIdx = Integer . toString ( i ) ; if ( indexes . contains ( tokenIdx ) ) { IAtomicConceptOfLabel acol = currentNode . getNodeData ( ) . createACoL ( ) ; acol . setId ( i ) ; acol . setToken ( token . getText ( ) ) ; acol . setLemma ( token . getLemma ( ) ) ; for ( ISense sense : token . getSenses ( ) ) { acol . addSense ( sense ) ; } currentNode . getNodeData ( ) . addACoL ( acol ) ; } } formula = formula . replaceAll ( "(\\d+)" , currentNode . getNodeData ( ) . getId ( ) + ".$1" ) ; formula = formula . trim ( ) ; currentNode . getNodeData ( ) . setcLabFormula ( formula ) ; } catch ( PipelineComponentException e ) { if ( log . isEnabledFor ( Level . WARN ) ) { log . warn ( "Falling back to heuristic parser for label (" + result . getText ( ) + "): " + e . getMessage ( ) , e ) ; fallbackCount ++ ; dcp . processNode ( currentNode ) ; } } return result ; }
Converts current node label into a formula using path to root as a context
10,688
public char match ( ISense source , ISense target ) throws MatcherLibraryException { List < String > sourceLemmas = source . getLemmas ( ) ; List < String > targetLemmas = target . getLemmas ( ) ; for ( String sourceLemma : sourceLemmas ) { for ( String targetLemma : targetLemmas ) { if ( sourceLemma . equals ( targetLemma ) ) { return IMappingElement . EQUIVALENCE ; } } } return IMappingElement . IDK ; }
Computes the relation with WordNet lemma matcher .
10,689
protected String resolveIOSPlaceholders ( String original ) { int index = 1 ; String resolved = original ; final Pattern pattern = Pattern . compile ( "%[a-zA-Z@]" ) ; final Matcher matcher = pattern . matcher ( original ) ; while ( matcher . find ( ) ) { String placeholderIOS = matcher . group ( ) ; String placeholderAndroid = placeholderMap . get ( placeholderIOS ) ; if ( placeholderAndroid != null ) { placeholderAndroid = String . format ( placeholderAndroid , index ++ ) ; resolved = resolved . replaceFirst ( placeholderIOS , placeholderAndroid ) ; } } return resolved ; }
Returns a string with resolved iOS placeholders .
10,690
private Map < URI , MatchResult > findSome ( URI entityType , URI relationship , Set < URI > types , MatchType matchType ) { if ( types == null || types . isEmpty ( ) || ( ! entityType . toASCIIString ( ) . equals ( MSM . Service . getURI ( ) ) && ! entityType . toASCIIString ( ) . equals ( MSM . Operation . getURI ( ) ) ) || ( ! relationship . toASCIIString ( ) . equals ( MSM . hasInput . getURI ( ) ) && ! relationship . toASCIIString ( ) . equals ( MSM . hasOutput . getURI ( ) ) && ! relationship . toASCIIString ( ) . equals ( SAWSDL . modelReference . getURI ( ) ) ) ) { return ImmutableMap . of ( ) ; } Table < URI , URI , MatchResult > expandedTypes ; if ( matchType . equals ( LogicConceptMatchType . Subsume ) ) { expandedTypes = HashBasedTable . create ( ) ; for ( URI type : types ) { expandedTypes . putAll ( this . conceptMatcher . listMatchesAtMostOfType ( ImmutableSet . of ( type ) , LogicConceptMatchType . Subsume ) ) ; expandedTypes . putAll ( this . conceptMatcher . listMatchesOfType ( ImmutableSet . of ( type ) , LogicConceptMatchType . Exact ) ) ; } } else if ( matchType . equals ( LogicConceptMatchType . Plugin ) ) { expandedTypes = this . conceptMatcher . listMatchesAtLeastOfType ( types , LogicConceptMatchType . Plugin ) ; } else { expandedTypes = HashBasedTable . create ( ) ; for ( URI type : types ) { expandedTypes . putAll ( this . conceptMatcher . listMatchesOfType ( ImmutableSet . of ( type ) , LogicConceptMatchType . Exact ) ) ; } } Multimap < URI , MatchResult > result = ArrayListMultimap . create ( ) ; Map < URI , Map < URI , MatchResult > > columnMap = expandedTypes . columnMap ( ) ; for ( URI type : columnMap . keySet ( ) ) { Set < URI > entities = ImmutableSet . of ( ) ; if ( relationship . toASCIIString ( ) . equals ( SAWSDL . modelReference . getURI ( ) ) ) { entities = listEntitesWithModelReference ( entityType , type ) ; } else if ( relationship . toASCIIString ( ) . equals ( MSM . hasInput . getURI ( ) ) || relationship . toASCIIString ( ) . equals ( MSM . hasOutput . getURI ( ) ) ) { entities = listEntitiesWithType ( entityType , relationship , type ) ; } for ( URI entity : entities ) { result . putAll ( entity , columnMap . get ( type ) . values ( ) ) ; } } return Maps . transformValues ( result . asMap ( ) , MatchResultsMerger . UNION ) ; }
Generic implementation for finding all the Services or Operations that have SOME of the given types as inputs or outputs .
10,691
private Set < URI > listEntitesWithModelReference ( URI entityType , URI modelReference ) { Set < URI > entities = ImmutableSet . of ( ) ; if ( entityType . toASCIIString ( ) . equals ( MSM . Service . getURI ( ) ) ) { entities = this . serviceManager . listServicesWithModelReference ( modelReference ) ; } else if ( entityType . toASCIIString ( ) . equals ( MSM . Operation . getURI ( ) ) ) { entities = this . serviceManager . listOperationsWithModelReference ( modelReference ) ; } return entities ; }
Generic implementation for finding all the Services or Operations that have one specific model reference .
10,692
private Set < URI > listEntitiesWithType ( URI entityType , URI relationship , URI type ) { Set < URI > entities = ImmutableSet . of ( ) ; if ( entityType . toASCIIString ( ) . equals ( MSM . Service . getURI ( ) ) ) { if ( relationship . toASCIIString ( ) . equals ( MSM . hasInput . getURI ( ) ) ) { entities = this . serviceManager . listServicesWithInputType ( type ) ; } else if ( relationship . toASCIIString ( ) . equals ( MSM . hasOutput . getURI ( ) ) ) { entities = this . serviceManager . listServicesWithOutputType ( type ) ; } } else if ( entityType . toASCIIString ( ) . equals ( MSM . Operation . getURI ( ) ) ) { if ( relationship . toASCIIString ( ) . equals ( MSM . hasInput . getURI ( ) ) ) { entities = this . serviceManager . listOperationsWithInputType ( type ) ; } else if ( relationship . toASCIIString ( ) . equals ( MSM . hasOutput . getURI ( ) ) ) { entities = this . serviceManager . listOperationsWithOutputType ( type ) ; } } return entities ; }
Generic implementation for finding all the Services or Operations that have one specific type as input or output .
10,693
public Map < URI , MatchResult > findOperationsConsumingAll ( Set < URI > inputTypes ) { return findOperationsConsumingAll ( inputTypes , LogicConceptMatchType . Plugin ) ; }
Discover registered operations that consume all the types of input provided . That is all those that have as input the types provided . All the input types should be matched to different inputs .
10,694
public Map < URI , MatchResult > findServicesClassifiedByAll ( Set < URI > modelReferences ) { return findServicesClassifiedByAll ( modelReferences , LogicConceptMatchType . Subsume ) ; }
Discover the services that are classified by all the types given . That is all those that have some level of matching with respect to all services provided in the model references .
10,695
public Map < FieldDescriptorType , Object > getAllFields ( ) { if ( hasLazyField ) { SmallSortedMap < FieldDescriptorType , Object > result = SmallSortedMap . newFieldMap ( 16 ) ; for ( int i = 0 ; i < fields . getNumArrayEntries ( ) ; i ++ ) { cloneFieldEntry ( result , fields . getArrayEntryAt ( i ) ) ; } for ( Map . Entry < FieldDescriptorType , Object > entry : fields . getOverflowEntries ( ) ) { cloneFieldEntry ( result , entry ) ; } if ( fields . isImmutable ( ) ) { result . makeImmutable ( ) ; } return result ; } return fields . isImmutable ( ) ? fields : Collections . unmodifiableMap ( fields ) ; }
Get a simple map containing all the fields .
10,696
public Iterator < Map . Entry < FieldDescriptorType , Object > > iterator ( ) { if ( hasLazyField ) { return new LazyIterator < FieldDescriptorType > ( fields . entrySet ( ) . iterator ( ) ) ; } return fields . entrySet ( ) . iterator ( ) ; }
Get an iterator to the field map . This iterator should not be leaked out of the protobuf library as it is not protected from mutation when fields is not immutable .
10,697
private static void writeElementNoTag ( final CodedOutputStream output , final WireFormat . FieldType type , final Object value ) throws IOException { switch ( type ) { case DOUBLE : output . writeDoubleNoTag ( ( Double ) value ) ; break ; case FLOAT : output . writeFloatNoTag ( ( Float ) value ) ; break ; case INT64 : output . writeInt64NoTag ( ( Long ) value ) ; break ; case UINT64 : output . writeUInt64NoTag ( ( Long ) value ) ; break ; case INT32 : output . writeInt32NoTag ( ( Integer ) value ) ; break ; case FIXED64 : output . writeFixed64NoTag ( ( Long ) value ) ; break ; case FIXED32 : output . writeFixed32NoTag ( ( Integer ) value ) ; break ; case BOOL : output . writeBoolNoTag ( ( Boolean ) value ) ; break ; case STRING : output . writeStringNoTag ( ( String ) value ) ; break ; case GROUP : output . writeGroupNoTag ( ( MessageLite ) value ) ; break ; case MESSAGE : output . writeMessageNoTag ( ( MessageLite ) value ) ; break ; case BYTES : output . writeBytesNoTag ( ( ByteString ) value ) ; break ; case UINT32 : output . writeUInt32NoTag ( ( Integer ) value ) ; break ; case SFIXED32 : output . writeSFixed32NoTag ( ( Integer ) value ) ; break ; case SFIXED64 : output . writeSFixed64NoTag ( ( Long ) value ) ; break ; case SINT32 : output . writeSInt32NoTag ( ( Integer ) value ) ; break ; case SINT64 : output . writeSInt64NoTag ( ( Long ) value ) ; break ; case ENUM : output . writeEnumNoTag ( ( ( Internal . EnumLite ) value ) . getNumber ( ) ) ; break ; } }
Write a field of arbitrary type without its tag to the stream .
10,698
public static void writeField ( final FieldDescriptorLite < ? > descriptor , final Object value , final CodedOutputStream output ) throws IOException { WireFormat . FieldType type = descriptor . getLiteType ( ) ; int number = descriptor . getNumber ( ) ; if ( descriptor . isRepeated ( ) ) { final List < ? > valueList = ( List < ? > ) value ; if ( descriptor . isPacked ( ) ) { output . writeTag ( number , WireFormat . WIRETYPE_LENGTH_DELIMITED ) ; int dataSize = 0 ; for ( final Object element : valueList ) { dataSize += computeElementSizeNoTag ( type , element ) ; } output . writeRawVarint32 ( dataSize ) ; for ( final Object element : valueList ) { writeElementNoTag ( output , type , element ) ; } } else { for ( final Object element : valueList ) { writeElement ( output , type , number , element ) ; } } } else { if ( value instanceof LazyField ) { writeElement ( output , type , number , ( ( LazyField ) value ) . getValue ( ) ) ; } else { writeElement ( output , type , number , value ) ; } } }
Write a single field .
10,699
public static int computeFieldSize ( final FieldDescriptorLite < ? > descriptor , final Object value ) { WireFormat . FieldType type = descriptor . getLiteType ( ) ; int number = descriptor . getNumber ( ) ; if ( descriptor . isRepeated ( ) ) { if ( descriptor . isPacked ( ) ) { int dataSize = 0 ; for ( final Object element : ( List < ? > ) value ) { dataSize += computeElementSizeNoTag ( type , element ) ; } return dataSize + CodedOutputStream . computeTagSize ( number ) + CodedOutputStream . computeRawVarint32Size ( dataSize ) ; } else { int size = 0 ; for ( final Object element : ( List < ? > ) value ) { size += computeElementSize ( type , number , element ) ; } return size ; } } else { return computeElementSize ( type , number , value ) ; } }
Compute the number of bytes needed to encode a particular field .