idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
26,600
public void allowDetachToRelease ( boolean allowRelease ) { if ( ( false == allowRelease ) && ! hasCache ( ) ) { setShouldCacheNodes ( true ) ; } if ( null != m_iter ) m_iter . allowDetachToRelease ( allowRelease ) ; super . allowDetachToRelease ( allowRelease ) ; }
Calling this with a value of false will cause the nodeset to be cached .
26,601
private void resolve ( byte level , int options ) { bidi . setInverse ( ( options & Bidi . REORDER_INVERSE_LIKE_DIRECT ) != 0 ) ; bidi . setReorderingMode ( options ) ; bidi . setPara ( text , level , null ) ; }
Performs bidi resolution of text .
26,602
public void encode ( OutputStream out ) throws IOException { DerOutputStream tmp = new DerOutputStream ( ) ; algId . encode ( tmp ) ; out . write ( tmp . toByteArray ( ) ) ; }
Encode the algorithm identifier in DER form to the stream .
26,603
public static LocaleData get ( Locale locale ) { if ( locale == null ) { throw new NullPointerException ( "locale == null" ) ; } final String languageTag = locale . toLanguageTag ( ) ; synchronized ( localeDataCache ) { LocaleData localeData = localeDataCache . get ( languageTag ) ; if ( localeData != null ) { return localeData ; } } LocaleData newLocaleData = initLocaleData ( locale ) ; synchronized ( localeDataCache ) { LocaleData localeData = localeDataCache . get ( languageTag ) ; if ( localeData != null ) { return localeData ; } localeDataCache . put ( languageTag , newLocaleData ) ; return newLocaleData ; } }
Returns a shared LocaleData for the given locale .
26,604
public boolean offer ( E e ) { if ( e == null ) throw new NullPointerException ( ) ; modCount ++ ; int i = size ; if ( i >= queue . length ) grow ( i + 1 ) ; size = i + 1 ; if ( i == 0 ) queue [ 0 ] = e ; else siftUp ( i , e ) ; return true ; }
Inserts the specified element into this priority queue .
26,605
boolean removeEq ( Object o ) { for ( int i = 0 ; i < size ; i ++ ) { if ( o == queue [ i ] ) { removeAt ( i ) ; return true ; } } return false ; }
Version of remove using reference equality not equals . Needed by iterator . remove .
26,606
public final static String getDefaultAlgorithm ( ) { String type ; type = AccessController . doPrivileged ( new PrivilegedAction < String > ( ) { public String run ( ) { return Security . getProperty ( "ssl.KeyManagerFactory.algorithm" ) ; } } ) ; if ( type == null ) { type = "SunX509" ; } return type ; }
Obtains the default KeyManagerFactory algorithm name .
26,607
void buildFieldDescriptors ( Field [ ] declaredFields ) { final Field f = ObjectStreamClass . fieldSerialPersistentFields ( this . forClass ( ) ) ; boolean useReflectFields = f == null ; ObjectStreamField [ ] _fields = null ; if ( ! useReflectFields ) { f . setAccessible ( true ) ; try { _fields = ( ObjectStreamField [ ] ) f . get ( null ) ; } catch ( IllegalAccessException ex ) { throw new AssertionError ( ex ) ; } } else { List < ObjectStreamField > serializableFields = new ArrayList < ObjectStreamField > ( declaredFields . length ) ; for ( Field declaredField : declaredFields ) { int modifiers = declaredField . getModifiers ( ) ; if ( ! Modifier . isStatic ( modifiers ) && ! Modifier . isTransient ( modifiers ) ) { ObjectStreamField field = new ObjectStreamField ( declaredField . getName ( ) , declaredField . getType ( ) ) ; serializableFields . add ( field ) ; } } if ( serializableFields . size ( ) == 0 ) { _fields = NO_FIELDS ; } else { _fields = serializableFields . toArray ( new ObjectStreamField [ serializableFields . size ( ) ] ) ; } } Arrays . sort ( _fields ) ; int primOffset = 0 , objectOffset = 0 ; for ( int i = 0 ; i < _fields . length ; i ++ ) { Class < ? > type = _fields [ i ] . getType ( ) ; if ( type . isPrimitive ( ) ) { _fields [ i ] . offset = primOffset ; primOffset += primitiveSize ( type ) ; } else { _fields [ i ] . offset = objectOffset ++ ; } } fields = _fields ; }
Builds the collection of field descriptors for the receiver
26,608
private boolean inSamePackage ( Class < ? > c1 , Class < ? > c2 ) { String nameC1 = c1 . getName ( ) ; String nameC2 = c2 . getName ( ) ; int indexDotC1 = nameC1 . lastIndexOf ( '.' ) ; int indexDotC2 = nameC2 . lastIndexOf ( '.' ) ; if ( indexDotC1 != indexDotC2 ) { return false ; } if ( indexDotC1 == - 1 ) { return true ; } return nameC1 . regionMatches ( 0 , nameC2 , 0 , indexDotC1 ) ; }
Checks if two classes belong to the same package .
26,609
public ObjectStreamField getField ( String name ) { ObjectStreamField [ ] allFields = getFields ( ) ; for ( int i = 0 ; i < allFields . length ; i ++ ) { ObjectStreamField f = allFields [ i ] ; if ( f . getName ( ) . equals ( name ) ) { return f ; } } return null ; }
Gets a field descriptor of the class represented by this class descriptor .
26,610
ObjectStreamField [ ] fields ( ) { if ( fields == null ) { Class < ? > forCl = forClass ( ) ; if ( forCl != null && isSerializable ( ) && ! forCl . isArray ( ) ) { buildFieldDescriptors ( forCl . getDeclaredFields ( ) ) ; } else { setFields ( NO_FIELDS ) ; } } return fields ; }
Returns the collection of field descriptors for the fields of the corresponding class
26,611
private void copyFieldAttributes ( ) { if ( ( loadFields == null ) || fields == null ) { return ; } for ( int i = 0 ; i < loadFields . length ; i ++ ) { ObjectStreamField loadField = loadFields [ i ] ; String name = loadField . getName ( ) ; for ( int j = 0 ; j < fields . length ; j ++ ) { ObjectStreamField field = fields [ j ] ; if ( name . equals ( field . getName ( ) ) ) { loadField . setUnshared ( field . isUnshared ( ) ) ; loadField . setOffset ( field . getOffset ( ) ) ; break ; } } } }
If a Class uses serialPersistentFields to define the serialized fields this . loadFields cannot get the unshared information when deserializing fields using current implementation of ObjectInputStream . This method provides a way to copy the unshared attribute from this . fields .
26,612
private void resolveProperties ( ) { if ( arePropertiesResolved ) { return ; } Class < ? > cl = forClass ( ) ; isProxy = Proxy . isProxyClass ( cl ) ; isEnum = Enum . class . isAssignableFrom ( cl ) ; isSerializable = isSerializable ( cl ) ; isExternalizable = isExternalizable ( cl ) ; arePropertiesResolved = true ; }
Resolves the class properties if they weren t already
26,613
public final Certificate getCertificate ( String alias ) throws KeyStoreException { if ( ! initialized ) { throw new KeyStoreException ( "Uninitialized keystore" ) ; } return keyStoreSpi . engineGetCertificate ( alias ) ; }
Returns the certificate associated with the given alias .
26,614
public final Date getCreationDate ( String alias ) throws KeyStoreException { if ( ! initialized ) { throw new KeyStoreException ( "Uninitialized keystore" ) ; } return keyStoreSpi . engineGetCreationDate ( alias ) ; }
Returns the creation date of the entry identified by the given alias .
26,615
public final void setKeyEntry ( String alias , Key key , char [ ] password , Certificate [ ] chain ) throws KeyStoreException { if ( ! initialized ) { throw new KeyStoreException ( "Uninitialized keystore" ) ; } if ( ( key instanceof PrivateKey ) && ( chain == null || chain . length == 0 ) ) { throw new IllegalArgumentException ( "Private key must be " + "accompanied by certificate " + "chain" ) ; } keyStoreSpi . engineSetKeyEntry ( alias , key , password , chain ) ; }
Assigns the given key to the given alias protecting it with the given password .
26,616
public final void setCertificateEntry ( String alias , Certificate cert ) throws KeyStoreException { if ( ! initialized ) { throw new KeyStoreException ( "Uninitialized keystore" ) ; } keyStoreSpi . engineSetCertificateEntry ( alias , cert ) ; }
Assigns the given trusted certificate to the given alias .
26,617
public final void store ( OutputStream stream , char [ ] password ) throws KeyStoreException , IOException , NoSuchAlgorithmException , CertificateException { if ( ! initialized ) { throw new KeyStoreException ( "Uninitialized keystore" ) ; } keyStoreSpi . engineStore ( stream , password ) ; }
Stores this keystore to the given output stream and protects its integrity with the given password .
26,618
public final void load ( InputStream stream , char [ ] password ) throws IOException , NoSuchAlgorithmException , CertificateException { keyStoreSpi . engineLoad ( stream , password ) ; initialized = true ; }
Loads this KeyStore from the given input stream .
26,619
private E xfer ( E e , boolean haveData , int how , long nanos ) { if ( haveData && ( e == null ) ) throw new NullPointerException ( ) ; Node s = null ; retry : for ( ; ; ) { for ( Node h = head , p = h ; p != null ; ) { boolean isData = p . isData ; Object item = p . item ; if ( item != FORGOTTEN && ( item != null ) == isData ) { if ( isData == haveData ) break ; if ( p . casItem ( item , e ) ) { for ( Node q = p ; q != h ; ) { Node n = q . next ; if ( head == h && casHead ( h , n == null ? q : n ) ) { h . forgetNext ( ) ; break ; } if ( ( h = head ) == null || ( q = h . next ) == null || ! q . isMatched ( ) ) break ; } LockSupport . unpark ( p . waiter ) ; @ SuppressWarnings ( "unchecked" ) E itemE = ( E ) item ; return itemE ; } } Node n = p . next ; p = ( UNLINKED != n ) ? n : ( h = head ) ; } if ( how != NOW ) { if ( s == null ) s = new Node ( e , haveData ) ; Node pred = tryAppend ( s , haveData ) ; if ( pred == null ) continue retry ; if ( how != ASYNC ) return awaitMatch ( s , pred , e , ( how == TIMED ) , nanos ) ; } return e ; } }
Implements all queuing methods . See above for explanation .
26,620
private Node tryAppend ( Node s , boolean haveData ) { for ( Node t = tail , p = t ; ; ) { Node n , u ; if ( p == null && ( p = head ) == null ) { if ( casHead ( null , s ) ) return s ; } else if ( p . cannotPrecede ( haveData ) ) return null ; else if ( ( n = p . next ) != null ) p = p != t && t != ( u = tail ) ? ( t = u ) : ( UNLINKED != n ) ? n : null ; else if ( ! p . casNext ( null , s ) ) p = p . next ; else { if ( p != t ) { while ( ( tail != t || ! casTail ( t , s ) ) && ( t = tail ) != null && ( s = t . next ) != null && ( s = s . next ) != null && s != UNLINKED ) ; } return p ; } } }
Tries to append node s as tail .
26,621
final Node firstDataNode ( ) { restartFromHead : for ( ; ; ) { for ( Node p = head ; p != null ; ) { Object item = p . item ; if ( p . isData ) { if ( item != null && item != FORGOTTEN ) return p ; } else if ( item == null ) break ; if ( UNLINKED == ( p = p . next ) ) continue restartFromHead ; } return null ; } }
Returns the first unmatched data node or null if none . Callers must recheck if the returned node s item field is null or self - linked before using .
26,622
public void dump ( java . io . PrintStream out ) { if ( out == null ) { out = System . out ; } this . fRData . dump ( out ) ; }
Dump the contents of the state table and character classes for this break iterator . For debugging only .
26,623
public static void compileRules ( String rules , OutputStream ruleBinary ) throws IOException { RBBIRuleBuilder . compileRules ( rules , ruleBinary ) ; }
Compile a set of source break rules into the binary state tables used by the break iterator engine . Creating a break iterator from precompiled rules is much faster than creating one from source rules .
26,624
public int next ( ) { if ( fCachedBreakPositions != null ) { if ( fPositionInCache < fCachedBreakPositions . length - 1 ) { ++ fPositionInCache ; int pos = fCachedBreakPositions [ fPositionInCache ] ; fText . setIndex ( pos ) ; return pos ; } else { reset ( ) ; } } int startPos = current ( ) ; fDictionaryCharCount = 0 ; int result = handleNext ( fRData . fFTable ) ; if ( fDictionaryCharCount > 0 ) { result = checkDictionary ( startPos , result , false ) ; } return result ; }
Advances the iterator to the next boundary position .
26,625
public int previous ( ) { int result ; int startPos ; CharacterIterator text = getText ( ) ; fLastStatusIndexValid = false ; if ( fCachedBreakPositions != null ) { if ( fPositionInCache > 0 ) { -- fPositionInCache ; if ( fPositionInCache <= 0 ) { fLastStatusIndexValid = false ; } int pos = fCachedBreakPositions [ fPositionInCache ] ; text . setIndex ( pos ) ; return pos ; } else { reset ( ) ; } } startPos = current ( ) ; if ( fText == null || startPos == fText . getBeginIndex ( ) ) { fLastRuleStatusIndex = 0 ; fLastStatusIndexValid = true ; return BreakIterator . DONE ; } if ( fRData . fSRTable != null || fRData . fSFTable != null ) { result = handlePrevious ( fRData . fRTable ) ; if ( fDictionaryCharCount > 0 ) { result = checkDictionary ( result , startPos , true ) ; } return result ; } int start = current ( ) ; previous32 ( fText ) ; int lastResult = handlePrevious ( fRData . fRTable ) ; if ( lastResult == BreakIterator . DONE ) { lastResult = fText . getBeginIndex ( ) ; fText . setIndex ( lastResult ) ; } result = lastResult ; int lastTag = 0 ; boolean breakTagValid = false ; for ( ; ; ) { result = next ( ) ; if ( result == BreakIterator . DONE || result >= start ) { break ; } lastResult = result ; lastTag = fLastRuleStatusIndex ; breakTagValid = true ; } fText . setIndex ( lastResult ) ; fLastRuleStatusIndex = lastTag ; fLastStatusIndexValid = breakTagValid ; return lastResult ; }
Moves the iterator backwards to the last boundary preceding this one .
26,626
public int following ( int offset ) { CharacterIterator text = getText ( ) ; if ( fCachedBreakPositions == null || offset < fCachedBreakPositions [ 0 ] || offset >= fCachedBreakPositions [ fCachedBreakPositions . length - 1 ] ) { fCachedBreakPositions = null ; return rulesFollowing ( offset ) ; } else { fPositionInCache = 0 ; while ( fPositionInCache < fCachedBreakPositions . length && offset >= fCachedBreakPositions [ fPositionInCache ] ) ++ fPositionInCache ; text . setIndex ( fCachedBreakPositions [ fPositionInCache ] ) ; return text . getIndex ( ) ; } }
Sets the iterator to refer to the first boundary position following the specified position .
26,627
public int preceding ( int offset ) { CharacterIterator text = getText ( ) ; if ( fCachedBreakPositions == null || offset <= fCachedBreakPositions [ 0 ] || offset > fCachedBreakPositions [ fCachedBreakPositions . length - 1 ] ) { fCachedBreakPositions = null ; return rulesPreceding ( offset ) ; } else { fPositionInCache = 0 ; while ( fPositionInCache < fCachedBreakPositions . length && offset > fCachedBreakPositions [ fPositionInCache ] ) ++ fPositionInCache ; -- fPositionInCache ; text . setIndex ( fCachedBreakPositions [ fPositionInCache ] ) ; return text . getIndex ( ) ; } }
Sets the iterator to refer to the last boundary position before the specified position .
26,628
protected static final void checkOffset ( int offset , CharacterIterator text ) { if ( offset < text . getBeginIndex ( ) || offset > text . getEndIndex ( ) ) { throw new IllegalArgumentException ( "offset out of bounds" ) ; } }
Throw IllegalArgumentException unless begin &lt ; = offset &lt ; end .
26,629
public boolean isBoundary ( int offset ) { checkOffset ( offset , fText ) ; if ( offset == fText . getBeginIndex ( ) ) { first ( ) ; return true ; } if ( offset == fText . getEndIndex ( ) ) { last ( ) ; return true ; } fText . setIndex ( offset ) ; previous32 ( fText ) ; int pos = fText . getIndex ( ) ; boolean result = following ( pos ) == offset ; return result ; }
Returns true if the specified position is a boundary position . As a side effect leaves the iterator pointing to the first boundary position at or after offset .
26,630
public Void visitCompilationUnit ( CompilationUnitTree unit , Void unused ) { scan ( unit . getImports ( ) , null ) ; scan ( unit . getPackageAnnotations ( ) , null ) ; scan ( unit . getTypeDecls ( ) , null ) ; return null ; }
TreeScanner methods .
26,631
private boolean checkAnnotations ( List < ? extends AnnotationTree > annotations , Tree node ) { for ( AnnotationTree annotation : annotations ) { if ( isJ2ObjCIncompatible ( annotation ) ) { nodesToStrip . add ( node ) ; return false ; } } return true ; }
Checks for any J2ObjCIncompatible annotations . Returns whether the caller should to continue scanning this node .
26,632
public final String getDisplayName ( String tzID , NameType type , long date ) { String name = getTimeZoneDisplayName ( tzID , type ) ; if ( name == null ) { String mzID = getMetaZoneID ( tzID , date ) ; name = getMetaZoneDisplayName ( mzID , type ) ; } return name ; }
Returns the display name of the time zone at the given date .
26,633
public Collection < MatchInfo > find ( CharSequence text , int start , EnumSet < NameType > types ) { throw new UnsupportedOperationException ( "The method is not implemented in TimeZoneNames base class." ) ; }
Finds time zone name prefix matches for the input text at the given offset and returns a collection of the matches .
26,634
static Object newInstance ( String className , ClassLoader cl , boolean doFallback ) throws ConfigurationError { try { Class providerClass = findProviderClass ( className , cl , doFallback ) ; Object instance = providerClass . newInstance ( ) ; debugPrintln ( "created new instance of " + providerClass + " using ClassLoader: " + cl ) ; return instance ; } catch ( ClassNotFoundException x ) { throw new ConfigurationError ( "Provider " + className + " not found" , x ) ; } catch ( Exception x ) { throw new ConfigurationError ( "Provider " + className + " could not be instantiated: " + x , x ) ; } }
Create an instance of a class using the specified ClassLoader
26,635
static Class findProviderClass ( String className , ClassLoader cl , boolean doFallback ) throws ClassNotFoundException , ConfigurationError { SecurityManager security = System . getSecurityManager ( ) ; try { if ( security != null ) { final int lastDot = className . lastIndexOf ( "." ) ; String packageName = className ; if ( lastDot != - 1 ) packageName = className . substring ( 0 , lastDot ) ; security . checkPackageAccess ( packageName ) ; } } catch ( SecurityException e ) { throw e ; } Class providerClass ; if ( cl == null ) { providerClass = Class . forName ( className ) ; } else { try { providerClass = cl . loadClass ( className ) ; } catch ( ClassNotFoundException x ) { if ( doFallback ) { ClassLoader current = ObjectFactory . class . getClassLoader ( ) ; if ( current == null ) { providerClass = Class . forName ( className ) ; } else if ( cl != current ) { cl = current ; providerClass = cl . loadClass ( className ) ; } else { throw x ; } } else { throw x ; } } } return providerClass ; }
Find a Class using the specified ClassLoader
26,636
private static String findJarServiceProviderName ( String factoryId ) { SecuritySupport ss = SecuritySupport . getInstance ( ) ; String serviceId = SERVICES_PATH + factoryId ; InputStream is = null ; ClassLoader cl = findClassLoader ( ) ; is = ss . getResourceAsStream ( cl , serviceId ) ; if ( is == null ) { ClassLoader current = ObjectFactory . class . getClassLoader ( ) ; if ( cl != current ) { cl = current ; is = ss . getResourceAsStream ( cl , serviceId ) ; } } if ( is == null ) { return null ; } debugPrintln ( "found jar resource=" + serviceId + " using ClassLoader: " + cl ) ; BufferedReader rd ; try { rd = new BufferedReader ( new InputStreamReader ( is , "UTF-8" ) ) ; } catch ( java . io . UnsupportedEncodingException e ) { rd = new BufferedReader ( new InputStreamReader ( is ) ) ; } String factoryClassName = null ; try { factoryClassName = rd . readLine ( ) ; } catch ( IOException x ) { return null ; } finally { try { rd . close ( ) ; } catch ( IOException exc ) { } } if ( factoryClassName != null && ! "" . equals ( factoryClassName ) ) { debugPrintln ( "found in resource, value=" + factoryClassName ) ; return factoryClassName ; } return null ; }
Find the name of service provider using Jar Service Provider Mechanism
26,637
private static String toHexString ( byte [ ] bytes ) { if ( bytes . length == 0 ) { return "(empty)" ; } StringBuilder sb = new StringBuilder ( bytes . length * 3 - 1 ) ; boolean isInitial = true ; for ( byte b : bytes ) { if ( isInitial ) { isInitial = false ; } else { sb . append ( ':' ) ; } int k = b & 0xFF ; sb . append ( HEXES [ k >>> 4 ] ) ; sb . append ( HEXES [ k & 0xF ] ) ; } return sb . toString ( ) ; }
convert byte array to hex string
26,638
public void setStartYear ( int year ) { if ( isFrozen ( ) ) { throw new UnsupportedOperationException ( "Attempt to modify a frozen SimpleTimeZone instance." ) ; } getSTZInfo ( ) . sy = year ; this . startYear = year ; transitionRulesInitialized = false ; }
Sets the daylight savings starting year .
26,639
public void setStartRule ( int month , int dayOfMonth , int time ) { if ( isFrozen ( ) ) { throw new UnsupportedOperationException ( "Attempt to modify a frozen SimpleTimeZone instance." ) ; } getSTZInfo ( ) . setStart ( month , - 1 , - 1 , time , dayOfMonth , false ) ; setStartRule ( month , dayOfMonth , 0 , time , WALL_TIME ) ; }
Sets the DST start rule to a fixed date within a month .
26,640
public void setEndRule ( int month , int dayOfMonth , int time ) { if ( isFrozen ( ) ) { throw new UnsupportedOperationException ( "Attempt to modify a frozen SimpleTimeZone instance." ) ; } getSTZInfo ( ) . setEnd ( month , - 1 , - 1 , time , dayOfMonth , false ) ; setEndRule ( month , dayOfMonth , WALL_TIME , time ) ; }
Sets the DST end rule to a fixed date within a month .
26,641
public void setDSTSavings ( int millisSavedDuringDST ) { if ( isFrozen ( ) ) { throw new UnsupportedOperationException ( "Attempt to modify a frozen SimpleTimeZone instance." ) ; } if ( millisSavedDuringDST <= 0 ) { throw new IllegalArgumentException ( ) ; } dst = millisSavedDuringDST ; transitionRulesInitialized = false ; }
Sets the amount of time in ms that the clock is advanced during DST .
26,642
private void readObject ( java . io . ObjectInputStream in ) throws IOException , ClassNotFoundException { in . defaultReadObject ( ) ; if ( xinfo != null ) { xinfo . applyTo ( this ) ; } }
on JDK 1 . 4 and later can t deserialize a SimpleTimeZone as a SimpleTimeZone ...
26,643
private int compareToRule ( int month , int monthLen , int prevMonthLen , int dayOfMonth , int dayOfWeek , int millis , int millisDelta , int ruleMode , int ruleMonth , int ruleDayOfWeek , int ruleDay , int ruleMillis ) { millis += millisDelta ; while ( millis >= Grego . MILLIS_PER_DAY ) { millis -= Grego . MILLIS_PER_DAY ; ++ dayOfMonth ; dayOfWeek = 1 + ( dayOfWeek % 7 ) ; if ( dayOfMonth > monthLen ) { dayOfMonth = 1 ; ++ month ; } } while ( millis < 0 ) { -- dayOfMonth ; dayOfWeek = 1 + ( ( dayOfWeek + 5 ) % 7 ) ; if ( dayOfMonth < 1 ) { dayOfMonth = prevMonthLen ; -- month ; } millis += Grego . MILLIS_PER_DAY ; } if ( month < ruleMonth ) return - 1 ; else if ( month > ruleMonth ) return 1 ; int ruleDayOfMonth = 0 ; if ( ruleDay > monthLen ) { ruleDay = monthLen ; } switch ( ruleMode ) { case DOM_MODE : ruleDayOfMonth = ruleDay ; break ; case DOW_IN_MONTH_MODE : if ( ruleDay > 0 ) ruleDayOfMonth = 1 + ( ruleDay - 1 ) * 7 + ( 7 + ruleDayOfWeek - ( dayOfWeek - dayOfMonth + 1 ) ) % 7 ; else { ruleDayOfMonth = monthLen + ( ruleDay + 1 ) * 7 - ( 7 + ( dayOfWeek + monthLen - dayOfMonth ) - ruleDayOfWeek ) % 7 ; } break ; case DOW_GE_DOM_MODE : ruleDayOfMonth = ruleDay + ( 49 + ruleDayOfWeek - ruleDay - dayOfWeek + dayOfMonth ) % 7 ; break ; case DOW_LE_DOM_MODE : ruleDayOfMonth = ruleDay - ( 49 - ruleDayOfWeek + ruleDay + dayOfWeek - dayOfMonth ) % 7 ; break ; } if ( dayOfMonth < ruleDayOfMonth ) return - 1 ; else if ( dayOfMonth > ruleDayOfMonth ) return 1 ; if ( millis < ruleMillis ) { return - 1 ; } else if ( millis > ruleMillis ) { return 1 ; } else { return 0 ; } }
Compare a given date in the year to a rule . Return 1 0 or - 1 depending on whether the date is after equal to or before the rule date . The millis are compared directly against the ruleMillis so any standard - daylight adjustments must be handled by the caller .
26,644
public boolean inDaylightTime ( Date date ) { GregorianCalendar gc = new GregorianCalendar ( this ) ; gc . setTime ( date ) ; return gc . inDaylightTime ( ) ; }
Overrides TimeZone Queries if the give date is in Daylight Saving Time .
26,645
private void construct ( int _raw , int _startMonth , int _startDay , int _startDayOfWeek , int _startTime , int _startTimeMode , int _endMonth , int _endDay , int _endDayOfWeek , int _endTime , int _endTimeMode , int _dst ) { raw = _raw ; startMonth = _startMonth ; startDay = _startDay ; startDayOfWeek = _startDayOfWeek ; startTime = _startTime ; startTimeMode = _startTimeMode ; endMonth = _endMonth ; endDay = _endDay ; endDayOfWeek = _endDayOfWeek ; endTime = _endTime ; endTimeMode = _endTimeMode ; dst = _dst ; startYear = 0 ; startMode = DOM_MODE ; endMode = DOM_MODE ; decodeRules ( ) ; if ( _dst <= 0 ) { throw new IllegalArgumentException ( ) ; } }
Internal construction method .
26,646
public boolean hasSameRules ( TimeZone othr ) { if ( this == othr ) { return true ; } if ( ! ( othr instanceof SimpleTimeZone ) ) { return false ; } SimpleTimeZone other = ( SimpleTimeZone ) othr ; return other != null && raw == other . raw && useDaylight == other . useDaylight && ( ! useDaylight || ( dst == other . dst && startMode == other . startMode && startMonth == other . startMonth && startDay == other . startDay && startDayOfWeek == other . startDayOfWeek && startTime == other . startTime && startTimeMode == other . startTimeMode && endMode == other . endMode && endMonth == other . endMonth && endDay == other . endDay && endDayOfWeek == other . endDayOfWeek && endTime == other . endTime && endTimeMode == other . endTimeMode && startYear == other . startYear ) ) ; }
Returns true if this zone has the same rules and offset as another zone .
26,647
private static int readFully ( InputStream in , ByteArrayOutputStream bout , int length ) throws IOException { int read = 0 ; byte [ ] buffer = new byte [ 2048 ] ; while ( length > 0 ) { int n = in . read ( buffer , 0 , length < 2048 ? length : 2048 ) ; if ( n <= 0 ) { break ; } bout . write ( buffer , 0 , n ) ; read += n ; length -= n ; } return read ; }
Read from the stream until length bytes have been read or EOF has been reached . Return the number of bytes actually read .
26,648
public static synchronized X509CertImpl intern ( X509Certificate c ) throws CertificateException { if ( c == null ) { return null ; } boolean isImpl = c instanceof X509CertImpl ; byte [ ] encoding ; if ( isImpl ) { encoding = ( ( X509CertImpl ) c ) . getEncodedInternal ( ) ; } else { encoding = c . getEncoded ( ) ; } X509CertImpl newC = ( X509CertImpl ) getFromCache ( certCache , encoding ) ; if ( newC != null ) { return newC ; } if ( isImpl ) { newC = ( X509CertImpl ) c ; } else { newC = new X509CertImpl ( encoding ) ; encoding = newC . getEncodedInternal ( ) ; } addToCache ( certCache , encoding , newC ) ; return newC ; }
Return an interned X509CertImpl for the given certificate . If the given X509Certificate or X509CertImpl is already present in the cert cache the cached object is returned . Otherwise if it is a X509Certificate it is first converted to a X509CertImpl . Then the X509CertImpl is added to the cache and returned .
26,649
private static synchronized Object getFromCache ( Cache cache , byte [ ] encoding ) { Object key = new Cache . EqualByteArray ( encoding ) ; Object value = cache . get ( key ) ; return value ; }
Get the X509CertImpl or X509CRLImpl from the cache .
26,650
private static synchronized void addToCache ( Cache cache , byte [ ] encoding , Object value ) { if ( encoding . length > ENC_MAX_LENGTH ) { return ; } Object key = new Cache . EqualByteArray ( encoding ) ; cache . put ( key , value ) ; }
Add the X509CertImpl or X509CRLImpl to the cache .
26,651
private static byte [ ] readOneBlock ( InputStream is ) throws IOException { int c = is . read ( ) ; if ( c == - 1 ) { return null ; } if ( c == DerValue . tag_Sequence ) { ByteArrayOutputStream bout = new ByteArrayOutputStream ( 2048 ) ; bout . write ( c ) ; readBERInternal ( is , bout , c ) ; return bout . toByteArray ( ) ; } else { char [ ] data = new char [ 2048 ] ; int pos = 0 ; int hyphen = ( c == '-' ) ? 1 : 0 ; int last = ( c == '-' ) ? - 1 : c ; while ( true ) { int next = is . read ( ) ; if ( next == - 1 ) { return null ; } if ( next == '-' ) { hyphen ++ ; } else { hyphen = 0 ; last = next ; } if ( hyphen == 5 && ( last == - 1 || last == '\r' || last == '\n' ) ) { break ; } } int end ; StringBuffer header = new StringBuffer ( "-----" ) ; while ( true ) { int next = is . read ( ) ; if ( next == - 1 ) { throw new IOException ( "Incomplete data" ) ; } if ( next == '\n' ) { end = '\n' ; break ; } if ( next == '\r' ) { next = is . read ( ) ; if ( next == - 1 ) { throw new IOException ( "Incomplete data" ) ; } if ( next == '\n' ) { end = '\n' ; } else { end = '\r' ; data [ pos ++ ] = ( char ) next ; } break ; } header . append ( ( char ) next ) ; } while ( true ) { int next = is . read ( ) ; if ( next == - 1 ) { throw new IOException ( "Incomplete data" ) ; } if ( next != '-' ) { data [ pos ++ ] = ( char ) next ; if ( pos >= data . length ) { data = Arrays . copyOf ( data , data . length + 1024 ) ; } } else { break ; } } StringBuffer footer = new StringBuffer ( "-" ) ; while ( true ) { int next = is . read ( ) ; if ( next == - 1 || next == end || next == '\n' ) { break ; } if ( next != '\r' ) footer . append ( ( char ) next ) ; } checkHeaderFooter ( header . toString ( ) , footer . toString ( ) ) ; BASE64Decoder decoder = new BASE64Decoder ( ) ; return decoder . decodeBuffer ( new String ( data , 0 , pos ) ) ; } }
Returns an ASN . 1 SEQUENCE from a stream which might be a BER - encoded binary block or a PEM - style BASE64 - encoded ASCII data . In the latter case it s de - BASE64 ed before return .
26,652
private Object readResolve ( ) { KnownLevel o = KnownLevel . matches ( this ) ; if ( o != null ) { return o . levelObject ; } Level level = new Level ( this . name , this . value , this . resourceBundleName ) ; return level ; }
This is a performance optimization .
26,653
public void reset ( ) { int i ; fOffsets [ 0 ] = 0x0080 ; fOffsets [ 1 ] = 0x00C0 ; fOffsets [ 2 ] = 0x0400 ; fOffsets [ 3 ] = 0x0600 ; fOffsets [ 4 ] = 0x0900 ; fOffsets [ 5 ] = 0x3040 ; fOffsets [ 6 ] = 0x30A0 ; fOffsets [ 7 ] = 0xFF00 ; for ( i = 0 ; i < NUMWINDOWS ; i ++ ) { fTimeStamps [ i ] = 0 ; } for ( i = 0 ; i <= MAXINDEX ; i ++ ) { fIndexCount [ i ] = 0 ; } fTimeStamp = 0 ; fCurrentWindow = 0 ; fMode = SINGLEBYTEMODE ; }
Reset the compressor to its initial state .
26,654
private int findDynamicWindow ( int c ) { for ( int i = NUMWINDOWS - 1 ; i >= 0 ; -- i ) { if ( inDynamicWindow ( c , i ) ) { ++ fTimeStamps [ i ] ; return i ; } } return INVALIDWINDOW ; }
Determine if a dynamic window for a certain character is defined
26,655
private static int findStaticWindow ( int c ) { for ( int i = NUMSTATICWINDOWS - 1 ; i >= 0 ; -- i ) { if ( inStaticWindow ( c , i ) ) { return i ; } } return INVALIDWINDOW ; }
Determine if a static window for a certain character is defined
26,656
private int getLRDefinedWindow ( ) { int leastRU = Integer . MAX_VALUE ; int whichWindow = INVALIDWINDOW ; for ( int i = NUMWINDOWS - 1 ; i >= 0 ; -- i ) { if ( fTimeStamps [ i ] < leastRU ) { leastRU = fTimeStamps [ i ] ; whichWindow = i ; } } return whichWindow ; }
Find the least - recently defined window
26,657
public char setIndex ( int location ) { if ( location < start || location > end ) { throw new IllegalArgumentException ( ) ; } offset = location ; if ( offset == end ) { return DONE ; } return string . charAt ( offset ) ; }
Sets the current index in the source string .
26,658
public void setText ( String value ) { string = value ; start = offset = 0 ; end = value . length ( ) ; }
Sets the source string to iterate over . The begin and end positions are set to the start and end of this string .
26,659
public static long getTimeScaleValue ( int scale , int value ) { TimeScaleData data = getTimeScaleData ( scale ) ; switch ( value ) { case UNITS_VALUE : return data . units ; case EPOCH_OFFSET_VALUE : return data . epochOffset ; case FROM_MIN_VALUE : return data . fromMin ; case FROM_MAX_VALUE : return data . fromMax ; case TO_MIN_VALUE : return data . toMin ; case TO_MAX_VALUE : return data . toMax ; case EPOCH_OFFSET_PLUS_1_VALUE : return data . epochOffsetP1 ; case EPOCH_OFFSET_MINUS_1_VALUE : return data . epochOffsetM1 ; case UNITS_ROUND_VALUE : return data . unitsRound ; case MIN_ROUND_VALUE : return data . minRound ; case MAX_ROUND_VALUE : return data . maxRound ; default : throw new IllegalArgumentException ( "value out of range: " + value ) ; } }
Get a value associated with a particular time scale .
26,660
public static BigDecimal toBigDecimalTrunc ( BigDecimal universalTime , int timeScale ) { TimeScaleData data = getTimeScaleData ( timeScale ) ; BigDecimal units = new BigDecimal ( data . units ) ; BigDecimal epochOffset = new BigDecimal ( data . epochOffset ) ; return universalTime . divide ( units , BigDecimal . ROUND_DOWN ) . subtract ( epochOffset ) ; }
Convert a time in the Universal Time Scale into another time scale . The division used to do the conversion rounds down .
26,661
public XObject execute ( XPathContext xctxt ) throws javax . xml . transform . TransformerException { XObject expr1 = m_left . execute ( xctxt ) ; if ( expr1 . bool ( ) ) { XObject expr2 = m_right . execute ( xctxt ) ; return expr2 . bool ( ) ? XBoolean . S_TRUE : XBoolean . S_FALSE ; } else return XBoolean . S_FALSE ; }
AND two expressions and return the boolean result . Override superclass method for optimization purposes .
26,662
public static void setBlocking ( FileDescriptor fd , boolean blocking ) throws IOException { try { int flags = Libcore . os . fcntlVoid ( fd , F_GETFL ) ; if ( ! blocking ) { flags |= O_NONBLOCK ; } else { flags &= ~ O_NONBLOCK ; } Libcore . os . fcntlLong ( fd , F_SETFL , flags ) ; } catch ( ErrnoException errnoException ) { throw errnoException . rethrowAsIOException ( ) ; } }
Sets fd to be blocking or non - blocking according to the state of blocking .
26,663
public final void initSign ( PrivateKey privateKey , SecureRandom random ) throws InvalidKeyException { engineInitSign ( privateKey , random ) ; state = SIGN ; }
Initialize this object for signing . If this method is called again with a different argument it negates the effect of this call .
26,664
public final void update ( byte b ) throws SignatureException { if ( state == VERIFY || state == SIGN ) { engineUpdate ( b ) ; } else { throw new SignatureException ( "object not initialized for " + "signature or verification" ) ; } }
Updates the data to be signed or verified by a byte .
26,665
public final void update ( byte [ ] data , int off , int len ) throws SignatureException { if ( state == SIGN || state == VERIFY ) { if ( data == null ) { throw new IllegalArgumentException ( "data is null" ) ; } if ( off < 0 || len < 0 ) { throw new IllegalArgumentException ( "off or len is less than 0" ) ; } if ( data . length - off < len ) { throw new IllegalArgumentException ( "data too small for specified offset and length" ) ; } engineUpdate ( data , off , len ) ; } else { throw new SignatureException ( "object not initialized for " + "signature or verification" ) ; } }
Updates the data to be signed or verified using the specified array of bytes starting at the specified offset .
26,666
int getPreviouslyCounted ( XPathContext support , int node ) { int n = m_countNodes . size ( ) ; m_countResult = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { int countedNode = m_countNodes . elementAt ( i ) ; if ( node == countedNode ) { m_countResult = i + 1 + m_countNodesStartCount ; break ; } DTM dtm = support . getDTM ( countedNode ) ; if ( dtm . isNodeAfter ( countedNode , node ) ) break ; } return m_countResult ; }
Try and find a node that was previously counted . If found return a positive integer that corresponds to the count .
26,667
int getLast ( ) { int size = m_countNodes . size ( ) ; return ( size > 0 ) ? m_countNodes . elementAt ( size - 1 ) : DTM . NULL ; }
Get the last node in the list .
26,668
private void pushRun ( int runBase , int runLen ) { this . runBase [ stackSize ] = runBase ; this . runLen [ stackSize ] = runLen ; stackSize ++ ; }
Pushes the specified run onto the pending - run stack .
26,669
private void mergeForceCollapse ( ) { while ( stackSize > 1 ) { int n = stackSize - 2 ; if ( n > 0 && runLen [ n - 1 ] < runLen [ n + 1 ] ) n -- ; mergeAt ( n ) ; } }
Merges all runs on the stack until only one remains . This method is called once to complete the sort .
26,670
public void setChoices ( double [ ] limits , String formats [ ] ) { if ( limits . length != formats . length ) { throw new IllegalArgumentException ( "Array and limit arrays must be of the same length." ) ; } choiceLimits = limits ; choiceFormats = formats ; }
Set the choices to be used in formatting .
26,671
public StringBuffer format ( double number , StringBuffer toAppendTo , FieldPosition status ) { int i ; for ( i = 0 ; i < choiceLimits . length ; ++ i ) { if ( ! ( number >= choiceLimits [ i ] ) ) { break ; } } -- i ; if ( i < 0 ) i = 0 ; return toAppendTo . append ( choiceFormats [ i ] ) ; }
Returns pattern with formatted double .
26,672
public Number parse ( String text , ParsePosition status ) { int start = status . index ; int furthest = start ; double bestNumber = Double . NaN ; double tempNumber = 0.0 ; for ( int i = 0 ; i < choiceFormats . length ; ++ i ) { String tempString = choiceFormats [ i ] ; if ( text . regionMatches ( start , tempString , 0 , tempString . length ( ) ) ) { status . index = start + tempString . length ( ) ; tempNumber = choiceLimits [ i ] ; if ( status . index > furthest ) { furthest = status . index ; bestNumber = tempNumber ; if ( furthest == text . length ( ) ) break ; } } } status . index = furthest ; if ( status . index == start ) { status . errorIndex = furthest ; } return new Double ( bestNumber ) ; }
Parses a Number from the input text .
26,673
public void play ( int port ) throws IOException { if ( acceptExecutor != null ) { throw new IllegalStateException ( "play() already called" ) ; } acceptExecutor = Executors . newSingleThreadExecutor ( ) ; requestExecutor = Executors . newFixedThreadPool ( workerThreads ) ; serverSocket = new ServerSocket ( port ) ; serverSocket . setReuseAddress ( true ) ; this . port = serverSocket . getLocalPort ( ) ; acceptExecutor . execute ( namedRunnable ( "MockWebServer-accept-" + port , new Runnable ( ) { public void run ( ) { try { acceptConnections ( ) ; } catch ( Throwable e ) { logger . log ( Level . WARNING , "MockWebServer connection failed" , e ) ; } try { serverSocket . close ( ) ; } catch ( Throwable e ) { logger . log ( Level . WARNING , "MockWebServer server socket close failed" , e ) ; } for ( Iterator < Socket > s = openClientSockets . keySet ( ) . iterator ( ) ; s . hasNext ( ) ; ) { try { s . next ( ) . close ( ) ; s . remove ( ) ; } catch ( Throwable e ) { logger . log ( Level . WARNING , "MockWebServer socket close failed" , e ) ; } } try { acceptExecutor . shutdown ( ) ; } catch ( Throwable e ) { logger . log ( Level . WARNING , "MockWebServer acceptExecutor shutdown failed" , e ) ; } try { requestExecutor . shutdown ( ) ; } catch ( Throwable e ) { logger . log ( Level . WARNING , "MockWebServer requestExecutor shutdown failed" , e ) ; } } private void acceptConnections ( ) throws Exception { while ( true ) { Socket socket ; try { socket = serverSocket . accept ( ) ; } catch ( SocketException e ) { return ; } SocketPolicy socketPolicy = dispatcher . peek ( ) . getSocketPolicy ( ) ; if ( socketPolicy == DISCONNECT_AT_START ) { dispatchBookkeepingRequest ( 0 , socket ) ; socket . close ( ) ; } else { openClientSockets . put ( socket , true ) ; serveConnection ( socket ) ; } } } } ) ) ; }
Starts the server serves all enqueued requests and shuts the server down .
26,674
public void putAll ( Map < ? , ? > attr ) { if ( ! Attributes . class . isInstance ( attr ) ) throw new ClassCastException ( ) ; for ( Map . Entry < ? , ? > me : ( attr ) . entrySet ( ) ) put ( me . getKey ( ) , me . getValue ( ) ) ; }
Copies all of the attribute name - value mappings from the specified Attributes to this Map . Duplicate mappings will be replaced .
26,675
public static void fatalError ( Throwable error , String path ) { StringWriter msg = new StringWriter ( ) ; PrintWriter writer = new PrintWriter ( msg ) ; writer . println ( String . format ( "internal error translating \"%s\"" , path ) ) ; error . printStackTrace ( writer ) ; writer . flush ( ) ; error ( msg . toString ( ) ) ; }
Report that an internal error happened when translating a specific source .
26,676
private int defaultThreadID ( ) { long tid = Thread . currentThread ( ) . getId ( ) ; if ( tid < MIN_SEQUENTIAL_THREAD_ID ) { return ( int ) tid ; } else { Integer id = threadIds . get ( ) ; if ( id == null ) { id = nextThreadId . getAndIncrement ( ) ; threadIds . set ( id ) ; } return id ; } }
Returns the default value for a new LogRecord s threadID .
26,677
public void setBreakIterator ( BreakIterator breakiter ) { search_ . setBreakIter ( breakiter ) ; if ( search_ . breakIter ( ) != null ) { if ( search_ . text ( ) != null ) { search_ . breakIter ( ) . setText ( ( CharacterIterator ) search_ . text ( ) . clone ( ) ) ; } } }
Set the BreakIterator that will be used to restrict the points at which matches are detected .
26,678
public void setTarget ( CharacterIterator text ) { if ( text == null || text . getEndIndex ( ) == text . getIndex ( ) ) { throw new IllegalArgumentException ( "Illegal null or empty text" ) ; } text . setIndex ( text . getBeginIndex ( ) ) ; search_ . setTarget ( text ) ; search_ . matchedIndex_ = DONE ; search_ . setMatchedLength ( 0 ) ; search_ . reset_ = true ; search_ . isForwardSearching_ = true ; if ( search_ . breakIter ( ) != null ) { search_ . breakIter ( ) . setText ( ( CharacterIterator ) text . clone ( ) ) ; } if ( search_ . internalBreakIter_ != null ) { search_ . internalBreakIter_ . setText ( ( CharacterIterator ) text . clone ( ) ) ; } }
Set the target text to be searched . Text iteration will then begin at the start of the text string . This method is useful if you want to reuse an iterator to search within a different body of text .
26,679
public void reset ( ) { setMatchNotFound ( ) ; setIndex ( search_ . beginIndex ( ) ) ; search_ . isOverlap_ = false ; search_ . isCanonicalMatch_ = false ; search_ . elementComparisonType_ = ElementComparisonType . STANDARD_ELEMENT_COMPARISON ; search_ . isForwardSearching_ = true ; search_ . reset_ = true ; }
Resets the iteration . Search will begin at the start of the text string if a forward iteration is initiated before a backwards iteration . Otherwise if a backwards iteration is initiated before a forwards iteration the search will begin at the end of the text string .
26,680
public void encode ( OutputStream out ) throws IOException { if ( notBefore == null || notAfter == null ) { throw new IOException ( "CertAttrSet:CertificateValidity:" + " null values to encode.\n" ) ; } DerOutputStream pair = new DerOutputStream ( ) ; if ( notBefore . getTime ( ) < YR_2050 ) { pair . putUTCTime ( notBefore ) ; } else pair . putGeneralizedTime ( notBefore ) ; if ( notAfter . getTime ( ) < YR_2050 ) { pair . putUTCTime ( notAfter ) ; } else { pair . putGeneralizedTime ( notAfter ) ; } DerOutputStream seq = new DerOutputStream ( ) ; seq . write ( DerValue . tag_Sequence , pair ) ; out . write ( seq . toByteArray ( ) ) ; }
Encode the CertificateValidity period in DER form to the stream .
26,681
public void reset ( ) { endRange = set . getRangeCount ( ) - 1 ; range = 0 ; endElement = - 1 ; nextElement = 0 ; if ( endRange >= 0 ) { loadRange ( range ) ; } stringIterator = null ; if ( set . strings != null ) { stringIterator = set . strings . iterator ( ) ; if ( ! stringIterator . hasNext ( ) ) { stringIterator = null ; } } }
Resets this iterator to the start of the set .
26,682
public boolean functionAvailable ( String ns , String funcName ) throws javax . xml . transform . TransformerException { try { if ( funcName == null ) { String fmsg = XSLMessages . createXPATHMessage ( XPATHErrorResources . ER_ARG_CANNOT_BE_NULL , new Object [ ] { "Function Name" } ) ; throw new NullPointerException ( fmsg ) ; } javax . xml . namespace . QName myQName = new QName ( ns , funcName ) ; javax . xml . xpath . XPathFunction xpathFunction = resolver . resolveFunction ( myQName , 0 ) ; if ( xpathFunction == null ) { return false ; } return true ; } catch ( Exception e ) { return false ; } }
Is the extension function available?
26,683
public boolean elementAvailable ( String ns , String elemName ) throws javax . xml . transform . TransformerException { return false ; }
Is the extension element available?
26,684
public ZipEntry getNextEntry ( ) throws IOException { JarEntry e ; if ( first == null ) { e = ( JarEntry ) super . getNextEntry ( ) ; if ( tryManifest ) { e = checkManifest ( e ) ; tryManifest = false ; } } else { e = first ; if ( first . getName ( ) . equalsIgnoreCase ( INDEX_NAME ) ) tryManifest = true ; first = null ; } if ( jv != null && e != null ) { if ( jv . nothingToVerify ( ) == true ) { jv = null ; mev = null ; } else { jv . beginEntry ( e , mev ) ; } } return e ; }
Reads the next ZIP file entry and positions the stream at the beginning of the entry data . If verification has been enabled any invalid signature detected while positioning the stream for the next entry will result in an exception .
26,685
public void throwException ( ) throws BufferUnderflowException , BufferOverflowException , UnmappableCharacterException , MalformedInputException , CharacterCodingException { switch ( this . type ) { case TYPE_UNDERFLOW : throw new BufferUnderflowException ( ) ; case TYPE_OVERFLOW : throw new BufferOverflowException ( ) ; case TYPE_UNMAPPABLE_CHAR : throw new UnmappableCharacterException ( this . length ) ; case TYPE_MALFORMED_INPUT : throw new MalformedInputException ( this . length ) ; default : throw new CharacterCodingException ( ) ; } }
Throws an exception corresponding to this coder result .
26,686
public boolean get ( int key , boolean valueIfKeyNotFound ) { int i = ContainerHelpers . binarySearch ( mKeys , mSize , key ) ; if ( i < 0 ) { return valueIfKeyNotFound ; } else { return mValues [ i ] ; } }
Gets the boolean mapped from the specified key or the specified value if no such mapping has been made .
26,687
public final void normalize ( ) { Node next ; for ( Node node = getFirstChild ( ) ; node != null ; node = next ) { next = node . getNextSibling ( ) ; node . normalize ( ) ; if ( node . getNodeType ( ) == Node . TEXT_NODE ) { ( ( TextImpl ) node ) . minimize ( ) ; } } }
Normalize the text nodes within this subtree . Although named similarly this method is unrelated to Document . normalize .
26,688
public void encode ( OutputStream out ) throws IOException { DerOutputStream tmp = new DerOutputStream ( ) ; if ( extensionValue == null ) { this . extensionId = PKIXExtensions . BasicConstraints_Id ; if ( ca ) { critical = true ; } else { critical = false ; } encodeThis ( ) ; } super . encode ( tmp ) ; out . write ( tmp . toByteArray ( ) ) ; }
Encode this extension value to the output stream .
26,689
public void addAttribute ( Attribute attribute , Object value ) { if ( attribute == null ) { throw new NullPointerException ( ) ; } int len = length ( ) ; if ( len == 0 ) { throw new IllegalArgumentException ( "Can't add attribute to 0-length text" ) ; } addAttributeImpl ( attribute , value , 0 , len ) ; }
Adds an attribute to the entire string .
26,690
public void addAttribute ( Attribute attribute , Object value , int beginIndex , int endIndex ) { if ( attribute == null ) { throw new NullPointerException ( ) ; } if ( beginIndex < 0 || endIndex > length ( ) || beginIndex >= endIndex ) { throw new IllegalArgumentException ( "Invalid substring range" ) ; } addAttributeImpl ( attribute , value , beginIndex , endIndex ) ; }
Adds an attribute to a subrange of the string .
26,691
public void addAttributes ( Map < ? extends Attribute , ? > attributes , int beginIndex , int endIndex ) { if ( attributes == null ) { throw new NullPointerException ( ) ; } if ( beginIndex < 0 || endIndex > length ( ) || beginIndex > endIndex ) { throw new IllegalArgumentException ( "Invalid substring range" ) ; } if ( beginIndex == endIndex ) { if ( attributes . isEmpty ( ) ) return ; throw new IllegalArgumentException ( "Can't add attribute to 0-length text" ) ; } if ( runCount == 0 ) { createRunAttributeDataVectors ( ) ; } int beginRunIndex = ensureRunBreak ( beginIndex ) ; int endRunIndex = ensureRunBreak ( endIndex ) ; Iterator iterator = attributes . entrySet ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { Map . Entry entry = ( Map . Entry ) iterator . next ( ) ; addAttributeRunData ( ( Attribute ) entry . getKey ( ) , entry . getValue ( ) , beginRunIndex , endRunIndex ) ; } }
Adds a set of attributes to a subrange of the string .
26,692
public AttributedCharacterIterator getIterator ( Attribute [ ] attributes , int beginIndex , int endIndex ) { return new AttributedStringIterator ( attributes , beginIndex , endIndex ) ; }
Creates an AttributedCharacterIterator instance that provides access to selected contents of this string . Information about attributes not listed in attributes that the implementor may have need not be made accessible through the iterator . If the list is null all available attribute information should be made accessible .
26,693
private Object getAttributeCheckRange ( Attribute attribute , int runIndex , int beginIndex , int endIndex ) { Object value = getAttribute ( attribute , runIndex ) ; if ( value instanceof Annotation ) { if ( beginIndex > 0 ) { int currIndex = runIndex ; int runStart = runStarts [ currIndex ] ; while ( runStart >= beginIndex && valuesMatch ( value , getAttribute ( attribute , currIndex - 1 ) ) ) { currIndex -- ; runStart = runStarts [ currIndex ] ; } if ( runStart < beginIndex ) { return null ; } } int textLength = length ( ) ; if ( endIndex < textLength ) { int currIndex = runIndex ; int runLimit = ( currIndex < runCount - 1 ) ? runStarts [ currIndex + 1 ] : textLength ; while ( runLimit <= endIndex && valuesMatch ( value , getAttribute ( attribute , currIndex + 1 ) ) ) { currIndex ++ ; runLimit = ( currIndex < runCount - 1 ) ? runStarts [ currIndex + 1 ] : textLength ; } if ( runLimit > endIndex ) { return null ; } } } return value ; }
gets an attribute value but returns an annotation only if it s range does not extend outside the range beginIndex .. endIndex
26,694
private boolean attributeValuesMatch ( Set attributes , int runIndex1 , int runIndex2 ) { Iterator iterator = attributes . iterator ( ) ; while ( iterator . hasNext ( ) ) { Attribute key = ( Attribute ) iterator . next ( ) ; if ( ! valuesMatch ( getAttribute ( key , runIndex1 ) , getAttribute ( key , runIndex2 ) ) ) { return false ; } } return true ; }
returns whether all specified attributes have equal values in the runs with the given indices
26,695
private final static boolean valuesMatch ( Object value1 , Object value2 ) { if ( value1 == null ) { return value2 == null ; } else { return value1 . equals ( value2 ) ; } }
returns whether the two objects are either both null or equal
26,696
private final void appendContents ( StringBuffer buf , CharacterIterator iterator ) { int index = iterator . getBeginIndex ( ) ; int end = iterator . getEndIndex ( ) ; while ( index < end ) { iterator . setIndex ( index ++ ) ; buf . append ( iterator . current ( ) ) ; } }
Appends the contents of the CharacterIterator iterator into the StringBuffer buf .
26,697
private static boolean mapsDiffer ( Map last , Map attrs ) { if ( last == null ) { return ( attrs != null && attrs . size ( ) > 0 ) ; } return ( ! last . equals ( attrs ) ) ; }
Returns true if the attributes specified in last and attrs differ .
26,698
public static double nextAfter ( double start , double direction ) { if ( Double . isNaN ( start ) || Double . isNaN ( direction ) ) { return start + direction ; } else if ( start == direction ) { return direction ; } else { long transducer = Double . doubleToRawLongBits ( start + 0.0d ) ; if ( direction > start ) { transducer = transducer + ( transducer >= 0L ? 1L : - 1L ) ; } else { assert direction < start ; if ( transducer > 0L ) -- transducer ; else if ( transducer < 0L ) ++ transducer ; else transducer = DoubleConsts . SIGN_BIT_MASK | 1L ; } return Double . longBitsToDouble ( transducer ) ; } }
Returns the floating - point number adjacent to the first argument in the direction of the second argument . If both arguments compare as equal the second argument is returned .
26,699
public static float nextAfter ( float start , double direction ) { if ( Float . isNaN ( start ) || Double . isNaN ( direction ) ) { return start + ( float ) direction ; } else if ( start == direction ) { return ( float ) direction ; } else { int transducer = Float . floatToRawIntBits ( start + 0.0f ) ; if ( direction > start ) { transducer = transducer + ( transducer >= 0 ? 1 : - 1 ) ; } else { assert direction < start ; if ( transducer > 0 ) -- transducer ; else if ( transducer < 0 ) ++ transducer ; else transducer = FloatConsts . SIGN_BIT_MASK | 1 ; } return Float . intBitsToFloat ( transducer ) ; } }
Returns the floating - point number adjacent to the first argument in the direction of the second argument . If both arguments compare as equal a value equivalent to the second argument is returned .