idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
27,600
public synchronized void co_exit_to ( Object arg_object , int thisCoroutine , int toCoroutine ) throws java . lang . NoSuchMethodException { if ( ! m_activeIDs . get ( toCoroutine ) ) throw new java . lang . NoSuchMethodException ( XMLMessages . createXMLMessage ( XMLErrorResources . ER_COROUTINE_NOT_AVAIL , new Object [ ] { Integer . toString ( toCoroutine ) } ) ) ; m_yield = arg_object ; m_nextCoroutine = toCoroutine ; m_activeIDs . clear ( thisCoroutine ) ; notify ( ) ; }
Make the ID available for reuse and terminate this coroutine transferring control to the specified coroutine . Note that this returns immediately rather than waiting for any further coroutine traffic so the thread can proceed with other shutdown activities .
27,601
static < E > Node < E > newNode ( E item ) { Node < E > node = new Node < E > ( ) ; U . putObject ( node , ITEM , item ) ; return node ; }
Returns a new node holding item . Uses relaxed write because item can only be seen after piggy - backing publication via casNext .
27,602
public String [ ] split ( CharSequence input , int limit ) { String [ ] fast = fastSplit ( pattern , input . toString ( ) , limit ) ; if ( fast != null ) { return fast ; } int index = 0 ; boolean matchLimited = limit > 0 ; ArrayList < String > matchList = new ArrayList < > ( ) ; Matcher m = matcher ( input ) ; while ( m . find ( ) ) { if ( ! matchLimited || matchList . size ( ) < limit - 1 ) { String match = input . subSequence ( index , m . start ( ) ) . toString ( ) ; matchList . add ( match ) ; index = m . end ( ) ; } else if ( matchList . size ( ) == limit - 1 ) { String match = input . subSequence ( index , input . length ( ) ) . toString ( ) ; matchList . add ( match ) ; index = m . end ( ) ; } } if ( index == 0 ) return new String [ ] { input . toString ( ) } ; if ( ! matchLimited || matchList . size ( ) < limit ) matchList . add ( input . subSequence ( index , input . length ( ) ) . toString ( ) ) ; int resultSize = matchList . size ( ) ; if ( limit == 0 ) while ( resultSize > 0 && matchList . get ( resultSize - 1 ) . equals ( "" ) ) resultSize -- ; String [ ] result = new String [ resultSize ] ; return matchList . subList ( 0 , resultSize ) . toArray ( result ) ; }
Splits the given input sequence around matches of this pattern .
27,603
private void readObject ( java . io . ObjectInputStream s ) throws java . io . IOException , ClassNotFoundException { s . defaultReadObject ( ) ; compile ( ) ; }
Recompile the Pattern instance from a stream . The original pattern string is read in and the object tree is recompiled from it .
27,604
public Stream < String > splitAsStream ( final CharSequence input ) { class MatcherIterator implements Iterator < String > { private final Matcher matcher ; private int current ; private String nextElement ; private int emptyElementCount ; MatcherIterator ( ) { this . matcher = matcher ( input ) ; } public String next ( ) { if ( ! hasNext ( ) ) throw new NoSuchElementException ( ) ; if ( emptyElementCount == 0 ) { String n = nextElement ; nextElement = null ; return n ; } else { emptyElementCount -- ; return "" ; } } public boolean hasNext ( ) { if ( nextElement != null || emptyElementCount > 0 ) return true ; if ( current == input . length ( ) ) return false ; while ( matcher . find ( ) ) { nextElement = input . subSequence ( current , matcher . start ( ) ) . toString ( ) ; current = matcher . end ( ) ; if ( ! nextElement . isEmpty ( ) ) { return true ; } else if ( current > 0 ) { emptyElementCount ++ ; } } nextElement = input . subSequence ( current , input . length ( ) ) . toString ( ) ; current = input . length ( ) ; if ( ! nextElement . isEmpty ( ) ) { return true ; } else { emptyElementCount = 0 ; nextElement = null ; return false ; } } } return StreamSupport . stream ( Spliterators . spliteratorUnknownSize ( new MatcherIterator ( ) , Spliterator . ORDERED | Spliterator . NONNULL ) , false ) ; }
Creates a stream from the given input sequence around matches of this pattern .
27,605
private Appendable normalize ( CharSequence src , Appendable dest , UnicodeSet . SpanCondition spanCondition ) { StringBuilder tempDest = new StringBuilder ( ) ; try { for ( int prevSpanLimit = 0 ; prevSpanLimit < src . length ( ) ; ) { int spanLimit = set . span ( src , prevSpanLimit , spanCondition ) ; int spanLength = spanLimit - prevSpanLimit ; if ( spanCondition == UnicodeSet . SpanCondition . NOT_CONTAINED ) { if ( spanLength != 0 ) { dest . append ( src , prevSpanLimit , spanLimit ) ; } spanCondition = UnicodeSet . SpanCondition . SIMPLE ; } else { if ( spanLength != 0 ) { dest . append ( norm2 . normalize ( src . subSequence ( prevSpanLimit , spanLimit ) , tempDest ) ) ; } spanCondition = UnicodeSet . SpanCondition . NOT_CONTAINED ; } prevSpanLimit = spanLimit ; } } catch ( IOException e ) { throw new ICUUncheckedIOException ( e ) ; } return dest ; }
an in - filter prefix .
27,606
public static Set < String > getAvailableIDs ( SystemTimeZoneType type , String region , Integer rawOffset ) { Set < String > baseSet = null ; switch ( type ) { case ANY : baseSet = getSystemZIDs ( ) ; break ; case CANONICAL : baseSet = getCanonicalSystemZIDs ( ) ; break ; case CANONICAL_LOCATION : baseSet = getCanonicalSystemLocationZIDs ( ) ; break ; default : throw new IllegalArgumentException ( "Unknown SystemTimeZoneType" ) ; } if ( region == null && rawOffset == null ) { return baseSet ; } if ( region != null ) { region = region . toUpperCase ( Locale . ENGLISH ) ; } Set < String > result = new TreeSet < String > ( ) ; for ( String id : baseSet ) { if ( region != null ) { String r = getRegion ( id ) ; if ( ! region . equals ( r ) ) { continue ; } } if ( rawOffset != null ) { TimeZone z = getSystemTimeZone ( id ) ; if ( z == null || ! rawOffset . equals ( z . getRawOffset ( ) ) ) { continue ; } } result . add ( id ) ; } if ( result . isEmpty ( ) ) { return Collections . emptySet ( ) ; } return Collections . unmodifiableSet ( result ) ; }
Returns an immutable set of system IDs for the given conditions .
27,607
public static synchronized int countEquivalentIDs ( String id ) { int count = 0 ; UResourceBundle res = openOlsonResource ( null , id ) ; if ( res != null ) { try { UResourceBundle links = res . get ( "links" ) ; int [ ] v = links . getIntVector ( ) ; count = v . length ; } catch ( MissingResourceException ex ) { } } return count ; }
Returns the number of IDs in the equivalency group that includes the given ID . An equivalency group contains zones that behave identically to the given zone .
27,608
public static synchronized String getEquivalentID ( String id , int index ) { String result = "" ; if ( index >= 0 ) { UResourceBundle res = openOlsonResource ( null , id ) ; if ( res != null ) { int zoneIdx = - 1 ; try { UResourceBundle links = res . get ( "links" ) ; int [ ] zones = links . getIntVector ( ) ; if ( index < zones . length ) { zoneIdx = zones [ index ] ; } } catch ( MissingResourceException ex ) { } if ( zoneIdx >= 0 ) { String tmp = getZoneID ( zoneIdx ) ; if ( tmp != null ) { result = tmp ; } } } } return result ; }
Returns an ID in the equivalency group that includes the given ID . An equivalency group contains zones that behave identically to the given zone .
27,609
public static String getCanonicalCLDRID ( String tzid ) { String canonical = CANONICAL_ID_CACHE . get ( tzid ) ; if ( canonical == null ) { canonical = findCLDRCanonicalID ( tzid ) ; if ( canonical == null ) { try { int zoneIdx = getZoneIndex ( tzid ) ; if ( zoneIdx >= 0 ) { UResourceBundle top = UResourceBundle . getBundleInstance ( ICUData . ICU_BASE_NAME , ZONEINFORESNAME , ICUResourceBundle . ICU_DATA_CLASS_LOADER ) ; UResourceBundle zones = top . get ( kZONES ) ; UResourceBundle zone = zones . get ( zoneIdx ) ; if ( zone . getType ( ) == UResourceBundle . INT ) { tzid = getZoneID ( zone . getInt ( ) ) ; canonical = findCLDRCanonicalID ( tzid ) ; } if ( canonical == null ) { canonical = tzid ; } } } catch ( MissingResourceException e ) { } } if ( canonical != null ) { CANONICAL_ID_CACHE . put ( tzid , canonical ) ; } } return canonical ; }
Return the canonical id for this tzid defined by CLDR which might be the id itself . If the given tzid is not known return null .
27,610
public static String getRegion ( String tzid ) { String region = REGION_CACHE . get ( tzid ) ; if ( region == null ) { int zoneIdx = getZoneIndex ( tzid ) ; if ( zoneIdx >= 0 ) { try { UResourceBundle top = UResourceBundle . getBundleInstance ( ICUData . ICU_BASE_NAME , ZONEINFORESNAME , ICUResourceBundle . ICU_DATA_CLASS_LOADER ) ; UResourceBundle regions = top . get ( kREGIONS ) ; if ( zoneIdx < regions . getSize ( ) ) { region = regions . getString ( zoneIdx ) ; } } catch ( MissingResourceException e ) { } if ( region != null ) { REGION_CACHE . put ( tzid , region ) ; } } } return region ; }
Return the region code for this tzid . If tzid is not a system zone ID this method returns null .
27,611
public static String getCanonicalCountry ( String tzid ) { String country = getRegion ( tzid ) ; if ( country != null && country . equals ( kWorld ) ) { country = null ; } return country ; }
Return the canonical country code for this tzid . If we have none or if the time zone is not associated with a country or unknown return null .
27,612
public static String getCanonicalCountry ( String tzid , Output < Boolean > isPrimary ) { isPrimary . value = Boolean . FALSE ; String country = getRegion ( tzid ) ; if ( country != null && country . equals ( kWorld ) ) { return null ; } Boolean singleZone = SINGLE_COUNTRY_CACHE . get ( tzid ) ; if ( singleZone == null ) { Set < String > ids = TimeZone . getAvailableIDs ( SystemTimeZoneType . CANONICAL_LOCATION , country , null ) ; assert ( ids . size ( ) >= 1 ) ; singleZone = Boolean . valueOf ( ids . size ( ) <= 1 ) ; SINGLE_COUNTRY_CACHE . put ( tzid , singleZone ) ; } if ( singleZone ) { isPrimary . value = Boolean . TRUE ; } else { try { UResourceBundle bundle = UResourceBundle . getBundleInstance ( ICUData . ICU_BASE_NAME , "metaZones" ) ; UResourceBundle primaryZones = bundle . get ( "primaryZones" ) ; String primaryZone = primaryZones . getString ( country ) ; if ( tzid . equals ( primaryZone ) ) { isPrimary . value = Boolean . TRUE ; } else { String canonicalID = getCanonicalCLDRID ( tzid ) ; if ( canonicalID != null && canonicalID . equals ( primaryZone ) ) { isPrimary . value = Boolean . TRUE ; } } } catch ( MissingResourceException e ) { } } return country ; }
Return the canonical country code for this tzid . If we have none or if the time zone is not associated with a country or unknown return null . When the given zone is the primary zone of the country true is set to isPrimary .
27,613
public static UResourceBundle openOlsonResource ( UResourceBundle top , String id ) { UResourceBundle res = null ; int zoneIdx = getZoneIndex ( id ) ; if ( zoneIdx >= 0 ) { try { if ( top == null ) { top = UResourceBundle . getBundleInstance ( ICUData . ICU_BASE_NAME , ZONEINFORESNAME , ICUResourceBundle . ICU_DATA_CLASS_LOADER ) ; } UResourceBundle zones = top . get ( kZONES ) ; UResourceBundle zone = zones . get ( zoneIdx ) ; if ( zone . getType ( ) == UResourceBundle . INT ) { zone = zones . get ( zone . getInt ( ) ) ; } res = zone ; } catch ( MissingResourceException e ) { res = null ; } } return res ; }
Given an ID and the top - level resource of the zoneinfo resource open the appropriate resource for the given time zone . Dereference links if necessary .
27,614
public static SimpleTimeZone getCustomTimeZone ( String id ) { int [ ] fields = new int [ 4 ] ; if ( parseCustomID ( id , fields ) ) { Integer key = Integer . valueOf ( fields [ 0 ] * ( fields [ 1 ] | fields [ 2 ] << 5 | fields [ 3 ] << 11 ) ) ; return CUSTOM_ZONE_CACHE . getInstance ( key , fields ) ; } return null ; }
Parse a custom time zone identifier and return a corresponding zone .
27,615
public static String getCustomID ( String id ) { int [ ] fields = new int [ 4 ] ; if ( parseCustomID ( id , fields ) ) { return formatCustomID ( fields [ 1 ] , fields [ 2 ] , fields [ 3 ] , fields [ 0 ] < 0 ) ; } return null ; }
Parse a custom time zone identifier and return the normalized custom time zone identifier for the given custom id string .
27,616
public static SimpleTimeZone getCustomTimeZone ( int offset ) { boolean negative = false ; int tmp = offset ; if ( offset < 0 ) { negative = true ; tmp = - offset ; } int hour , min , sec ; if ( ASSERT ) { Assert . assrt ( "millis!=0" , tmp % 1000 != 0 ) ; } tmp /= 1000 ; sec = tmp % 60 ; tmp /= 60 ; min = tmp % 60 ; hour = tmp / 60 ; String zid = formatCustomID ( hour , min , sec , negative ) ; return new SimpleTimeZone ( offset , zid ) ; }
Creates a custom zone for the offset
27,617
public void encode ( OutputStream out ) throws IOException { DerOutputStream tmp = new DerOutputStream ( ) ; tmp . write ( key . getEncoded ( ) ) ; out . write ( tmp . toByteArray ( ) ) ; }
Encode the key in DER form to the stream .
27,618
public String getLocalNameOfNode ( Node n ) { String name = n . getLocalName ( ) ; return ( null == name ) ? super . getLocalNameOfNode ( n ) : name ; }
Returns the local name of the given node as defined by the XML Namespaces specification . This is prepared to handle documents built using DOM Level 1 methods by falling back upon explicitly parsing the node name .
27,619
public double num ( XPathContext xctxt ) throws javax . xml . transform . TransformerException { return execute ( xctxt ) . num ( ) ; }
Evaluate expression to a number .
27,620
public boolean bool ( XPathContext xctxt ) throws javax . xml . transform . TransformerException { return execute ( xctxt ) . bool ( ) ; }
Evaluate expression to a boolean .
27,621
public DTMIterator asIteratorRaw ( XPathContext xctxt , int contextNode ) throws javax . xml . transform . TransformerException { try { xctxt . pushCurrentNodeAndExpression ( contextNode , contextNode ) ; XNodeSet nodeset = ( XNodeSet ) execute ( xctxt ) ; return nodeset . iterRaw ( ) ; } finally { xctxt . popCurrentNodeAndExpression ( ) ; } }
Given an select expression and a context evaluate the XPath and return the resulting iterator but do not clone .
27,622
public void add ( StandardPlural rangeStart , StandardPlural rangeEnd , StandardPlural result ) { if ( isFrozen ) { throw new UnsupportedOperationException ( ) ; } explicit [ result . ordinal ( ) ] = true ; if ( rangeStart == null ) { for ( StandardPlural rs : StandardPlural . values ( ) ) { if ( rangeEnd == null ) { for ( StandardPlural re : StandardPlural . values ( ) ) { matrix . setIfNew ( rs , re , result ) ; } } else { explicit [ rangeEnd . ordinal ( ) ] = true ; matrix . setIfNew ( rs , rangeEnd , result ) ; } } } else if ( rangeEnd == null ) { explicit [ rangeStart . ordinal ( ) ] = true ; for ( StandardPlural re : StandardPlural . values ( ) ) { matrix . setIfNew ( rangeStart , re , result ) ; } } else { explicit [ rangeStart . ordinal ( ) ] = true ; explicit [ rangeEnd . ordinal ( ) ] = true ; matrix . setIfNew ( rangeStart , rangeEnd , result ) ; } }
Internal method for building . If the start or end are null it means everything of that type .
27,623
static CharInfo getCharInfo ( String entitiesFileName , String method ) { CharInfo charInfo = ( CharInfo ) m_getCharInfoCache . get ( entitiesFileName ) ; if ( charInfo != null ) { return mutableCopyOf ( charInfo ) ; } try { charInfo = getCharInfoBasedOnPrivilege ( entitiesFileName , method , true ) ; m_getCharInfoCache . put ( entitiesFileName , charInfo ) ; return mutableCopyOf ( charInfo ) ; } catch ( Exception e ) { } try { return getCharInfoBasedOnPrivilege ( entitiesFileName , method , false ) ; } catch ( Exception e ) { } String absoluteEntitiesFileName ; if ( entitiesFileName . indexOf ( ':' ) < 0 ) { absoluteEntitiesFileName = SystemIDResolver . getAbsoluteURIFromRelative ( entitiesFileName ) ; } else { try { absoluteEntitiesFileName = SystemIDResolver . getAbsoluteURI ( entitiesFileName , null ) ; } catch ( TransformerException te ) { throw new WrappedRuntimeException ( te ) ; } } return getCharInfoBasedOnPrivilege ( entitiesFileName , method , false ) ; }
Factory that reads in a resource file that describes the mapping of characters to entity references .
27,624
private static CharInfo mutableCopyOf ( CharInfo charInfo ) { CharInfo copy = new CharInfo ( ) ; int max = charInfo . array_of_bits . length ; System . arraycopy ( charInfo . array_of_bits , 0 , copy . array_of_bits , 0 , max ) ; copy . firstWordNotUsed = charInfo . firstWordNotUsed ; max = charInfo . shouldMapAttrChar_ASCII . length ; System . arraycopy ( charInfo . shouldMapAttrChar_ASCII , 0 , copy . shouldMapAttrChar_ASCII , 0 , max ) ; max = charInfo . shouldMapTextChar_ASCII . length ; System . arraycopy ( charInfo . shouldMapTextChar_ASCII , 0 , copy . shouldMapTextChar_ASCII , 0 , max ) ; copy . m_charToString = ( HashMap ) charInfo . m_charToString . clone ( ) ; copy . onlyQuotAmpLtGt = charInfo . onlyQuotAmpLtGt ; return copy ; }
Create a mutable copy of the cached one .
27,625
private boolean extraEntity ( String outputString , int charToMap ) { boolean extra = false ; if ( charToMap < ASCII_MAX ) { switch ( charToMap ) { case '"' : if ( ! outputString . equals ( "&quot;" ) ) extra = true ; break ; case '&' : if ( ! outputString . equals ( "&amp;" ) ) extra = true ; break ; case '<' : if ( ! outputString . equals ( "&lt;" ) ) extra = true ; break ; case '>' : if ( ! outputString . equals ( "&gt;" ) ) extra = true ; break ; default : extra = true ; } } return extra ; }
This method returns true if there are some non - standard mappings to entities other than quot amp lt gt and its only purpose is for performance .
27,626
boolean defineChar2StringMapping ( String outputString , char inputChar ) { CharKey character = new CharKey ( inputChar ) ; m_charToString . put ( character , outputString ) ; set ( inputChar ) ; boolean extraMapping = extraEntity ( outputString , inputChar ) ; return extraMapping ; }
Call this method to register a char to String mapping for example to map < to &lt ; .
27,627
public static int bounds ( String source , int offset16 ) { char ch = source . charAt ( offset16 ) ; if ( isSurrogate ( ch ) ) { if ( isLeadSurrogate ( ch ) ) { if ( ++ offset16 < source . length ( ) && isTrailSurrogate ( source . charAt ( offset16 ) ) ) { return LEAD_SURROGATE_BOUNDARY ; } } else { -- offset16 ; if ( offset16 >= 0 && isLeadSurrogate ( source . charAt ( offset16 ) ) ) { return TRAIL_SURROGATE_BOUNDARY ; } } } return SINGLE_CHAR_BOUNDARY ; }
Returns the type of the boundaries around the char at offset16 . Used for random access .
27,628
public static int append ( char [ ] target , int limit , int char32 ) { if ( char32 < CODEPOINT_MIN_VALUE || char32 > CODEPOINT_MAX_VALUE ) { throw new IllegalArgumentException ( "Illegal codepoint" ) ; } if ( char32 >= SUPPLEMENTARY_MIN_VALUE ) { target [ limit ++ ] = getLeadSurrogate ( char32 ) ; target [ limit ++ ] = getTrailSurrogate ( char32 ) ; } else { target [ limit ++ ] = ( char ) char32 ; } return limit ; }
Adds a codepoint to offset16 position of the argument char array .
27,629
public static int countCodePoint ( String source ) { if ( source == null || source . length ( ) == 0 ) { return 0 ; } return findCodePointOffset ( source , source . length ( ) ) ; }
Number of codepoints in a UTF16 String
27,630
public static int countCodePoint ( StringBuffer source ) { if ( source == null || source . length ( ) == 0 ) { return 0 ; } return findCodePointOffset ( source , source . length ( ) ) ; }
Number of codepoints in a UTF16 String buffer
27,631
public static int countCodePoint ( char source [ ] , int start , int limit ) { if ( source == null || source . length == 0 ) { return 0 ; } return findCodePointOffset ( source , start , limit , limit - start ) ; }
Number of codepoints in a UTF16 char array substring
27,632
public static void setCharAt ( StringBuffer target , int offset16 , int char32 ) { int count = 1 ; char single = target . charAt ( offset16 ) ; if ( isSurrogate ( single ) ) { if ( isLeadSurrogate ( single ) && ( target . length ( ) > offset16 + 1 ) && isTrailSurrogate ( target . charAt ( offset16 + 1 ) ) ) { count ++ ; } else { if ( isTrailSurrogate ( single ) && ( offset16 > 0 ) && isLeadSurrogate ( target . charAt ( offset16 - 1 ) ) ) { offset16 -- ; count ++ ; } } } target . replace ( offset16 , offset16 + count , valueOf ( char32 ) ) ; }
Set a code point into a UTF16 position . Adjusts target according if we are replacing a non - supplementary codepoint with a supplementary and vice versa .
27,633
public static int setCharAt ( char target [ ] , int limit , int offset16 , int char32 ) { if ( offset16 >= limit ) { throw new ArrayIndexOutOfBoundsException ( offset16 ) ; } int count = 1 ; char single = target [ offset16 ] ; if ( isSurrogate ( single ) ) { if ( isLeadSurrogate ( single ) && ( target . length > offset16 + 1 ) && isTrailSurrogate ( target [ offset16 + 1 ] ) ) { count ++ ; } else { if ( isTrailSurrogate ( single ) && ( offset16 > 0 ) && isLeadSurrogate ( target [ offset16 - 1 ] ) ) { offset16 -- ; count ++ ; } } } String str = valueOf ( char32 ) ; int result = limit ; int strlength = str . length ( ) ; target [ offset16 ] = str . charAt ( 0 ) ; if ( count == strlength ) { if ( count == 2 ) { target [ offset16 + 1 ] = str . charAt ( 1 ) ; } } else { System . arraycopy ( target , offset16 + count , target , offset16 + strlength , limit - ( offset16 + count ) ) ; if ( count < strlength ) { target [ offset16 + 1 ] = str . charAt ( 1 ) ; result ++ ; if ( result < target . length ) { target [ result ] = 0 ; } } else { result -- ; target [ result ] = 0 ; } } return result ; }
Set a code point into a UTF16 position in a char array . Adjusts target according if we are replacing a non - supplementary codepoint with a supplementary and vice versa .
27,634
public static int moveCodePointOffset ( String source , int offset16 , int shift32 ) { int result = offset16 ; int size = source . length ( ) ; int count ; char ch ; if ( offset16 < 0 || offset16 > size ) { throw new StringIndexOutOfBoundsException ( offset16 ) ; } if ( shift32 > 0 ) { if ( shift32 + offset16 > size ) { throw new StringIndexOutOfBoundsException ( offset16 ) ; } count = shift32 ; while ( result < size && count > 0 ) { ch = source . charAt ( result ) ; if ( isLeadSurrogate ( ch ) && ( ( result + 1 ) < size ) && isTrailSurrogate ( source . charAt ( result + 1 ) ) ) { result ++ ; } count -- ; result ++ ; } } else { if ( offset16 + shift32 < 0 ) { throw new StringIndexOutOfBoundsException ( offset16 ) ; } for ( count = - shift32 ; count > 0 ; count -- ) { result -- ; if ( result < 0 ) { break ; } ch = source . charAt ( result ) ; if ( isTrailSurrogate ( ch ) && result > 0 && isLeadSurrogate ( source . charAt ( result - 1 ) ) ) { result -- ; } } } if ( count != 0 ) { throw new StringIndexOutOfBoundsException ( shift32 ) ; } return result ; }
Shifts offset16 by the argument number of codepoints
27,635
public static int moveCodePointOffset ( char source [ ] , int start , int limit , int offset16 , int shift32 ) { int size = source . length ; int count ; char ch ; int result = offset16 + start ; if ( start < 0 || limit < start ) { throw new StringIndexOutOfBoundsException ( start ) ; } if ( limit > size ) { throw new StringIndexOutOfBoundsException ( limit ) ; } if ( offset16 < 0 || result > limit ) { throw new StringIndexOutOfBoundsException ( offset16 ) ; } if ( shift32 > 0 ) { if ( shift32 + result > size ) { throw new StringIndexOutOfBoundsException ( result ) ; } count = shift32 ; while ( result < limit && count > 0 ) { ch = source [ result ] ; if ( isLeadSurrogate ( ch ) && ( result + 1 < limit ) && isTrailSurrogate ( source [ result + 1 ] ) ) { result ++ ; } count -- ; result ++ ; } } else { if ( result + shift32 < start ) { throw new StringIndexOutOfBoundsException ( result ) ; } for ( count = - shift32 ; count > 0 ; count -- ) { result -- ; if ( result < start ) { break ; } ch = source [ result ] ; if ( isTrailSurrogate ( ch ) && result > start && isLeadSurrogate ( source [ result - 1 ] ) ) { result -- ; } } } if ( count != 0 ) { throw new StringIndexOutOfBoundsException ( shift32 ) ; } result -= start ; return result ; }
Shifts offset16 by the argument number of codepoints within a subarray .
27,636
public static String newString ( int [ ] codePoints , int offset , int count ) { if ( count < 0 ) { throw new IllegalArgumentException ( ) ; } char [ ] chars = new char [ count ] ; int w = 0 ; for ( int r = offset , e = offset + count ; r < e ; ++ r ) { int cp = codePoints [ r ] ; if ( cp < 0 || cp > 0x10ffff ) { throw new IllegalArgumentException ( ) ; } while ( true ) { try { if ( cp < 0x010000 ) { chars [ w ] = ( char ) cp ; w ++ ; } else { chars [ w ] = ( char ) ( LEAD_SURROGATE_OFFSET_ + ( cp >> LEAD_SURROGATE_SHIFT_ ) ) ; chars [ w + 1 ] = ( char ) ( TRAIL_SURROGATE_MIN_VALUE + ( cp & TRAIL_SURROGATE_MASK_ ) ) ; w += 2 ; } break ; } catch ( IndexOutOfBoundsException ex ) { int newlen = ( int ) ( Math . ceil ( ( double ) codePoints . length * ( w + 2 ) / ( r - offset + 1 ) ) ) ; char [ ] temp = new char [ newlen ] ; System . arraycopy ( chars , 0 , temp , 0 , w ) ; chars = temp ; } } } return new String ( chars , 0 , w ) ; }
Cover JDK 1 . 5 API . Create a String from an array of codePoints .
27,637
public static int getSingleCodePoint ( CharSequence s ) { if ( s == null || s . length ( ) == 0 ) { return - 1 ; } else if ( s . length ( ) == 1 ) { return s . charAt ( 0 ) ; } else if ( s . length ( ) > 2 ) { return - 1 ; } int cp = Character . codePointAt ( s , 0 ) ; if ( cp > 0xFFFF ) { return cp ; } return - 1 ; }
Utility for getting a code point from a CharSequence that contains exactly one code point .
27,638
public static ExecutorService newCachedThreadPool ( ThreadFactory threadFactory ) { return new ThreadPoolExecutor ( 0 , Integer . MAX_VALUE , 60L , TimeUnit . SECONDS , new SynchronousQueue < Runnable > ( ) , threadFactory ) ; }
Creates a thread pool that creates new threads as needed but will reuse previously constructed threads when they are available and uses the provided ThreadFactory to create new threads when needed .
27,639
private int getMoreData ( ) throws IOException { if ( done ) return - 1 ; int readin = input . read ( ibuffer ) ; if ( readin == - 1 ) { done = true ; try { obuffer = cipher . doFinal ( ) ; } catch ( IllegalBlockSizeException e ) { obuffer = null ; } catch ( BadPaddingException e ) { obuffer = null ; } if ( obuffer == null ) return - 1 ; else { ostart = 0 ; ofinish = obuffer . length ; return ofinish ; } } try { obuffer = cipher . update ( ibuffer , 0 , readin ) ; } catch ( IllegalStateException e ) { obuffer = null ; } ; ostart = 0 ; if ( obuffer == null ) ofinish = 0 ; else ofinish = obuffer . length ; return ofinish ; }
private convenience function .
27,640
private boolean matchModes ( QName m1 , QName m2 ) { return ( ( ( null == m1 ) && ( null == m2 ) ) || ( ( null != m1 ) && ( null != m2 ) && m1 . equals ( m2 ) ) ) ; }
Tell if two modes match according to the rules of XSLT .
27,641
public boolean matches ( XPathContext xctxt , int targetNode , QName mode ) throws TransformerException { double score = m_stepPattern . getMatchScore ( xctxt , targetNode ) ; return ( XPath . MATCH_SCORE_NONE != score ) && matchModes ( mode , m_template . getMode ( ) ) ; }
Return the mode associated with the template .
27,642
public final void setMaxPriority ( int pri ) { int ngroupsSnapshot ; ThreadGroup [ ] groupsSnapshot ; synchronized ( this ) { checkAccess ( ) ; if ( pri < Thread . MIN_PRIORITY ) { pri = Thread . MIN_PRIORITY ; } if ( pri > Thread . MAX_PRIORITY ) { pri = Thread . MAX_PRIORITY ; } maxPriority = ( parent != null ) ? Math . min ( pri , parent . maxPriority ) : pri ; ngroupsSnapshot = ngroups ; if ( groups != null ) { groupsSnapshot = Arrays . copyOf ( groups , ngroupsSnapshot ) ; } else { groupsSnapshot = null ; } } for ( int i = 0 ; i < ngroupsSnapshot ; i ++ ) { groupsSnapshot [ i ] . setMaxPriority ( pri ) ; } }
before using it .
27,643
public final boolean parentOf ( ThreadGroup g ) { for ( ; g != null ; g = g . parent ) { if ( g == this ) { return true ; } } return false ; }
Tests if this thread group is either the thread group argument or one of its ancestor thread groups .
27,644
public int activeCount ( ) { int result ; int ngroupsSnapshot ; ThreadGroup [ ] groupsSnapshot ; synchronized ( this ) { if ( destroyed ) { return 0 ; } result = nthreads ; ngroupsSnapshot = ngroups ; if ( groups != null ) { groupsSnapshot = Arrays . copyOf ( groups , ngroupsSnapshot ) ; } else { groupsSnapshot = null ; } } for ( int i = 0 ; i < ngroupsSnapshot ; i ++ ) { result += groupsSnapshot [ i ] . activeCount ( ) ; } return result ; }
Returns an estimate of the number of active threads in this thread group and its subgroups . Recursively iterates over all subgroups in this thread group .
27,645
public int activeGroupCount ( ) { int ngroupsSnapshot ; ThreadGroup [ ] groupsSnapshot ; synchronized ( this ) { if ( destroyed ) { return 0 ; } ngroupsSnapshot = ngroups ; if ( groups != null ) { groupsSnapshot = Arrays . copyOf ( groups , ngroupsSnapshot ) ; } else { groupsSnapshot = null ; } } int n = ngroupsSnapshot ; for ( int i = 0 ; i < ngroupsSnapshot ; i ++ ) { n += groupsSnapshot [ i ] . activeGroupCount ( ) ; } return n ; }
Returns an estimate of the number of active groups in this thread group and its subgroups . Recursively iterates over all subgroups in this thread group .
27,646
private final void add ( ThreadGroup g ) { synchronized ( this ) { if ( destroyed ) { throw new IllegalThreadStateException ( ) ; } if ( groups == null ) { groups = new ThreadGroup [ 4 ] ; } else if ( ngroups == groups . length ) { groups = Arrays . copyOf ( groups , ngroups * 2 ) ; } groups [ ngroups ] = g ; ngroups ++ ; } }
Adds the specified Thread group to this group .
27,647
private void remove ( ThreadGroup g ) { synchronized ( this ) { if ( destroyed ) { return ; } for ( int i = 0 ; i < ngroups ; i ++ ) { if ( groups [ i ] == g ) { ngroups -= 1 ; System . arraycopy ( groups , i + 1 , groups , i , ngroups - i ) ; groups [ ngroups ] = null ; break ; } } if ( nthreads == 0 ) { notifyAll ( ) ; } if ( daemon && ( nthreads == 0 ) && ( nUnstartedThreads == 0 ) && ( ngroups == 0 ) ) { destroy ( ) ; } } }
Removes the specified Thread group from this group .
27,648
void add ( Thread t ) { synchronized ( this ) { if ( destroyed ) { throw new IllegalThreadStateException ( ) ; } if ( threads == null ) { threads = new Thread [ 4 ] ; } else if ( nthreads == threads . length ) { threads = Arrays . copyOf ( threads , nthreads * 2 ) ; } threads [ nthreads ] = t ; nthreads ++ ; nUnstartedThreads -- ; } }
Adds the specified thread to this thread group .
27,649
private void remove ( Thread t ) { synchronized ( this ) { if ( destroyed ) { return ; } for ( int i = 0 ; i < nthreads ; i ++ ) { if ( threads [ i ] == t ) { System . arraycopy ( threads , i + 1 , threads , i , -- nthreads - i ) ; threads [ nthreads ] = null ; break ; } } } }
Removes the specified Thread from this group . Invoking this method on a thread group that has been destroyed has no effect .
27,650
public int getCharFromName ( int choice , String name ) { if ( choice >= UCharacterNameChoice . CHAR_NAME_CHOICE_COUNT || name == null || name . length ( ) == 0 ) { return - 1 ; } int result = getExtendedChar ( name . toLowerCase ( Locale . ENGLISH ) , choice ) ; if ( result >= - 1 ) { return result ; } String upperCaseName = name . toUpperCase ( Locale . ENGLISH ) ; if ( choice == UCharacterNameChoice . UNICODE_CHAR_NAME || choice == UCharacterNameChoice . EXTENDED_CHAR_NAME ) { int count = 0 ; if ( m_algorithm_ != null ) { count = m_algorithm_ . length ; } for ( count -- ; count >= 0 ; count -- ) { result = m_algorithm_ [ count ] . getChar ( upperCaseName ) ; if ( result >= 0 ) { return result ; } } } if ( choice == UCharacterNameChoice . EXTENDED_CHAR_NAME ) { result = getGroupChar ( upperCaseName , UCharacterNameChoice . UNICODE_CHAR_NAME ) ; if ( result == - 1 ) { result = getGroupChar ( upperCaseName , UCharacterNameChoice . CHAR_NAME_ALIAS ) ; } } else { result = getGroupChar ( upperCaseName , choice ) ; } return result ; }
Find a character by its name and return its code point value
27,651
public String getExtendedName ( int ch ) { String result = getName ( ch , UCharacterNameChoice . UNICODE_CHAR_NAME ) ; if ( result == null ) { result = getExtendedOr10Name ( ch ) ; } return result ; }
Retrieves the extended name
27,652
public int getGroup ( int codepoint ) { int endGroup = m_groupcount_ ; int msb = getCodepointMSB ( codepoint ) ; int result = 0 ; while ( result < endGroup - 1 ) { int gindex = ( result + endGroup ) >> 1 ; if ( msb < getGroupMSB ( gindex ) ) { endGroup = gindex ; } else { result = gindex ; } } return result ; }
Gets the group index for the codepoint or the group before it .
27,653
public String getExtendedOr10Name ( int ch ) { String result = null ; if ( result == null ) { int type = getType ( ch ) ; if ( type >= TYPE_NAMES_ . length ) { result = UNKNOWN_TYPE_NAME_ ; } else { result = TYPE_NAMES_ [ type ] ; } synchronized ( m_utilStringBuffer_ ) { m_utilStringBuffer_ . setLength ( 0 ) ; m_utilStringBuffer_ . append ( '<' ) ; m_utilStringBuffer_ . append ( result ) ; m_utilStringBuffer_ . append ( '-' ) ; String chStr = Integer . toHexString ( ch ) . toUpperCase ( Locale . ENGLISH ) ; int zeros = 4 - chStr . length ( ) ; while ( zeros > 0 ) { m_utilStringBuffer_ . append ( '0' ) ; zeros -- ; } m_utilStringBuffer_ . append ( chStr ) ; m_utilStringBuffer_ . append ( '>' ) ; result = m_utilStringBuffer_ . toString ( ) ; } } return result ; }
Gets the extended and 1 . 0 name when the most current unicode names fail
27,654
public String getAlgorithmName ( int index , int codepoint ) { String result = null ; synchronized ( m_utilStringBuffer_ ) { m_utilStringBuffer_ . setLength ( 0 ) ; m_algorithm_ [ index ] . appendName ( codepoint , m_utilStringBuffer_ ) ; result = m_utilStringBuffer_ . toString ( ) ; } return result ; }
Gets the Algorithmic name of the codepoint
27,655
public synchronized String getGroupName ( int ch , int choice ) { int msb = getCodepointMSB ( ch ) ; int group = getGroup ( ch ) ; if ( msb == m_groupinfo_ [ group * m_groupsize_ ] ) { int index = getGroupLengths ( group , m_groupoffsets_ , m_grouplengths_ ) ; int offset = ch & GROUP_MASK_ ; return getGroupName ( index + m_groupoffsets_ [ offset ] , m_grouplengths_ [ offset ] , choice ) ; } return null ; }
Gets the group name of the character
27,656
boolean setToken ( char token [ ] , byte tokenstring [ ] ) { if ( token != null && tokenstring != null && token . length > 0 && tokenstring . length > 0 ) { m_tokentable_ = token ; m_tokenstring_ = tokenstring ; return true ; } return false ; }
Sets the token data
27,657
boolean setAlgorithm ( AlgorithmName alg [ ] ) { if ( alg != null && alg . length != 0 ) { m_algorithm_ = alg ; return true ; } return false ; }
Set the algorithm name information array
27,658
boolean setGroupCountSize ( int count , int size ) { if ( count <= 0 || size <= 0 ) { return false ; } m_groupcount_ = count ; m_groupsize_ = size ; return true ; }
Sets the number of group and size of each group in number of char
27,659
boolean setGroup ( char group [ ] , byte groupstring [ ] ) { if ( group != null && groupstring != null && group . length > 0 && groupstring . length > 0 ) { m_groupinfo_ = group ; m_groupstring_ = groupstring ; return true ; } return false ; }
Sets the group name data
27,660
private String getAlgName ( int ch , int choice ) { if ( choice == UCharacterNameChoice . UNICODE_CHAR_NAME || choice == UCharacterNameChoice . EXTENDED_CHAR_NAME ) { synchronized ( m_utilStringBuffer_ ) { m_utilStringBuffer_ . setLength ( 0 ) ; for ( int index = m_algorithm_ . length - 1 ; index >= 0 ; index -- ) { if ( m_algorithm_ [ index ] . contains ( ch ) ) { m_algorithm_ [ index ] . appendName ( ch , m_utilStringBuffer_ ) ; return m_utilStringBuffer_ . toString ( ) ; } } } } return null ; }
Gets the algorithmic name for the argument character
27,661
private synchronized int getGroupChar ( String name , int choice ) { for ( int i = 0 ; i < m_groupcount_ ; i ++ ) { int startgpstrindex = getGroupLengths ( i , m_groupoffsets_ , m_grouplengths_ ) ; int result = getGroupChar ( startgpstrindex , m_grouplengths_ , name , choice ) ; if ( result != - 1 ) { return ( m_groupinfo_ [ i * m_groupsize_ ] << GROUP_SHIFT_ ) | result ; } } return - 1 ; }
Getting the character with the tokenized argument name
27,662
private int getGroupChar ( int index , char length [ ] , String name , int choice ) { byte b = 0 ; char token ; int len ; int namelen = name . length ( ) ; int nindex ; int count ; for ( int result = 0 ; result <= LINES_PER_GROUP_ ; result ++ ) { nindex = 0 ; len = length [ result ] ; if ( choice != UCharacterNameChoice . UNICODE_CHAR_NAME && choice != UCharacterNameChoice . EXTENDED_CHAR_NAME ) { int fieldIndex = choice == UCharacterNameChoice . ISO_COMMENT_ ? 2 : choice ; do { int oldindex = index ; index += UCharacterUtility . skipByteSubString ( m_groupstring_ , index , len , ( byte ) ';' ) ; len -= ( index - oldindex ) ; } while ( -- fieldIndex > 0 ) ; } for ( count = 0 ; count < len && nindex != - 1 && nindex < namelen ; ) { b = m_groupstring_ [ index + count ] ; count ++ ; if ( b >= m_tokentable_ . length ) { if ( name . charAt ( nindex ++ ) != ( b & 0xFF ) ) { nindex = - 1 ; } } else { token = m_tokentable_ [ b & 0xFF ] ; if ( token == 0xFFFE ) { token = m_tokentable_ [ b << 8 | ( m_groupstring_ [ index + count ] & 0x00ff ) ] ; count ++ ; } if ( token == 0xFFFF ) { if ( name . charAt ( nindex ++ ) != ( b & 0xFF ) ) { nindex = - 1 ; } } else { nindex = UCharacterUtility . compareNullTermByteSubString ( name , m_tokenstring_ , nindex , token ) ; } } } if ( namelen == nindex && ( count == len || m_groupstring_ [ index + count ] == ';' ) ) { return result ; } index += len ; } return - 1 ; }
Compares and retrieve character if name is found within the argument group
27,663
private static int getType ( int ch ) { if ( UCharacterUtility . isNonCharacter ( ch ) ) { return NON_CHARACTER_ ; } int result = UCharacter . getType ( ch ) ; if ( result == UCharacterCategory . SURROGATE ) { if ( ch <= UTF16 . LEAD_SURROGATE_MAX_VALUE ) { result = LEAD_SURROGATE_ ; } else { result = TRAIL_SURROGATE_ ; } } return result ; }
Gets the character extended type
27,664
private int addAlgorithmName ( int maxlength ) { int result = 0 ; for ( int i = m_algorithm_ . length - 1 ; i >= 0 ; i -- ) { result = m_algorithm_ [ i ] . add ( m_nameSet_ , maxlength ) ; if ( result > maxlength ) { maxlength = result ; } } return maxlength ; }
Adds all algorithmic names into the name set . Equivalent to part of calcAlgNameSetsLengths .
27,665
private int addExtendedName ( int maxlength ) { for ( int i = TYPE_NAMES_ . length - 1 ; i >= 0 ; i -- ) { int length = 9 + add ( m_nameSet_ , TYPE_NAMES_ [ i ] ) ; if ( length > maxlength ) { maxlength = length ; } } return maxlength ; }
Adds all extended names into the name set . Equivalent to part of calcExtNameSetsLengths .
27,666
private int [ ] addGroupName ( int offset , int length , byte tokenlength [ ] , int set [ ] ) { int resultnlength = 0 ; int resultplength = 0 ; while ( resultplength < length ) { char b = ( char ) ( m_groupstring_ [ offset + resultplength ] & 0xff ) ; resultplength ++ ; if ( b == ';' ) { break ; } if ( b >= m_tokentable_ . length ) { add ( set , b ) ; resultnlength ++ ; } else { char token = m_tokentable_ [ b & 0x00ff ] ; if ( token == 0xFFFE ) { b = ( char ) ( b << 8 | ( m_groupstring_ [ offset + resultplength ] & 0x00ff ) ) ; token = m_tokentable_ [ b ] ; resultplength ++ ; } if ( token == 0xFFFF ) { add ( set , b ) ; resultnlength ++ ; } else { byte tlength = tokenlength [ b ] ; if ( tlength == 0 ) { synchronized ( m_utilStringBuffer_ ) { m_utilStringBuffer_ . setLength ( 0 ) ; UCharacterUtility . getNullTermByteSubString ( m_utilStringBuffer_ , m_tokenstring_ , token ) ; tlength = ( byte ) add ( set , m_utilStringBuffer_ ) ; } tokenlength [ b ] = tlength ; } resultnlength += tlength ; } } } m_utilIntBuffer_ [ 0 ] = resultnlength ; m_utilIntBuffer_ [ 1 ] = resultplength ; return m_utilIntBuffer_ ; }
Adds names of a group to the argument set . Equivalent to calcNameSetLength .
27,667
private boolean initNameSetsLengths ( ) { if ( m_maxNameLength_ > 0 ) { return true ; } String extra = "0123456789ABCDEF<>-" ; for ( int i = extra . length ( ) - 1 ; i >= 0 ; i -- ) { add ( m_nameSet_ , extra . charAt ( i ) ) ; } m_maxNameLength_ = addAlgorithmName ( 0 ) ; m_maxNameLength_ = addExtendedName ( m_maxNameLength_ ) ; addGroupName ( m_maxNameLength_ ) ; return true ; }
Sets up the name sets and the calculation of the maximum lengths . Equivalent to calcNameSetsLengths .
27,668
private void convert ( int set [ ] , UnicodeSet uset ) { uset . clear ( ) ; if ( ! initNameSetsLengths ( ) ) { return ; } for ( char c = 255 ; c > 0 ; c -- ) { if ( contains ( set , c ) ) { uset . add ( c ) ; } } }
Converts the char set cset into a Unicode set uset . Equivalent to charSetToUSet .
27,669
public void set ( V newReference , boolean newMark ) { Pair < V > current = pair ; if ( newReference != current . reference || newMark != current . mark ) this . pair = Pair . of ( newReference , newMark ) ; }
Unconditionally sets the value of both the reference and mark .
27,670
public int serialize ( OutputStream os ) throws IOException { DataOutputStream dos = new DataOutputStream ( os ) ; int bytesWritten = 0 ; bytesWritten += serializeHeader ( dos ) ; for ( int i = 0 ; i < dataLength ; i ++ ) { dos . writeChar ( index [ data16 + i ] ) ; } bytesWritten += dataLength * 2 ; return bytesWritten ; }
Serialize a Trie2_16 onto an OutputStream .
27,671
private static InetAddress [ ] lookupHostByName ( String host , int netId ) throws UnknownHostException { BlockGuard . getThreadPolicy ( ) . onNetwork ( ) ; Object cachedResult = addressCache . get ( host , netId ) ; if ( cachedResult != null ) { if ( cachedResult instanceof InetAddress [ ] ) { return ( InetAddress [ ] ) cachedResult ; } else { throw new UnknownHostException ( ( String ) cachedResult ) ; } } try { StructAddrinfo hints = new StructAddrinfo ( ) ; hints . ai_flags = AI_ADDRCONFIG ; hints . ai_family = AF_UNSPEC ; hints . ai_socktype = SOCK_STREAM ; InetAddress [ ] addresses = NetworkOs . getaddrinfo ( host , hints ) ; for ( InetAddress address : addresses ) { address . holder ( ) . hostName = host ; } addressCache . put ( host , netId , addresses ) ; return addresses ; } catch ( GaiException gaiException ) { if ( gaiException . getCause ( ) instanceof ErrnoException ) { if ( ( ( ErrnoException ) gaiException . getCause ( ) ) . errno == EACCES ) { throw new SecurityException ( "Permission denied (missing INTERNET permission?)" , gaiException ) ; } } String detailMessage = "Unable to resolve host \"" + host + "\": " + NetworkOs . gai_strerror ( gaiException . error ) ; addressCache . putUnknownHost ( host , netId , detailMessage ) ; throw gaiException . rethrowAsUnknownHostException ( detailMessage ) ; } }
Resolves a hostname to its IP addresses using a cache .
27,672
public byte [ ] toByteArray ( ) { int length = getLength ( ) + 1 ; byte result [ ] = new byte [ length ] ; System . arraycopy ( m_key_ , 0 , result , 0 , length ) ; return result ; }
Duplicates and returns the value of this CollationKey as a sequence of big - endian bytes terminated by a null .
27,673
public int compareTo ( CollationKey target ) { for ( int i = 0 ; ; ++ i ) { int l = m_key_ [ i ] & 0xff ; int r = target . m_key_ [ i ] & 0xff ; if ( l < r ) { return - 1 ; } else if ( l > r ) { return 1 ; } else if ( l == 0 ) { return 0 ; } } }
Compare this CollationKey to another CollationKey . The collation rules of the Collator that created this key are applied .
27,674
private int getLength ( ) { if ( m_length_ >= 0 ) { return m_length_ ; } int length = m_key_ . length ; for ( int index = 0 ; index < length ; index ++ ) { if ( m_key_ [ index ] == 0 ) { length = index ; break ; } } m_length_ = length ; return m_length_ ; }
Gets the length of the CollationKey
27,675
public Node getNode ( int nodeHandle ) { int identity = makeNodeIdentity ( nodeHandle ) ; return ( Node ) m_nodes . elementAt ( identity ) ; }
Return an DOM node for the given node .
27,676
protected int getNextNodeIdentity ( int identity ) { identity += 1 ; if ( identity >= m_nodes . size ( ) ) { if ( ! nextNode ( ) ) identity = DTM . NULL ; } return identity ; }
Get the next node identity value in the list and call the iterator if it hasn t been added yet .
27,677
public int getHandleOfNode ( Node node ) { if ( null != node ) { if ( ( m_root == node ) || ( m_root . getNodeType ( ) == DOCUMENT_NODE && m_root == node . getOwnerDocument ( ) ) || ( m_root . getNodeType ( ) != DOCUMENT_NODE && m_root . getOwnerDocument ( ) == node . getOwnerDocument ( ) ) ) { for ( Node cursor = node ; cursor != null ; cursor = ( cursor . getNodeType ( ) != ATTRIBUTE_NODE ) ? cursor . getParentNode ( ) : ( ( org . w3c . dom . Attr ) cursor ) . getOwnerElement ( ) ) { if ( cursor == m_root ) return getHandleFromNode ( node ) ; } } } return DTM . NULL ; }
Get the handle from a Node . This is a more robust version of getHandleFromNode intended to be usable by the public .
27,678
public boolean isWhitespace ( int nodeHandle ) { int type = getNodeType ( nodeHandle ) ; Node node = getNode ( nodeHandle ) ; if ( TEXT_NODE == type || CDATA_SECTION_NODE == type ) { FastStringBuffer buf = StringBufferPool . get ( ) ; while ( node != null ) { buf . append ( node . getNodeValue ( ) ) ; node = logicalNextDOMTextNode ( node ) ; } boolean b = buf . isWhitespace ( 0 , buf . length ( ) ) ; StringBufferPool . free ( buf ) ; return b ; } return false ; }
Determine if the string - value of a node is whitespace
27,679
public void dispatchToEvents ( int nodeHandle , org . xml . sax . ContentHandler ch ) throws org . xml . sax . SAXException { TreeWalker treeWalker = m_walker ; ContentHandler prevCH = treeWalker . getContentHandler ( ) ; if ( null != prevCH ) { treeWalker = new TreeWalker ( null ) ; } treeWalker . setContentHandler ( ch ) ; try { Node node = getNode ( nodeHandle ) ; treeWalker . traverseFragment ( node ) ; } finally { treeWalker . setContentHandler ( null ) ; } }
Directly create SAX parser events from a subtree .
27,680
void reExecutePeriodic ( RunnableScheduledFuture < ? > task ) { if ( canRunInCurrentRunState ( true ) ) { super . getQueue ( ) . add ( task ) ; if ( ! canRunInCurrentRunState ( true ) && remove ( task ) ) task . cancel ( false ) ; else ensurePrestart ( ) ; } }
Requeues a periodic task unless current run state precludes it . Same idea as delayedExecute except drops task rather than rejecting .
27,681
protected < V > RunnableScheduledFuture < V > decorateTask ( Runnable runnable , RunnableScheduledFuture < V > task ) { return task ; }
Modifies or replaces the task used to execute a runnable . This method can be used to override the concrete class used for managing internal tasks . The default implementation simply returns the given task .
27,682
protected < V > RunnableScheduledFuture < V > decorateTask ( Callable < V > callable , RunnableScheduledFuture < V > task ) { return task ; }
Modifies or replaces the task used to execute a callable . This method can be used to override the concrete class used for managing internal tasks . The default implementation simply returns the given task .
27,683
long triggerTime ( long delay ) { return System . nanoTime ( ) + ( ( delay < ( Long . MAX_VALUE >> 1 ) ) ? delay : overflowFree ( delay ) ) ; }
Returns the nanoTime - based trigger time of a delayed action .
27,684
private long overflowFree ( long delay ) { Delayed head = ( Delayed ) super . getQueue ( ) . peek ( ) ; if ( head != null ) { long headDelay = head . getDelay ( NANOSECONDS ) ; if ( headDelay < 0 && ( delay - headDelay < 0 ) ) delay = Long . MAX_VALUE + headDelay ; } return delay ; }
Constrains the values of all delays in the queue to be within Long . MAX_VALUE of each other to avoid overflow in compareTo . This may occur if a task is eligible to be dequeued but has not yet been while some other task is added with a delay of Long . MAX_VALUE .
27,685
public static int floatToIntBits ( float value ) { int result = floatToRawIntBits ( value ) ; if ( ( ( result & FloatConsts . EXP_BIT_MASK ) == FloatConsts . EXP_BIT_MASK ) && ( result & FloatConsts . SIGNIF_BIT_MASK ) != 0 ) result = 0x7fc00000 ; return result ; }
Returns a representation of the specified floating - point value according to the IEEE 754 floating - point single format bit layout .
27,686
private void getMatchingCACerts ( ForwardState currentState , List < CertStore > certStores , Collection < X509Certificate > caCerts ) throws IOException { if ( debug != null ) { debug . println ( "ForwardBuilder.getMatchingCACerts()..." ) ; } int initialSize = caCerts . size ( ) ; X509CertSelector sel = null ; if ( currentState . isInitial ( ) ) { if ( targetCertConstraints . getBasicConstraints ( ) == - 2 ) { return ; } if ( debug != null ) { debug . println ( "ForwardBuilder.getMatchingCACerts(): ca is target" ) ; } if ( caTargetSelector == null ) { caTargetSelector = ( X509CertSelector ) targetCertConstraints . clone ( ) ; if ( buildParams . explicitPolicyRequired ( ) ) caTargetSelector . setPolicy ( getMatchingPolicies ( ) ) ; } sel = caTargetSelector ; } else { if ( caSelector == null ) { caSelector = new AdaptableX509CertSelector ( ) ; if ( buildParams . explicitPolicyRequired ( ) ) caSelector . setPolicy ( getMatchingPolicies ( ) ) ; } caSelector . setSubject ( currentState . issuerDN ) ; CertPathHelper . setPathToNames ( caSelector , currentState . subjectNamesTraversed ) ; AuthorityKeyIdentifierExtension akidext = currentState . cert . getAuthorityKeyIdentifierExtension ( ) ; caSelector . parseAuthorityKeyIdentifierExtension ( akidext ) ; caSelector . setValidityPeriod ( currentState . cert . getNotBefore ( ) , currentState . cert . getNotAfter ( ) ) ; sel = caSelector ; } sel . setBasicConstraints ( - 1 ) ; for ( X509Certificate trustedCert : trustedCerts ) { if ( sel . match ( trustedCert ) ) { if ( debug != null ) { debug . println ( "ForwardBuilder.getMatchingCACerts: " + "found matching trust anchor" ) ; } if ( caCerts . add ( trustedCert ) && ! searchAllCertStores ) { return ; } } } sel . setCertificateValid ( buildParams . date ( ) ) ; sel . setBasicConstraints ( currentState . traversedCACerts ) ; if ( currentState . isInitial ( ) || ( buildParams . maxPathLength ( ) == - 1 ) || ( buildParams . maxPathLength ( ) > currentState . traversedCACerts ) ) { if ( addMatchingCerts ( sel , certStores , caCerts , searchAllCertStores ) && ! searchAllCertStores ) { return ; } } if ( ! currentState . isInitial ( ) && Builder . USE_AIA ) { AuthorityInfoAccessExtension aiaExt = currentState . cert . getAuthorityInfoAccessExtension ( ) ; if ( aiaExt != null ) { getCerts ( aiaExt , caCerts ) ; } } if ( debug != null ) { int numCerts = caCerts . size ( ) - initialSize ; debug . println ( "ForwardBuilder.getMatchingCACerts: found " + numCerts + " CA certs" ) ; } }
Retrieves all CA certificates which satisfy constraints and requirements specified in the parameters and PKIX state .
27,687
@ SuppressWarnings ( "unchecked" ) private boolean getCerts ( AuthorityInfoAccessExtension aiaExt , Collection < X509Certificate > certs ) { if ( Builder . USE_AIA == false ) { return false ; } List < AccessDescription > adList = aiaExt . getAccessDescriptions ( ) ; if ( adList == null || adList . isEmpty ( ) ) { return false ; } boolean add = false ; for ( AccessDescription ad : adList ) { CertStore cs = URICertStore . getInstance ( ad ) ; if ( cs != null ) { try { if ( certs . addAll ( ( Collection < X509Certificate > ) cs . getCertificates ( caSelector ) ) ) { add = true ; if ( ! searchAllCertStores ) { return true ; } } } catch ( CertStoreException cse ) { if ( debug != null ) { debug . println ( "exception getting certs from CertStore:" ) ; cse . printStackTrace ( ) ; } } } } return add ; }
because of the selector so the cast is safe
27,688
public boolean offer ( E e ) { final ReentrantLock lock = this . lock ; lock . lock ( ) ; try { q . offer ( e ) ; if ( q . peek ( ) == e ) { leader = null ; available . signal ( ) ; } return true ; } finally { lock . unlock ( ) ; } }
Inserts the specified element into this delay queue .
27,689
public E take ( ) throws InterruptedException { final ReentrantLock lock = this . lock ; lock . lockInterruptibly ( ) ; try { for ( ; ; ) { E first = q . peek ( ) ; if ( first == null ) available . await ( ) ; else { long delay = first . getDelay ( NANOSECONDS ) ; if ( delay <= 0L ) return q . poll ( ) ; first = null ; if ( leader != null ) available . await ( ) ; else { Thread thisThread = Thread . currentThread ( ) ; leader = thisThread ; try { available . awaitNanos ( delay ) ; } finally { if ( leader == thisThread ) leader = null ; } } } } } finally { if ( leader == null && q . peek ( ) != null ) available . signal ( ) ; lock . unlock ( ) ; } }
Retrieves and removes the head of this queue waiting if necessary until an element with an expired delay is available on this queue .
27,690
public E poll ( long timeout , TimeUnit unit ) throws InterruptedException { long nanos = unit . toNanos ( timeout ) ; final ReentrantLock lock = this . lock ; lock . lockInterruptibly ( ) ; try { for ( ; ; ) { E first = q . peek ( ) ; if ( first == null ) { if ( nanos <= 0L ) return null ; else nanos = available . awaitNanos ( nanos ) ; } else { long delay = first . getDelay ( NANOSECONDS ) ; if ( delay <= 0L ) return q . poll ( ) ; if ( nanos <= 0L ) return null ; first = null ; if ( nanos < delay || leader != null ) nanos = available . awaitNanos ( nanos ) ; else { Thread thisThread = Thread . currentThread ( ) ; leader = thisThread ; try { long timeLeft = available . awaitNanos ( delay ) ; nanos -= delay - timeLeft ; } finally { if ( leader == thisThread ) leader = null ; } } } } } finally { if ( leader == null && q . peek ( ) != null ) available . signal ( ) ; lock . unlock ( ) ; } }
Retrieves and removes the head of this queue waiting if necessary until an element with an expired delay is available on this queue or the specified wait time expires .
27,691
private E peekExpired ( ) { E first = q . peek ( ) ; return ( first == null || first . getDelay ( NANOSECONDS ) > 0 ) ? null : first ; }
Returns first element only if it is expired . Used only by drainTo . Call only when holding lock .
27,692
public void clear ( ) { final ReentrantLock lock = this . lock ; lock . lock ( ) ; try { q . clear ( ) ; } finally { lock . unlock ( ) ; } }
Atomically removes all of the elements from this delay queue . The queue will be empty after this call returns . Elements with an unexpired delay are not waited for ; they are simply discarded from the queue .
27,693
public boolean remove ( Object o ) { final ReentrantLock lock = this . lock ; lock . lock ( ) ; try { return q . remove ( o ) ; } finally { lock . unlock ( ) ; } }
Removes a single instance of the specified element from this queue if it is present whether or not it has expired .
27,694
Vector getCounters ( ElemNumber numberElem ) { Vector counters = ( Vector ) this . get ( numberElem ) ; return ( null == counters ) ? putElemNumber ( numberElem ) : counters ; }
Get the list of counters that corresponds to the given ElemNumber object .
27,695
Vector putElemNumber ( ElemNumber numberElem ) { Vector counters = new Vector ( ) ; this . put ( numberElem , counters ) ; return counters ; }
Put a counter into the table and create an empty vector as it s value .
27,696
void appendBtoFList ( NodeSetDTM flist , NodeSetDTM blist ) { int n = blist . size ( ) ; for ( int i = ( n - 1 ) ; i >= 0 ; i -- ) { flist . addElement ( blist . item ( i ) ) ; } }
Add a list of counted nodes that were built in backwards document order or a list of counted nodes that are in forwards document order .
27,697
public int countNode ( XPathContext support , ElemNumber numberElem , int node ) throws TransformerException { int count = 0 ; Vector counters = getCounters ( numberElem ) ; int nCounters = counters . size ( ) ; int target = numberElem . getTargetNode ( support , node ) ; if ( DTM . NULL != target ) { for ( int i = 0 ; i < nCounters ; i ++ ) { Counter counter = ( Counter ) counters . elementAt ( i ) ; count = counter . getPreviouslyCounted ( support , target ) ; if ( count > 0 ) return count ; } count = 0 ; if ( m_newFound == null ) m_newFound = new NodeSetDTM ( support . getDTMManager ( ) ) ; for ( ; DTM . NULL != target ; target = numberElem . getPreviousNode ( support , target ) ) { if ( 0 != count ) { for ( int i = 0 ; i < nCounters ; i ++ ) { Counter counter = ( Counter ) counters . elementAt ( i ) ; int cacheLen = counter . m_countNodes . size ( ) ; if ( ( cacheLen > 0 ) && ( counter . m_countNodes . elementAt ( cacheLen - 1 ) == target ) ) { count += ( cacheLen + counter . m_countNodesStartCount ) ; if ( cacheLen > 0 ) appendBtoFList ( counter . m_countNodes , m_newFound ) ; m_newFound . removeAllElements ( ) ; return count ; } } } m_newFound . addElement ( target ) ; count ++ ; } Counter counter = new Counter ( numberElem , new NodeSetDTM ( support . getDTMManager ( ) ) ) ; m_countersMade ++ ; appendBtoFList ( counter . m_countNodes , m_newFound ) ; m_newFound . removeAllElements ( ) ; counters . addElement ( counter ) ; } return count ; }
Count forward until the given node is found or until we have looked to the given amount .
27,698
int match ( byte [ ] text , int textLen , byte [ ] [ ] escapeSequences ) { int i , j ; int escN ; int hits = 0 ; int misses = 0 ; int shifts = 0 ; int quality ; scanInput : for ( i = 0 ; i < textLen ; i ++ ) { if ( text [ i ] == 0x1b ) { checkEscapes : for ( escN = 0 ; escN < escapeSequences . length ; escN ++ ) { byte [ ] seq = escapeSequences [ escN ] ; if ( ( textLen - i ) < seq . length ) { continue checkEscapes ; } for ( j = 1 ; j < seq . length ; j ++ ) { if ( seq [ j ] != text [ i + j ] ) { continue checkEscapes ; } } hits ++ ; i += seq . length - 1 ; continue scanInput ; } misses ++ ; } if ( text [ i ] == 0x0e || text [ i ] == 0x0f ) { shifts ++ ; } } if ( hits == 0 ) { return 0 ; } quality = ( 100 * hits - 100 * misses ) / ( hits + misses ) ; if ( hits + shifts < 5 ) { quality -= ( 5 - ( hits + shifts ) ) * 10 ; } if ( quality < 0 ) { quality = 0 ; } return quality ; }
Matching function shared among the 2022 detectors JP CN and KR Counts up the number of legal an unrecognized escape sequences in the sample of text and computes a score based on the total number & the proportion that fit the encoding .
27,699
private static DateFormatSymbols getCachedInstance ( Locale locale ) { SoftReference < DateFormatSymbols > ref = cachedInstances . get ( locale ) ; DateFormatSymbols dfs = null ; if ( ref == null || ( dfs = ref . get ( ) ) == null ) { dfs = new DateFormatSymbols ( locale ) ; ref = new SoftReference < DateFormatSymbols > ( dfs ) ; SoftReference < DateFormatSymbols > x = cachedInstances . putIfAbsent ( locale , ref ) ; if ( x != null ) { DateFormatSymbols y = x . get ( ) ; if ( y != null ) { dfs = y ; } else { cachedInstances . put ( locale , ref ) ; } } } return dfs ; }
Returns a cached DateFormatSymbols if it s found in the cache . Otherwise this method returns a newly cached instance for the given locale .