idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
25,400
public static Function < RequestEnvelope , String > userId ( ) { return r -> Optional . ofNullable ( r ) . map ( RequestEnvelope :: getContext ) . map ( Context :: getSystem ) . map ( SystemState :: getUser ) . map ( User :: getUserId ) . orElseThrow ( ( ) -> new PersistenceException ( "Could not retrieve user ID from request envelope to generate persistence ID" ) ) ; }
Produces a partition key from the user ID contained in an incoming request .
25,401
public static Function < RequestEnvelope , String > deviceId ( ) { return r -> Optional . ofNullable ( r ) . map ( RequestEnvelope :: getContext ) . map ( Context :: getSystem ) . map ( SystemState :: getDevice ) . map ( Device :: getDeviceId ) . orElseThrow ( ( ) -> new PersistenceException ( "Could not retrieve device ID from request envelope to generate persistence ID" ) ) ; }
Produces a partition key from the device ID contained in an incoming request .
25,402
public Plugin create ( final PluginWrapper pluginWrapper ) { String pluginClassName = pluginWrapper . getDescriptor ( ) . getPluginClass ( ) ; log . debug ( "Create instance for plugin '{}'" , pluginClassName ) ; Class < ? > pluginClass ; try { pluginClass = pluginWrapper . getPluginClassLoader ( ) . loadClass ( pluginClassName ) ; } catch ( ClassNotFoundException e ) { log . error ( e . getMessage ( ) , e ) ; return null ; } int modifiers = pluginClass . getModifiers ( ) ; if ( Modifier . isAbstract ( modifiers ) || Modifier . isInterface ( modifiers ) || ( ! Plugin . class . isAssignableFrom ( pluginClass ) ) ) { log . error ( "The plugin class '{}' is not valid" , pluginClassName ) ; return null ; } try { Constructor < ? > constructor = pluginClass . getConstructor ( PluginWrapper . class ) ; return ( Plugin ) constructor . newInstance ( pluginWrapper ) ; } catch ( Exception e ) { log . error ( e . getMessage ( ) , e ) ; } return null ; }
Creates a plugin instance . If an error occurs than that error is logged and the method returns null .
25,403
public void addVertex ( V vertex ) { if ( containsVertex ( vertex ) ) { return ; } neighbors . put ( vertex , new ArrayList < V > ( ) ) ; }
Add a vertex to the graph . Nothing happens if vertex is already in graph .
25,404
public void addEdge ( V from , V to ) { addVertex ( from ) ; addVertex ( to ) ; neighbors . get ( from ) . add ( to ) ; }
Add an edge to the graph ; if either vertex does not exist it s added . This implementation allows the creation of multi - edges and self - loops .
25,405
public void removeEdge ( V from , V to ) { if ( ! containsVertex ( from ) ) { throw new IllegalArgumentException ( "Nonexistent vertex " + from ) ; } if ( ! containsVertex ( to ) ) { throw new IllegalArgumentException ( "Nonexistent vertex " + to ) ; } neighbors . get ( from ) . remove ( to ) ; }
Remove an edge from the graph . Nothing happens if no such edge .
25,406
public List < PluginWrapper > getPlugins ( PluginState pluginState ) { List < PluginWrapper > plugins = new ArrayList < > ( ) ; for ( PluginWrapper plugin : getPlugins ( ) ) { if ( pluginState . equals ( plugin . getPluginState ( ) ) ) { plugins . add ( plugin ) ; } } return plugins ; }
Returns a copy of plugins with that state .
25,407
public void loadPlugins ( ) { log . debug ( "Lookup plugins in '{}'" , pluginsRoot ) ; if ( Files . notExists ( pluginsRoot ) || ! Files . isDirectory ( pluginsRoot ) ) { log . warn ( "No '{}' root" , pluginsRoot ) ; return ; } List < Path > pluginPaths = pluginRepository . getPluginPaths ( ) ; if ( pluginPaths . isEmpty ( ) ) { log . info ( "No plugins" ) ; return ; } log . debug ( "Found {} possible plugins: {}" , pluginPaths . size ( ) , pluginPaths ) ; for ( Path pluginPath : pluginPaths ) { try { loadPluginFromPath ( pluginPath ) ; } catch ( PluginException e ) { log . error ( e . getMessage ( ) , e ) ; } } try { resolvePlugins ( ) ; } catch ( PluginException e ) { log . error ( e . getMessage ( ) , e ) ; } }
Load plugins .
25,408
public void startPlugins ( ) { for ( PluginWrapper pluginWrapper : resolvedPlugins ) { PluginState pluginState = pluginWrapper . getPluginState ( ) ; if ( ( PluginState . DISABLED != pluginState ) && ( PluginState . STARTED != pluginState ) ) { try { log . info ( "Start plugin '{}'" , getPluginLabel ( pluginWrapper . getDescriptor ( ) ) ) ; pluginWrapper . getPlugin ( ) . start ( ) ; pluginWrapper . setPluginState ( PluginState . STARTED ) ; startedPlugins . add ( pluginWrapper ) ; firePluginStateEvent ( new PluginStateEvent ( this , pluginWrapper , pluginState ) ) ; } catch ( Exception e ) { log . error ( e . getMessage ( ) , e ) ; } } } }
Start all active plugins .
25,409
public PluginState startPlugin ( String pluginId ) { checkPluginId ( pluginId ) ; PluginWrapper pluginWrapper = getPlugin ( pluginId ) ; PluginDescriptor pluginDescriptor = pluginWrapper . getDescriptor ( ) ; PluginState pluginState = pluginWrapper . getPluginState ( ) ; if ( PluginState . STARTED == pluginState ) { log . debug ( "Already started plugin '{}'" , getPluginLabel ( pluginDescriptor ) ) ; return PluginState . STARTED ; } if ( ! resolvedPlugins . contains ( pluginWrapper ) ) { log . warn ( "Cannot start an unresolved plugin '{}'" , getPluginLabel ( pluginDescriptor ) ) ; return pluginState ; } if ( PluginState . DISABLED == pluginState ) { if ( ! enablePlugin ( pluginId ) ) { return pluginState ; } } for ( PluginDependency dependency : pluginDescriptor . getDependencies ( ) ) { startPlugin ( dependency . getPluginId ( ) ) ; } try { log . info ( "Start plugin '{}'" , getPluginLabel ( pluginDescriptor ) ) ; pluginWrapper . getPlugin ( ) . start ( ) ; pluginWrapper . setPluginState ( PluginState . STARTED ) ; startedPlugins . add ( pluginWrapper ) ; firePluginStateEvent ( new PluginStateEvent ( this , pluginWrapper , pluginState ) ) ; } catch ( PluginException e ) { log . error ( e . getMessage ( ) , e ) ; } return pluginWrapper . getPluginState ( ) ; }
Start the specified plugin and its dependencies .
25,410
public void stopPlugins ( ) { Collections . reverse ( startedPlugins ) ; Iterator < PluginWrapper > itr = startedPlugins . iterator ( ) ; while ( itr . hasNext ( ) ) { PluginWrapper pluginWrapper = itr . next ( ) ; PluginState pluginState = pluginWrapper . getPluginState ( ) ; if ( PluginState . STARTED == pluginState ) { try { log . info ( "Stop plugin '{}'" , getPluginLabel ( pluginWrapper . getDescriptor ( ) ) ) ; pluginWrapper . getPlugin ( ) . stop ( ) ; pluginWrapper . setPluginState ( PluginState . STOPPED ) ; itr . remove ( ) ; firePluginStateEvent ( new PluginStateEvent ( this , pluginWrapper , pluginState ) ) ; } catch ( PluginException e ) { log . error ( e . getMessage ( ) , e ) ; } } } }
Stop all active plugins .
25,411
protected String idForPath ( Path pluginPath ) { for ( PluginWrapper plugin : plugins . values ( ) ) { if ( plugin . getPluginPath ( ) . equals ( pluginPath ) ) { return plugin . getPluginId ( ) ; } } return null ; }
Tests for already loaded plugins on given path .
25,412
protected void validatePluginDescriptor ( PluginDescriptor descriptor ) throws PluginException { if ( StringUtils . isNullOrEmpty ( descriptor . getPluginId ( ) ) ) { throw new PluginException ( "Field 'id' cannot be empty" ) ; } if ( descriptor . getVersion ( ) == null ) { throw new PluginException ( "Field 'version' cannot be empty" ) ; } }
Override this to change the validation criteria .
25,413
public static Path findWithEnding ( Path basePath , String ... endings ) { for ( String ending : endings ) { Path newPath = basePath . resolveSibling ( basePath . getFileName ( ) + ending ) ; if ( Files . exists ( newPath ) ) { return newPath ; } } return null ; }
Finds a path with various endings or null if not found .
25,414
public static boolean isZipFile ( Path path ) { return Files . isRegularFile ( path ) && path . toString ( ) . toLowerCase ( ) . endsWith ( ".zip" ) ; }
Return true only if path is a zip file .
25,415
public static boolean isJarFile ( Path path ) { return Files . isRegularFile ( path ) && path . toString ( ) . toLowerCase ( ) . endsWith ( ".jar" ) ; }
Return true only if path is a jar file .
25,416
protected PluginWrapper loadPluginFromPath ( Path pluginPath ) throws PluginException { try { pluginPath = FileUtils . expandIfZip ( pluginPath ) ; } catch ( Exception e ) { log . warn ( "Failed to unzip " + pluginPath , e ) ; return null ; } return super . loadPluginFromPath ( pluginPath ) ; }
Load a plugin from disk . If the path is a zip file first unpack
25,417
protected SSLParameters engineGetSupportedSSLParameters ( ) { SSLSocket socket = getDefaultSocket ( ) ; SSLParameters params = new SSLParameters ( ) ; params . setCipherSuites ( socket . getSupportedCipherSuites ( ) ) ; params . setProtocols ( socket . getSupportedProtocols ( ) ) ; return params ; }
Returns a copy of the SSLParameters indicating the maximum supported settings for this SSL context .
25,418
private static < A , B > Entry < A , B > createEntry ( A text , B field ) { return new SimpleImmutableEntry < > ( text , field ) ; }
Helper method to create an immutable entry .
25,419
private void construct ( DerValue derVal ) throws IOException { if ( derVal . isConstructed ( ) && derVal . isContextSpecific ( ) ) { derVal = derVal . data . getDerValue ( ) ; version = derVal . getInteger ( ) ; if ( derVal . data . available ( ) != 0 ) { throw new IOException ( "X.509 version, bad format" ) ; } } }
Construct the class from the passed DerValue
25,420
public void encode ( OutputStream out ) throws IOException { if ( version == V1 ) { return ; } DerOutputStream tmp = new DerOutputStream ( ) ; tmp . putInteger ( version ) ; DerOutputStream seq = new DerOutputStream ( ) ; seq . write ( DerValue . createTag ( DerValue . TAG_CONTEXT , true , ( byte ) 0 ) , tmp ) ; out . write ( seq . toByteArray ( ) ) ; }
Encode the CertificateVersion period in DER form to the stream .
25,421
public int getIndex ( String uri , String localName ) { int max = length * 5 ; for ( int i = 0 ; i < max ; i += 5 ) { if ( data [ i ] . equals ( uri ) && data [ i + 1 ] . equals ( localName ) ) { return i / 5 ; } } return - 1 ; }
Look up an attribute s index by Namespace name .
25,422
public String getType ( String uri , String localName ) { int max = length * 5 ; for ( int i = 0 ; i < max ; i += 5 ) { if ( data [ i ] . equals ( uri ) && data [ i + 1 ] . equals ( localName ) ) { return data [ i + 3 ] ; } } return null ; }
Look up an attribute s type by Namespace - qualified name .
25,423
public void clear ( ) { if ( data != null ) { for ( int i = 0 ; i < ( length * 5 ) ; i ++ ) data [ i ] = null ; } length = 0 ; }
Clear the attribute list for reuse .
25,424
public void setAttributes ( Attributes atts ) { clear ( ) ; length = atts . getLength ( ) ; if ( length > 0 ) { data = new String [ length * 5 ] ; for ( int i = 0 ; i < length ; i ++ ) { data [ i * 5 ] = atts . getURI ( i ) ; data [ i * 5 + 1 ] = atts . getLocalName ( i ) ; data [ i * 5 + 2 ] = atts . getQName ( i ) ; data [ i * 5 + 3 ] = atts . getType ( i ) ; data [ i * 5 + 4 ] = atts . getValue ( i ) ; } } }
Copy an entire Attributes object .
25,425
public void addAttribute ( String uri , String localName , String qName , String type , String value ) { ensureCapacity ( length + 1 ) ; data [ length * 5 ] = uri ; data [ length * 5 + 1 ] = localName ; data [ length * 5 + 2 ] = qName ; data [ length * 5 + 3 ] = type ; data [ length * 5 + 4 ] = value ; length ++ ; }
Add an attribute to the end of the list .
25,426
public void setAttribute ( int index , String uri , String localName , String qName , String type , String value ) { if ( index >= 0 && index < length ) { data [ index * 5 ] = uri ; data [ index * 5 + 1 ] = localName ; data [ index * 5 + 2 ] = qName ; data [ index * 5 + 3 ] = type ; data [ index * 5 + 4 ] = value ; } else { badIndex ( index ) ; } }
Set an attribute in the list .
25,427
public void setURI ( int index , String uri ) { if ( index >= 0 && index < length ) { data [ index * 5 ] = uri ; } else { badIndex ( index ) ; } }
Set the Namespace URI of a specific attribute .
25,428
public void setLocalName ( int index , String localName ) { if ( index >= 0 && index < length ) { data [ index * 5 + 1 ] = localName ; } else { badIndex ( index ) ; } }
Set the local name of a specific attribute .
25,429
public void setQName ( int index , String qName ) { if ( index >= 0 && index < length ) { data [ index * 5 + 2 ] = qName ; } else { badIndex ( index ) ; } }
Set the qualified name of a specific attribute .
25,430
public void setType ( int index , String type ) { if ( index >= 0 && index < length ) { data [ index * 5 + 3 ] = type ; } else { badIndex ( index ) ; } }
Set the type of a specific attribute .
25,431
public void setValue ( int index , String value ) { if ( index >= 0 && index < length ) { data [ index * 5 + 4 ] = value ; } else { badIndex ( index ) ; } }
Set the value of a specific attribute .
25,432
private void ensureCapacity ( int n ) { if ( n <= 0 ) { return ; } int max ; if ( data == null || data . length == 0 ) { max = 25 ; } else if ( data . length >= n * 5 ) { return ; } else { max = data . length ; } while ( max < n * 5 ) { max *= 2 ; } String newData [ ] = new String [ max ] ; if ( length > 0 ) { System . arraycopy ( data , 0 , newData , 0 , length * 5 ) ; } data = newData ; }
Ensure the internal array s capacity .
25,433
protected void read ( UCharacterName data ) throws IOException { m_tokenstringindex_ = m_byteBuffer_ . getInt ( ) ; m_groupindex_ = m_byteBuffer_ . getInt ( ) ; m_groupstringindex_ = m_byteBuffer_ . getInt ( ) ; m_algnamesindex_ = m_byteBuffer_ . getInt ( ) ; int count = m_byteBuffer_ . getChar ( ) ; char token [ ] = ICUBinary . getChars ( m_byteBuffer_ , count , 0 ) ; int size = m_groupindex_ - m_tokenstringindex_ ; byte tokenstr [ ] = new byte [ size ] ; m_byteBuffer_ . get ( tokenstr ) ; data . setToken ( token , tokenstr ) ; count = m_byteBuffer_ . getChar ( ) ; data . setGroupCountSize ( count , GROUP_INFO_SIZE_ ) ; count *= GROUP_INFO_SIZE_ ; char group [ ] = ICUBinary . getChars ( m_byteBuffer_ , count , 0 ) ; size = m_algnamesindex_ - m_groupstringindex_ ; byte groupstring [ ] = new byte [ size ] ; m_byteBuffer_ . get ( groupstring ) ; data . setGroup ( group , groupstring ) ; count = m_byteBuffer_ . getInt ( ) ; UCharacterName . AlgorithmName alg [ ] = new UCharacterName . AlgorithmName [ count ] ; for ( int i = 0 ; i < count ; i ++ ) { UCharacterName . AlgorithmName an = readAlg ( ) ; if ( an == null ) { throw new IOException ( "unames.icu read error: Algorithmic names creation error" ) ; } alg [ i ] = an ; } data . setAlgorithm ( alg ) ; }
Read and break up the stream of data passed in as arguments and fills up UCharacterName . If unsuccessful false will be returned .
25,434
private UCharacterName . AlgorithmName readAlg ( ) throws IOException { UCharacterName . AlgorithmName result = new UCharacterName . AlgorithmName ( ) ; int rangestart = m_byteBuffer_ . getInt ( ) ; int rangeend = m_byteBuffer_ . getInt ( ) ; byte type = m_byteBuffer_ . get ( ) ; byte variant = m_byteBuffer_ . get ( ) ; if ( ! result . setInfo ( rangestart , rangeend , type , variant ) ) { return null ; } int size = m_byteBuffer_ . getChar ( ) ; if ( type == UCharacterName . AlgorithmName . TYPE_1_ ) { char factor [ ] = ICUBinary . getChars ( m_byteBuffer_ , variant , 0 ) ; result . setFactor ( factor ) ; size -= ( variant << 1 ) ; } StringBuilder prefix = new StringBuilder ( ) ; char c = ( char ) ( m_byteBuffer_ . get ( ) & 0x00FF ) ; while ( c != 0 ) { prefix . append ( c ) ; c = ( char ) ( m_byteBuffer_ . get ( ) & 0x00FF ) ; } result . setPrefix ( prefix . toString ( ) ) ; size -= ( ALG_INFO_SIZE_ + prefix . length ( ) + 1 ) ; if ( size > 0 ) { byte string [ ] = new byte [ size ] ; m_byteBuffer_ . get ( string ) ; result . setFactorString ( string ) ; } return result ; }
Reads an individual record of AlgorithmNames
25,435
protected String getMethodSignature ( MethodDeclaration m ) { StringBuilder sb = new StringBuilder ( ) ; ExecutableElement element = m . getExecutableElement ( ) ; char prefix = Modifier . isStatic ( m . getModifiers ( ) ) ? '+' : '-' ; String returnType = nameTable . getObjCType ( element . getReturnType ( ) ) ; String selector = nameTable . getMethodSelector ( element ) ; if ( m . isConstructor ( ) ) { returnType = "instancetype" ; } else if ( selector . equals ( "hash" ) ) { returnType = "NSUInteger" ; } sb . append ( UnicodeUtils . format ( "%c (%s%s)" , prefix , returnType , nullability ( element ) ) ) ; List < SingleVariableDeclaration > params = m . getParameters ( ) ; String [ ] selParts = selector . split ( ":" ) ; if ( params . isEmpty ( ) ) { assert selParts . length == 1 && ! selector . endsWith ( ":" ) ; sb . append ( selParts [ 0 ] ) ; } else { assert params . size ( ) == selParts . length ; int baseLength = sb . length ( ) + selParts [ 0 ] . length ( ) ; for ( int i = 0 ; i < params . size ( ) ; i ++ ) { if ( i != 0 ) { sb . append ( '\n' ) ; sb . append ( pad ( baseLength - selParts [ i ] . length ( ) ) ) ; } VariableElement var = params . get ( i ) . getVariableElement ( ) ; String typeName = nameTable . getObjCType ( var . asType ( ) ) ; sb . append ( UnicodeUtils . format ( "%s:(%s%s)%s" , selParts [ i ] , typeName , nullability ( var ) , nameTable . getVariableShortName ( var ) ) ) ; } } return sb . toString ( ) ; }
Create an Objective - C method signature string .
25,436
public static < K , V > Cache < K , V > newSoftMemoryCache ( int size ) { return new MemoryCache < > ( true , size ) ; }
Return a new memory cache with the specified maximum size unlimited lifetime for entries with the values held by SoftReferences .
25,437
public static < K , V > Cache < K , V > newHardMemoryCache ( int size ) { return new MemoryCache < > ( false , size ) ; }
Return a new memory cache with the specified maximum size unlimited lifetime for entries with the values held by standard references .
25,438
@ SuppressWarnings ( "unchecked" ) public static < K , V > Cache < K , V > newNullCache ( ) { return ( Cache < K , V > ) NullCache . INSTANCE ; }
Return a dummy cache that does nothing .
25,439
private void emptyQueue ( ) { if ( queue == null ) { return ; } int startSize = cacheMap . size ( ) ; while ( true ) { @ SuppressWarnings ( "unchecked" ) CacheEntry < K , V > entry = ( CacheEntry < K , V > ) queue . poll ( ) ; if ( entry == null ) { break ; } K key = entry . getKey ( ) ; if ( key == null ) { continue ; } CacheEntry < K , V > currentEntry = cacheMap . remove ( key ) ; if ( ( currentEntry != null ) && ( entry != currentEntry ) ) { cacheMap . put ( key , currentEntry ) ; } } if ( DEBUG ) { int endSize = cacheMap . size ( ) ; if ( startSize != endSize ) { System . out . println ( "*** Expunged " + ( startSize - endSize ) + " entries, " + endSize + " entries left" ) ; } } }
Empty the reference queue and remove all corresponding entries from the cache .
25,440
private void expungeExpiredEntries ( ) { emptyQueue ( ) ; if ( lifetime == 0 ) { return ; } int cnt = 0 ; long time = System . currentTimeMillis ( ) ; for ( Iterator < CacheEntry < K , V > > t = cacheMap . values ( ) . iterator ( ) ; t . hasNext ( ) ; ) { CacheEntry < K , V > entry = t . next ( ) ; if ( entry . isValid ( time ) == false ) { t . remove ( ) ; cnt ++ ; } } if ( DEBUG ) { if ( cnt != 0 ) { System . out . println ( "Removed " + cnt + " expired entries, remaining " + cacheMap . size ( ) ) ; } } }
Scan all entries and remove all expired ones .
25,441
public synchronized void accept ( CacheVisitor < K , V > visitor ) { expungeExpiredEntries ( ) ; Map < K , V > cached = getCachedEntries ( ) ; visitor . visit ( cached ) ; }
it is a heavyweight method .
25,442
public int currentCodePoint ( ) { int ch = current ( ) ; if ( UTF16 . isLeadSurrogate ( ( char ) ch ) ) { next ( ) ; int ch2 = current ( ) ; previous ( ) ; if ( UTF16 . isTrailSurrogate ( ( char ) ch2 ) ) { return Character . toCodePoint ( ( char ) ch , ( char ) ch2 ) ; } } return ch ; }
Returns the codepoint at the current index . If the current index is invalid DONE is returned . If the current index points to a lead surrogate and there is a following trail surrogate then the code point is returned . Otherwise the code unit at index is returned . Index is not changed .
25,443
protected final int getSurrogateOffset ( char lead , char trail ) { if ( m_dataManipulate_ == null ) { throw new NullPointerException ( "The field DataManipulate in this Trie is null" ) ; } int offset = m_dataManipulate_ . getFoldingOffset ( getLeadValue ( lead ) ) ; if ( offset > 0 ) { return getRawOffset ( offset , ( char ) ( trail & SURROGATE_MASK_ ) ) ; } return - 1 ; }
Gets the offset to the data which the surrogate pair points to .
25,444
public void write ( byte [ ] b , int off , int len ) throws IOException { out . write ( b , off , len ) ; cksum . update ( b , off , len ) ; }
Writes an array of bytes . Will block until the bytes are actually written .
25,445
void addEntry ( SelChImpl sc ) { putDescriptor ( totalChannels , IOUtil . fdVal ( sc . getFD ( ) ) ) ; putEventOps ( totalChannels , 0 ) ; putReventOps ( totalChannels , 0 ) ; totalChannels ++ ; }
Prepare another pollfd struct for use .
25,446
static void replaceEntry ( PollArrayWrapper source , int sindex , PollArrayWrapper target , int tindex ) { target . putDescriptor ( tindex , source . getDescriptor ( sindex ) ) ; target . putEventOps ( tindex , source . getEventOps ( sindex ) ) ; target . putReventOps ( tindex , source . getReventOps ( sindex ) ) ; }
Writes the pollfd entry from the source wrapper at the source index over the entry in the target wrapper at the target index . The source array remains unchanged unless the source array and the target are the same array .
25,447
private final boolean breakExceptionAt ( int n ) { int bestPosn = - 1 ; int bestValue = - 1 ; text . setIndex ( n ) ; backwardsTrie . reset ( ) ; int uch ; if ( ( uch = text . previousCodePoint ( ) ) == ' ' ) { } else { uch = text . nextCodePoint ( ) ; } BytesTrie . Result r = BytesTrie . Result . INTERMEDIATE_VALUE ; while ( ( uch = text . previousCodePoint ( ) ) != UCharacterIterator . DONE && ( ( r = backwardsTrie . nextForCodePoint ( uch ) ) . hasNext ( ) ) ) { if ( r . hasValue ( ) ) { bestPosn = text . getIndex ( ) ; bestValue = backwardsTrie . getValue ( ) ; } } if ( r . matches ( ) ) { bestValue = backwardsTrie . getValue ( ) ; bestPosn = text . getIndex ( ) ; } if ( bestPosn >= 0 ) { if ( bestValue == Builder . MATCH ) { return true ; } else if ( bestValue == Builder . PARTIAL && forwardsPartialTrie != null ) { forwardsPartialTrie . reset ( ) ; BytesTrie . Result rfwd = BytesTrie . Result . INTERMEDIATE_VALUE ; text . setIndex ( bestPosn ) ; while ( ( uch = text . nextCodePoint ( ) ) != BreakIterator . DONE && ( ( rfwd = forwardsPartialTrie . nextForCodePoint ( uch ) ) . hasNext ( ) ) ) { } if ( rfwd . matches ( ) ) { return true ; } } } return false ; }
Is there an exception at this point?
25,448
public static TerribleFailureHandler setWtfHandler ( TerribleFailureHandler handler ) { if ( handler == null ) { throw new NullPointerException ( "handler == null" ) ; } TerribleFailureHandler oldHandler = sWtfHandler ; sWtfHandler = handler ; return oldHandler ; }
Sets the terrible failure handler for testing .
25,449
public final void init ( AlgorithmParameterSpec params , SecureRandom random ) throws InvalidAlgorithmParameterException { if ( serviceIterator == null ) { spi . engineInit ( params , random ) ; return ; } Exception failure = null ; KeyGeneratorSpi mySpi = spi ; do { try { mySpi . engineInit ( params , random ) ; initType = I_PARAMS ; initKeySize = 0 ; initParams = params ; initRandom = random ; return ; } catch ( Exception e ) { if ( failure == null ) { failure = e ; } mySpi = nextSpi ( mySpi , false ) ; } } while ( mySpi != null ) ; if ( failure instanceof InvalidAlgorithmParameterException ) { throw ( InvalidAlgorithmParameterException ) failure ; } if ( failure instanceof RuntimeException ) { throw ( RuntimeException ) failure ; } throw new InvalidAlgorithmParameterException ( "init() failed" , failure ) ; }
Initializes this key generator with the specified parameter set and a user - provided source of randomness .
25,450
public final void init ( int keysize , SecureRandom random ) { if ( serviceIterator == null ) { spi . engineInit ( keysize , random ) ; return ; } RuntimeException failure = null ; KeyGeneratorSpi mySpi = spi ; do { try { mySpi . engineInit ( keysize , random ) ; initType = I_SIZE ; initKeySize = keysize ; initParams = null ; initRandom = random ; return ; } catch ( RuntimeException e ) { if ( failure == null ) { failure = e ; } mySpi = nextSpi ( mySpi , false ) ; } } while ( mySpi != null ) ; throw failure ; }
Initializes this key generator for a certain keysize using a user - provided source of randomness .
25,451
public void reset ( ) { contexts = new Context [ 32 ] ; namespaceDeclUris = false ; contextPos = 0 ; contexts [ contextPos ] = currentContext = new Context ( ) ; currentContext . declarePrefix ( "xml" , XMLNS ) ; }
Reset this Namespace support object for reuse .
25,452
public void pushContext ( ) { int max = contexts . length ; contexts [ contextPos ] . declsOK = false ; contextPos ++ ; if ( contextPos >= max ) { Context newContexts [ ] = new Context [ max * 2 ] ; System . arraycopy ( contexts , 0 , newContexts , 0 , max ) ; max *= 2 ; contexts = newContexts ; } currentContext = contexts [ contextPos ] ; if ( currentContext == null ) { contexts [ contextPos ] = currentContext = new Context ( ) ; } if ( contextPos > 0 ) { currentContext . setParent ( contexts [ contextPos - 1 ] ) ; } }
Start a new Namespace context . The new context will automatically inherit the declarations of its parent context but it will also keep track of which declarations were made within this context .
25,453
public Enumeration getPrefixes ( String uri ) { ArrayList < String > prefixes = new ArrayList < String > ( ) ; Enumeration allPrefixes = getPrefixes ( ) ; while ( allPrefixes . hasMoreElements ( ) ) { String prefix = ( String ) allPrefixes . nextElement ( ) ; if ( uri . equals ( getURI ( prefix ) ) ) { prefixes . add ( prefix ) ; } } return Collections . enumeration ( prefixes ) ; }
Return an enumeration of all prefixes for a given URI whose declarations are active in the current context . This includes declarations from parent contexts that have not been overridden .
25,454
public synchronized static Set < MeasureUnit > getAvailable ( String type ) { populateCache ( ) ; Map < String , MeasureUnit > units = cache . get ( type ) ; return units == null ? Collections . < MeasureUnit > emptySet ( ) : Collections . unmodifiableSet ( new HashSet < MeasureUnit > ( units . values ( ) ) ) ; }
For the given type return the available units .
25,455
public synchronized static Set < MeasureUnit > getAvailable ( ) { Set < MeasureUnit > result = new HashSet < MeasureUnit > ( ) ; for ( String type : new HashSet < String > ( MeasureUnit . getAvailableTypes ( ) ) ) { for ( MeasureUnit unit : MeasureUnit . getAvailable ( type ) ) { result . add ( unit ) ; } } return Collections . unmodifiableSet ( result ) ; }
Get all of the available units . Returned set is unmodifiable .
25,456
public static MeasureUnit resolveUnitPerUnit ( MeasureUnit unit , MeasureUnit perUnit ) { return unitPerUnitToSingleUnit . get ( Pair . of ( unit , perUnit ) ) ; }
For ICU use only .
25,457
public static < T > TerminalOp < T , Boolean > makeRef ( Predicate < ? super T > predicate , MatchKind matchKind ) { Objects . requireNonNull ( predicate ) ; Objects . requireNonNull ( matchKind ) ; class MatchSink extends BooleanTerminalSink < T > { MatchSink ( ) { super ( matchKind ) ; } public void accept ( T t ) { if ( ! stop && predicate . test ( t ) == matchKind . stopOnPredicateMatches ) { stop = true ; value = matchKind . shortCircuitResult ; } } } return new MatchOp < > ( StreamShape . REFERENCE , matchKind , MatchSink :: new ) ; }
Constructs a quantified predicate matcher for a Stream .
25,458
private static double floorOrCeil ( double a , double negativeBoundary , double positiveBoundary , double sign ) { int exponent = Math . getExponent ( a ) ; if ( exponent < 0 ) { return ( ( a == 0.0 ) ? a : ( ( a < 0.0 ) ? negativeBoundary : positiveBoundary ) ) ; } else if ( exponent >= 52 ) { return a ; } assert exponent >= 0 && exponent <= 51 ; long doppel = Double . doubleToRawLongBits ( a ) ; long mask = DoubleConsts . SIGNIF_BIT_MASK >> exponent ; if ( ( mask & doppel ) == 0L ) return a ; else { double result = Double . longBitsToDouble ( doppel & ( ~ mask ) ) ; if ( sign * a > 0.0 ) result = result + sign ; return result ; } }
Internal method to share logic between floor and ceil .
25,459
void dumpAssociationTables ( ) { Enumeration associations = m_patternTable . elements ( ) ; while ( associations . hasMoreElements ( ) ) { TemplateSubPatternAssociation head = ( TemplateSubPatternAssociation ) associations . nextElement ( ) ; while ( null != head ) { System . out . print ( "(" + head . getTargetString ( ) + ", " + head . getPattern ( ) + ")" ) ; head = head . getNext ( ) ; } System . out . println ( "\n....." ) ; } TemplateSubPatternAssociation head = m_wildCardPatterns ; System . out . print ( "wild card list: " ) ; while ( null != head ) { System . out . print ( "(" + head . getTargetString ( ) + ", " + head . getPattern ( ) + ")" ) ; head = head . getNext ( ) ; } System . out . println ( "\n....." ) ; }
Dump all patterns and elements that match those patterns
25,460
public void compose ( StylesheetRoot sroot ) { if ( DEBUG ) { System . out . println ( "Before wildcard insert..." ) ; dumpAssociationTables ( ) ; } if ( null != m_wildCardPatterns ) { Enumeration associations = m_patternTable . elements ( ) ; while ( associations . hasMoreElements ( ) ) { TemplateSubPatternAssociation head = ( TemplateSubPatternAssociation ) associations . nextElement ( ) ; TemplateSubPatternAssociation wild = m_wildCardPatterns ; while ( null != wild ) { try { head = insertAssociationIntoList ( head , ( TemplateSubPatternAssociation ) wild . clone ( ) , true ) ; } catch ( CloneNotSupportedException cnse ) { } wild = wild . getNext ( ) ; } } } if ( DEBUG ) { System . out . println ( "After wildcard insert..." ) ; dumpAssociationTables ( ) ; } }
After all templates have been added this function should be called .
25,461
private TemplateSubPatternAssociation insertAssociationIntoList ( TemplateSubPatternAssociation head , TemplateSubPatternAssociation item , boolean isWildCardInsert ) { double priority = getPriorityOrScore ( item ) ; double workPriority ; int importLevel = item . getImportLevel ( ) ; int docOrder = item . getDocOrderPos ( ) ; TemplateSubPatternAssociation insertPoint = head ; TemplateSubPatternAssociation next ; boolean insertBefore ; while ( true ) { next = insertPoint . getNext ( ) ; if ( null == next ) break ; else { workPriority = getPriorityOrScore ( next ) ; if ( importLevel > next . getImportLevel ( ) ) break ; else if ( importLevel < next . getImportLevel ( ) ) insertPoint = next ; else if ( priority > workPriority ) break ; else if ( priority < workPriority ) insertPoint = next ; else if ( docOrder >= next . getDocOrderPos ( ) ) break ; else insertPoint = next ; } } if ( ( null == next ) || ( insertPoint == head ) ) { workPriority = getPriorityOrScore ( insertPoint ) ; if ( importLevel > insertPoint . getImportLevel ( ) ) insertBefore = true ; else if ( importLevel < insertPoint . getImportLevel ( ) ) insertBefore = false ; else if ( priority > workPriority ) insertBefore = true ; else if ( priority < workPriority ) insertBefore = false ; else if ( docOrder >= insertPoint . getDocOrderPos ( ) ) insertBefore = true ; else insertBefore = false ; } else insertBefore = false ; if ( isWildCardInsert ) { if ( insertBefore ) { item . setNext ( insertPoint ) ; String key = insertPoint . getTargetString ( ) ; item . setTargetString ( key ) ; putHead ( key , item ) ; return item ; } else { item . setNext ( next ) ; insertPoint . setNext ( item ) ; return head ; } } else { if ( insertBefore ) { item . setNext ( insertPoint ) ; if ( insertPoint . isWild ( ) || item . isWild ( ) ) m_wildCardPatterns = item ; else putHead ( item . getTargetString ( ) , item ) ; return item ; } else { item . setNext ( next ) ; insertPoint . setNext ( item ) ; return head ; } } }
Insert the given TemplateSubPatternAssociation into the the linked list . Sort by import precedence then priority then by document order .
25,462
private void insertPatternInTable ( StepPattern pattern , ElemTemplate template ) { String target = pattern . getTargetString ( ) ; if ( null != target ) { String pstring = template . getMatch ( ) . getPatternString ( ) ; TemplateSubPatternAssociation association = new TemplateSubPatternAssociation ( template , pattern , pstring ) ; boolean isWildCard = association . isWild ( ) ; TemplateSubPatternAssociation head = isWildCard ? m_wildCardPatterns : getHead ( target ) ; if ( null == head ) { if ( isWildCard ) m_wildCardPatterns = association ; else putHead ( target , association ) ; } else { insertAssociationIntoList ( head , association , false ) ; } } }
Add a template to the template list .
25,463
private double getPriorityOrScore ( TemplateSubPatternAssociation matchPat ) { double priority = matchPat . getTemplate ( ) . getPriority ( ) ; if ( priority == XPath . MATCH_SCORE_NONE ) { Expression ex = matchPat . getStepPattern ( ) ; if ( ex instanceof NodeTest ) { return ( ( NodeTest ) ex ) . getDefaultScore ( ) ; } } return priority ; }
Given a match pattern and template association return the score of that match . This score or priority can always be statically calculated .
25,464
public TemplateSubPatternAssociation getHead ( XPathContext xctxt , int targetNode , DTM dtm ) { short targetNodeType = dtm . getNodeType ( targetNode ) ; TemplateSubPatternAssociation head ; switch ( targetNodeType ) { case DTM . ELEMENT_NODE : case DTM . ATTRIBUTE_NODE : head = ( TemplateSubPatternAssociation ) m_patternTable . get ( dtm . getLocalName ( targetNode ) ) ; break ; case DTM . TEXT_NODE : case DTM . CDATA_SECTION_NODE : head = m_textPatterns ; break ; case DTM . ENTITY_REFERENCE_NODE : case DTM . ENTITY_NODE : head = ( TemplateSubPatternAssociation ) m_patternTable . get ( dtm . getNodeName ( targetNode ) ) ; break ; case DTM . PROCESSING_INSTRUCTION_NODE : head = ( TemplateSubPatternAssociation ) m_patternTable . get ( dtm . getLocalName ( targetNode ) ) ; break ; case DTM . COMMENT_NODE : head = m_commentPatterns ; break ; case DTM . DOCUMENT_NODE : case DTM . DOCUMENT_FRAGMENT_NODE : head = m_docPatterns ; break ; case DTM . NOTATION_NODE : default : head = ( TemplateSubPatternAssociation ) m_patternTable . get ( dtm . getNodeName ( targetNode ) ) ; } return ( null == head ) ? m_wildCardPatterns : head ; }
Get the head of the most likely list of associations to check based on the name and type of the targetNode argument .
25,465
public ElemTemplate getTemplateFast ( XPathContext xctxt , int targetNode , int expTypeID , QName mode , int maxImportLevel , boolean quietConflictWarnings , DTM dtm ) throws TransformerException { TemplateSubPatternAssociation head ; switch ( dtm . getNodeType ( targetNode ) ) { case DTM . ELEMENT_NODE : case DTM . ATTRIBUTE_NODE : head = ( TemplateSubPatternAssociation ) m_patternTable . get ( dtm . getLocalNameFromExpandedNameID ( expTypeID ) ) ; break ; case DTM . TEXT_NODE : case DTM . CDATA_SECTION_NODE : head = m_textPatterns ; break ; case DTM . ENTITY_REFERENCE_NODE : case DTM . ENTITY_NODE : head = ( TemplateSubPatternAssociation ) m_patternTable . get ( dtm . getNodeName ( targetNode ) ) ; break ; case DTM . PROCESSING_INSTRUCTION_NODE : head = ( TemplateSubPatternAssociation ) m_patternTable . get ( dtm . getLocalName ( targetNode ) ) ; break ; case DTM . COMMENT_NODE : head = m_commentPatterns ; break ; case DTM . DOCUMENT_NODE : case DTM . DOCUMENT_FRAGMENT_NODE : head = m_docPatterns ; break ; case DTM . NOTATION_NODE : default : head = ( TemplateSubPatternAssociation ) m_patternTable . get ( dtm . getNodeName ( targetNode ) ) ; } if ( null == head ) { head = m_wildCardPatterns ; if ( null == head ) return null ; } xctxt . pushNamespaceContextNull ( ) ; try { do { if ( ( maxImportLevel > - 1 ) && ( head . getImportLevel ( ) > maxImportLevel ) ) { continue ; } ElemTemplate template = head . getTemplate ( ) ; xctxt . setNamespaceContext ( template ) ; if ( ( head . m_stepPattern . execute ( xctxt , targetNode , dtm , expTypeID ) != NodeTest . SCORE_NONE ) && head . matchMode ( mode ) ) { if ( quietConflictWarnings ) checkConflicts ( head , xctxt , targetNode , mode ) ; return template ; } } while ( null != ( head = head . getNext ( ) ) ) ; } finally { xctxt . popNamespaceContext ( ) ; } return null ; }
Given a target element find the template that best matches in the given XSL document according to the rules specified in the xsl draft . This variation of getTemplate assumes the current node and current expression node have already been pushed .
25,466
public ElemTemplate getTemplate ( XPathContext xctxt , int targetNode , QName mode , boolean quietConflictWarnings , DTM dtm ) throws TransformerException { TemplateSubPatternAssociation head = getHead ( xctxt , targetNode , dtm ) ; if ( null != head ) { xctxt . pushNamespaceContextNull ( ) ; xctxt . pushCurrentNodeAndExpression ( targetNode , targetNode ) ; try { do { ElemTemplate template = head . getTemplate ( ) ; xctxt . setNamespaceContext ( template ) ; if ( ( head . m_stepPattern . execute ( xctxt , targetNode ) != NodeTest . SCORE_NONE ) && head . matchMode ( mode ) ) { if ( quietConflictWarnings ) checkConflicts ( head , xctxt , targetNode , mode ) ; return template ; } } while ( null != ( head = head . getNext ( ) ) ) ; } finally { xctxt . popCurrentNodeAndExpression ( ) ; xctxt . popNamespaceContext ( ) ; } } return null ; }
Given a target element find the template that best matches in the given XSL document according to the rules specified in the xsl draft .
25,467
private void addObjectIfNotFound ( Object obj , Vector v ) { int n = v . size ( ) ; boolean addIt = true ; for ( int i = 0 ; i < n ; i ++ ) { if ( v . elementAt ( i ) == obj ) { addIt = false ; break ; } } if ( addIt ) { v . addElement ( obj ) ; } }
Add object to vector if not already there .
25,468
private void putHead ( String key , TemplateSubPatternAssociation assoc ) { if ( key . equals ( PsuedoNames . PSEUDONAME_TEXT ) ) m_textPatterns = assoc ; else if ( key . equals ( PsuedoNames . PSEUDONAME_ROOT ) ) m_docPatterns = assoc ; else if ( key . equals ( PsuedoNames . PSEUDONAME_COMMENT ) ) m_commentPatterns = assoc ; m_patternTable . put ( key , assoc ) ; }
Get the head of the assocation list that is keyed by target .
25,469
public Date firstBetween ( Date start , Date end ) { return rule . firstBetween ( start , end ) ; }
Return the first occurrence of this holiday that is on or after the given start date and before the given end date .
25,470
public boolean isBetween ( Date start , Date end ) { return rule . isBetween ( start , end ) ; }
Check whether this holiday occurs at least once between the two dates given .
25,471
private void setup ( XMLReader xmlReader ) { if ( xmlReader == null ) { throw new NullPointerException ( "XMLReader must not be null" ) ; } this . xmlReader = xmlReader ; qAtts = new AttributesAdapter ( ) ; }
Internal setup .
25,472
private void setupXMLReader ( ) throws SAXException { xmlReader . setFeature ( "http://xml.org/sax/features/namespace-prefixes" , true ) ; try { xmlReader . setFeature ( "http://xml.org/sax/features/namespaces" , false ) ; } catch ( SAXException e ) { } xmlReader . setContentHandler ( this ) ; }
Set up the XML reader .
25,473
public void startElement ( String uri , String localName , String qName , Attributes atts ) throws SAXException { if ( documentHandler != null ) { qAtts . setAttributes ( atts ) ; documentHandler . startElement ( qName , qAtts ) ; } }
Adapt a SAX2 start element event .
25,474
public void endElement ( String uri , String localName , String qName ) throws SAXException { if ( documentHandler != null ) documentHandler . endElement ( qName ) ; }
Adapt a SAX2 end element event .
25,475
public void processingInstruction ( String target , String data ) throws SAXException { if ( documentHandler != null ) documentHandler . processingInstruction ( target , data ) ; }
Adapt a SAX2 processing instruction event .
25,476
public static < F , S > Pair < F , S > of ( F first , S second ) { if ( first == null || second == null ) { throw new IllegalArgumentException ( "Pair.of requires non null values." ) ; } return new Pair < F , S > ( first , second ) ; }
Creates a pair object
25,477
protected boolean sameFile ( URL u1 , URL u2 ) { if ( ! ( ( u1 . getProtocol ( ) == u2 . getProtocol ( ) ) || ( u1 . getProtocol ( ) != null && u1 . getProtocol ( ) . equalsIgnoreCase ( u2 . getProtocol ( ) ) ) ) ) return false ; if ( ! ( u1 . getFile ( ) == u2 . getFile ( ) || ( u1 . getFile ( ) != null && u1 . getFile ( ) . equals ( u2 . getFile ( ) ) ) ) ) return false ; int port1 , port2 ; try { port1 = ( u1 . getPort ( ) != - 1 ) ? u1 . getPort ( ) : ( ( URLStreamHandler ) u1 . getHandler ( ) ) . getDefaultPort ( ) ; port2 = ( u2 . getPort ( ) != - 1 ) ? u2 . getPort ( ) : ( ( URLStreamHandler ) u2 . getHandler ( ) ) . getDefaultPort ( ) ; if ( port1 != port2 ) return false ; } catch ( MalformedURLException e ) { return false ; } if ( ! hostsEqual ( u1 , u2 ) ) return false ; return true ; }
Compare two urls to see whether they refer to the same file i . e . having the same protocol host port and path . This method requires that none of its arguments is null . This is guaranteed by the fact that it is only called indirectly by java . net . URL class .
25,478
protected synchronized InetAddress getHostAddress ( URL u ) { if ( u . hostAddress != null ) return ( InetAddress ) u . hostAddress ; String host = u . getHost ( ) ; if ( host == null || host . equals ( "" ) ) { return null ; } else { try { u . hostAddress = InetAddress . getByName ( host ) ; } catch ( UnknownHostException ex ) { return null ; } catch ( SecurityException se ) { return null ; } } return ( InetAddress ) u . hostAddress ; }
Get the IP address of our host . An empty host field or a DNS failure will result in a null return .
25,479
private static void _smartAppend ( StringBuilder buf , char c ) { if ( buf . length ( ) != 0 && buf . charAt ( buf . length ( ) - 1 ) != c ) { buf . append ( c ) ; } }
Append c to buf unless buf is empty or buf already ends in c .
25,480
public Node selectSingleNode ( Node contextNode , String str , Node namespaceNode ) throws TransformerException { NodeIterator nl = selectNodeIterator ( contextNode , str , namespaceNode ) ; return nl . nextNode ( ) ; }
Use an XPath string to select a single node . XPath namespace prefixes are resolved from the namespaceNode .
25,481
public SSLParameters getSSLParameters ( ) { SSLParameters parameters = new SSLParameters ( ) ; parameters . setCipherSuites ( getEnabledCipherSuites ( ) ) ; parameters . setProtocols ( getEnabledProtocols ( ) ) ; if ( getNeedClientAuth ( ) ) { parameters . setNeedClientAuth ( true ) ; } else if ( getWantClientAuth ( ) ) { parameters . setWantClientAuth ( true ) ; } return parameters ; }
Returns the SSLParameters in effect for newly accepted connections . The ciphersuites and protocols of the returned SSLParameters are always non - null .
25,482
public void setSSLParameters ( SSLParameters params ) { String [ ] s ; s = params . getCipherSuites ( ) ; if ( s != null ) { setEnabledCipherSuites ( s ) ; } s = params . getProtocols ( ) ; if ( s != null ) { setEnabledProtocols ( s ) ; } if ( params . getNeedClientAuth ( ) ) { setNeedClientAuth ( true ) ; } else if ( params . getWantClientAuth ( ) ) { setWantClientAuth ( true ) ; } else { setWantClientAuth ( false ) ; } }
Applies SSLParameters to newly accepted connections .
25,483
public void encode ( DerOutputStream out ) throws IOException { DerOutputStream tmp = new DerOutputStream ( ) ; hashAlgId . encode ( tmp ) ; tmp . putOctetString ( issuerNameHash ) ; tmp . putOctetString ( issuerKeyHash ) ; certSerialNumber . encode ( tmp ) ; out . write ( DerValue . tag_Sequence , tmp ) ; if ( debug ) { HexDumpEncoder encoder = new HexDumpEncoder ( ) ; System . out . println ( "Encoded certId is " + encoder . encode ( out . toByteArray ( ) ) ) ; } }
Encode the CertId using ASN . 1 DER . The hash algorithm used is SHA - 1 .
25,484
public final void init ( Key key , SecureRandom random ) throws InvalidKeyException { if ( spi != null && ( key == null || lock == null ) ) { spi . engineInit ( key , random ) ; } else { try { chooseProvider ( I_NO_PARAMS , key , null , random ) ; } catch ( InvalidAlgorithmParameterException e ) { throw new InvalidKeyException ( e ) ; } } }
Initializes this key agreement with the given key and source of randomness . The given key is required to contain all the algorithm parameters required for this key agreement .
25,485
public final void init ( Key key , AlgorithmParameterSpec params ) throws InvalidKeyException , InvalidAlgorithmParameterException { init ( key , params , JceSecurity . RANDOM ) ; }
Initializes this key agreement with the given key and set of algorithm parameters .
25,486
public final void init ( Key key , AlgorithmParameterSpec params , SecureRandom random ) throws InvalidKeyException , InvalidAlgorithmParameterException { if ( spi != null ) { spi . engineInit ( key , params , random ) ; } else { chooseProvider ( I_PARAMS , key , params , random ) ; } }
Initializes this key agreement with the given key set of algorithm parameters and source of randomness .
25,487
public final Key doPhase ( Key key , boolean lastPhase ) throws InvalidKeyException , IllegalStateException { chooseFirstProvider ( ) ; return spi . engineDoPhase ( key , lastPhase ) ; }
Executes the next phase of this key agreement with the given key that was received from one of the other parties involved in this key agreement .
25,488
public static DTMIterator newDTMIterator ( Compiler compiler , int opPos , boolean isTopLevel ) throws javax . xml . transform . TransformerException { int firstStepPos = OpMap . getFirstChildPos ( opPos ) ; int analysis = analyze ( compiler , firstStepPos , 0 ) ; boolean isOneStep = isOneStep ( analysis ) ; DTMIterator iter ; if ( isOneStep && walksSelfOnly ( analysis ) && isWild ( analysis ) && ! hasPredicate ( analysis ) ) { if ( DEBUG_ITERATOR_CREATION ) diagnoseIterator ( "SelfIteratorNoPredicate" , analysis , compiler ) ; iter = new SelfIteratorNoPredicate ( compiler , opPos , analysis ) ; } else if ( walksChildrenOnly ( analysis ) && isOneStep ) { if ( isWild ( analysis ) && ! hasPredicate ( analysis ) ) { if ( DEBUG_ITERATOR_CREATION ) diagnoseIterator ( "ChildIterator" , analysis , compiler ) ; iter = new ChildIterator ( compiler , opPos , analysis ) ; } else { if ( DEBUG_ITERATOR_CREATION ) diagnoseIterator ( "ChildTestIterator" , analysis , compiler ) ; iter = new ChildTestIterator ( compiler , opPos , analysis ) ; } } else if ( isOneStep && walksAttributes ( analysis ) ) { if ( DEBUG_ITERATOR_CREATION ) diagnoseIterator ( "AttributeIterator" , analysis , compiler ) ; iter = new AttributeIterator ( compiler , opPos , analysis ) ; } else if ( isOneStep && ! walksFilteredList ( analysis ) ) { if ( ! walksNamespaces ( analysis ) && ( walksInDocOrder ( analysis ) || isSet ( analysis , BIT_PARENT ) ) ) { if ( false || DEBUG_ITERATOR_CREATION ) diagnoseIterator ( "OneStepIteratorForward" , analysis , compiler ) ; iter = new OneStepIteratorForward ( compiler , opPos , analysis ) ; } else { if ( false || DEBUG_ITERATOR_CREATION ) diagnoseIterator ( "OneStepIterator" , analysis , compiler ) ; iter = new OneStepIterator ( compiler , opPos , analysis ) ; } } else if ( isOptimizableForDescendantIterator ( compiler , firstStepPos , 0 ) ) { if ( DEBUG_ITERATOR_CREATION ) diagnoseIterator ( "DescendantIterator" , analysis , compiler ) ; iter = new DescendantIterator ( compiler , opPos , analysis ) ; } else { if ( isNaturalDocOrder ( compiler , firstStepPos , 0 , analysis ) ) { if ( false || DEBUG_ITERATOR_CREATION ) { diagnoseIterator ( "WalkingIterator" , analysis , compiler ) ; } iter = new WalkingIterator ( compiler , opPos , analysis , true ) ; } else { if ( DEBUG_ITERATOR_CREATION ) diagnoseIterator ( "WalkingIteratorSorted" , analysis , compiler ) ; iter = new WalkingIteratorSorted ( compiler , opPos , analysis , true ) ; } } if ( iter instanceof LocPathIterator ) ( ( LocPathIterator ) iter ) . setIsTopLevel ( isTopLevel ) ; return iter ; }
Create a new LocPathIterator iterator . The exact type of iterator returned is based on an analysis of the XPath operations .
25,489
static public int getAnalysisBitFromAxes ( int axis ) { switch ( axis ) { case Axis . ANCESTOR : return BIT_ANCESTOR ; case Axis . ANCESTORORSELF : return BIT_ANCESTOR_OR_SELF ; case Axis . ATTRIBUTE : return BIT_ATTRIBUTE ; case Axis . CHILD : return BIT_CHILD ; case Axis . DESCENDANT : return BIT_DESCENDANT ; case Axis . DESCENDANTORSELF : return BIT_DESCENDANT_OR_SELF ; case Axis . FOLLOWING : return BIT_FOLLOWING ; case Axis . FOLLOWINGSIBLING : return BIT_FOLLOWING_SIBLING ; case Axis . NAMESPACE : case Axis . NAMESPACEDECLS : return BIT_NAMESPACE ; case Axis . PARENT : return BIT_PARENT ; case Axis . PRECEDING : return BIT_PRECEDING ; case Axis . PRECEDINGSIBLING : return BIT_PRECEDING_SIBLING ; case Axis . SELF : return BIT_SELF ; case Axis . ALLFROMNODE : return BIT_DESCENDANT_OR_SELF ; case Axis . DESCENDANTSFROMROOT : case Axis . ALL : case Axis . DESCENDANTSORSELFFROMROOT : return BIT_ANY_DESCENDANT_FROM_ROOT ; case Axis . ROOT : return BIT_ROOT ; case Axis . FILTEREDLIST : return BIT_FILTER ; default : return BIT_FILTER ; } }
Get a corresponding BIT_XXX from an axis .
25,490
public static boolean mightBeProximate ( Compiler compiler , int opPos , int stepType ) throws javax . xml . transform . TransformerException { boolean mightBeProximate = false ; int argLen ; switch ( stepType ) { case OpCodes . OP_VARIABLE : case OpCodes . OP_EXTFUNCTION : case OpCodes . OP_FUNCTION : case OpCodes . OP_GROUP : argLen = compiler . getArgLength ( opPos ) ; break ; default : argLen = compiler . getArgLengthOfStep ( opPos ) ; } int predPos = compiler . getFirstPredicateOpPos ( opPos ) ; int count = 0 ; while ( OpCodes . OP_PREDICATE == compiler . getOp ( predPos ) ) { count ++ ; int innerExprOpPos = predPos + 2 ; int predOp = compiler . getOp ( innerExprOpPos ) ; switch ( predOp ) { case OpCodes . OP_VARIABLE : return true ; case OpCodes . OP_LOCATIONPATH : break ; case OpCodes . OP_NUMBER : case OpCodes . OP_NUMBERLIT : return true ; case OpCodes . OP_FUNCTION : boolean isProx = functionProximateOrContainsProximate ( compiler , innerExprOpPos ) ; if ( isProx ) return true ; break ; case OpCodes . OP_GT : case OpCodes . OP_GTE : case OpCodes . OP_LT : case OpCodes . OP_LTE : case OpCodes . OP_EQUALS : int leftPos = OpMap . getFirstChildPos ( innerExprOpPos ) ; int rightPos = compiler . getNextOpPos ( leftPos ) ; isProx = isProximateInnerExpr ( compiler , leftPos ) ; if ( isProx ) return true ; isProx = isProximateInnerExpr ( compiler , rightPos ) ; if ( isProx ) return true ; break ; default : return true ; } predPos = compiler . getNextOpPos ( predPos ) ; } return mightBeProximate ; }
Tell if the predicates need to have proximity knowledge .
25,491
private static int analyze ( Compiler compiler , int stepOpCodePos , int stepIndex ) throws javax . xml . transform . TransformerException { int stepType ; int stepCount = 0 ; int analysisResult = 0x00000000 ; while ( OpCodes . ENDOP != ( stepType = compiler . getOp ( stepOpCodePos ) ) ) { stepCount ++ ; boolean predAnalysis = analyzePredicate ( compiler , stepOpCodePos , stepType ) ; if ( predAnalysis ) analysisResult |= BIT_PREDICATE ; switch ( stepType ) { case OpCodes . OP_VARIABLE : case OpCodes . OP_EXTFUNCTION : case OpCodes . OP_FUNCTION : case OpCodes . OP_GROUP : analysisResult |= BIT_FILTER ; break ; case OpCodes . FROM_ROOT : analysisResult |= BIT_ROOT ; break ; case OpCodes . FROM_ANCESTORS : analysisResult |= BIT_ANCESTOR ; break ; case OpCodes . FROM_ANCESTORS_OR_SELF : analysisResult |= BIT_ANCESTOR_OR_SELF ; break ; case OpCodes . FROM_ATTRIBUTES : analysisResult |= BIT_ATTRIBUTE ; break ; case OpCodes . FROM_NAMESPACE : analysisResult |= BIT_NAMESPACE ; break ; case OpCodes . FROM_CHILDREN : analysisResult |= BIT_CHILD ; break ; case OpCodes . FROM_DESCENDANTS : analysisResult |= BIT_DESCENDANT ; break ; case OpCodes . FROM_DESCENDANTS_OR_SELF : if ( 2 == stepCount && BIT_ROOT == analysisResult ) { analysisResult |= BIT_ANY_DESCENDANT_FROM_ROOT ; } analysisResult |= BIT_DESCENDANT_OR_SELF ; break ; case OpCodes . FROM_FOLLOWING : analysisResult |= BIT_FOLLOWING ; break ; case OpCodes . FROM_FOLLOWING_SIBLINGS : analysisResult |= BIT_FOLLOWING_SIBLING ; break ; case OpCodes . FROM_PRECEDING : analysisResult |= BIT_PRECEDING ; break ; case OpCodes . FROM_PRECEDING_SIBLINGS : analysisResult |= BIT_PRECEDING_SIBLING ; break ; case OpCodes . FROM_PARENT : analysisResult |= BIT_PARENT ; break ; case OpCodes . FROM_SELF : analysisResult |= BIT_SELF ; break ; case OpCodes . MATCH_ATTRIBUTE : analysisResult |= ( BIT_MATCH_PATTERN | BIT_ATTRIBUTE ) ; break ; case OpCodes . MATCH_ANY_ANCESTOR : analysisResult |= ( BIT_MATCH_PATTERN | BIT_ANCESTOR ) ; break ; case OpCodes . MATCH_IMMEDIATE_ANCESTOR : analysisResult |= ( BIT_MATCH_PATTERN | BIT_PARENT ) ; break ; default : throw new RuntimeException ( XSLMessages . createXPATHMessage ( XPATHErrorResources . ER_NULL_ERROR_HANDLER , new Object [ ] { Integer . toString ( stepType ) } ) ) ; } if ( OpCodes . NODETYPE_NODE == compiler . getOp ( stepOpCodePos + 3 ) ) { analysisResult |= BIT_NODETEST_ANY ; } stepOpCodePos = compiler . getNextStepPos ( stepOpCodePos ) ; if ( stepOpCodePos < 0 ) break ; } analysisResult |= ( stepCount & BITS_COUNT ) ; return analysisResult ; }
Analyze the location path and return 32 bits that give information about the location path as a whole . See the BIT_XXX constants for meaning about each of the bits .
25,492
public static boolean isDownwardAxisOfMany ( int axis ) { return ( ( Axis . DESCENDANTORSELF == axis ) || ( Axis . DESCENDANT == axis ) || ( Axis . FOLLOWING == axis ) || ( Axis . PRECEDING == axis ) ) ; }
Tell if the given axis goes downword . Bogus name if you can think of a better one please do tell . This really has to do with inverting attribute axis .
25,493
static boolean analyzePredicate ( Compiler compiler , int opPos , int stepType ) throws javax . xml . transform . TransformerException { int argLen ; switch ( stepType ) { case OpCodes . OP_VARIABLE : case OpCodes . OP_EXTFUNCTION : case OpCodes . OP_FUNCTION : case OpCodes . OP_GROUP : argLen = compiler . getArgLength ( opPos ) ; break ; default : argLen = compiler . getArgLengthOfStep ( opPos ) ; } int pos = compiler . getFirstPredicateOpPos ( opPos ) ; int nPredicates = compiler . countPredicates ( pos ) ; return ( nPredicates > 0 ) ? true : false ; }
Analyze a step and give information about it s predicates . Right now this just returns true or false if the step has a predicate .
25,494
public void setCurrency ( Currency currency ) { if ( currency == null ) { throw new NullPointerException ( ) ; } this . currency = currency ; intlCurrencySymbol = currency . getCurrencyCode ( ) ; currencySymbol = currency . getSymbol ( locale ) ; }
Sets the currency of these DecimalFormatSymbols . This also sets the currency symbol attribute to the currency s symbol in the DecimalFormatSymbols locale and the international currency symbol attribute to the currency s ISO 4217 currency code .
25,495
protected void initializeData ( ULocale desiredLocale , String type ) { String key = desiredLocale . getBaseName ( ) + '+' + type ; String ns = desiredLocale . getKeywordValue ( "numbers" ) ; if ( ns != null && ns . length ( ) > 0 ) { key += '+' + ns ; } DateFormatSymbols dfs = DFSCACHE . getInstance ( key , desiredLocale ) ; initializeData ( dfs ) ; }
We may need to deescalate this API to
25,496
void initializeData ( DateFormatSymbols dfs ) { this . eras = dfs . eras ; this . eraNames = dfs . eraNames ; this . narrowEras = dfs . narrowEras ; this . months = dfs . months ; this . shortMonths = dfs . shortMonths ; this . narrowMonths = dfs . narrowMonths ; this . standaloneMonths = dfs . standaloneMonths ; this . standaloneShortMonths = dfs . standaloneShortMonths ; this . standaloneNarrowMonths = dfs . standaloneNarrowMonths ; this . weekdays = dfs . weekdays ; this . shortWeekdays = dfs . shortWeekdays ; this . shorterWeekdays = dfs . shorterWeekdays ; this . narrowWeekdays = dfs . narrowWeekdays ; this . standaloneWeekdays = dfs . standaloneWeekdays ; this . standaloneShortWeekdays = dfs . standaloneShortWeekdays ; this . standaloneShorterWeekdays = dfs . standaloneShorterWeekdays ; this . standaloneNarrowWeekdays = dfs . standaloneNarrowWeekdays ; this . ampms = dfs . ampms ; this . ampmsNarrow = dfs . ampmsNarrow ; this . timeSeparator = dfs . timeSeparator ; this . shortQuarters = dfs . shortQuarters ; this . quarters = dfs . quarters ; this . standaloneShortQuarters = dfs . standaloneShortQuarters ; this . standaloneQuarters = dfs . standaloneQuarters ; this . leapMonthPatterns = dfs . leapMonthPatterns ; this . shortYearNames = dfs . shortYearNames ; this . shortZodiacNames = dfs . shortZodiacNames ; this . abbreviatedDayPeriods = dfs . abbreviatedDayPeriods ; this . wideDayPeriods = dfs . wideDayPeriods ; this . narrowDayPeriods = dfs . narrowDayPeriods ; this . standaloneAbbreviatedDayPeriods = dfs . standaloneAbbreviatedDayPeriods ; this . standaloneWideDayPeriods = dfs . standaloneWideDayPeriods ; this . standaloneNarrowDayPeriods = dfs . standaloneNarrowDayPeriods ; this . zoneStrings = dfs . zoneStrings ; this . localPatternChars = dfs . localPatternChars ; this . capitalization = dfs . capitalization ; this . actualLocale = dfs . actualLocale ; this . validLocale = dfs . validLocale ; this . requestedLocale = dfs . requestedLocale ; }
Initializes format symbols using another instance .
25,497
private String [ ] loadDayPeriodStrings ( Map < String , String > resourceMap ) { String strings [ ] = new String [ DAY_PERIOD_KEYS . length ] ; if ( resourceMap != null ) { for ( int i = 0 ; i < DAY_PERIOD_KEYS . length ; ++ i ) { strings [ i ] = resourceMap . get ( DAY_PERIOD_KEYS [ i ] ) ; } } return strings ; }
Loads localized names for day periods in the requested format .
25,498
final void setLocale ( ULocale valid , ULocale actual ) { if ( ( valid == null ) != ( actual == null ) ) { throw new IllegalArgumentException ( ) ; } this . validLocale = valid ; this . actualLocale = actual ; }
Sets information about the locales that were used to create this object . If the object was not constructed from locale data both arguments should be set to null . Otherwise neither should be null . The actual locale must be at the same level or less specific than the valid locale . This method is intended for use by factories or other entities that create objects of this class .
25,499
private void checkVariableRange ( int ch , String rule , int start ) { if ( ch >= curData . variablesBase && ch < variableLimit ) { syntaxError ( "Variable range character in rule" , rule , start ) ; } }
Assert that the given character is NOT within the variable range . If it is signal an error . This is neccesary to ensure that the variable range does not overlap characters used in a rule .