idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
10,600
public static void inclusiveBetween ( final double start , final double end , final double value , final String message ) { if ( value < start || value > end ) { throw new IllegalArgumentException ( message ) ; } }
Validate that the specified primitive value falls between the two inclusive values specified ; otherwise throws an exception with the specified message .
10,601
@ SuppressWarnings ( "boxing" ) public static void exclusiveBetween ( final long start , final long end , final long value ) { if ( value <= start || value >= end ) { throw new IllegalArgumentException ( StringUtils . simpleFormat ( DEFAULT_EXCLUSIVE_BETWEEN_EX_MESSAGE , value , start , end ) ) ; } }
Validate that the specified primitive value falls between the two exclusive values specified ; otherwise throws an exception .
10,602
public static void exclusiveBetween ( final long start , final long end , final long value , final String message ) { if ( value <= start || value >= end ) { throw new IllegalArgumentException ( message ) ; } }
Validate that the specified primitive value falls between the two exclusive values specified ; otherwise throws an exception with the specified message .
10,603
@ GwtIncompatible ( "incompatible method" ) public static void isInstanceOf ( final Class < ? > type , final Object obj ) { if ( ! type . isInstance ( obj ) ) { throw new IllegalArgumentException ( StringUtils . simpleFormat ( DEFAULT_IS_INSTANCE_OF_EX_MESSAGE , type . getName ( ) , obj == null ? "null" : obj . getClas...
Validates that the argument is an instance of the specified class if not throws an exception .
10,604
private StringBuilder spacer ( final int spaces ) { final StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < spaces ; i ++ ) { sb . append ( " " ) ; } return sb ; }
Creates a StringBuilder responsible for the indenting .
10,605
private boolean performStateCheck ( final int increment ) { CheckIntervalData currentData ; CheckIntervalData nextData ; State currentState ; do { final long time = now ( ) ; currentState = state . get ( ) ; currentData = checkIntervalData . get ( ) ; nextData = nextCheckIntervalData ( increment , currentData , current...
Actually checks the state of this circuit breaker and executes a state transition if necessary .
10,606
private static Map < State , StateStrategy > createStrategyMap ( ) { final Map < State , StateStrategy > map = new EnumMap < > ( State . class ) ; map . put ( State . CLOSED , new StateStrategyClosed ( ) ) ; map . put ( State . OPEN , new StateStrategyOpen ( ) ) ; return map ; }
Creates the map with strategy objects . It allows access for a strategy for a given state .
10,607
public String [ ] [ ] lemmatize ( int numTaggings , String [ ] toks , String [ ] tags ) { Sequence [ ] bestSequences = model . bestSequences ( numTaggings , toks , new Object [ ] { tags } , contextGenerator , sequenceValidator ) ; String [ ] [ ] lemmaClasses = new String [ bestSequences . length ] [ ] ; for ( int i = 0...
Generates a specified number of lemma classes for the input tokens and tags .
10,608
@ GwtIncompatible ( "incompatible method" ) public String getFormattedExceptionMessage ( final String baseMessage ) { final StringBuilder buffer = new StringBuilder ( 256 ) ; if ( baseMessage != null ) { buffer . append ( baseMessage ) ; } if ( contextValues . size ( ) > 0 ) { if ( buffer . length ( ) > 0 ) { buffer . ...
Builds the message containing the contextual information .
10,609
public final String [ ] getTokensWithMultiWords ( final String [ ] tokens ) { final Span [ ] multiWordSpans = multiWordsToSpans ( tokens ) ; final List < String > tokenList = new ArrayList < String > ( Arrays . asList ( tokens ) ) ; int counter = 0 ; for ( final Span mwSpan : multiWordSpans ) { final int fromIndex = mw...
Get input text and join the multiwords found in the dictionary object .
10,610
public final Span [ ] multiWordsToSpans ( final String [ ] tokens ) { final List < Span > multiWordsFound = new LinkedList < Span > ( ) ; for ( int offsetFrom = 0 ; offsetFrom < tokens . length ; offsetFrom ++ ) { Span multiwordFound = null ; String tokensSearching [ ] = new String [ ] { } ; for ( int offsetTo = offset...
Detects multiword expressions ignoring case .
10,611
private int compareDate ( Date a , Date b ) { final Date ta = new Date ( a . getTime ( ) ) ; final Date tb = new Date ( b . getTime ( ) ) ; final long d1 = setHourToZero ( ta ) . getTime ( ) ; final long d2 = setHourToZero ( tb ) . getTime ( ) ; return ( int ) Math . round ( ( d2 - d1 ) / 1000.0 / 60.0 / 60.0 / 24.0 ) ...
Calculate the number of days between two dates
10,612
@ SuppressWarnings ( "deprecation" ) private Date setHourToZero ( Date in ) { final Date d = new Date ( in . getTime ( ) ) ; d . setHours ( 0 ) ; d . setMinutes ( 0 ) ; d . setSeconds ( 0 ) ; long t = d . getTime ( ) / 1000 ; t = t * 1000 ; return new Date ( t ) ; }
Set hour minutes second and milliseconds to zero .
10,613
@ SuppressWarnings ( "deprecation" ) private Date getWeekOne ( int year ) { GregorianCalendar weekOne = new GregorianCalendar ( ) ; weekOne . setFirstDayOfWeek ( getFirstDayOfWeek ( ) ) ; weekOne . setMinimalDaysInFirstWeek ( getMinimalDaysInFirstWeek ( ) ) ; weekOne . setTime ( new Date ( year , 0 , 1 ) ) ; int dow = ...
Gets the date of the first week for the specified year .
10,614
protected final void createTagDictionary ( final String dictPath ) { if ( ! dictPath . equalsIgnoreCase ( Flags . DEFAULT_DICT_PATH ) ) { try { getPosTaggerFactory ( ) . setTagDictionary ( getPosTaggerFactory ( ) . createTagDictionary ( new File ( dictPath ) ) ) ; } catch ( final IOException e ) { throw new TerminateTo...
Create a tag dictionary with the dictionary contained in the dictPath .
10,615
protected final void createAutomaticDictionary ( final ObjectStream < POSSample > aDictSamples , final int aDictCutOff ) { if ( aDictCutOff != Flags . DEFAULT_DICT_CUTOFF ) { try { TagDictionary dict = getPosTaggerFactory ( ) . getTagDictionary ( ) ; if ( dict == null ) { dict = getPosTaggerFactory ( ) . createEmptyTag...
Automatically create a tag dictionary from training data .
10,616
protected final Dictionary createNgramDictionary ( final ObjectStream < POSSample > aDictSamples , final int aNgramCutoff ) { Dictionary ngramDict = null ; if ( aNgramCutoff != Flags . DEFAULT_DICT_CUTOFF ) { System . err . print ( "Building ngram dictionary ... " ) ; try { ngramDict = POSTaggerME . buildNGramDictionar...
Create ngram dictionary from training data .
10,617
public String getQualifiedSurroundingClassName ( ) { TypeElement typeElement = ( TypeElement ) field . getEnclosingElement ( ) ; return typeElement . getQualifiedName ( ) . toString ( ) ; }
Get the full qualified class name this field is part of .
10,618
private static void setInternal ( int [ ] array , int fromIndex , int toIndex ) { int first = wordIndex ( fromIndex ) ; int last = wordIndex ( toIndex ) ; maybeGrowArrayToIndex ( array , last ) ; int startBit = bitOffset ( fromIndex ) ; int endBit = bitOffset ( toIndex ) ; if ( first == last ) { maskInWord ( array , fi...
Sets all bits to true within the given range .
10,619
private static int lastSetWordIndex ( int [ ] array ) { int i = array . length - 1 ; for ( ; i >= 0 && wordAt ( array , i ) == 0 ; -- i ) { } return i ; }
Returns the index of the last word containing a true bit in an array or - 1 if none .
10,620
private static void flipMaskedWord ( int [ ] array , int index , int from , int to ) { if ( from == to ) { return ; } to = 32 - to ; int word = wordAt ( array , index ) ; word ^= ( ( 0xffffffff >>> from ) << ( from + to ) ) >>> to ; array [ index ] = word & WORD_MASK ; }
Flips all bits in a word within the given range .
10,621
private static void maskInWord ( int [ ] array , int index , int from , int to ) { if ( from == to ) { return ; } to = 32 - to ; int word = wordAt ( array , index ) ; word |= ( ( 0xffffffff >>> from ) << ( from + to ) ) >>> to ; array [ index ] = word & WORD_MASK ; }
Sets all bits to true in a word within the given bit range .
10,622
private static void maskOutWord ( int [ ] array , int index , int from , int to ) { if ( from == to ) { return ; } int word = wordAt ( array , index ) ; if ( word == 0 ) { return ; } int mask ; if ( from != 0 ) { mask = 0xffffffff >>> ( 32 - from ) ; } else { mask = 0 ; } if ( to != 32 ) { mask |= 0xffffffff << to ; } ...
Sets all bits to false in a word within the given bit range .
10,623
public final List < Morpheme > getMorphemes ( final String [ ] tokens ) { final List < String > origPosTags = posAnnotate ( tokens ) ; final List < Morpheme > morphemes = getMorphemesFromStrings ( origPosTags , tokens ) ; return morphemes ; }
Get morphological analysis from a tokenized sentence .
10,624
public final List < String > posAnnotate ( final String [ ] tokens ) { final String [ ] annotatedText = this . posTagger . tag ( tokens ) ; final List < String > posTags = new ArrayList < String > ( Arrays . asList ( annotatedText ) ) ; return posTags ; }
Produce postags from a tokenized sentence .
10,625
public final String [ ] [ ] getAllPosTags ( final String [ ] tokens ) { final String [ ] [ ] allPosTags = this . posTagger . tag ( 13 , tokens ) ; return allPosTags ; }
Produces a multidimensional array containing all the tagging possible for a given sentence .
10,626
@ GwtIncompatible ( "incompatible method" ) public static < T extends Comparable < ? super T > > T median ( final T ... items ) { Validate . notEmpty ( items ) ; Validate . noNullElements ( items ) ; final TreeSet < T > sort = new TreeSet < > ( ) ; Collections . addAll ( sort , items ) ; @ SuppressWarnings ( "unchecked...
Find the best guess middle value among comparables . If there is an even number of total values the lower of the two middle values will be returned .
10,627
public static < T > T mode ( final T ... items ) { if ( ArrayUtils . isNotEmpty ( items ) ) { final HashMap < T , MutableInt > occurrences = new HashMap < > ( items . length ) ; for ( final T t : items ) { final MutableInt count = occurrences . get ( t ) ; if ( count == null ) { occurrences . put ( t , new MutableInt (...
Find the most frequently occurring item .
10,628
public final void crossValidate ( final TrainingParameters params ) { POSTaggerCrossValidator validator = null ; try { validator = getPOSTaggerCrossValidator ( params ) ; validator . evaluate ( this . trainSamples , this . folds ) ; } catch ( final IOException e ) { System . err . println ( "IO error while loading trai...
Cross validate when no separate testset is available .
10,629
private POSTaggerCrossValidator getPOSTaggerCrossValidator ( final TrainingParameters params ) { final File dictPath = new File ( Flags . getDictionaryFeatures ( params ) ) ; if ( this . posTaggerFactory == null ) { throw new IllegalStateException ( "You must create the POSTaggerFactory features!" ) ; } POSTaggerCrossV...
Get the postagger cross validator .
10,630
private static Type [ ] extractTypeArgumentsFrom ( final Map < TypeVariable < ? > , Type > mappings , final TypeVariable < ? > [ ] variables ) { final Type [ ] result = new Type [ variables . length ] ; int index = 0 ; for ( final TypeVariable < ? > var : variables ) { Validate . isTrue ( mappings . containsKey ( var )...
Helper method to establish the formal parameters for a parameterized type .
10,631
public static < V > String replace ( final Object source , final Map < String , V > valueMap ) { return new StrSubstitutor ( valueMap ) . replace ( source ) ; }
Replaces all the occurrences of variables in the given source object with their matching values from the map .
10,632
public static < V > String replace ( final Object source , final Map < String , V > valueMap , final String prefix , final String suffix ) { return new StrSubstitutor ( valueMap , prefix , suffix ) . replace ( source ) ; }
Replaces all the occurrences of variables in the given source object with their matching values from the map . This method allows to specify a custom variable prefix and suffix
10,633
public static String replace ( final Object source , final Properties valueProperties ) { if ( valueProperties == null ) { return source . toString ( ) ; } final Map < String , String > valueMap = new HashMap < > ( ) ; final Enumeration < ? > propNames = valueProperties . propertyNames ( ) ; while ( propNames . hasMore...
Replaces all the occurrences of variables in the given source object with their matching values from the properties .
10,634
public String replace ( final CharSequence source ) { if ( source == null ) { return null ; } return replace ( source , 0 , source . length ( ) ) ; }
Replaces all the occurrences of variables with their matching values from the resolver using the given source as a template . The source is not altered by this method .
10,635
public String replace ( final StrBuilder source ) { if ( source == null ) { return null ; } final StrBuilder buf = new StrBuilder ( source . length ( ) ) . append ( source ) ; substitute ( buf , 0 , buf . length ( ) ) ; return buf . toString ( ) ; }
Replaces all the occurrences of variables with their matching values from the resolver using the given source builder as a template . The builder is not altered by this method .
10,636
public boolean replaceIn ( final StrBuilder source ) { if ( source == null ) { return false ; } return substitute ( source , 0 , source . length ( ) ) ; }
Replaces all the occurrences of variables within the given source builder with their matching values from the resolver .
10,637
@ SuppressWarnings ( "unchecked" ) public static < L , M , R > ImmutableTriple < L , M , R > nullTriple ( ) { return NULL ; }
Returns an immutable triple of nulls .
10,638
static Token [ ] lexx ( final String format ) { final ArrayList < Token > list = new ArrayList < > ( format . length ( ) ) ; boolean inLiteral = false ; StringBuilder buffer = null ; Token previous = null ; for ( int i = 0 ; i < format . length ( ) ; i ++ ) { final char ch = format . charAt ( i ) ; if ( inLiteral && ch...
Parses a classic date format string into Tokens
10,639
public StrBuilder setNullText ( String nullText ) { if ( nullText != null && nullText . isEmpty ( ) ) { nullText = null ; } this . nullText = nullText ; return this ; }
Sets the text to be appended when null is added .
10,640
public StrBuilder setLength ( final int length ) { if ( length < 0 ) { throw new StringIndexOutOfBoundsException ( length ) ; } if ( length < size ) { size = length ; } else if ( length > size ) { ensureCapacity ( length ) ; final int oldEnd = size ; final int newEnd = length ; size = length ; for ( int i = oldEnd ; i ...
Updates the length of the builder by either dropping the last characters or adding filler of Unicode zero .
10,641
public StrBuilder ensureCapacity ( final int capacity ) { if ( capacity > buffer . length ) { final char [ ] old = buffer ; buffer = new char [ capacity * 2 ] ; System . arraycopy ( old , 0 , buffer , 0 , size ) ; } return this ; }
Checks the capacity and ensures that it is at least the size specified .
10,642
public StrBuilder minimizeCapacity ( ) { if ( buffer . length > length ( ) ) { final char [ ] old = buffer ; buffer = new char [ length ( ) ] ; System . arraycopy ( old , 0 , buffer , 0 , size ) ; } return this ; }
Minimizes the capacity to the actual length of the string .
10,643
public StrBuilder setCharAt ( final int index , final char ch ) { if ( index < 0 || index >= length ( ) ) { throw new StringIndexOutOfBoundsException ( index ) ; } buffer [ index ] = ch ; return this ; }
Sets the character at the specified index .
10,644
public StrBuilder deleteCharAt ( final int index ) { if ( index < 0 || index >= size ) { throw new StringIndexOutOfBoundsException ( index ) ; } deleteImpl ( index , index + 1 , 1 ) ; return this ; }
Deletes the character at the specified index .
10,645
public char [ ] toCharArray ( ) { if ( size == 0 ) { return ArrayUtils . EMPTY_CHAR_ARRAY ; } final char chars [ ] = new char [ size ] ; System . arraycopy ( buffer , 0 , chars , 0 , size ) ; return chars ; }
Copies the builder s character array into a new character array .
10,646
public char [ ] toCharArray ( final int startIndex , int endIndex ) { endIndex = validateRange ( startIndex , endIndex ) ; final int len = endIndex - startIndex ; if ( len == 0 ) { return ArrayUtils . EMPTY_CHAR_ARRAY ; } final char chars [ ] = new char [ len ] ; System . arraycopy ( buffer , startIndex , chars , 0 , l...
Copies part of the builder s character array into a new character array .
10,647
public StrBuilder append ( final boolean value ) { if ( value ) { ensureCapacity ( size + 4 ) ; buffer [ size ++ ] = 't' ; buffer [ size ++ ] = 'r' ; buffer [ size ++ ] = 'u' ; buffer [ size ++ ] = 'e' ; } else { ensureCapacity ( size + 5 ) ; buffer [ size ++ ] = 'f' ; buffer [ size ++ ] = 'a' ; buffer [ size ++ ] = 'l...
Appends a boolean value to the string builder .
10,648
public StrBuilder append ( final char ch ) { final int len = length ( ) ; ensureCapacity ( len + 1 ) ; buffer [ size ++ ] = ch ; return this ; }
Appends a char value to the string builder .
10,649
public StrBuilder appendSeparator ( final String standard , final String defaultIfEmpty ) { final String str = isEmpty ( ) ? defaultIfEmpty : standard ; if ( str != null ) { append ( str ) ; } return this ; }
Appends one of both separators to the StrBuilder . If the builder is currently empty it will append the defaultIfEmpty - separator Otherwise it will append the standard - separator
10,650
public StrBuilder appendPadding ( final int length , final char padChar ) { if ( length >= 0 ) { ensureCapacity ( size + length ) ; for ( int i = 0 ; i < length ; i ++ ) { buffer [ size ++ ] = padChar ; } } return this ; }
Appends the pad character to the builder the specified number of times .
10,651
public StrBuilder insert ( final int index , final Object obj ) { if ( obj == null ) { return insert ( index , nullText ) ; } return insert ( index , obj . toString ( ) ) ; }
Inserts the string representation of an object into this builder . Inserting null will use the stored null text value .
10,652
public StrBuilder insert ( final int index , String str ) { validateIndex ( index ) ; if ( str == null ) { str = nullText ; } if ( str != null ) { final int strLen = str . length ( ) ; if ( strLen > 0 ) { final int newSize = size + strLen ; ensureCapacity ( newSize ) ; System . arraycopy ( buffer , index , buffer , ind...
Inserts the string into this builder . Inserting null will use the stored null text value .
10,653
public StrBuilder insert ( final int index , final char chars [ ] ) { validateIndex ( index ) ; if ( chars == null ) { return insert ( index , nullText ) ; } final int len = chars . length ; if ( len > 0 ) { ensureCapacity ( size + len ) ; System . arraycopy ( buffer , index , buffer , index + len , size - index ) ; Sy...
Inserts the character array into this builder . Inserting null will use the stored null text value .
10,654
public StrBuilder insert ( final int index , final char chars [ ] , final int offset , final int length ) { validateIndex ( index ) ; if ( chars == null ) { return insert ( index , nullText ) ; } if ( offset < 0 || offset > chars . length ) { throw new StringIndexOutOfBoundsException ( "Invalid offset: " + offset ) ; }...
Inserts part of the character array into this builder . Inserting null will use the stored null text value .
10,655
public StrBuilder delete ( final int startIndex , int endIndex ) { endIndex = validateRange ( startIndex , endIndex ) ; final int len = endIndex - startIndex ; if ( len > 0 ) { deleteImpl ( startIndex , endIndex , len ) ; } return this ; }
Deletes the characters between the two specified indices .
10,656
public StrBuilder deleteAll ( final String str ) { final int len = ( str == null ? 0 : str . length ( ) ) ; if ( len > 0 ) { int index = indexOf ( str , 0 ) ; while ( index >= 0 ) { deleteImpl ( index , index + len , len ) ; index = indexOf ( str , index ) ; } } return this ; }
Deletes the string wherever it occurs in the builder .
10,657
public StrBuilder replace ( final int startIndex , int endIndex , final String replaceStr ) { endIndex = validateRange ( startIndex , endIndex ) ; final int insertLen = ( replaceStr == null ? 0 : replaceStr . length ( ) ) ; replaceImpl ( startIndex , endIndex , endIndex - startIndex , replaceStr , insertLen ) ; return ...
Replaces a portion of the string builder with another string . The length of the inserted string does not have to match the removed length .
10,658
public StrBuilder replaceAll ( final char search , final char replace ) { if ( search != replace ) { for ( int i = 0 ; i < size ; i ++ ) { if ( buffer [ i ] == search ) { buffer [ i ] = replace ; } } } return this ; }
Replaces the search character with the replace character throughout the builder .
10,659
public StrBuilder replaceFirst ( final char search , final char replace ) { if ( search != replace ) { for ( int i = 0 ; i < size ; i ++ ) { if ( buffer [ i ] == search ) { buffer [ i ] = replace ; break ; } } } return this ; }
Replaces the first instance of the search character with the replace character in the builder .
10,660
public StrBuilder replaceAll ( final String searchStr , final String replaceStr ) { final int searchLen = ( searchStr == null ? 0 : searchStr . length ( ) ) ; if ( searchLen > 0 ) { final int replaceLen = ( replaceStr == null ? 0 : replaceStr . length ( ) ) ; int index = indexOf ( searchStr , 0 ) ; while ( index >= 0 )...
Replaces the search string with the replace string throughout the builder .
10,661
public StrBuilder reverse ( ) { if ( size == 0 ) { return this ; } final int half = size / 2 ; final char [ ] buf = buffer ; for ( int leftIdx = 0 , rightIdx = size - 1 ; leftIdx < half ; leftIdx ++ , rightIdx -- ) { final char swap = buf [ leftIdx ] ; buf [ leftIdx ] = buf [ rightIdx ] ; buf [ rightIdx ] = swap ; } re...
Reverses the string builder placing each character in the opposite index .
10,662
public StrBuilder trim ( ) { if ( size == 0 ) { return this ; } int len = size ; final char [ ] buf = buffer ; int pos = 0 ; while ( pos < len && buf [ pos ] <= ' ' ) { pos ++ ; } while ( pos < len && buf [ len - 1 ] <= ' ' ) { len -- ; } if ( len < size ) { delete ( len , size ) ; } if ( pos > 0 ) { delete ( 0 , pos )...
Trims the builder by removing characters less than or equal to a space from the beginning and end .
10,663
public boolean contains ( final char ch ) { final char [ ] thisBuf = buffer ; for ( int i = 0 ; i < this . size ; i ++ ) { if ( thisBuf [ i ] == ch ) { return true ; } } return false ; }
Checks if the string builder contains the specified char .
10,664
public int indexOf ( final char ch , int startIndex ) { startIndex = ( startIndex < 0 ? 0 : startIndex ) ; if ( startIndex >= size ) { return - 1 ; } final char [ ] thisBuf = buffer ; for ( int i = startIndex ; i < size ; i ++ ) { if ( thisBuf [ i ] == ch ) { return i ; } } return - 1 ; }
Searches the string builder to find the first reference to the specified char .
10,665
public int lastIndexOf ( final char ch , int startIndex ) { startIndex = ( startIndex >= size ? size - 1 : startIndex ) ; if ( startIndex < 0 ) { return - 1 ; } for ( int i = startIndex ; i >= 0 ; i -- ) { if ( buffer [ i ] == ch ) { return i ; } } return - 1 ; }
Searches the string builder to find the last reference to the specified char .
10,666
public boolean equalsIgnoreCase ( final StrBuilder other ) { if ( this == other ) { return true ; } if ( this . size != other . size ) { return false ; } final char thisBuf [ ] = this . buffer ; final char otherBuf [ ] = other . buffer ; for ( int i = size - 1 ; i >= 0 ; i -- ) { final char c1 = thisBuf [ i ] ; final c...
Checks the contents of this builder against another to see if they contain the same character content ignoring case .
10,667
protected int validateRange ( final int startIndex , int endIndex ) { if ( startIndex < 0 ) { throw new StringIndexOutOfBoundsException ( startIndex ) ; } if ( endIndex > size ) { endIndex = size ; } if ( startIndex > endIndex ) { throw new StringIndexOutOfBoundsException ( "end < start" ) ; } return endIndex ; }
Validates parameters defining a range of the builder .
10,668
public T get ( ) throws ConcurrentException { T result = object ; if ( result == NO_INIT ) { synchronized ( this ) { result = object ; if ( result == NO_INIT ) { object = result = initialize ( ) ; } } } return result ; }
Returns the object wrapped by this instance . On first access the object is created . After that it is cached and can be accessed pretty fast .
10,669
public static Thread findThreadById ( final long threadId , final ThreadGroup threadGroup ) { Validate . isTrue ( threadGroup != null , "The thread group must not be null" ) ; final Thread thread = findThreadById ( threadId ) ; if ( thread != null && threadGroup . equals ( thread . getThreadGroup ( ) ) ) { return threa...
Return the active thread with the specified id if it belongs to the specified thread group .
10,670
public static Thread findThreadById ( final long threadId , final String threadGroupName ) { Validate . isTrue ( threadGroupName != null , "The thread group name must not be null" ) ; final Thread thread = findThreadById ( threadId ) ; if ( thread != null && thread . getThreadGroup ( ) != null && thread . getThreadGrou...
Return the active thread with the specified id if it belongs to a thread group with the specified group name .
10,671
public static Collection < Thread > findThreadsByName ( final String threadName , final ThreadGroup threadGroup ) { return findThreads ( threadGroup , false , new NamePredicate ( threadName ) ) ; }
Return active threads with the specified name if they belong to a specified thread group .
10,672
public static Collection < Thread > findThreadsByName ( final String threadName , final String threadGroupName ) { Validate . isTrue ( threadName != null , "The thread name must not be null" ) ; Validate . isTrue ( threadGroupName != null , "The thread group name must not be null" ) ; final Collection < ThreadGroup > t...
Return active threads with the specified name if they belong to a thread group with the specified group name .
10,673
public static Thread findThreadById ( final long threadId ) { final Collection < Thread > result = findThreads ( new ThreadIdPredicate ( threadId ) ) ; return result . isEmpty ( ) ? null : result . iterator ( ) . next ( ) ; }
Return the active thread with the specified id .
10,674
public < T > Optional < T > as ( Class < T > type ) { return inner . filter ( d -> d . is ( type ) ) . map ( d -> d . as ( type ) ) ; }
Returns inner value as optional of input type if the inner value is absent or not an instance of the input type an empty optional is returned
10,675
@ SuppressWarnings ( "unchecked" ) private static < R , T extends Throwable > R typeErasure ( final Throwable throwable ) throws T { throw ( T ) throwable ; }
Claim a Throwable is another Exception type using type erasure . This hides a checked exception from the java compiler allowing a checked exception to be thrown without having the exception in the method s throw clause .
10,676
@ GwtIncompatible ( "incompatible method" ) public static boolean hasCause ( Throwable chain , final Class < ? extends Throwable > type ) { if ( chain instanceof UndeclaredThrowableException ) { chain = chain . getCause ( ) ; } return type . isInstance ( chain ) ; }
Does the throwable s causal chain have an immediate or wrapped exception of the given type?
10,677
private boolean hasStage ( InputProcessor processor ) { if ( ! ( processor instanceof InputMultiplexer ) ) { return processor == stage ; } InputMultiplexer im = ( InputMultiplexer ) processor ; SnapshotArray < InputProcessor > ips = im . getProcessors ( ) ; for ( InputProcessor ip : ips ) { if ( hasStage ( ip ) ) { ret...
Compares the given processor to the console s stage . If given a multiplexer it is iterated through recursively to check all of the multiplexer s processors for comparison .
10,678
public String tag ( final String word , final String posTag ) { final List < WordData > wdList = this . dictLookup . lookup ( word . toLowerCase ( ) ) ; String newPosTag = null ; for ( final WordData wd : wdList ) { newPosTag = wd . getTag ( ) . toString ( ) ; } if ( newPosTag == null ) { newPosTag = posTag ; } return ...
Get the postag for a surface form from a FSA morfologik generated dictionary .
10,679
private static String appendIfMissing ( final String str , final CharSequence suffix , final boolean ignoreCase , final CharSequence ... suffixes ) { if ( str == null || isEmpty ( suffix ) || endsWith ( str , suffix , ignoreCase ) ) { return str ; } if ( suffixes != null && suffixes . length > 0 ) { for ( final CharSeq...
Appends the suffix to the end of the string if the string does not already end with the suffix .
10,680
public static String appendIfMissing ( final String str , final CharSequence suffix , final CharSequence ... suffixes ) { return appendIfMissing ( str , suffix , false , suffixes ) ; }
Appends the suffix to the end of the string if the string does not already end with any of the suffixes .
10,681
public static String appendIfMissingIgnoreCase ( final String str , final CharSequence suffix , final CharSequence ... suffixes ) { return appendIfMissing ( str , suffix , true , suffixes ) ; }
Appends the suffix to the end of the string if the string does not already end case insensitive with any of the suffixes .
10,682
public static String prependIfMissingIgnoreCase ( final String str , final CharSequence prefix , final CharSequence ... prefixes ) { return prependIfMissing ( str , prefix , true , prefixes ) ; }
Prepends the prefix to the start of the string if the string does not already start case insensitive with any of the prefixes .
10,683
public final void getAllTagsLemmasToNAF ( final KAFDocument kaf ) { final List < List < WF > > sentences = kaf . getSentences ( ) ; for ( final List < WF > wfs : sentences ) { final List < ixa . kaflib . Span < WF > > tokenSpans = new ArrayList < ixa . kaflib . Span < WF > > ( ) ; final String [ ] tokens = new String [...
Add all postags and lemmas to morphofeat attribute .
10,684
public final String getAllTagsLemmasToCoNLL ( final KAFDocument kaf ) { final StringBuilder sb = new StringBuilder ( ) ; final List < List < WF > > sentences = kaf . getSentences ( ) ; for ( final List < WF > wfs : sentences ) { final List < ixa . kaflib . Span < WF > > tokenSpans = new ArrayList < ixa . kaflib . Span ...
Give all lemmas and tags possible for a sentence in conll tabulated format .
10,685
private boolean isSetterForField ( ExecutableElement setter , VariableElement field ) { return setter . getParameters ( ) != null && setter . getParameters ( ) . size ( ) == 1 && setter . getParameters ( ) . get ( 0 ) . asType ( ) . equals ( field . asType ( ) ) ; }
Checks if the setter method is valid for the given field
10,686
private TypeElement getSurroundingClass ( Element e ) throws ProcessingException { if ( e . getEnclosingElement ( ) . getKind ( ) == ElementKind . CLASS ) { return ( TypeElement ) e . getEnclosingElement ( ) ; } throw new ProcessingException ( e , "Field %s is not part of a class. Only fields in a class can be annotat...
Checks if a Element is in class and returns the TypeElement of the surrounding class
10,687
private TypeElement checkAndGetClass ( Element e ) throws ProcessingException { if ( e . getKind ( ) != ElementKind . CLASS ) { throw new ProcessingException ( e , "%s is annotated with @%s but only classes can be annotated with this annotation" , e . toString ( ) , ObjectMappable . class . getSimpleName ( ) ) ; } retu...
Check the Element if it s a class and returns the corresponding TypeElement
10,688
private FieldSpec generateRxMappingMethod ( ObjectMappableAnnotatedClass clazz ) { String objectVarName = "item" ; String cursorVarName = "cursor" ; TypeName elementType = ClassName . get ( clazz . getElement ( ) . asType ( ) ) ; CodeBlock . Builder initBlockBuilder = CodeBlock . builder ( ) . add ( "new $L<$L, $L>() {...
Generates the field that can be used as RxJava method
10,689
private TypeSpec generateContentValuesBuilderClass ( ObjectMappableAnnotatedClass clazz , String mapperClassName , String className ) { String cvVarName = "contentValues" ; MethodSpec constructor = MethodSpec . constructorBuilder ( ) . addModifiers ( Modifier . PRIVATE ) . addStatement ( "$L = new $T()" , cvVarName , C...
Generates the ContentValues Builder Class
10,690
private MethodSpec generateContentValuesMethod ( ObjectMappableAnnotatedClass clazz , String mapperClassName , String className ) { ClassName typeName = ClassName . get ( getPackageName ( clazz ) , mapperClassName , className ) ; return MethodSpec . methodBuilder ( "contentValues" ) . addJavadoc ( "Get a typesafe Conte...
Generates a static file to get
10,691
private String getPackageName ( ObjectMappableAnnotatedClass clazz ) { PackageElement pkg = elements . getPackageOf ( clazz . getElement ( ) ) ; return pkg . isUnnamed ( ) ? "" : pkg . getQualifiedName ( ) . toString ( ) ; }
Get the package name of a certain clazz
10,692
protected QueryBuilder rawQueryOnManyTables ( final Iterable < String > tables , final String sql ) { return new QueryBuilder ( tables , sql ) ; }
Creates a raw query and enables auto updates for the given tables
10,693
private QueryObservable executeQuery ( QueryBuilder queryBuilder ) { String sql = queryBuilder . rawStatement ; Iterable < String > affectedTables = queryBuilder . rawStatementAffectedTables ; if ( queryBuilder . statement != null ) { SqlCompileable . CompileableStatement compileableStatement = queryBuilder . statement...
Executes the a query
10,694
protected Observable < Long > insert ( final String table , final ContentValues contentValues ) { return Observable . defer ( new Func0 < Observable < Long > > ( ) { public Observable < Long > call ( ) { return Observable . just ( db . insert ( table , contentValues ) ) ; } } ) ; }
Insert a row into the given table
10,695
protected Observable < Integer > delete ( final String table ) { return delete ( table , null ) ; }
Deletes all rows from a table
10,696
protected Observable < Integer > delete ( final String table , final String whereClause , final String ... whereArgs ) { return Observable . defer ( new Func0 < Observable < Integer > > ( ) { public Observable < Integer > call ( ) { return Observable . just ( db . delete ( table , whereClause , whereArgs ) ) ; } } ) ; ...
Delete data from a table
10,697
private static Locale parseLocale ( final String str ) { if ( isISO639LanguageCode ( str ) ) { return new Locale ( str ) ; } final String [ ] segments = str . split ( "_" , - 1 ) ; final String language = segments [ 0 ] ; if ( segments . length == 2 ) { final String country = segments [ 1 ] ; if ( isISO639LanguageCode ...
Tries to parse a locale from the given String .
10,698
private static boolean isISO639LanguageCode ( final String str ) { return StringUtils . isAllLowerCase ( str ) && ( str . length ( ) == 2 || str . length ( ) == 3 ) ; }
Checks whether the given String is a ISO 639 compliant language code .
10,699
public static int compareModifierVisibility ( Element a , Element b ) { if ( a . getModifiers ( ) . contains ( Modifier . PUBLIC ) && ! b . getModifiers ( ) . contains ( Modifier . PUBLIC ) ) { return - 1 ; } if ( isDefaultModifier ( a . getModifiers ( ) ) && ! isDefaultModifier ( b . getModifiers ( ) ) ) { return - 1 ...
Compare the modifier of two elements