idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
27,200
public String normalize ( CharSequence src ) { if ( src instanceof String ) { int spanLength = spanQuickCheckYes ( src ) ; if ( spanLength == src . length ( ) ) { return ( String ) src ; } StringBuilder sb = new StringBuilder ( src . length ( ) ) . append ( src , 0 , spanLength ) ; return normalizeSecondAndAppend ( sb , src . subSequence ( spanLength , src . length ( ) ) ) . toString ( ) ; } return normalize ( src , new StringBuilder ( src . length ( ) ) ) . toString ( ) ; }
Returns the normalized form of the source string .
27,201
public void encode ( DerOutputStream out ) throws IOException { DerOutputStream tmp = new DerOutputStream ( ) ; issuerDomain . encode ( tmp ) ; subjectDomain . encode ( tmp ) ; out . write ( DerValue . tag_Sequence , tmp ) ; }
Write the CertificatePolicyMap to the DerOutputStream .
27,202
private static void addMapping ( Map < String , String > map , String key , String value , String kind ) { String oldValue = map . put ( key , value ) ; if ( oldValue != null && ! oldValue . equals ( value ) ) { ErrorUtil . error ( kind + " redefined; was \"" + oldValue + ", now " + value ) ; } }
Adds a class method or package - prefix property to its map reporting an error if that mapping was previously specified .
27,203
private static int initializeTimeout ( ) { Integer tmp = Integer . getInteger ( "com.sun.security.ocsp.timeout" ) ; if ( tmp == null || tmp < 0 ) { return DEFAULT_CONNECT_TIMEOUT ; } return tmp * 1000 ; }
Initialize the timeout length by getting the OCSP timeout system property . If the property has not been set or if its value is negative set the timeout length to the default .
27,204
public static RevocationStatus check ( X509Certificate cert , X509Certificate issuerCert , URI responderURI , X509Certificate responderCert , Date date ) throws IOException , CertPathValidatorException { return check ( cert , issuerCert , responderURI , responderCert , date , Collections . < Extension > emptyList ( ) ) ; }
Obtains the revocation status of a certificate using OCSP .
27,205
void linkBefore ( E e , Node < E > succ ) { final Node < E > pred = succ . prev ; final Node < E > newNode = new Node < > ( pred , e , succ ) ; succ . prev = newNode ; if ( pred == null ) first = newNode ; else pred . next = newNode ; size ++ ; modCount ++ ; }
Inserts element e before non - null Node succ .
27,206
private E unlinkFirst ( Node < E > f ) { final E element = f . item ; final Node < E > next = f . next ; f . item = null ; f . next = null ; first = next ; if ( next == null ) last = null ; else next . prev = null ; size -- ; modCount ++ ; return element ; }
Unlinks non - null first node f .
27,207
private E unlinkLast ( Node < E > l ) { final E element = l . item ; final Node < E > prev = l . prev ; l . item = null ; l . prev = null ; last = prev ; if ( prev == null ) first = null ; else prev . next = null ; size -- ; modCount ++ ; return element ; }
Unlinks non - null last node l .
27,208
public E getFirst ( ) { final Node < E > f = first ; if ( f == null ) throw new NoSuchElementException ( ) ; return f . item ; }
Returns the first element in this list .
27,209
public E getLast ( ) { final Node < E > l = last ; if ( l == null ) throw new NoSuchElementException ( ) ; return l . item ; }
Returns the last element in this list .
27,210
public E removeFirst ( ) { final Node < E > f = first ; if ( f == null ) throw new NoSuchElementException ( ) ; return unlinkFirst ( f ) ; }
Removes and returns the first element from this list .
27,211
public E removeLast ( ) { final Node < E > l = last ; if ( l == null ) throw new NoSuchElementException ( ) ; return unlinkLast ( l ) ; }
Removes and returns the last element from this list .
27,212
public Attributes getAttributes ( ) throws IOException { JarEntry e = getJarEntry ( ) ; return e != null ? e . getAttributes ( ) : null ; }
Return the Attributes object for this connection if the URL for it points to a JAR file entry null otherwise .
27,213
public Attributes getMainAttributes ( ) throws IOException { Manifest man = getManifest ( ) ; return man != null ? man . getMainAttributes ( ) : null ; }
Returns the main Attributes for the JAR file for this connection .
27,214
public void addRule ( TransliterationRule rule ) { ruleVector . add ( rule ) ; int len ; if ( ( len = rule . getAnteContextLength ( ) ) > maxContextLength ) { maxContextLength = len ; } rules = null ; }
Add a rule to this set . Rules are added in order and order is significant .
27,215
public void freeze ( ) { int n = ruleVector . size ( ) ; index = new int [ 257 ] ; List < TransliterationRule > v = new ArrayList < TransliterationRule > ( 2 * n ) ; int [ ] indexValue = new int [ n ] ; for ( int j = 0 ; j < n ; ++ j ) { TransliterationRule r = ruleVector . get ( j ) ; indexValue [ j ] = r . getIndexValue ( ) ; } for ( int x = 0 ; x < 256 ; ++ x ) { index [ x ] = v . size ( ) ; for ( int j = 0 ; j < n ; ++ j ) { if ( indexValue [ j ] >= 0 ) { if ( indexValue [ j ] == x ) { v . add ( ruleVector . get ( j ) ) ; } } else { TransliterationRule r = ruleVector . get ( j ) ; if ( r . matchesIndexValue ( x ) ) { v . add ( r ) ; } } } } index [ 256 ] = v . size ( ) ; rules = new TransliterationRule [ v . size ( ) ] ; v . toArray ( rules ) ; StringBuilder errors = null ; for ( int x = 0 ; x < 256 ; ++ x ) { for ( int j = index [ x ] ; j < index [ x + 1 ] - 1 ; ++ j ) { TransliterationRule r1 = rules [ j ] ; for ( int k = j + 1 ; k < index [ x + 1 ] ; ++ k ) { TransliterationRule r2 = rules [ k ] ; if ( r1 . masks ( r2 ) ) { if ( errors == null ) { errors = new StringBuilder ( ) ; } else { errors . append ( "\n" ) ; } errors . append ( "Rule " + r1 + " masks " + r2 ) ; } } } } if ( errors != null ) { throw new IllegalArgumentException ( errors . toString ( ) ) ; } }
Close this rule set to further additions check it for masked rules and index it to optimize performance .
27,216
String toRules ( boolean escapeUnprintable ) { int i ; int count = ruleVector . size ( ) ; StringBuilder ruleSource = new StringBuilder ( ) ; for ( i = 0 ; i < count ; ++ i ) { if ( i != 0 ) { ruleSource . append ( '\n' ) ; } TransliterationRule r = ruleVector . get ( i ) ; ruleSource . append ( r . toRule ( escapeUnprintable ) ) ; } return ruleSource . toString ( ) ; }
Create rule strings that represents this rule set .
27,217
private void fixVariableDeclarations ( SwitchStatement node ) { List < Statement > statements = node . getStatements ( ) ; Block block = new Block ( ) ; List < Statement > blockStmts = block . getStatements ( ) ; for ( int i = 0 ; i < statements . size ( ) ; i ++ ) { Statement stmt = statements . get ( i ) ; if ( stmt instanceof VariableDeclarationStatement ) { VariableDeclarationStatement declStmt = ( VariableDeclarationStatement ) stmt ; statements . remove ( i -- ) ; List < VariableDeclarationFragment > fragments = declStmt . getFragments ( ) ; for ( VariableDeclarationFragment decl : fragments ) { Expression initializer = decl . getInitializer ( ) ; if ( initializer != null ) { Assignment assignment = new Assignment ( new SimpleName ( decl . getVariableElement ( ) ) , TreeUtil . remove ( initializer ) ) ; statements . add ( ++ i , new ExpressionStatement ( assignment ) ) ; } } blockStmts . add ( declStmt ) ; } } if ( blockStmts . size ( ) > 0 ) { node . replaceWith ( block ) ; blockStmts . add ( node ) ; } }
Moves all variable declarations above the first case statement .
27,218
private static < T extends Annotation > void insertAnnotationValues ( Annotation annotation , Class < T > annotationClass , ArrayList < T > unfoldedAnnotations ) { Class < T [ ] > annotationArrayClass = ( Class < T [ ] > ) ( ( T [ ] ) Array . newInstance ( annotationClass , 0 ) ) . getClass ( ) ; Method valuesMethod ; try { valuesMethod = annotation . getClass ( ) . getDeclaredMethod ( "value" ) ; } catch ( NoSuchMethodException e ) { throw new AssertionError ( "annotation container = " + annotation + "annotation element class = " + annotationClass + "; missing value() method" ) ; } catch ( SecurityException e ) { throw new IncompleteAnnotationException ( annotation . getClass ( ) , "value" ) ; } if ( ! valuesMethod . getReturnType ( ) . isArray ( ) ) { throw new AssertionError ( "annotation container = " + annotation + "annotation element class = " + annotationClass + "; value() doesn't return array" ) ; } if ( ! annotationClass . equals ( valuesMethod . getReturnType ( ) . getComponentType ( ) ) ) { throw new AssertionError ( "annotation container = " + annotation + "annotation element class = " + annotationClass + "; value() returns incorrect type" ) ; } T [ ] nestedAnnotations ; try { nestedAnnotations = ( T [ ] ) valuesMethod . invoke ( annotation ) ; } catch ( IllegalAccessException | InvocationTargetException e ) { throw new AssertionError ( e ) ; } for ( int i = 0 ; i < nestedAnnotations . length ; ++ i ) { unfoldedAnnotations . add ( nestedAnnotations [ i ] ) ; } }
Extracts annotations from a container annotation and inserts them into a list .
27,219
public static boolean matchClassNamePrefix ( String actual , String expected ) { return actual . equals ( expected ) || actual . equals ( getCamelCase ( expected ) ) ; }
When reflection is stripped the transpiled code uses NSStringFromClass to return the name of a class . For example instead of getting something like java . lang . Throwable we get JavaLangThrowable .
27,220
public static long getSerialVersionUID ( Class < ? extends Serializable > clazz ) { try { return clazz . getField ( "serialVersionUID" ) . getLong ( null ) ; } catch ( NoSuchFieldException | IllegalAccessException ex ) { return 0 ; } }
Transpiled code that directly acccess the serialVersionUID field when reflection is stripped won t compile because this field is also stripped .
27,221
private void checkLabelBiDi ( CharSequence label , int labelStart , int labelLength , Info info ) { int c ; int i = labelStart ; c = Character . codePointAt ( label , i ) ; i += Character . charCount ( c ) ; int firstMask = U_MASK ( UBiDiProps . INSTANCE . getClass ( c ) ) ; if ( ( firstMask & ~ L_R_AL_MASK ) != 0 ) { setNotOkBiDi ( info ) ; } int lastMask ; int labelLimit = labelStart + labelLength ; for ( ; ; ) { if ( i >= labelLimit ) { lastMask = firstMask ; break ; } c = Character . codePointBefore ( label , labelLimit ) ; labelLimit -= Character . charCount ( c ) ; int dir = UBiDiProps . INSTANCE . getClass ( c ) ; if ( dir != UCharacterDirection . DIR_NON_SPACING_MARK ) { lastMask = U_MASK ( dir ) ; break ; } } if ( ( firstMask & L_MASK ) != 0 ? ( lastMask & ~ L_EN_MASK ) != 0 : ( lastMask & ~ R_AL_EN_AN_MASK ) != 0 ) { setNotOkBiDi ( info ) ; } int mask = 0 ; while ( i < labelLimit ) { c = Character . codePointAt ( label , i ) ; i += Character . charCount ( c ) ; mask |= U_MASK ( UBiDiProps . INSTANCE . getClass ( c ) ) ; } if ( ( firstMask & L_MASK ) != 0 ) { if ( ( mask & ~ L_EN_ES_CS_ET_ON_BN_NSM_MASK ) != 0 ) { setNotOkBiDi ( info ) ; } } else { if ( ( mask & ~ R_AL_AN_EN_ES_CS_ET_ON_BN_NSM_MASK ) != 0 ) { setNotOkBiDi ( info ) ; } if ( ( mask & EN_AN_MASK ) == EN_AN_MASK ) { setNotOkBiDi ( info ) ; } } if ( ( ( firstMask | mask | lastMask ) & R_AL_AN_MASK ) != 0 ) { setBiDi ( info ) ; } }
processing several earlier labels .
27,222
public static final int getKeySize ( Key key ) { int size = - 1 ; if ( key instanceof Length ) { try { Length ruler = ( Length ) key ; size = ruler . length ( ) ; } catch ( UnsupportedOperationException usoe ) { } if ( size >= 0 ) { return size ; } } if ( key instanceof SecretKey ) { SecretKey sk = ( SecretKey ) key ; String format = sk . getFormat ( ) ; if ( "RAW" . equals ( format ) && sk . getEncoded ( ) != null ) { size = ( sk . getEncoded ( ) . length * 8 ) ; } } else if ( key instanceof RSAKey ) { RSAKey pubk = ( RSAKey ) key ; size = pubk . getModulus ( ) . bitLength ( ) ; } else if ( key instanceof ECKey ) { ECKey pubk = ( ECKey ) key ; ECParameterSpec params = pubk . getParams ( ) ; if ( params != null ) { size = params . getOrder ( ) . bitLength ( ) ; } } else if ( key instanceof DSAKey ) { DSAKey pubk = ( DSAKey ) key ; DSAParams params = pubk . getParams ( ) ; if ( params != null ) { size = params . getP ( ) . bitLength ( ) ; } } else if ( key instanceof DHKey ) { DHKey pubk = ( DHKey ) key ; size = pubk . getParams ( ) . getP ( ) . bitLength ( ) ; } return size ; }
Returns the key size of the given key object in bits .
27,223
private static void validateDHPublicKey ( DHPublicKey publicKey ) throws InvalidKeyException { DHParameterSpec paramSpec = publicKey . getParams ( ) ; BigInteger p = paramSpec . getP ( ) ; BigInteger g = paramSpec . getG ( ) ; BigInteger y = publicKey . getY ( ) ; validateDHPublicKey ( p , g , y ) ; }
Returns whether the Diffie - Hellman public key is valid or not .
27,224
public static long doubleToLongBits ( double value ) { long result = doubleToRawLongBits ( value ) ; if ( ( ( result & DoubleConsts . EXP_BIT_MASK ) == DoubleConsts . EXP_BIT_MASK ) && ( result & DoubleConsts . SIGNIF_BIT_MASK ) != 0L ) result = 0x7ff8000000000000L ; return result ; }
Returns a representation of the specified floating - point value according to the IEEE 754 floating - point double format bit layout .
27,225
boolean removeMapping ( Object o ) { if ( ! ( o instanceof Map . Entry ) ) return false ; Entry < K , V > [ ] tab = getTable ( ) ; Map . Entry < ? , ? > entry = ( Map . Entry < ? , ? > ) o ; Object k = maskNull ( entry . getKey ( ) ) ; int h = sun . misc . Hashing . singleWordWangJenkinsHash ( k ) ; int i = indexFor ( h , tab . length ) ; Entry < K , V > prev = tab [ i ] ; Entry < K , V > e = prev ; while ( e != null ) { Entry < K , V > next = e . next ; if ( h == e . hash && e . equals ( entry ) ) { modCount ++ ; size -- ; if ( prev == e ) tab [ i ] = next ; else prev . next = next ; return true ; } prev = e ; e = next ; } return false ; }
Special version of remove needed by Entry set
27,226
private boolean containsNullValue ( ) { Entry < K , V > [ ] tab = getTable ( ) ; for ( int i = tab . length ; i -- > 0 ; ) for ( Entry < K , V > e = tab [ i ] ; e != null ; e = e . next ) if ( e . value == null ) return true ; return false ; }
Special - case code for containsValue with null argument
27,227
private void redirectToJavaLoggerProxy ( ) { DefaultLoggerProxy lp = DefaultLoggerProxy . class . cast ( this . loggerProxy ) ; JavaLoggerProxy jlp = new JavaLoggerProxy ( lp . name , lp . level ) ; this . javaLoggerProxy = jlp ; this . loggerProxy = jlp ; }
Creates a new JavaLoggerProxy and redirects the platform logger to it
27,228
public void setLevel ( int newLevel ) { loggerProxy . setLevel ( newLevel == 0 ? null : Level . valueOf ( newLevel ) ) ; }
Sets the log level .
27,229
public boolean isLoggable ( Level level ) { if ( level == null ) { throw new NullPointerException ( ) ; } JavaLoggerProxy jlp = javaLoggerProxy ; return jlp != null ? jlp . isLoggable ( level ) : loggerProxy . isLoggable ( level ) ; }
Returns true if a message of the given level would actually be logged by this logger .
27,230
static int tieBreakOrder ( Object a , Object b ) { int d ; if ( a == null || b == null || ( d = a . getClass ( ) . getName ( ) . compareTo ( b . getClass ( ) . getName ( ) ) ) == 0 ) d = ( System . identityHashCode ( a ) <= System . identityHashCode ( b ) ? - 1 : 1 ) ; return d ; }
Tie - breaking utility for ordering insertions when equal hashCodes and non - comparable . We don t require a total order just a consistent insertion rule to maintain equivalence across rebalancings . Tie - breaking further than necessary simplifies testing a bit .
27,231
private final void contendedLock ( ) { boolean waiting = false ; for ( int s ; ; ) { if ( ( ( s = lockState ) & ~ WAITER ) == 0 ) { if ( U . compareAndSwapInt ( this , LOCKSTATE , s , WRITER ) ) { if ( waiting ) waiter = null ; return ; } } else if ( ( s & WAITER ) == 0 ) { if ( U . compareAndSwapInt ( this , LOCKSTATE , s , s | WAITER ) ) { waiting = true ; waiter = Thread . currentThread ( ) ; } } else if ( waiting ) LockSupport . park ( this ) ; } }
Possibly blocks awaiting root lock .
27,232
final Node < K , V > find ( int h , Object k ) { if ( k != null ) { for ( Node < K , V > e = first ; e != null ; ) { int s ; K ek ; if ( ( ( s = lockState ) & ( WAITER | WRITER ) ) != 0 ) { if ( e . hash == h && ( ( ek = e . key ) == k || ( ek != null && k . equals ( ek ) ) ) ) return e ; e = e . next ; } else if ( U . compareAndSwapInt ( this , LOCKSTATE , s , s + READER ) ) { TreeNode < K , V > r , p ; try { p = ( ( r = root ) == null ? null : r . findTreeNode ( h , k , null ) ) ; } finally { Thread w ; if ( U . getAndAddInt ( this , LOCKSTATE , - READER ) == ( READER | WAITER ) && ( w = waiter ) != null ) LockSupport . unpark ( w ) ; } return p ; } } } return null ; }
Returns matching node or null if none . Tries to search using tree comparisons from root but continues linear search when lock not available .
27,233
final TreeNode < K , V > putTreeVal ( int h , K k , V v ) { Class < ? > kc = null ; boolean searched = false ; for ( TreeNode < K , V > p = root ; ; ) { int dir , ph ; K pk ; if ( p == null ) { first = root = new TreeNode < K , V > ( h , k , v , null , null ) ; break ; } else if ( ( ph = p . hash ) > h ) dir = - 1 ; else if ( ph < h ) dir = 1 ; else if ( ( pk = p . key ) == k || ( pk != null && k . equals ( pk ) ) ) return p ; else if ( ( kc == null && ( kc = comparableClassFor ( k ) ) == null ) || ( dir = compareComparables ( kc , k , pk ) ) == 0 ) { if ( ! searched ) { TreeNode < K , V > q , ch ; searched = true ; if ( ( ( ch = p . left ) != null && ( q = ch . findTreeNode ( h , k , kc ) ) != null ) || ( ( ch = p . right ) != null && ( q = ch . findTreeNode ( h , k , kc ) ) != null ) ) return q ; } dir = tieBreakOrder ( k , pk ) ; } TreeNode < K , V > xp = p ; if ( ( p = ( dir <= 0 ) ? p . left : p . right ) == null ) { TreeNode < K , V > x , f = first ; first = x = new TreeNode < K , V > ( h , k , v , f , xp ) ; if ( f != null ) f . prev = x ; if ( dir <= 0 ) xp . left = x ; else xp . right = x ; if ( ! xp . red ) x . red = true ; else { lockRoot ( ) ; try { root = balanceInsertion ( root , x ) ; } finally { unlockRoot ( ) ; } } break ; } } assert checkInvariants ( root ) ; return null ; }
Finds or adds a node .
27,234
static < K , V > TreeNode < K , V > rotateLeft ( TreeNode < K , V > root , TreeNode < K , V > p ) { TreeNode < K , V > r , pp , rl ; if ( p != null && ( r = p . right ) != null ) { if ( ( rl = p . right = r . left ) != null ) rl . parent = p ; if ( ( pp = r . parent = p . parent ) == null ) ( root = r ) . red = false ; else if ( pp . left == p ) pp . left = r ; else pp . right = r ; r . left = p ; p . parent = r ; } return root ; }
Red - black tree methods all adapted from CLR
27,235
static < K , V > boolean checkInvariants ( TreeNode < K , V > t ) { TreeNode < K , V > tp = t . parent , tl = t . left , tr = t . right , tb = t . prev , tn = ( TreeNode < K , V > ) t . next ; if ( tb != null && tb . next != t ) return false ; if ( tn != null && tn . prev != t ) return false ; if ( tp != null && t != tp . left && t != tp . right ) return false ; if ( tl != null && ( tl . parent != t || tl . hash > t . hash ) ) return false ; if ( tr != null && ( tr . parent != t || tr . hash < t . hash ) ) return false ; if ( t . red && tl != null && tl . red && tr != null && tr . red ) return false ; if ( tl != null && ! checkInvariants ( tl ) ) return false ; if ( tr != null && ! checkInvariants ( tr ) ) return false ; return true ; }
Checks invariants recursively for the tree of Nodes rooted at t .
27,236
final Node < K , V > advance ( ) { Node < K , V > e ; if ( ( e = next ) != null ) e = e . next ; for ( ; ; ) { Node < K , V > [ ] t ; int i , n ; if ( e != null ) return next = e ; if ( baseIndex >= baseLimit || ( t = tab ) == null || ( n = t . length ) <= ( i = index ) || i < 0 ) return next = null ; if ( ( e = tabAt ( t , i ) ) != null && e . hash < 0 ) { if ( e instanceof ForwardingNode ) { tab = ( ( ForwardingNode < K , V > ) e ) . nextTable ; e = null ; pushState ( t , i , n ) ; continue ; } else if ( e instanceof TreeBin ) e = ( ( TreeBin < K , V > ) e ) . first ; else e = null ; } if ( stack != null ) recoverState ( n ) ; else if ( ( index = i + baseSize ) >= n ) index = ++ baseIndex ; } }
Advances if possible returning next valid node or null if none .
27,237
private void pushState ( Node < K , V > [ ] t , int i , int n ) { TableStack < K , V > s = spare ; if ( s != null ) spare = s . next ; else s = new TableStack < K , V > ( ) ; s . tab = t ; s . length = n ; s . index = i ; s . next = stack ; stack = s ; }
Saves traversal state upon encountering a forwarding node .
27,238
private void recoverState ( int n ) { TableStack < K , V > s ; int len ; while ( ( s = stack ) != null && ( index += ( len = s . length ) ) >= n ) { n = len ; index = s . index ; tab = s . tab ; s . tab = null ; TableStack < K , V > next = s . next ; s . next = spare ; stack = next ; spare = s ; } if ( s == null && ( index += baseSize ) >= n ) index = ++ baseIndex ; }
Possibly pops traversal state .
27,239
public final UnicodeSet applyPattern ( String pattern ) { checkFrozen ( ) ; return applyPattern ( pattern , null , null , IGNORE_SPACE ) ; }
Modifies this set to represent the set specified by the given pattern . See the class description for the syntax of the pattern language . Whitespace is ignored .
27,240
public UnicodeSet applyPattern ( String pattern , int options ) { checkFrozen ( ) ; return applyPattern ( pattern , null , null , options ) ; }
Modifies this set to represent the set specified by the given pattern optionally ignoring whitespace . See the class description for the syntax of the pattern language .
27,241
public static boolean resemblesPattern ( String pattern , int pos ) { return ( ( pos + 1 ) < pattern . length ( ) && pattern . charAt ( pos ) == '[' ) || resemblesPropertyPattern ( pattern , pos ) ; }
Return true if the given position in the given pattern appears to be the start of a UnicodeSet pattern .
27,242
public String toPattern ( boolean escapeUnprintable ) { if ( pat != null && ! escapeUnprintable ) { return pat ; } StringBuilder result = new StringBuilder ( ) ; return _toPattern ( result , escapeUnprintable ) . toString ( ) ; }
Returns a string representation of this set . If the result of calling this function is passed to a UnicodeSet constructor it will produce another set that is equal to this one .
27,243
public int matchesAt ( CharSequence text , int offset ) { int lastLen = - 1 ; strings : if ( strings . size ( ) != 0 ) { char firstChar = text . charAt ( offset ) ; String trial = null ; Iterator < String > it = strings . iterator ( ) ; while ( it . hasNext ( ) ) { trial = it . next ( ) ; char firstStringChar = trial . charAt ( 0 ) ; if ( firstStringChar < firstChar ) continue ; if ( firstStringChar > firstChar ) break strings ; } for ( ; ; ) { int tempLen = matchesAt ( text , offset , trial ) ; if ( lastLen > tempLen ) break strings ; lastLen = tempLen ; if ( ! it . hasNext ( ) ) break ; trial = it . next ( ) ; } } if ( lastLen < 2 ) { int cp = UTF16 . charAt ( text , offset ) ; if ( contains ( cp ) ) lastLen = UTF16 . getCharCount ( cp ) ; } return offset + lastLen ; }
Tests whether the text matches at the offset . If so returns the end of the longest substring that it matches . If not returns - 1 .
27,244
private UnicodeSet add_unchecked ( int start , int end ) { if ( start < MIN_VALUE || start > MAX_VALUE ) { throw new IllegalArgumentException ( "Invalid code point U+" + Utility . hex ( start , 6 ) ) ; } if ( end < MIN_VALUE || end > MAX_VALUE ) { throw new IllegalArgumentException ( "Invalid code point U+" + Utility . hex ( end , 6 ) ) ; } if ( start < end ) { add ( range ( start , end ) , 2 , 0 ) ; } else if ( start == end ) { add ( start ) ; } return this ; }
for internal use after checkFrozen has been called
27,245
private final UnicodeSet add_unchecked ( int c ) { if ( c < MIN_VALUE || c > MAX_VALUE ) { throw new IllegalArgumentException ( "Invalid code point U+" + Utility . hex ( c , 6 ) ) ; } int i = findCodePoint ( c ) ; if ( ( i & 1 ) != 0 ) return this ; if ( c == list [ i ] - 1 ) { list [ i ] = c ; if ( c == MAX_VALUE ) { ensureCapacity ( len + 1 ) ; list [ len ++ ] = HIGH ; } if ( i > 0 && c == list [ i - 1 ] ) { System . arraycopy ( list , i + 1 , list , i - 1 , len - i - 1 ) ; len -= 2 ; } } else if ( i > 0 && c == list [ i - 1 ] ) { list [ i - 1 ] ++ ; } else { if ( len + 2 > list . length ) { int [ ] temp = new int [ len + 2 + GROW_EXTRA ] ; if ( i != 0 ) System . arraycopy ( list , 0 , temp , 0 , i ) ; System . arraycopy ( list , i , temp , i + 2 , len - i ) ; list = temp ; } else { System . arraycopy ( list , i , list , i + 2 , len - i ) ; } list [ i ] = c ; list [ i + 1 ] = c + 1 ; len += 2 ; } pat = null ; return this ; }
for internal use only after checkFrozen has been called
27,246
public final UnicodeSet retain ( CharSequence cs ) { int cp = getSingleCP ( cs ) ; if ( cp < 0 ) { String s = cs . toString ( ) ; boolean isIn = strings . contains ( s ) ; if ( isIn && size ( ) == 1 ) { return this ; } clear ( ) ; strings . add ( s ) ; pat = null ; } else { retain ( cp , cp ) ; } return this ; }
Retain the specified string in this set if it is present . Upon return this set will be empty if it did not contain s or will only contain s if it did contain s .
27,247
public final UnicodeSet remove ( CharSequence s ) { int cp = getSingleCP ( s ) ; if ( cp < 0 ) { strings . remove ( s . toString ( ) ) ; pat = null ; } else { remove ( cp , cp ) ; } return this ; }
Removes the specified string from this set if it is present . The set will not contain the specified string once the call returns .
27,248
public boolean contains ( int c ) { if ( c < MIN_VALUE || c > MAX_VALUE ) { throw new IllegalArgumentException ( "Invalid code point U+" + Utility . hex ( c , 6 ) ) ; } if ( bmpSet != null ) { return bmpSet . contains ( c ) ; } if ( stringSpan != null ) { return stringSpan . contains ( c ) ; } int i = findCodePoint ( c ) ; return ( ( i & 1 ) != 0 ) ; }
Returns true if this set contains the given character .
27,249
public boolean contains ( int start , int end ) { if ( start < MIN_VALUE || start > MAX_VALUE ) { throw new IllegalArgumentException ( "Invalid code point U+" + Utility . hex ( start , 6 ) ) ; } if ( end < MIN_VALUE || end > MAX_VALUE ) { throw new IllegalArgumentException ( "Invalid code point U+" + Utility . hex ( end , 6 ) ) ; } int i = findCodePoint ( start ) ; return ( ( i & 1 ) != 0 && end < list [ i ] ) ; }
Returns true if this set contains every character of the given range .
27,250
public boolean containsAll ( UnicodeSet b ) { int [ ] listB = b . list ; boolean needA = true ; boolean needB = true ; int aPtr = 0 ; int bPtr = 0 ; int aLen = len - 1 ; int bLen = b . len - 1 ; int startA = 0 , startB = 0 , limitA = 0 , limitB = 0 ; while ( true ) { if ( needA ) { if ( aPtr >= aLen ) { if ( needB && bPtr >= bLen ) { break ; } return false ; } startA = list [ aPtr ++ ] ; limitA = list [ aPtr ++ ] ; } if ( needB ) { if ( bPtr >= bLen ) { break ; } startB = listB [ bPtr ++ ] ; limitB = listB [ bPtr ++ ] ; } if ( startB >= limitA ) { needA = true ; needB = false ; continue ; } if ( startB >= startA && limitB <= limitA ) { needA = false ; needB = true ; continue ; } return false ; } if ( ! strings . containsAll ( b . strings ) ) return false ; return true ; }
Returns true if this set contains all the characters and strings of the given set .
27,251
private boolean containsAll ( String s , int i ) { if ( i >= s . length ( ) ) { return true ; } int cp = UTF16 . charAt ( s , i ) ; if ( contains ( cp ) && containsAll ( s , i + UTF16 . getCharCount ( cp ) ) ) { return true ; } for ( String setStr : strings ) { if ( s . startsWith ( setStr , i ) && containsAll ( s , i + setStr . length ( ) ) ) { return true ; } } return false ; }
Recursive routine called if we fail to find a match in containsAll and there are strings
27,252
public String getRegexEquivalent ( ) { if ( strings . size ( ) == 0 ) { return toString ( ) ; } StringBuilder result = new StringBuilder ( "(?:" ) ; appendNewPattern ( result , true , false ) ; for ( String s : strings ) { result . append ( '|' ) ; _appendToPat ( result , s , true ) ; } return result . append ( ")" ) . toString ( ) ; }
Get the Regex equivalent for this UnicodeSet
27,253
public boolean containsNone ( int start , int end ) { if ( start < MIN_VALUE || start > MAX_VALUE ) { throw new IllegalArgumentException ( "Invalid code point U+" + Utility . hex ( start , 6 ) ) ; } if ( end < MIN_VALUE || end > MAX_VALUE ) { throw new IllegalArgumentException ( "Invalid code point U+" + Utility . hex ( end , 6 ) ) ; } int i = - 1 ; while ( true ) { if ( start < list [ ++ i ] ) break ; } return ( ( i & 1 ) == 0 && end < list [ i ] ) ; }
Returns true if this set contains none of the characters of the given range .
27,254
public UnicodeSet complementAll ( UnicodeSet c ) { checkFrozen ( ) ; xor ( c . list , c . len , 0 ) ; SortedSetRelation . doOperation ( strings , SortedSetRelation . COMPLEMENTALL , c . strings ) ; return this ; }
Complements in this set all elements contained in the specified set . Any character in the other set will be removed if it is in this set or will be added if it is not in this set .
27,255
public UnicodeSet clear ( ) { checkFrozen ( ) ; list [ 0 ] = HIGH ; len = 1 ; pat = null ; strings . clear ( ) ; return this ; }
Removes all of the elements from this set . This set will be empty after this call returns .
27,256
public UnicodeSet compact ( ) { checkFrozen ( ) ; if ( len != list . length ) { int [ ] temp = new int [ len ] ; System . arraycopy ( list , 0 , temp , 0 , len ) ; list = temp ; } rangeList = null ; buffer = null ; return this ; }
Reallocate this objects internal structures to take up the least possible space without changing this object s value .
27,257
private int [ ] range ( int start , int end ) { if ( rangeList == null ) { rangeList = new int [ ] { start , end + 1 , HIGH } ; } else { rangeList [ 0 ] = start ; rangeList [ 1 ] = end + 1 ; } return rangeList ; }
Assumes start < = end .
27,258
private UnicodeSet applyFilter ( Filter filter , int src ) { clear ( ) ; int startHasProperty = - 1 ; UnicodeSet inclusions = getInclusions ( src ) ; int limitRange = inclusions . getRangeCount ( ) ; for ( int j = 0 ; j < limitRange ; ++ j ) { int start = inclusions . getRangeStart ( j ) ; int end = inclusions . getRangeEnd ( j ) ; for ( int ch = start ; ch <= end ; ++ ch ) { if ( filter . contains ( ch ) ) { if ( startHasProperty < 0 ) { startHasProperty = ch ; } } else if ( startHasProperty >= 0 ) { add_unchecked ( startHasProperty , ch - 1 ) ; startHasProperty = - 1 ; } } } if ( startHasProperty >= 0 ) { add_unchecked ( startHasProperty , 0x10FFFF ) ; } return this ; }
Generic filter - based scanning code for UCD property UnicodeSets .
27,259
private static String mungeCharName ( String source ) { source = PatternProps . trimWhiteSpace ( source ) ; StringBuilder buf = null ; for ( int i = 0 ; i < source . length ( ) ; ++ i ) { char ch = source . charAt ( i ) ; if ( PatternProps . isWhiteSpace ( ch ) ) { if ( buf == null ) { buf = new StringBuilder ( ) . append ( source , 0 , i ) ; } else if ( buf . charAt ( buf . length ( ) - 1 ) == ' ' ) { continue ; } ch = ' ' ; } if ( buf != null ) { buf . append ( ch ) ; } } return buf == null ? source : buf . toString ( ) ; }
Remove leading and trailing Pattern_White_Space and compress internal Pattern_White_Space to a single space character .
27,260
public UnicodeSet applyIntPropertyValue ( int prop , int value ) { checkFrozen ( ) ; if ( prop == UProperty . GENERAL_CATEGORY_MASK ) { applyFilter ( new GeneralCategoryMaskFilter ( value ) , UCharacterProperty . SRC_CHAR ) ; } else if ( prop == UProperty . SCRIPT_EXTENSIONS ) { applyFilter ( new ScriptExtensionsFilter ( value ) , UCharacterProperty . SRC_PROPSVEC ) ; } else { applyFilter ( new IntPropertyFilter ( prop , value ) , UCharacterProperty . INSTANCE . getSource ( prop ) ) ; } return this ; }
Modifies this set to contain those code points which have the given value for the given binary or enumerated property as returned by UCharacter . getIntPropertyValue . Prior contents of this set are lost .
27,261
private static boolean resemblesPropertyPattern ( String pattern , int pos ) { if ( ( pos + 5 ) > pattern . length ( ) ) { return false ; } return pattern . regionMatches ( pos , "[:" , 0 , 2 ) || pattern . regionMatches ( true , pos , "\\p" , 0 , 2 ) || pattern . regionMatches ( pos , "\\N" , 0 , 2 ) ; }
Return true if the given position in the given pattern appears to be the start of a property set pattern .
27,262
private static boolean resemblesPropertyPattern ( RuleCharacterIterator chars , int iterOpts ) { boolean result = false ; iterOpts &= ~ RuleCharacterIterator . PARSE_ESCAPES ; Object pos = chars . getPos ( null ) ; int c = chars . next ( iterOpts ) ; if ( c == '[' || c == '\\' ) { int d = chars . next ( iterOpts & ~ RuleCharacterIterator . SKIP_WHITESPACE ) ; result = ( c == '[' ) ? ( d == ':' ) : ( d == 'N' || d == 'p' || d == 'P' ) ; } chars . setPos ( pos ) ; return result ; }
Return true if the given iterator appears to point at a property pattern . Regardless of the result return with the iterator unchanged .
27,263
private UnicodeSet applyPropertyPattern ( String pattern , ParsePosition ppos , SymbolTable symbols ) { int pos = ppos . getIndex ( ) ; if ( ( pos + 5 ) > pattern . length ( ) ) { return null ; } boolean posix = false ; boolean isName = false ; boolean invert = false ; if ( pattern . regionMatches ( pos , "[:" , 0 , 2 ) ) { posix = true ; pos = PatternProps . skipWhiteSpace ( pattern , ( pos + 2 ) ) ; if ( pos < pattern . length ( ) && pattern . charAt ( pos ) == '^' ) { ++ pos ; invert = true ; } } else if ( pattern . regionMatches ( true , pos , "\\p" , 0 , 2 ) || pattern . regionMatches ( pos , "\\N" , 0 , 2 ) ) { char c = pattern . charAt ( pos + 1 ) ; invert = ( c == 'P' ) ; isName = ( c == 'N' ) ; pos = PatternProps . skipWhiteSpace ( pattern , ( pos + 2 ) ) ; if ( pos == pattern . length ( ) || pattern . charAt ( pos ++ ) != '{' ) { return null ; } } else { return null ; } int close = pattern . indexOf ( posix ? ":]" : "}" , pos ) ; if ( close < 0 ) { return null ; } int equals = pattern . indexOf ( '=' , pos ) ; String propName , valueName ; if ( equals >= 0 && equals < close && ! isName ) { propName = pattern . substring ( pos , equals ) ; valueName = pattern . substring ( equals + 1 , close ) ; } else { propName = pattern . substring ( pos , close ) ; valueName = "" ; if ( isName ) { valueName = propName ; propName = "na" ; } } applyPropertyAlias ( propName , valueName , symbols ) ; if ( invert ) { complement ( ) ; } ppos . setIndex ( close + ( posix ? 2 : 1 ) ) ; return this ; }
Parse the given property pattern at the given parse position .
27,264
private void applyPropertyPattern ( RuleCharacterIterator chars , Appendable rebuiltPat , SymbolTable symbols ) { String patStr = chars . lookahead ( ) ; ParsePosition pos = new ParsePosition ( 0 ) ; applyPropertyPattern ( patStr , pos , symbols ) ; if ( pos . getIndex ( ) == 0 ) { syntaxError ( chars , "Invalid property pattern" ) ; } chars . jumpahead ( pos . getIndex ( ) ) ; append ( rebuiltPat , patStr . substring ( 0 , pos . getIndex ( ) ) ) ; }
Parse a property pattern .
27,265
private static final void addCaseMapping ( UnicodeSet set , int result , StringBuilder full ) { if ( result >= 0 ) { if ( result > UCaseProps . MAX_STRING_LENGTH ) { set . add ( result ) ; } else { set . add ( full . toString ( ) ) ; full . setLength ( 0 ) ; } } }
use str as a temporary string to avoid constructing one
27,266
public UnicodeSet freeze ( ) { if ( ! isFrozen ( ) ) { buffer = null ; if ( list . length > ( len + GROW_EXTRA ) ) { int capacity = ( len == 0 ) ? 1 : len ; int [ ] oldList = list ; list = new int [ capacity ] ; for ( int i = capacity ; i -- > 0 ; ) { list [ i ] = oldList [ i ] ; } } if ( ! strings . isEmpty ( ) ) { stringSpan = new UnicodeSetStringSpan ( this , new ArrayList < String > ( strings ) , UnicodeSetStringSpan . ALL ) ; } if ( stringSpan == null || ! stringSpan . needsStringSpanUTF16 ( ) ) { bmpSet = new BMPSet ( list , len ) ; } } return this ; }
Freeze this class according to the Freezable interface .
27,267
public int compareTo ( UnicodeSet o , ComparisonStyle style ) { if ( style != ComparisonStyle . LEXICOGRAPHIC ) { int diff = size ( ) - o . size ( ) ; if ( diff != 0 ) { return ( diff < 0 ) == ( style == ComparisonStyle . SHORTER_FIRST ) ? - 1 : 1 ; } } int result ; for ( int i = 0 ; ; ++ i ) { if ( 0 != ( result = list [ i ] - o . list [ i ] ) ) { if ( list [ i ] == HIGH ) { if ( strings . isEmpty ( ) ) return 1 ; String item = strings . first ( ) ; return compare ( item , o . list [ i ] ) ; } if ( o . list [ i ] == HIGH ) { if ( o . strings . isEmpty ( ) ) return - 1 ; String item = o . strings . first ( ) ; int compareResult = compare ( item , list [ i ] ) ; return compareResult > 0 ? - 1 : compareResult < 0 ? 1 : 0 ; } return ( i & 1 ) == 0 ? result : - result ; } if ( list [ i ] == HIGH ) { break ; } } return compare ( strings , o . strings ) ; }
Compares UnicodeSets in three different ways .
27,268
public static < T extends Comparable < T > > int compare ( Collection < T > collection1 , Collection < T > collection2 , ComparisonStyle style ) { if ( style != ComparisonStyle . LEXICOGRAPHIC ) { int diff = collection1 . size ( ) - collection2 . size ( ) ; if ( diff != 0 ) { return ( diff < 0 ) == ( style == ComparisonStyle . SHORTER_FIRST ) ? - 1 : 1 ; } } return compare ( collection1 , collection2 ) ; }
Utility to compare two collections optionally by size and then lexicographically .
27,269
public final void init ( byte [ ] params ) throws IOException { if ( this . initialized ) throw new IOException ( "already initialized" ) ; paramSpi . engineInit ( params ) ; this . initialized = true ; }
Imports the specified parameters and decodes them according to the primary decoding format for parameters . The primary decoding format for parameters is ASN . 1 if an ASN . 1 specification for this type of parameters exists .
27,270
private boolean areElementsSame ( int index1 , int [ ] target , int index2 , int length ) { for ( int i = 0 ; i < length ; ++ i ) { if ( v [ index1 + i ] != target [ index2 + i ] ) { return false ; } } return true ; }
starting from index2 to index2 + length - 1
27,271
private int findRow ( int rangeStart ) { int index = 0 ; index = prevRow * columns ; if ( rangeStart >= v [ index ] ) { if ( rangeStart < v [ index + 1 ] ) { return index ; } else { index += columns ; if ( rangeStart < v [ index + 1 ] ) { ++ prevRow ; return index ; } else { index += columns ; if ( rangeStart < v [ index + 1 ] ) { prevRow += 2 ; return index ; } else if ( ( rangeStart - v [ index + 1 ] ) < 10 ) { prevRow += 2 ; do { ++ prevRow ; index += columns ; } while ( rangeStart >= v [ index + 1 ] ) ; return index ; } } } } else if ( rangeStart < v [ 1 ] ) { prevRow = 0 ; return 0 ; } int start = 0 ; int mid = 0 ; int limit = rows ; while ( start < limit - 1 ) { mid = ( start + limit ) / 2 ; index = columns * mid ; if ( rangeStart < v [ index ] ) { limit = mid ; } else if ( rangeStart < v [ index + 1 ] ) { prevRow = mid ; return index ; } else { start = mid ; } } prevRow = start ; index = start * columns ; return index ; }
points to the start of a row .
27,272
public static boolean isWeak ( byte [ ] key , int offset ) throws InvalidKeyException { if ( key == null ) { throw new InvalidKeyException ( "null key" ) ; } if ( key . length - offset < DES_KEY_LEN ) { throw new InvalidKeyException ( "Wrong key size" ) ; } for ( int i = 0 ; i < WEAK_KEYS . length ; i ++ ) { boolean found = true ; for ( int j = 0 ; j < DES_KEY_LEN && found == true ; j ++ ) { if ( WEAK_KEYS [ i ] [ j ] != key [ j + offset ] ) { found = false ; } } if ( found == true ) { return found ; } } return false ; }
Checks if the given DES key material is weak or semi - weak .
27,273
public static boolean hasValidCppCharacters ( String s ) { for ( char c : s . toCharArray ( ) ) { if ( ! isValidCppCharacter ( c ) ) { return false ; } } return true ; }
Returns true if all characters in a string can be expressed as either C ++ universal characters or valid hexadecimal escape sequences .
27,274
private byte [ ] embiggen ( byte [ ] b , int len ) { if ( b == null || b . length < len ) { return new byte [ len ] ; } else { return b ; } }
If b . length is at least len return b . Otherwise return a new byte array of length len .
27,275
void shrink ( ) { int n = m_opMap . elementAt ( MAPINDEX_LENGTH ) ; m_opMap . setToSize ( n + 4 ) ; m_opMap . setElementAt ( 0 , n ) ; m_opMap . setElementAt ( 0 , n + 1 ) ; m_opMap . setElementAt ( 0 , n + 2 ) ; n = m_tokenQueue . size ( ) ; m_tokenQueue . setToSize ( n + 4 ) ; m_tokenQueue . setElementAt ( null , n ) ; m_tokenQueue . setElementAt ( null , n + 1 ) ; m_tokenQueue . setElementAt ( null , n + 2 ) ; }
Replace the large arrays with a small array .
27,276
public int getNextStepPos ( int opPos ) { int stepType = getOp ( opPos ) ; if ( ( stepType >= OpCodes . AXES_START_TYPES ) && ( stepType <= OpCodes . AXES_END_TYPES ) ) { return getNextOpPos ( opPos ) ; } else if ( ( stepType >= OpCodes . FIRST_NODESET_OP ) && ( stepType <= OpCodes . LAST_NODESET_OP ) ) { int newOpPos = getNextOpPos ( opPos ) ; while ( OpCodes . OP_PREDICATE == getOp ( newOpPos ) ) { newOpPos = getNextOpPos ( newOpPos ) ; } stepType = getOp ( newOpPos ) ; if ( ! ( ( stepType >= OpCodes . AXES_START_TYPES ) && ( stepType <= OpCodes . AXES_END_TYPES ) ) ) { return OpCodes . ENDOP ; } return newOpPos ; } else { throw new RuntimeException ( XSLMessages . createXPATHMessage ( XPATHErrorResources . ER_UNKNOWN_STEP , new Object [ ] { String . valueOf ( stepType ) } ) ) ; } }
Given a location step position return the end position i . e . the beginning of the next step .
27,277
public String getStepNS ( int opPosOfStep ) { int argLenOfStep = getArgLengthOfStep ( opPosOfStep ) ; if ( argLenOfStep == 3 ) { int index = m_opMap . elementAt ( opPosOfStep + 4 ) ; if ( index >= 0 ) return ( String ) m_tokenQueue . elementAt ( index ) ; else if ( OpCodes . ELEMWILDCARD == index ) return NodeTest . WILD ; else return null ; } else return null ; }
Get the namespace of the step .
27,278
private void parseIPv4 ( String name ) throws IOException { int slashNdx = name . indexOf ( '/' ) ; if ( slashNdx == - 1 ) { address = InetAddress . getByName ( name ) . getAddress ( ) ; } else { address = new byte [ 8 ] ; byte [ ] mask = InetAddress . getByName ( name . substring ( slashNdx + 1 ) ) . getAddress ( ) ; byte [ ] host = InetAddress . getByName ( name . substring ( 0 , slashNdx ) ) . getAddress ( ) ; System . arraycopy ( host , 0 , address , 0 , 4 ) ; System . arraycopy ( mask , 0 , address , 4 , 4 ) ; } }
Parse an IPv4 address .
27,279
public int compareTo ( Object o ) { ObjectStreamField f = ( ObjectStreamField ) o ; boolean thisPrimitive = this . isPrimitive ( ) ; boolean fPrimitive = f . isPrimitive ( ) ; if ( thisPrimitive != fPrimitive ) { return thisPrimitive ? - 1 : 1 ; } return this . getName ( ) . compareTo ( f . getName ( ) ) ; }
Compares this field descriptor to the specified one . Checks first if one of the compared fields has a primitive type and the other one not . If so the field with the primitive type is considered to be smaller . If both fields are equal their names are compared .
27,280
public Class < ? > getType ( ) { Class < ? > cl = getTypeInternal ( ) ; if ( isDeserialized && ! cl . isPrimitive ( ) ) { return Object . class ; } return cl ; }
Gets the type of this field .
27,281
public String getTypeString ( ) { if ( isPrimitive ( ) ) { return null ; } if ( typeString == null ) { Class < ? > t = getTypeInternal ( ) ; String typeName = t . getName ( ) . replace ( '.' , '/' ) ; String str = ( t . isArray ( ) ) ? typeName : ( "L" + typeName + ';' ) ; typeString = str . intern ( ) ; } return typeString ; }
Gets the type signature used by the VM to represent the type of this field .
27,282
private boolean defaultResolve ( ) { switch ( typeString . charAt ( 0 ) ) { case 'I' : type = int . class ; return true ; case 'B' : type = byte . class ; return true ; case 'C' : type = char . class ; return true ; case 'S' : type = short . class ; return true ; case 'Z' : type = boolean . class ; return true ; case 'J' : type = long . class ; return true ; case 'F' : type = float . class ; return true ; case 'D' : type = double . class ; return true ; default : type = Object . class ; return false ; } }
Resolves typeString into type . Returns true if the type is primitive and false otherwise .
27,283
private void addReturnTypeNarrowingDeclarations ( AbstractTypeDeclaration node ) { TypeElement type = node . getTypeElement ( ) ; if ( deadCodeMap != null && deadCodeMap . containsClass ( type , elementUtil ) ) { return ; } Map < String , ExecutablePair > newDeclarations = new HashMap < > ( ) ; Map < String , TypeMirror > resolvedReturnTypes = new HashMap < > ( ) ; for ( DeclaredType inheritedType : typeUtil . getObjcOrderedInheritedTypes ( type . asType ( ) ) ) { TypeElement inheritedElem = ( TypeElement ) inheritedType . asElement ( ) ; for ( ExecutableElement methodElem : ElementUtil . getMethods ( inheritedElem ) ) { if ( ElementUtil . isPrivate ( methodElem ) ) { continue ; } TypeMirror declaredReturnType = typeUtil . erasure ( methodElem . getReturnType ( ) ) ; if ( ! TypeUtil . isReferenceType ( declaredReturnType ) ) { continue ; } String selector = nameTable . getMethodSelector ( methodElem ) ; ExecutableType methodType = typeUtil . asMemberOf ( inheritedType , methodElem ) ; TypeMirror returnType = typeUtil . erasure ( methodType . getReturnType ( ) ) ; TypeMirror resolvedReturnType = resolvedReturnTypes . get ( selector ) ; if ( resolvedReturnType == null ) { resolvedReturnType = declaredReturnType ; resolvedReturnTypes . put ( selector , resolvedReturnType ) ; } else if ( ! typeUtil . isSubtype ( returnType , resolvedReturnType ) ) { continue ; } if ( resolvedReturnType != returnType && ! nameTable . getObjCType ( resolvedReturnType ) . equals ( nameTable . getObjCType ( returnType ) ) ) { newDeclarations . put ( selector , new ExecutablePair ( methodElem , methodType ) ) ; resolvedReturnTypes . put ( selector , returnType ) ; } } } for ( Map . Entry < String , ExecutablePair > newDecl : newDeclarations . entrySet ( ) ) { if ( deadCodeMap != null && deadCodeMap . containsMethod ( newDecl . getValue ( ) . element ( ) , typeUtil ) ) { continue ; } node . addBodyDeclaration ( newReturnTypeNarrowingDeclaration ( newDecl . getKey ( ) , newDecl . getValue ( ) , type ) ) ; } }
specific than what is already declared in inherited types .
27,284
public Stream < P_OUT > unordered ( ) { if ( ! isOrdered ( ) ) return this ; return new StatelessOp < P_OUT , P_OUT > ( this , StreamShape . REFERENCE , StreamOpFlag . NOT_ORDERED ) { public Sink < P_OUT > opWrapSink ( int flags , Sink < P_OUT > sink ) { return sink ; } } ; }
Stateless intermediate operations from Stream
27,285
public void forEach ( Consumer < ? super P_OUT > action ) { evaluate ( ForEachOps . makeRef ( action , false ) ) ; }
Terminal operations from Stream
27,286
public void clearLocalSlots ( int start , int len ) { start += _currentFrameBottom ; System . arraycopy ( m_nulls , 0 , _stackFrames , start , len ) ; }
Use this to clear the variables in a section of the stack . This is used to clear the parameter section of the stack so that default param values can tell if they ve already been set . It is important to note that this function has a 1K limitation .
27,287
public XObject getGlobalVariable ( XPathContext xctxt , final int index ) throws TransformerException { XObject val = _stackFrames [ index ] ; if ( val . getType ( ) == XObject . CLASS_UNRESOLVEDVARIABLE ) return ( _stackFrames [ index ] = val . execute ( xctxt ) ) ; return val ; }
Get a global variable or parameter from the global stack frame .
27,288
public XObject getVariableOrParam ( XPathContext xctxt , org . apache . xml . utils . QName qname ) throws javax . xml . transform . TransformerException { org . apache . xml . utils . PrefixResolver prefixResolver = xctxt . getNamespaceContext ( ) ; if ( prefixResolver instanceof org . apache . xalan . templates . ElemTemplateElement ) { org . apache . xalan . templates . ElemVariable vvar ; org . apache . xalan . templates . ElemTemplateElement prev = ( org . apache . xalan . templates . ElemTemplateElement ) prefixResolver ; if ( ! ( prev instanceof org . apache . xalan . templates . Stylesheet ) ) { while ( ! ( prev . getParentNode ( ) instanceof org . apache . xalan . templates . Stylesheet ) ) { org . apache . xalan . templates . ElemTemplateElement savedprev = prev ; while ( null != ( prev = prev . getPreviousSiblingElem ( ) ) ) { if ( prev instanceof org . apache . xalan . templates . ElemVariable ) { vvar = ( org . apache . xalan . templates . ElemVariable ) prev ; if ( vvar . getName ( ) . equals ( qname ) ) return getLocalVariable ( xctxt , vvar . getIndex ( ) ) ; } } prev = savedprev . getParentElem ( ) ; } } vvar = prev . getStylesheetRoot ( ) . getVariableOrParamComposed ( qname ) ; if ( null != vvar ) return getGlobalVariable ( xctxt , vvar . getIndex ( ) ) ; } throw new javax . xml . transform . TransformerException ( XSLMessages . createXPATHMessage ( XPATHErrorResources . ER_VAR_NOT_RESOLVABLE , new Object [ ] { qname . toString ( ) } ) ) ; }
Get a variable based on it s qualified name . This is for external use only .
27,289
public Gender getListGender ( List < Gender > genders ) { if ( genders . size ( ) == 0 ) { return Gender . OTHER ; } if ( genders . size ( ) == 1 ) { return genders . get ( 0 ) ; } switch ( style ) { case NEUTRAL : return Gender . OTHER ; case MIXED_NEUTRAL : boolean hasFemale = false ; boolean hasMale = false ; for ( Gender gender : genders ) { switch ( gender ) { case FEMALE : if ( hasMale ) { return Gender . OTHER ; } hasFemale = true ; break ; case MALE : if ( hasFemale ) { return Gender . OTHER ; } hasMale = true ; break ; case OTHER : return Gender . OTHER ; } } return hasMale ? Gender . MALE : Gender . FEMALE ; case MALE_TAINTS : for ( Gender gender : genders ) { if ( gender != Gender . FEMALE ) { return Gender . MALE ; } } return Gender . FEMALE ; default : return Gender . OTHER ; } }
Get the gender of a list based on locale usage .
27,290
public void encode ( DerOutputStream out ) throws IOException { DerOutputStream tmp = new DerOutputStream ( ) ; name . encode ( tmp ) ; int nameType = name . getType ( ) ; if ( nameType == GeneralNameInterface . NAME_ANY || nameType == GeneralNameInterface . NAME_X400 || nameType == GeneralNameInterface . NAME_EDI ) { out . writeImplicit ( DerValue . createTag ( DerValue . TAG_CONTEXT , true , ( byte ) nameType ) , tmp ) ; } else if ( nameType == GeneralNameInterface . NAME_DIRECTORY ) { out . write ( DerValue . createTag ( DerValue . TAG_CONTEXT , true , ( byte ) nameType ) , tmp ) ; } else { out . writeImplicit ( DerValue . createTag ( DerValue . TAG_CONTEXT , false , ( byte ) nameType ) , tmp ) ; } }
Encode the name to the specified DerOutputStream .
27,291
protected int handleGetExtendedYear ( ) { int year ; if ( newestStamp ( ERA , YEAR , UNSET ) <= getStamp ( EXTENDED_YEAR ) ) { year = internalGet ( EXTENDED_YEAR , 1 ) ; } else { int cycle = internalGet ( ERA , 1 ) - 1 ; year = cycle * 60 + internalGet ( YEAR , 1 ) - ( epochYear - CHINESE_EPOCH_YEAR ) ; } return year ; }
Implement abstract Calendar method to return the extended year defined by the current fields . This will use either the ERA and YEAR field as the cycle and year - of - cycle or the EXTENDED_YEAR field as the continuous year count depending on which is newer .
27,292
protected int handleGetMonthLength ( int extendedYear , int month ) { int thisStart = handleComputeMonthStart ( extendedYear , month , true ) - EPOCH_JULIAN_DAY + 1 ; int nextStart = newMoonNear ( thisStart + SYNODIC_GAP , true ) ; return nextStart - thisStart ; }
Override Calendar method to return the number of days in the given extended year and month .
27,293
private int newMoonNear ( int days , boolean after ) { astro . setTime ( daysToMillis ( days ) ) ; long newMoon = astro . getMoonTime ( CalendarAstronomer . NEW_MOON , after ) ; return millisToDays ( newMoon ) ; }
Return the closest new moon to the given date searching either forward or backward in time .
27,294
private int majorSolarTerm ( int days ) { astro . setTime ( daysToMillis ( days ) ) ; int term = ( ( int ) Math . floor ( 6 * astro . getSunLongitude ( ) / Math . PI ) + 2 ) % 12 ; if ( term < 1 ) { term += 12 ; } return term ; }
Return the major solar term on or before a given date . This will be an integer from 1 .. 12 with 1 corresponding to 330 degrees 2 to 0 degrees 3 to 30 degrees ... and 12 to 300 degrees .
27,295
private boolean hasNoMajorSolarTerm ( int newMoon ) { int mst = majorSolarTerm ( newMoon ) ; int nmn = newMoonNear ( newMoon + SYNODIC_GAP , true ) ; int mstt = majorSolarTerm ( nmn ) ; return mst == mstt ; }
Return true if the given month lacks a major solar term .
27,296
private boolean isLeapMonthBetween ( int newMoon1 , int newMoon2 ) { if ( synodicMonthsBetween ( newMoon1 , newMoon2 ) >= 50 ) { throw new IllegalArgumentException ( "isLeapMonthBetween(" + newMoon1 + ", " + newMoon2 + "): Invalid parameters" ) ; } return ( newMoon2 >= newMoon1 ) && ( isLeapMonthBetween ( newMoon1 , newMoonNear ( newMoon2 - SYNODIC_GAP , false ) ) || hasNoMajorSolarTerm ( newMoon2 ) ) ; }
Return true if there is a leap month on or after month newMoon1 and at or before month newMoon2 .
27,297
private int newYear ( int gyear ) { long cacheValue = newYearCache . get ( gyear ) ; if ( cacheValue == CalendarCache . EMPTY ) { int solsticeBefore = winterSolstice ( gyear - 1 ) ; int solsticeAfter = winterSolstice ( gyear ) ; int newMoon1 = newMoonNear ( solsticeBefore + 1 , true ) ; int newMoon2 = newMoonNear ( newMoon1 + SYNODIC_GAP , true ) ; int newMoon11 = newMoonNear ( solsticeAfter + 1 , false ) ; if ( synodicMonthsBetween ( newMoon1 , newMoon11 ) == 12 && ( hasNoMajorSolarTerm ( newMoon1 ) || hasNoMajorSolarTerm ( newMoon2 ) ) ) { cacheValue = newMoonNear ( newMoon2 + SYNODIC_GAP , true ) ; } else { cacheValue = newMoon2 ; } newYearCache . put ( gyear , cacheValue ) ; } return ( int ) cacheValue ; }
Return the Chinese new year of the given Gregorian year .
27,298
protected int handleComputeMonthStart ( int eyear , int month , boolean useMonth ) { if ( month < 0 || month > 11 ) { int [ ] rem = new int [ 1 ] ; eyear += floorDivide ( month , 12 , rem ) ; month = rem [ 0 ] ; } int gyear = eyear + epochYear - 1 ; int newYear = newYear ( gyear ) ; int newMoon = newMoonNear ( newYear + month * 29 , true ) ; int julianDay = newMoon + EPOCH_JULIAN_DAY ; int saveMonth = internalGet ( MONTH ) ; int saveIsLeapMonth = internalGet ( IS_LEAP_MONTH ) ; int isLeapMonth = useMonth ? saveIsLeapMonth : 0 ; computeGregorianFields ( julianDay ) ; computeChineseFields ( newMoon , getGregorianYear ( ) , getGregorianMonth ( ) , false ) ; if ( month != internalGet ( MONTH ) || isLeapMonth != internalGet ( IS_LEAP_MONTH ) ) { newMoon = newMoonNear ( newMoon + SYNODIC_GAP , true ) ; julianDay = newMoon + EPOCH_JULIAN_DAY ; } internalSet ( MONTH , saveMonth ) ; internalSet ( IS_LEAP_MONTH , saveIsLeapMonth ) ; return julianDay - 1 ; }
Return the Julian day number of day before the first day of the given month in the given extended year .
27,299
private void readObject ( ObjectInputStream stream ) throws IOException , ClassNotFoundException { epochYear = CHINESE_EPOCH_YEAR ; zoneAstro = CHINA_ZONE ; stream . defaultReadObject ( ) ; astro = new CalendarAstronomer ( ) ; winterSolsticeCache = new CalendarCache ( ) ; newYearCache = new CalendarCache ( ) ; }
Override readObject .