idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
25,700
public String getRelativePath ( ) { StringBuilder sb = new StringBuilder ( ) ; String pkg = typeRef . getPackageName ( ) . replace ( '.' , '/' ) ; if ( pkg . length ( ) > 0 ) { sb . append ( pkg ) ; sb . append ( '/' ) ; } appendDeclaringTypes ( typeRef , '$' , sb ) ; sb . append ( typeRef . getSimpleName ( ) ) ; sb . append ( ".class" ) ; return sb . toString ( ) ; }
Returns the relative classfile path .
25,701
private static void appendDeclaringTypes ( TypeReference typeRef , char innerClassDelimiter , StringBuilder sb ) { TypeReference declaringType = typeRef . getDeclaringType ( ) ; if ( declaringType != null ) { appendDeclaringTypes ( declaringType , innerClassDelimiter , sb ) ; sb . append ( declaringType . getSimpleName ( ) ) ; sb . append ( innerClassDelimiter ) ; } }
Recurse depth - first so order of declaring types is correct .
25,702
public FieldDeclaration getFieldNode ( String name , String signature ) { for ( EntityDeclaration node : type . getMembers ( ) ) { if ( node . getEntityType ( ) == EntityType . FIELD ) { FieldDeclaration field = ( FieldDeclaration ) node ; if ( field . getName ( ) . equals ( name ) && signature ( field . getReturnType ( ) ) . equals ( signature ) ) { return field ; } } } return null ; }
Returns the Procyon field definition for a specified variable or null if not found .
25,703
public MethodDeclaration getMethod ( String name , String signature ) { for ( EntityDeclaration node : type . getMembers ( ) ) { if ( node . getEntityType ( ) == EntityType . METHOD ) { MethodDeclaration method = ( MethodDeclaration ) node ; if ( method . getName ( ) . equals ( name ) && signature . equals ( signature ( method ) ) ) { return method ; } } } return null ; }
Returns the Procyon method definition for a specified method or null if not found .
25,704
public ConstructorDeclaration getConstructor ( String signature ) { for ( EntityDeclaration node : type . getMembers ( ) ) { if ( node . getEntityType ( ) == EntityType . CONSTRUCTOR ) { ConstructorDeclaration cons = ( ConstructorDeclaration ) node ; if ( signature . equals ( signature ( cons ) ) ) { return cons ; } } } return null ; }
Returns the Procyon method definition for a specified constructor or null if not found .
25,705
public static BasicPeriodFormatterService getInstance ( ) { if ( instance == null ) { PeriodFormatterDataService ds = ResourceBasedPeriodFormatterDataService . getInstance ( ) ; instance = new BasicPeriodFormatterService ( ds ) ; } return instance ; }
Return the default service instance . This uses the default data service .
25,706
public final Result get ( long timeout , TimeUnit unit ) throws InterruptedException , ExecutionException , TimeoutException { return mFuture . get ( timeout , unit ) ; }
Waits if necessary for at most the given time for the computation to complete and then retrieves its result .
25,707
public void setText ( String text ) { if ( text == null ) { throw new NullPointerException ( ) ; } this . text = text ; this . begin = 0 ; this . end = text . length ( ) ; this . pos = 0 ; }
Reset this iterator to point to a new string . This package - visible method is used by other java . text classes that want to avoid allocating new StringCharacterIterator objects every time their setText method is called .
25,708
public static boolean isBlockOrSF ( String s ) { if ( s . endsWith ( ".SF" ) || s . endsWith ( ".DSA" ) || s . endsWith ( ".RSA" ) || s . endsWith ( ".EC" ) ) { return true ; } return false ; }
Utility method used by JarVerifier and JarSigner to determine the signature file names and PKCS7 block files names that are supported
25,709
private MessageDigest getDigest ( String algorithm ) { if ( createdDigests == null ) createdDigests = new HashMap < String , MessageDigest > ( ) ; MessageDigest digest = createdDigests . get ( algorithm ) ; if ( digest == null ) { try { digest = MessageDigest . getInstance ( algorithm ) ; createdDigests . put ( algorithm , digest ) ; } catch ( NoSuchAlgorithmException nsae ) { } } return digest ; }
get digest from cache
25,710
public void process ( Hashtable < String , CodeSigner [ ] > signers , List manifestDigests ) throws IOException , SignatureException , NoSuchAlgorithmException , JarException , CertificateException { Object obj = null ; try { obj = Providers . startJarVerification ( ) ; processImpl ( signers , manifestDigests ) ; } finally { Providers . stopJarVerification ( obj ) ; } }
process the signature block file . Goes through the . SF file and adds code signers for each section where the . SF section hash was verified against the Manifest section .
25,711
private boolean verifyManifestHash ( Manifest sf , ManifestDigester md , BASE64Decoder decoder , List manifestDigests ) throws IOException { Attributes mattr = sf . getMainAttributes ( ) ; boolean manifestSigned = false ; for ( Map . Entry < Object , Object > se : mattr . entrySet ( ) ) { String key = se . getKey ( ) . toString ( ) ; if ( key . toUpperCase ( Locale . ENGLISH ) . endsWith ( "-DIGEST-MANIFEST" ) ) { String algorithm = key . substring ( 0 , key . length ( ) - 16 ) ; manifestDigests . add ( key ) ; manifestDigests . add ( se . getValue ( ) ) ; MessageDigest digest = getDigest ( algorithm ) ; if ( digest != null ) { byte [ ] computedHash = md . manifestDigest ( digest ) ; byte [ ] expectedHash = decoder . decodeBuffer ( ( String ) se . getValue ( ) ) ; if ( debug != null ) { debug . println ( "Signature File: Manifest digest " + digest . getAlgorithm ( ) ) ; debug . println ( " sigfile " + toHex ( expectedHash ) ) ; debug . println ( " computed " + toHex ( computedHash ) ) ; debug . println ( ) ; } if ( MessageDigest . isEqual ( computedHash , expectedHash ) ) { manifestSigned = true ; } else { } } } } return manifestSigned ; }
See if the whole manifest was signed .
25,712
private boolean verifySection ( Attributes sfAttr , String name , ManifestDigester md , BASE64Decoder decoder ) throws IOException { boolean oneDigestVerified = false ; ManifestDigester . Entry mde = md . get ( name , block . isOldStyle ( ) ) ; if ( mde == null ) { throw new SecurityException ( "no manifiest section for signature file entry " + name ) ; } if ( sfAttr != null ) { for ( Map . Entry < Object , Object > se : sfAttr . entrySet ( ) ) { String key = se . getKey ( ) . toString ( ) ; if ( key . toUpperCase ( Locale . ENGLISH ) . endsWith ( "-DIGEST" ) ) { String algorithm = key . substring ( 0 , key . length ( ) - 7 ) ; MessageDigest digest = getDigest ( algorithm ) ; if ( digest != null ) { boolean ok = false ; byte [ ] expected = decoder . decodeBuffer ( ( String ) se . getValue ( ) ) ; byte [ ] computed ; if ( workaround ) { computed = mde . digestWorkaround ( digest ) ; } else { computed = mde . digest ( digest ) ; } if ( debug != null ) { debug . println ( "Signature Block File: " + name + " digest=" + digest . getAlgorithm ( ) ) ; debug . println ( " expected " + toHex ( expected ) ) ; debug . println ( " computed " + toHex ( computed ) ) ; debug . println ( ) ; } if ( MessageDigest . isEqual ( computed , expected ) ) { oneDigestVerified = true ; ok = true ; } else { if ( ! workaround ) { computed = mde . digestWorkaround ( digest ) ; if ( MessageDigest . isEqual ( computed , expected ) ) { if ( debug != null ) { debug . println ( " re-computed " + toHex ( computed ) ) ; debug . println ( ) ; } workaround = true ; oneDigestVerified = true ; ok = true ; } } } if ( ! ok ) { throw new SecurityException ( "invalid " + digest . getAlgorithm ( ) + " signature file digest for " + name ) ; } } } } } return oneDigestVerified ; }
given the . SF digest header and the data from the section in the manifest see if the hashes match . if not throw a SecurityException .
25,713
static String toHex ( byte [ ] data ) { StringBuffer sb = new StringBuffer ( data . length * 2 ) ; for ( int i = 0 ; i < data . length ; i ++ ) { sb . append ( hexc [ ( data [ i ] >> 4 ) & 0x0f ] ) ; sb . append ( hexc [ data [ i ] & 0x0f ] ) ; } return sb . toString ( ) ; }
convert a byte array to a hex string for debugging purposes
25,714
static boolean contains ( CodeSigner [ ] set , CodeSigner signer ) { for ( int i = 0 ; i < set . length ; i ++ ) { if ( set [ i ] . equals ( signer ) ) return true ; } return false ; }
returns true if set contains signer
25,715
static boolean isSubSet ( CodeSigner [ ] subset , CodeSigner [ ] set ) { if ( set == subset ) return true ; boolean match ; for ( int i = 0 ; i < subset . length ; i ++ ) { if ( ! contains ( set , subset [ i ] ) ) return false ; } return true ; }
returns true if subset is a subset of set
25,716
static boolean matches ( CodeSigner [ ] signers , CodeSigner [ ] oldSigners , CodeSigner [ ] newSigners ) { if ( ( oldSigners == null ) && ( signers == newSigners ) ) return true ; boolean match ; if ( ( oldSigners != null ) && ! isSubSet ( oldSigners , signers ) ) return false ; if ( ! isSubSet ( newSigners , signers ) ) { return false ; } for ( int i = 0 ; i < signers . length ; i ++ ) { boolean found = ( ( oldSigners != null ) && contains ( oldSigners , signers [ i ] ) ) || contains ( newSigners , signers [ i ] ) ; if ( ! found ) return false ; } return true ; }
returns true if signer contains exactly the same code signers as oldSigner and newSigner false otherwise . oldSigner is allowed to be null .
25,717
static Object newInstance ( ClassLoader classLoader , String className ) throws ClassNotFoundException , IllegalAccessException , InstantiationException { Class driverClass ; if ( classLoader == null ) { driverClass = Class . forName ( className ) ; } else { driverClass = classLoader . loadClass ( className ) ; } return driverClass . newInstance ( ) ; }
Creates a new instance of the specified class name
25,718
public void putNextEntry ( ZipEntry ze ) throws IOException { if ( firstEntry ) { byte [ ] edata = ze . getExtra ( ) ; if ( edata == null || ! hasMagic ( edata ) ) { if ( edata == null ) { edata = new byte [ 4 ] ; } else { byte [ ] tmp = new byte [ edata . length + 4 ] ; System . arraycopy ( edata , 0 , tmp , 4 , edata . length ) ; edata = tmp ; } set16 ( edata , 0 , JAR_MAGIC ) ; set16 ( edata , 2 , 0 ) ; ze . setExtra ( edata ) ; } firstEntry = false ; } super . putNextEntry ( ze ) ; }
Begins writing a new JAR file entry and positions the stream to the start of the entry data . This method will also close any previous entry . The default compression method will be used if no compression method was specified for the entry . The current time will be used if the entry has no set modification time .
25,719
protected void printInstanceVariables ( ) { Iterable < VariableDeclarationFragment > fields = getInstanceFields ( ) ; if ( Iterables . isEmpty ( fields ) ) { newline ( ) ; return ; } println ( " {" ) ; println ( " @public" ) ; indent ( ) ; FieldDeclaration lastDeclaration = null ; boolean needsAsterisk = false ; for ( VariableDeclarationFragment fragment : fields ) { VariableElement varElement = fragment . getVariableElement ( ) ; FieldDeclaration declaration = ( FieldDeclaration ) fragment . getParent ( ) ; if ( declaration != lastDeclaration ) { if ( lastDeclaration != null ) { println ( ";" ) ; } lastDeclaration = declaration ; JavadocGenerator . printDocComment ( getBuilder ( ) , declaration . getJavadoc ( ) ) ; printIndent ( ) ; if ( ElementUtil . isWeakReference ( varElement ) && ! ElementUtil . isVolatile ( varElement ) ) { print ( "__unsafe_unretained " ) ; } String objcType = getDeclarationType ( varElement ) ; needsAsterisk = objcType . endsWith ( "*" ) ; if ( needsAsterisk ) { objcType = objcType . substring ( 0 , objcType . length ( ) - 2 ) ; } print ( objcType ) ; print ( ' ' ) ; } else { print ( ", " ) ; } if ( needsAsterisk ) { print ( '*' ) ; } print ( nameTable . getVariableShortName ( varElement ) ) ; } println ( ";" ) ; unindent ( ) ; println ( "}" ) ; }
Prints the list of instance variables in a type .
25,720
protected void printDeadClassConstant ( VariableDeclarationFragment fragment ) { VariableElement var = fragment . getVariableElement ( ) ; Object value = var . getConstantValue ( ) ; assert value != null ; String declType = getDeclarationType ( var ) ; declType += ( declType . endsWith ( "*" ) ? "" : " " ) ; String name = nameTable . getVariableShortName ( var ) ; if ( ElementUtil . isPrimitiveConstant ( var ) ) { printf ( "#define %s_%s %s\n" , typeName , name , LiteralGenerator . generate ( value ) ) ; } else { println ( "FOUNDATION_EXPORT " + UnicodeUtils . format ( "%s%s_%s" , declType , typeName , name ) + ";" ) ; } }
Overridden in TypePrivateDeclarationGenerator
25,721
private void printMethodDeclaration ( MethodDeclaration m , boolean isCompanionClass ) { ExecutableElement methodElement = m . getExecutableElement ( ) ; TypeElement typeElement = ElementUtil . getDeclaringClass ( methodElement ) ; if ( typeElement . getKind ( ) . isInterface ( ) ) { if ( isCompanionClass != ElementUtil . isStatic ( methodElement ) ) { return ; } } newline ( ) ; JavadocGenerator . printDocComment ( getBuilder ( ) , m . getJavadoc ( ) ) ; String methodSignature = getMethodSignature ( m ) ; int identifierStartIndex = methodSignature . indexOf ( ')' ) + 1 ; int identifierEndIndex = methodSignature . contains ( ":" ) ? methodSignature . indexOf ( ':' ) : methodSignature . length ( ) ; generatedSourceMappings . addMethodMapping ( m , getBuilder ( ) . length ( ) + identifierStartIndex , identifierEndIndex - identifierStartIndex ) ; print ( methodSignature ) ; String methodName = nameTable . getMethodSelector ( methodElement ) ; if ( ! m . isConstructor ( ) && NameTable . needsObjcMethodFamilyNoneAttribute ( methodName ) ) { print ( " OBJC_METHOD_FAMILY_NONE" ) ; } if ( needsDeprecatedAttribute ( m . getAnnotations ( ) ) ) { print ( " " + DEPRECATED_ATTRIBUTE ) ; } if ( m . isUnavailable ( ) ) { print ( " NS_UNAVAILABLE" ) ; } println ( ";" ) ; }
Emit method declaration .
25,722
protected String nullability ( Element element ) { if ( options . nullability ( ) ) { if ( ElementUtil . hasNullableAnnotation ( element ) ) { return " __nullable" ; } if ( ElementUtil . isNonnull ( element , parametersNonnullByDefault ) ) { return " __nonnull" ; } } return "" ; }
Returns an Objective - C nullability attribute string if there is a matching JSR305 annotation or an empty string .
25,723
private long mappingOffset ( ) { int ps = Bits . pageSize ( ) ; long offset = address % ps ; return ( offset >= 0 ) ? offset : ( ps + offset ) ; }
of the mapping . Computed each time to avoid storing in every direct buffer .
25,724
public final boolean isLoaded ( ) { checkMapped ( ) ; if ( ( address == 0 ) || ( capacity ( ) == 0 ) ) return true ; long offset = mappingOffset ( ) ; long length = mappingLength ( offset ) ; return isLoaded0 ( mappingAddress ( offset ) , length , Bits . pageCount ( length ) ) ; }
Tells whether or not this buffer s content is resident in physical memory .
25,725
public final MappedByteBuffer load ( ) { checkMapped ( ) ; if ( ( address == 0 ) || ( capacity ( ) == 0 ) ) return this ; long offset = mappingOffset ( ) ; long length = mappingLength ( offset ) ; load0 ( mappingAddress ( offset ) , length ) ; Unsafe unsafe = Unsafe . getUnsafe ( ) ; int ps = Bits . pageSize ( ) ; int count = Bits . pageCount ( length ) ; long a = mappingAddress ( offset ) ; byte x = 0 ; for ( int i = 0 ; i < count ; i ++ ) { x ^= unsafe . getByte ( a ) ; a += ps ; } if ( unused != 0 ) unused = x ; return this ; }
Loads this buffer s content into physical memory .
25,726
public final MappedByteBuffer force ( ) { checkMapped ( ) ; if ( ( address != 0 ) && ( capacity ( ) != 0 ) ) { long offset = mappingOffset ( ) ; force0 ( fd , mappingAddress ( offset ) , mappingLength ( offset ) ) ; } return this ; }
Forces any changes made to this buffer s content to be written to the storage device containing the mapped file .
25,727
public static ListFormatter getInstance ( Locale locale ) { return getInstance ( ULocale . forLocale ( locale ) , Style . STANDARD ) ; }
Create a list formatter that is appropriate for a locale .
25,728
public static ListFormatter getInstance ( ULocale locale , Style style ) { return cache . get ( locale , style . getName ( ) ) ; }
Create a list formatter that is appropriate for a locale and style .
25,729
FormattedListBuilder format ( Collection < ? > items , int index ) { Iterator < ? > it = items . iterator ( ) ; int count = items . size ( ) ; switch ( count ) { case 0 : return new FormattedListBuilder ( "" , false ) ; case 1 : return new FormattedListBuilder ( it . next ( ) , index == 0 ) ; case 2 : return new FormattedListBuilder ( it . next ( ) , index == 0 ) . append ( two , it . next ( ) , index == 1 ) ; } FormattedListBuilder builder = new FormattedListBuilder ( it . next ( ) , index == 0 ) ; builder . append ( start , it . next ( ) , index == 1 ) ; for ( int idx = 2 ; idx < count - 1 ; ++ idx ) { builder . append ( middle , it . next ( ) , index == idx ) ; } return builder . append ( end , it . next ( ) , index == count - 1 ) ; }
the offset .
25,730
public String getPatternForNumItems ( int count ) { if ( count <= 0 ) { throw new IllegalArgumentException ( "count must be > 0" ) ; } ArrayList < String > list = new ArrayList < String > ( ) ; for ( int i = 0 ; i < count ; i ++ ) { list . add ( String . format ( "{%d}" , i ) ) ; } return format ( list ) ; }
Returns the pattern to use for a particular item count .
25,731
public void markUsedElements ( CodeReferenceMap publicRootSet ) { if ( publicRootSet == null ) { markUsedElements ( ) ; return ; } for ( String clazz : publicRootSet . getReferencedClasses ( ) ) { ClassReferenceNode classNode = ( ClassReferenceNode ) elementReferenceMap . get ( ElementReferenceMapper . stitchClassIdentifier ( clazz ) ) ; assert ( classNode != null ) ; Iterable < ExecutableElement > methods = ElementUtil . getMethods ( classNode . classElement ) ; for ( ExecutableElement method : methods ) { if ( ElementUtil . isPublic ( method ) ) { rootSet . add ( ElementReferenceMapper . stitchMethodIdentifier ( method , env . typeUtil ( ) , env . elementUtil ( ) ) ) ; } } } for ( Table . Cell < String , String , ImmutableSet < String > > cell : publicRootSet . getReferencedMethods ( ) . cellSet ( ) ) { String clazzName = cell . getRowKey ( ) ; String methodName = cell . getColumnKey ( ) ; for ( String signature : cell . getValue ( ) ) { rootSet . add ( ElementReferenceMapper . stitchMethodIdentifier ( clazzName , methodName , signature ) ) ; } } markUsedElements ( staticSet ) ; markUsedElements ( rootSet ) ; }
the isPublic check .
25,732
public void traverseMethod ( String methodID ) { MethodReferenceNode node = ( MethodReferenceNode ) elementReferenceMap . get ( methodID ) ; if ( node == null ) { ErrorUtil . warning ( "Encountered .class method while accessing: " + methodID ) ; return ; } if ( node . reachable ) { return ; } node . reachable = true ; markParentClasses ( ElementUtil . getDeclaringClass ( node . methodElement ) ) ; for ( String invokedMethodID : node . invokedMethods ) { traverseMethod ( invokedMethodID ) ; } for ( String overrideMethodID : node . overridingMethods ) { traverseMethod ( overrideMethodID ) ; } }
Traverses the method invocation graph created by ElementReferenceMapper and marks all methods that are reachable from the inputRootSet . Also covers all methods that possibly override these called methods .
25,733
public final void init ( int opmode , Key key ) throws InvalidKeyException { init ( opmode , key , JceSecurity . RANDOM ) ; }
Initializes this cipher with a key .
25,734
public final void init ( int opmode , Key key , SecureRandom random ) throws InvalidKeyException { initialized = false ; checkOpmode ( opmode ) ; try { chooseProvider ( InitType . KEY , opmode , key , null , null , random ) ; } catch ( InvalidAlgorithmParameterException e ) { throw new InvalidKeyException ( e ) ; } initialized = true ; this . opmode = opmode ; }
Initializes this cipher with a key and a source of randomness .
25,735
public final void init ( int opmode , Key key , AlgorithmParameterSpec params , SecureRandom random ) throws InvalidKeyException , InvalidAlgorithmParameterException { initialized = false ; checkOpmode ( opmode ) ; chooseProvider ( InitType . ALGORITHM_PARAM_SPEC , opmode , key , params , null , random ) ; initialized = true ; this . opmode = opmode ; }
Initializes this cipher with a key a set of algorithm parameters and a source of randomness .
25,736
public final void init ( int opmode , Certificate certificate , SecureRandom random ) throws InvalidKeyException { initialized = false ; checkOpmode ( opmode ) ; if ( certificate instanceof java . security . cert . X509Certificate ) { X509Certificate cert = ( X509Certificate ) certificate ; Set critSet = cert . getCriticalExtensionOIDs ( ) ; if ( critSet != null && ! critSet . isEmpty ( ) && critSet . contains ( KEY_USAGE_EXTENSION_OID ) ) { boolean [ ] keyUsageInfo = cert . getKeyUsage ( ) ; if ( ( keyUsageInfo != null ) && ( ( ( opmode == Cipher . ENCRYPT_MODE ) && ( keyUsageInfo . length > 3 ) && ( keyUsageInfo [ 3 ] == false ) ) || ( ( opmode == Cipher . WRAP_MODE ) && ( keyUsageInfo . length > 2 ) && ( keyUsageInfo [ 2 ] == false ) ) ) ) { throw new InvalidKeyException ( "Wrong key usage" ) ; } } } PublicKey publicKey = ( certificate == null ? null : certificate . getPublicKey ( ) ) ; try { chooseProvider ( InitType . KEY , opmode , ( Key ) publicKey , null , null , random ) ; } catch ( InvalidAlgorithmParameterException e ) { throw new InvalidKeyException ( e ) ; } initialized = true ; this . opmode = opmode ; }
Initializes this cipher with the public key from the given certificate and a source of randomness .
25,737
public final int doFinal ( byte [ ] output , int outputOffset ) throws IllegalBlockSizeException , ShortBufferException , BadPaddingException { checkCipherState ( ) ; if ( ( output == null ) || ( outputOffset < 0 ) ) { throw new IllegalArgumentException ( "Bad arguments" ) ; } updateProviderIfNeeded ( ) ; return spi . engineDoFinal ( null , 0 , 0 , output , outputOffset ) ; }
Finishes a multiple - part encryption or decryption operation depending on how this cipher was initialized .
25,738
public final byte [ ] wrap ( Key key ) throws IllegalBlockSizeException , InvalidKeyException { if ( ! ( this instanceof NullCipher ) ) { if ( ! initialized ) { throw new IllegalStateException ( "Cipher not initialized" ) ; } if ( opmode != Cipher . WRAP_MODE ) { throw new IllegalStateException ( "Cipher not initialized " + "for wrapping keys" ) ; } } updateProviderIfNeeded ( ) ; return spi . engineWrap ( key ) ; }
Wrap a key .
25,739
public final Key unwrap ( byte [ ] wrappedKey , String wrappedKeyAlgorithm , int wrappedKeyType ) throws InvalidKeyException , NoSuchAlgorithmException { if ( ! ( this instanceof NullCipher ) ) { if ( ! initialized ) { throw new IllegalStateException ( "Cipher not initialized" ) ; } if ( opmode != Cipher . UNWRAP_MODE ) { throw new IllegalStateException ( "Cipher not initialized " + "for unwrapping keys" ) ; } } if ( ( wrappedKeyType != SECRET_KEY ) && ( wrappedKeyType != PRIVATE_KEY ) && ( wrappedKeyType != PUBLIC_KEY ) ) { throw new InvalidParameterException ( "Invalid key type" ) ; } updateProviderIfNeeded ( ) ; return spi . engineUnwrap ( wrappedKey , wrappedKeyAlgorithm , wrappedKeyType ) ; }
Unwrap a previously wrapped key .
25,740
public static final AlgorithmParameterSpec getMaxAllowedParameterSpec ( String transformation ) throws NoSuchAlgorithmException { if ( transformation == null ) { throw new NullPointerException ( "transformation == null" ) ; } tokenizeTransformation ( transformation ) ; return null ; }
Returns an AlgorithmParameterSpec object which contains the maximum cipher parameter value according to the jurisdiction policy file . If JCE unlimited strength jurisdiction policy files are installed or there is no maximum limit on the parameters for the specified transformation in the policy file null will be returned .
25,741
static boolean matchAttribute ( Provider . Service service , String attr , String value ) { if ( value == null ) { return true ; } final String pattern = service . getAttribute ( attr ) ; if ( pattern == null ) { return true ; } final String valueUc = value . toUpperCase ( Locale . US ) ; return valueUc . matches ( pattern . toUpperCase ( Locale . US ) ) ; }
If the attribute listed exists check that it matches the regular expression .
25,742
private final Node registerNode ( Node newNode ) { if ( state == State . BUILDING_FAST ) { return newNode ; } Node oldNode = nodes . get ( newNode ) ; if ( oldNode != null ) { return oldNode ; } oldNode = nodes . put ( newNode , newNode ) ; assert ( oldNode == null ) ; return newNode ; }
Makes sure that there is only one unique node registered that is equivalent to newNode unless BUILDING_FAST .
25,743
private final ValueNode registerFinalValue ( int value ) { lookupFinalValueNode . setFinalValue ( value ) ; Node oldNode = nodes . get ( lookupFinalValueNode ) ; if ( oldNode != null ) { return ( ValueNode ) oldNode ; } ValueNode newNode = new ValueNode ( value ) ; oldNode = nodes . put ( newNode , newNode ) ; assert ( oldNode == null ) ; return newNode ; }
Makes sure that there is only one unique FinalValueNode registered with this value . Avoids creating a node if the value is a duplicate .
25,744
protected Stylesheet getStylesheetRoot ( StylesheetHandler handler ) throws TransformerConfigurationException { StylesheetRoot stylesheet ; stylesheet = new StylesheetRoot ( handler . getSchema ( ) , handler . getStylesheetProcessor ( ) . getErrorListener ( ) ) ; if ( handler . getStylesheetProcessor ( ) . isSecureProcessing ( ) ) stylesheet . setSecureProcessing ( true ) ; return stylesheet ; }
This method could be over - ridden by a class that extends this class .
25,745
public String createTypeSignature ( TypeMirror type ) { StringBuilder sb = new StringBuilder ( ) ; genTypeSignature ( type , sb ) ; return sb . toString ( ) ; }
Create a signature for a specified type .
25,746
public String createClassSignature ( TypeElement type ) { if ( ! hasGenericSignature ( type ) ) { return null ; } StringBuilder sb = new StringBuilder ( ) ; genClassSignature ( type , sb ) ; return sb . toString ( ) ; }
Create a class signature string for a specified type .
25,747
public String createFieldTypeSignature ( VariableElement variable ) { if ( ! hasGenericSignature ( variable . asType ( ) ) ) { return null ; } StringBuilder sb = new StringBuilder ( ) ; genTypeSignature ( variable . asType ( ) , sb ) ; return sb . toString ( ) ; }
Create a field signature string for a specified variable .
25,748
public String createMethodTypeSignature ( ExecutableElement method ) { if ( ! hasGenericSignature ( method ) ) { return null ; } StringBuilder sb = new StringBuilder ( ) ; genMethodTypeSignature ( method , sb ) ; return sb . toString ( ) ; }
Create a method signature string for a specified method or constructor .
25,749
public static void checkSuperClass ( Service s , Class < ? > subClass , Class < ? > superClass ) throws NoSuchAlgorithmException { if ( superClass == null ) { return ; } if ( superClass . isAssignableFrom ( subClass ) == false ) { throw new NoSuchAlgorithmException ( "class configured for " + s . getType ( ) + ": " + s . getClassName ( ) + " not a " + s . getType ( ) ) ; } }
Check is subClass is a subclass of superClass . If not throw a NoSuchAlgorithmException .
25,750
protected void engineInitSign ( PrivateKey privateKey , SecureRandom random ) throws InvalidKeyException { this . appRandom = random ; engineInitSign ( privateKey ) ; }
Initializes this signature object with the specified private key and source of randomness for signing operations .
25,751
private void setMaxDelimCodePoint ( ) { if ( delimiters == null ) { maxDelimCodePoint = 0 ; return ; } int m = 0 ; int c ; int count = 0 ; for ( int i = 0 ; i < delimiters . length ( ) ; i += Character . charCount ( c ) ) { c = delimiters . charAt ( i ) ; if ( c >= Character . MIN_HIGH_SURROGATE && c <= Character . MAX_LOW_SURROGATE ) { c = delimiters . codePointAt ( i ) ; hasSurrogates = true ; } if ( m < c ) m = c ; count ++ ; } maxDelimCodePoint = m ; if ( hasSurrogates ) { delimiterCodePoints = new int [ count ] ; for ( int i = 0 , j = 0 ; i < count ; i ++ , j += Character . charCount ( c ) ) { c = delimiters . codePointAt ( j ) ; delimiterCodePoints [ i ] = c ; } } }
Set maxDelimCodePoint to the highest char in the delimiter set .
25,752
private int skipDelimiters ( int startPos ) { if ( delimiters == null ) throw new NullPointerException ( ) ; int position = startPos ; while ( ! retDelims && position < maxPosition ) { if ( ! hasSurrogates ) { char c = str . charAt ( position ) ; if ( ( c > maxDelimCodePoint ) || ( delimiters . indexOf ( c ) < 0 ) ) break ; position ++ ; } else { int c = str . codePointAt ( position ) ; if ( ( c > maxDelimCodePoint ) || ! isDelimiter ( c ) ) { break ; } position += Character . charCount ( c ) ; } } return position ; }
Skips delimiters starting from the specified position . If retDelims is false returns the index of the first non - delimiter character at or after startPos . If retDelims is true startPos is returned .
25,753
private int scanToken ( int startPos ) { int position = startPos ; while ( position < maxPosition ) { if ( ! hasSurrogates ) { char c = str . charAt ( position ) ; if ( ( c <= maxDelimCodePoint ) && ( delimiters . indexOf ( c ) >= 0 ) ) break ; position ++ ; } else { int c = str . codePointAt ( position ) ; if ( ( c <= maxDelimCodePoint ) && isDelimiter ( c ) ) break ; position += Character . charCount ( c ) ; } } if ( retDelims && ( startPos == position ) ) { if ( ! hasSurrogates ) { char c = str . charAt ( position ) ; if ( ( c <= maxDelimCodePoint ) && ( delimiters . indexOf ( c ) >= 0 ) ) position ++ ; } else { int c = str . codePointAt ( position ) ; if ( ( c <= maxDelimCodePoint ) && isDelimiter ( c ) ) position += Character . charCount ( c ) ; } } return position ; }
Skips ahead from startPos and returns the index of the next delimiter character encountered or maxPosition if no such delimiter is found .
25,754
private void set ( int position , boolean val ) { if ( position >= bitString . length ) { boolean [ ] tmp = new boolean [ position + 1 ] ; System . arraycopy ( bitString , 0 , tmp , 0 , bitString . length ) ; bitString = tmp ; } bitString [ position ] = val ; }
Set the bit at the specified position .
25,755
public static void makeRules ( String description , NFRuleSet owner , NFRule predecessor , RuleBasedNumberFormat ownersOwner , List < NFRule > returnList ) { NFRule rule1 = new NFRule ( ownersOwner , description ) ; description = rule1 . ruleText ; int brack1 = description . indexOf ( '[' ) ; int brack2 = brack1 < 0 ? - 1 : description . indexOf ( ']' ) ; if ( brack2 < 0 || brack1 > brack2 || rule1 . baseValue == PROPER_FRACTION_RULE || rule1 . baseValue == NEGATIVE_NUMBER_RULE || rule1 . baseValue == INFINITY_RULE || rule1 . baseValue == NAN_RULE ) { rule1 . extractSubstitutions ( owner , description , predecessor ) ; } else { NFRule rule2 = null ; StringBuilder sbuf = new StringBuilder ( ) ; if ( ( rule1 . baseValue > 0 && rule1 . baseValue % ( power ( rule1 . radix , rule1 . exponent ) ) == 0 ) || rule1 . baseValue == IMPROPER_FRACTION_RULE || rule1 . baseValue == MASTER_RULE ) { rule2 = new NFRule ( ownersOwner , null ) ; if ( rule1 . baseValue >= 0 ) { rule2 . baseValue = rule1 . baseValue ; if ( ! owner . isFractionSet ( ) ) { ++ rule1 . baseValue ; } } else if ( rule1 . baseValue == IMPROPER_FRACTION_RULE ) { rule2 . baseValue = PROPER_FRACTION_RULE ; } else if ( rule1 . baseValue == MASTER_RULE ) { rule2 . baseValue = rule1 . baseValue ; rule1 . baseValue = IMPROPER_FRACTION_RULE ; } rule2 . radix = rule1 . radix ; rule2 . exponent = rule1 . exponent ; sbuf . append ( description . substring ( 0 , brack1 ) ) ; if ( brack2 + 1 < description . length ( ) ) { sbuf . append ( description . substring ( brack2 + 1 ) ) ; } rule2 . extractSubstitutions ( owner , sbuf . toString ( ) , predecessor ) ; } sbuf . setLength ( 0 ) ; sbuf . append ( description . substring ( 0 , brack1 ) ) ; sbuf . append ( description . substring ( brack1 + 1 , brack2 ) ) ; if ( brack2 + 1 < description . length ( ) ) { sbuf . append ( description . substring ( brack2 + 1 ) ) ; } rule1 . extractSubstitutions ( owner , sbuf . toString ( ) , predecessor ) ; if ( rule2 != null ) { if ( rule2 . baseValue >= 0 ) { returnList . add ( rule2 ) ; } else { owner . setNonNumericalRule ( rule2 ) ; } } } if ( rule1 . baseValue >= 0 ) { returnList . add ( rule1 ) ; } else { owner . setNonNumericalRule ( rule1 ) ; } }
Creates one or more rules based on the description passed in .
25,756
private void extractSubstitutions ( NFRuleSet owner , String ruleText , NFRule predecessor ) { this . ruleText = ruleText ; sub1 = extractSubstitution ( owner , predecessor ) ; if ( sub1 == null ) { sub2 = null ; } else { sub2 = extractSubstitution ( owner , predecessor ) ; } ruleText = this . ruleText ; int pluralRuleStart = ruleText . indexOf ( "$(" ) ; int pluralRuleEnd = ( pluralRuleStart >= 0 ? ruleText . indexOf ( ")$" , pluralRuleStart ) : - 1 ) ; if ( pluralRuleEnd >= 0 ) { int endType = ruleText . indexOf ( ',' , pluralRuleStart ) ; if ( endType < 0 ) { throw new IllegalArgumentException ( "Rule \"" + ruleText + "\" does not have a defined type" ) ; } String type = this . ruleText . substring ( pluralRuleStart + 2 , endType ) ; PluralRules . PluralType pluralType ; if ( "cardinal" . equals ( type ) ) { pluralType = PluralRules . PluralType . CARDINAL ; } else if ( "ordinal" . equals ( type ) ) { pluralType = PluralRules . PluralType . ORDINAL ; } else { throw new IllegalArgumentException ( type + " is an unknown type" ) ; } rulePatternFormat = formatter . createPluralFormat ( pluralType , ruleText . substring ( endType + 1 , pluralRuleEnd ) ) ; } }
Searches the rule s rule text for the substitution tokens creates the substitutions and removes the substitution tokens from the rule s rule text .
25,757
private NFSubstitution extractSubstitution ( NFRuleSet owner , NFRule predecessor ) { NFSubstitution result ; int subStart ; int subEnd ; subStart = indexOfAnyRulePrefix ( ruleText ) ; if ( subStart == - 1 ) { return null ; } if ( ruleText . startsWith ( ">>>" , subStart ) ) { subEnd = subStart + 2 ; } else { char c = ruleText . charAt ( subStart ) ; subEnd = ruleText . indexOf ( c , subStart + 1 ) ; if ( c == '<' && subEnd != - 1 && subEnd < ruleText . length ( ) - 1 && ruleText . charAt ( subEnd + 1 ) == c ) { ++ subEnd ; } } if ( subEnd == - 1 ) { return null ; } result = NFSubstitution . makeSubstitution ( subStart , this , predecessor , owner , this . formatter , ruleText . substring ( subStart , subEnd + 1 ) ) ; ruleText = ruleText . substring ( 0 , subStart ) + ruleText . substring ( subEnd + 1 ) ; return result ; }
Searches the rule s rule text for the first substitution token creates a substitution based on it and removes the token from the rule s rule text .
25,758
final void setBaseValue ( long newBaseValue ) { baseValue = newBaseValue ; radix = 10 ; if ( baseValue >= 1 ) { exponent = expectedExponent ( ) ; if ( sub1 != null ) { sub1 . setDivisor ( radix , exponent ) ; } if ( sub2 != null ) { sub2 . setDivisor ( radix , exponent ) ; } } else { exponent = 0 ; } }
Sets the rule s base value and causes the radix and exponent to be recalculated . This is used during construction when we don t know the rule s base value until after it s been constructed . It should not be used at any other time .
25,759
private short expectedExponent ( ) { if ( radix == 0 || baseValue < 1 ) { return 0 ; } short tempResult = ( short ) ( Math . log ( baseValue ) / Math . log ( radix ) ) ; if ( power ( radix , ( short ) ( tempResult + 1 ) ) <= baseValue ) { return ( short ) ( tempResult + 1 ) ; } else { return tempResult ; } }
This calculates the rule s exponent based on its radix and base value . This will be the highest power the radix can be raised to and still produce a result less than or equal to the base value .
25,760
private static int indexOfAnyRulePrefix ( String ruleText ) { int result = - 1 ; if ( ruleText . length ( ) > 0 ) { int pos ; for ( String string : RULE_PREFIXES ) { pos = ruleText . indexOf ( string ) ; if ( pos != - 1 && ( result == - 1 || pos < result ) ) { result = pos ; } } } return result ; }
Searches the rule s rule text for any of the specified strings .
25,761
public void doFormat ( double number , StringBuilder toInsertInto , int pos , int recursionCount ) { int pluralRuleStart = ruleText . length ( ) ; int lengthOffset = 0 ; if ( rulePatternFormat == null ) { toInsertInto . insert ( pos , ruleText ) ; } else { pluralRuleStart = ruleText . indexOf ( "$(" ) ; int pluralRuleEnd = ruleText . indexOf ( ")$" , pluralRuleStart ) ; int initialLength = toInsertInto . length ( ) ; if ( pluralRuleEnd < ruleText . length ( ) - 1 ) { toInsertInto . insert ( pos , ruleText . substring ( pluralRuleEnd + 2 ) ) ; } double pluralVal = number ; if ( 0 <= pluralVal && pluralVal < 1 ) { pluralVal = Math . round ( pluralVal * power ( radix , exponent ) ) ; } else { pluralVal = pluralVal / power ( radix , exponent ) ; } toInsertInto . insert ( pos , rulePatternFormat . format ( ( long ) ( pluralVal ) ) ) ; if ( pluralRuleStart > 0 ) { toInsertInto . insert ( pos , ruleText . substring ( 0 , pluralRuleStart ) ) ; } lengthOffset = ruleText . length ( ) - ( toInsertInto . length ( ) - initialLength ) ; } if ( sub2 != null ) { sub2 . doSubstitution ( number , toInsertInto , pos - ( sub2 . getPos ( ) > pluralRuleStart ? lengthOffset : 0 ) , recursionCount ) ; } if ( sub1 != null ) { sub1 . doSubstitution ( number , toInsertInto , pos - ( sub1 . getPos ( ) > pluralRuleStart ? lengthOffset : 0 ) , recursionCount ) ; } }
Formats the number and inserts the resulting text into toInsertInto .
25,762
static long power ( long base , short exponent ) { if ( exponent < 0 ) { throw new IllegalArgumentException ( "Exponent can not be negative" ) ; } if ( base < 0 ) { throw new IllegalArgumentException ( "Base can not be negative" ) ; } long result = 1 ; while ( exponent > 0 ) { if ( ( exponent & 1 ) == 1 ) { result *= base ; } base *= base ; exponent >>= 1 ; } return result ; }
This is an equivalent to Math . pow that accurately works on 64 - bit numbers
25,763
public Number doParse ( String text , ParsePosition parsePosition , boolean isFractionRule , double upperBound ) { ParsePosition pp = new ParsePosition ( 0 ) ; int sub1Pos = sub1 != null ? sub1 . getPos ( ) : ruleText . length ( ) ; int sub2Pos = sub2 != null ? sub2 . getPos ( ) : ruleText . length ( ) ; String workText = stripPrefix ( text , ruleText . substring ( 0 , sub1Pos ) , pp ) ; int prefixLength = text . length ( ) - workText . length ( ) ; if ( pp . getIndex ( ) == 0 && sub1Pos != 0 ) { return ZERO ; } if ( baseValue == INFINITY_RULE ) { parsePosition . setIndex ( pp . getIndex ( ) ) ; return Double . POSITIVE_INFINITY ; } if ( baseValue == NAN_RULE ) { parsePosition . setIndex ( pp . getIndex ( ) ) ; return Double . NaN ; } int highWaterMark = 0 ; double result = 0 ; int start = 0 ; double tempBaseValue = Math . max ( 0 , baseValue ) ; do { pp . setIndex ( 0 ) ; double partialResult = matchToDelimiter ( workText , start , tempBaseValue , ruleText . substring ( sub1Pos , sub2Pos ) , rulePatternFormat , pp , sub1 , upperBound ) . doubleValue ( ) ; if ( pp . getIndex ( ) != 0 || sub1 == null ) { start = pp . getIndex ( ) ; String workText2 = workText . substring ( pp . getIndex ( ) ) ; ParsePosition pp2 = new ParsePosition ( 0 ) ; partialResult = matchToDelimiter ( workText2 , 0 , partialResult , ruleText . substring ( sub2Pos ) , rulePatternFormat , pp2 , sub2 , upperBound ) . doubleValue ( ) ; if ( pp2 . getIndex ( ) != 0 || sub2 == null ) { if ( prefixLength + pp . getIndex ( ) + pp2 . getIndex ( ) > highWaterMark ) { highWaterMark = prefixLength + pp . getIndex ( ) + pp2 . getIndex ( ) ; result = partialResult ; } } } } while ( sub1Pos != sub2Pos && pp . getIndex ( ) > 0 && pp . getIndex ( ) < workText . length ( ) && pp . getIndex ( ) != start ) ; parsePosition . setIndex ( highWaterMark ) ; if ( isFractionRule && highWaterMark > 0 && sub1 == null ) { result = 1 / result ; } if ( result == ( long ) result ) { return Long . valueOf ( ( long ) result ) ; } else { return new Double ( result ) ; } }
Attempts to parse the string with this rule .
25,764
private boolean allIgnorable ( String str ) { if ( str == null || str . length ( ) == 0 ) { return true ; } RbnfLenientScanner scanner = formatter . getLenientScanner ( ) ; return scanner != null && scanner . allIgnorable ( str ) ; }
Checks to see whether a string consists entirely of ignorable characters .
25,765
protected int serializeHeader ( DataOutputStream dos ) throws IOException { int bytesWritten = 0 ; dos . writeInt ( header . signature ) ; dos . writeShort ( header . options ) ; dos . writeShort ( header . indexLength ) ; dos . writeShort ( header . shiftedDataLength ) ; dos . writeShort ( header . index2NullOffset ) ; dos . writeShort ( header . dataNullOffset ) ; dos . writeShort ( header . shiftedHighStart ) ; bytesWritten += 16 ; int i ; for ( i = 0 ; i < header . indexLength ; i ++ ) { dos . writeChar ( index [ i ] ) ; } bytesWritten += header . indexLength ; return bytesWritten ; }
Serialize a trie2 Header and Index onto an OutputStream . This is common code used for both the Trie2_16 and Trie2_32 serialize functions .
25,766
int rangeEnd ( int start , int limitp , int val ) { int c ; int limit = Math . min ( highStart , limitp ) ; for ( c = start + 1 ; c < limit ; c ++ ) { if ( get ( c ) != val ) { break ; } } if ( c >= highStart ) { c = limitp ; } return c - 1 ; }
Find the last character in a contiguous range of characters with the same Trie2 value as the input character .
25,767
public final synchronized void add ( String name , L listener ) { if ( this . map == null ) { this . map = new HashMap < > ( ) ; } L [ ] array = this . map . get ( name ) ; int size = ( array != null ) ? array . length : 0 ; L [ ] clone = newArray ( size + 1 ) ; clone [ size ] = listener ; if ( array != null ) { System . arraycopy ( array , 0 , clone , 0 , size ) ; } this . map . put ( name , clone ) ; }
Adds a listener to the list of listeners for the specified property . This listener is called as many times as it was added .
25,768
public final synchronized void remove ( String name , L listener ) { if ( this . map != null ) { L [ ] array = this . map . get ( name ) ; if ( array != null ) { for ( int i = 0 ; i < array . length ; i ++ ) { if ( listener . equals ( array [ i ] ) ) { int size = array . length - 1 ; if ( size > 0 ) { L [ ] clone = newArray ( size ) ; System . arraycopy ( array , 0 , clone , 0 , i ) ; System . arraycopy ( array , i + 1 , clone , i , size - i ) ; this . map . put ( name , clone ) ; } else { this . map . remove ( name ) ; if ( this . map . isEmpty ( ) ) { this . map = null ; } } break ; } } } } }
Removes a listener from the list of listeners for the specified property . If the listener was added more than once to the same event source this listener will be notified one less time after being removed .
25,769
public final synchronized L [ ] get ( String name ) { return ( this . map != null ) ? this . map . get ( name ) : null ; }
Returns the list of listeners for the specified property .
25,770
public final void set ( String name , L [ ] listeners ) { if ( listeners != null ) { if ( this . map == null ) { this . map = new HashMap < > ( ) ; } this . map . put ( name , listeners ) ; } else if ( this . map != null ) { this . map . remove ( name ) ; if ( this . map . isEmpty ( ) ) { this . map = null ; } } }
Sets new list of listeners for the specified property .
25,771
public final synchronized L [ ] getListeners ( ) { if ( this . map == null ) { return newArray ( 0 ) ; } List < L > list = new ArrayList < > ( ) ; L [ ] listeners = this . map . get ( null ) ; if ( listeners != null ) { for ( L listener : listeners ) { list . add ( listener ) ; } } for ( Entry < String , L [ ] > entry : this . map . entrySet ( ) ) { String name = entry . getKey ( ) ; if ( name != null ) { for ( L listener : entry . getValue ( ) ) { list . add ( newProxy ( name , listener ) ) ; } } } return list . toArray ( newArray ( list . size ( ) ) ) ; }
Returns all listeners in the map .
25,772
public final L [ ] getListeners ( String name ) { if ( name != null ) { L [ ] listeners = get ( name ) ; if ( listeners != null ) { return listeners . clone ( ) ; } } return newArray ( 0 ) ; }
Returns listeners that have been associated with the named property .
25,773
public final synchronized boolean hasListeners ( String name ) { if ( this . map == null ) { return false ; } L [ ] array = this . map . get ( null ) ; return ( array != null ) || ( ( name != null ) && ( null != this . map . get ( name ) ) ) ; }
Indicates whether the map contains at least one listener to be notified .
25,774
public final Set < Entry < String , L [ ] > > getEntries ( ) { return ( this . map != null ) ? this . map . entrySet ( ) : Collections . < Entry < String , L [ ] > > emptySet ( ) ; }
Returns a set of entries from the map . Each entry is a pair consisted of the property name and the corresponding list of listeners .
25,775
public int getWaitQueueLength ( Condition condition ) { if ( condition == null ) throw new NullPointerException ( ) ; if ( ! ( condition instanceof AbstractQueuedSynchronizer . ConditionObject ) ) throw new IllegalArgumentException ( "not owner" ) ; return sync . getWaitQueueLength ( ( AbstractQueuedSynchronizer . ConditionObject ) condition ) ; }
Returns an estimate of the number of threads waiting on the given condition associated with this lock . Note that because timeouts and interrupts may occur at any time the estimate serves only as an upper bound on the actual number of waiters . This method is designed for use in monitoring of the system state not for synchronization control .
25,776
protected Collection < Thread > getWaitingThreads ( Condition condition ) { if ( condition == null ) throw new NullPointerException ( ) ; if ( ! ( condition instanceof AbstractQueuedSynchronizer . ConditionObject ) ) throw new IllegalArgumentException ( "not owner" ) ; return sync . getWaitingThreads ( ( AbstractQueuedSynchronizer . ConditionObject ) condition ) ; }
Returns a collection containing those threads that may be waiting on the given condition associated with this lock . Because the actual set of threads may change dynamically while constructing this result the returned collection is only a best - effort estimate . The elements of the returned collection are in no particular order . This method is designed to facilitate construction of subclasses that provide more extensive condition monitoring facilities .
25,777
public static SimpleFormatter compileMinMaxArguments ( CharSequence pattern , int min , int max ) { StringBuilder sb = new StringBuilder ( ) ; String compiledPattern = SimpleFormatterImpl . compileToStringMinMaxArguments ( pattern , sb , min , max ) ; return new SimpleFormatter ( compiledPattern ) ; }
Creates a formatter from the pattern string . The number of arguments checked against the given limits is the highest argument number plus one not the number of occurrences of arguments .
25,778
public synchronized String findValue ( String k ) { if ( k == null ) { for ( int i = nkeys ; -- i >= 0 ; ) if ( keys [ i ] == null ) return values [ i ] ; } else for ( int i = nkeys ; -- i >= 0 ; ) { if ( k . equalsIgnoreCase ( keys [ i ] ) ) return values [ i ] ; } return null ; }
Find the value that corresponds to this key . It finds only the first occurrence of the key .
25,779
public synchronized int getKey ( String k ) { for ( int i = nkeys ; -- i >= 0 ; ) if ( ( keys [ i ] == k ) || ( k != null && k . equalsIgnoreCase ( keys [ i ] ) ) ) return i ; return - 1 ; }
return the location of the key
25,780
public boolean filterNTLMResponses ( String k ) { boolean found = false ; for ( int i = 0 ; i < nkeys ; i ++ ) { if ( k . equalsIgnoreCase ( keys [ i ] ) && values [ i ] != null && values [ i ] . length ( ) > 5 && values [ i ] . regionMatches ( true , 0 , "NTLM " , 0 , 5 ) ) { found = true ; break ; } } if ( found ) { int j = 0 ; for ( int i = 0 ; i < nkeys ; i ++ ) { if ( k . equalsIgnoreCase ( keys [ i ] ) && ( "Negotiate" . equalsIgnoreCase ( values [ i ] ) || "Kerberos" . equalsIgnoreCase ( values [ i ] ) ) ) { continue ; } if ( i != j ) { keys [ j ] = keys [ i ] ; values [ j ] = values [ i ] ; } j ++ ; } if ( j != nkeys ) { nkeys = j ; return true ; } } return false ; }
Removes bare Negotiate and Kerberos headers when an NTLM ... appears . All Performed on headers with key being k .
25,781
public synchronized void print ( PrintStream p ) { for ( int i = 0 ; i < nkeys ; i ++ ) if ( keys [ i ] != null ) { p . print ( keys [ i ] + ( values [ i ] != null ? ": " + values [ i ] : "" ) + "\r\n" ) ; } p . print ( "\r\n" ) ; p . flush ( ) ; }
Prints the key - value pairs represented by this header . Also prints the RFC required blank line at the end . Omits pairs with a null key .
25,782
public synchronized void add ( String k , String v ) { grow ( ) ; keys [ nkeys ] = k ; values [ nkeys ] = v ; nkeys ++ ; }
Adds a key value pair to the end of the header . Duplicates are allowed
25,783
public synchronized void prepend ( String k , String v ) { grow ( ) ; for ( int i = nkeys ; i > 0 ; i -- ) { keys [ i ] = keys [ i - 1 ] ; values [ i ] = values [ i - 1 ] ; } keys [ 0 ] = k ; values [ 0 ] = v ; nkeys ++ ; }
Prepends a key value pair to the beginning of the header . Duplicates are allowed
25,784
public synchronized void remove ( String k ) { if ( k == null ) { for ( int i = 0 ; i < nkeys ; i ++ ) { while ( keys [ i ] == null && i < nkeys ) { for ( int j = i ; j < nkeys - 1 ; j ++ ) { keys [ j ] = keys [ j + 1 ] ; values [ j ] = values [ j + 1 ] ; } nkeys -- ; } } } else { for ( int i = 0 ; i < nkeys ; i ++ ) { while ( k . equalsIgnoreCase ( keys [ i ] ) && i < nkeys ) { for ( int j = i ; j < nkeys - 1 ; j ++ ) { keys [ j ] = keys [ j + 1 ] ; values [ j ] = values [ j + 1 ] ; } nkeys -- ; } } } }
Remove the key from the header . If there are multiple values under the same key they are all removed . Nothing is done if the key doesn t exist . After a remove the other pairs order are not changed .
25,785
public synchronized void setIfNotSet ( String k , String v ) { if ( findValue ( k ) == null ) { add ( k , v ) ; } }
Set s the value of a key only if there is no key with that value already .
25,786
public void mergeHeader ( InputStream is ) throws java . io . IOException { if ( is == null ) return ; char s [ ] = new char [ 10 ] ; int firstc = is . read ( ) ; while ( firstc != '\n' && firstc != '\r' && firstc >= 0 ) { int len = 0 ; int keyend = - 1 ; int c ; boolean inKey = firstc > ' ' ; s [ len ++ ] = ( char ) firstc ; parseloop : { while ( ( c = is . read ( ) ) >= 0 ) { switch ( c ) { case ':' : if ( inKey && len > 0 ) keyend = len ; inKey = false ; break ; case '\t' : c = ' ' ; case ' ' : inKey = false ; break ; case '\r' : case '\n' : firstc = is . read ( ) ; if ( c == '\r' && firstc == '\n' ) { firstc = is . read ( ) ; if ( firstc == '\r' ) firstc = is . read ( ) ; } if ( firstc == '\n' || firstc == '\r' || firstc > ' ' ) break parseloop ; c = ' ' ; break ; } if ( len >= s . length ) { char ns [ ] = new char [ s . length * 2 ] ; System . arraycopy ( s , 0 , ns , 0 , len ) ; s = ns ; } s [ len ++ ] = ( char ) c ; } firstc = - 1 ; } while ( len > 0 && s [ len - 1 ] <= ' ' ) len -- ; String k ; if ( keyend <= 0 ) { k = null ; keyend = 0 ; } else { k = String . copyValueOf ( s , 0 , keyend ) ; if ( keyend < len && s [ keyend ] == ':' ) keyend ++ ; while ( keyend < len && s [ keyend ] <= ' ' ) keyend ++ ; } String v ; if ( keyend >= len ) v = new String ( ) ; else v = String . copyValueOf ( s , keyend , len - keyend ) ; add ( k , v ) ; } }
Parse and merge a MIME header from an input stream .
25,787
public static DayPeriodRules getInstance ( ULocale locale ) { String localeCode = locale . getName ( ) ; if ( localeCode . isEmpty ( ) ) { localeCode = "root" ; } Integer ruleSetNum = null ; while ( ruleSetNum == null ) { ruleSetNum = DATA . localesToRuleSetNumMap . get ( localeCode ) ; if ( ruleSetNum == null ) { localeCode = ULocale . getFallback ( localeCode ) ; if ( localeCode . isEmpty ( ) ) { break ; } } else { break ; } } if ( ruleSetNum == null || DATA . rules [ ruleSetNum ] == null ) { return null ; } return DATA . rules [ ruleSetNum ] ; }
Get a DayPeriodRules object given a locale . If data hasn t been loaded it will be loaded for all locales at once .
25,788
public void write ( byte [ ] b , int off , int len ) throws IOException { if ( def . finished ( ) ) { throw new IOException ( "write beyond end of stream" ) ; } if ( ( off | len | ( off + len ) | ( b . length - ( off + len ) ) ) < 0 ) { throw new IndexOutOfBoundsException ( ) ; } else if ( len == 0 ) { return ; } if ( ! def . finished ( ) ) { def . setInput ( b , off , len ) ; while ( ! def . needsInput ( ) ) { deflate ( ) ; } } }
Writes an array of bytes to the compressed output stream . This method will block until all the bytes are written .
25,789
public void close ( ) throws IOException { if ( ! closed ) { finish ( ) ; if ( usesDefaultDeflater ) def . end ( ) ; out . close ( ) ; closed = true ; } }
Writes remaining compressed data to the output stream and closes the underlying stream .
25,790
protected void deflate ( ) throws IOException { int len = 0 ; while ( ( len = def . deflate ( buf , 0 , buf . length ) ) > 0 ) { out . write ( buf , 0 , len ) ; } }
Writes next block of compressed data to the output stream .
25,791
public void flush ( ) throws IOException { if ( syncFlush && ! def . finished ( ) ) { int len = 0 ; while ( ( len = def . deflate ( buf , 0 , buf . length , Deflater . SYNC_FLUSH ) ) > 0 ) { out . write ( buf , 0 , len ) ; if ( len < buf . length ) break ; } } out . flush ( ) ; }
Flushes the compressed output stream .
25,792
public Object object ( ) { if ( m_DTMXRTreeFrag . getXPathContext ( ) != null ) return new org . apache . xml . dtm . ref . DTMNodeIterator ( ( DTMIterator ) ( new org . apache . xpath . NodeSetDTM ( m_dtmRoot , m_DTMXRTreeFrag . getXPathContext ( ) . getDTMManager ( ) ) ) ) ; else return super . object ( ) ; }
Return a java object that s closest to the representation that should be handed to an extension .
25,793
public static boolean isNonCharacter ( int ch ) { if ( ( ch & NON_CHARACTER_SUFFIX_MIN_3_0_ ) == NON_CHARACTER_SUFFIX_MIN_3_0_ ) { return true ; } return ch >= NON_CHARACTER_MIN_3_1_ && ch <= NON_CHARACTER_MAX_3_1_ ; }
Determines if codepoint is a non character
25,794
static int getNullTermByteSubString ( StringBuffer str , byte [ ] array , int index ) { byte b = 1 ; while ( b != 0 ) { b = array [ index ] ; if ( b != 0 ) { str . append ( ( char ) ( b & 0x00FF ) ) ; } index ++ ; } return index ; }
Retrieves a null terminated substring from an array of bytes . Substring is a set of non - zero bytes starting from argument start to the next zero byte . If the first byte is a zero the next byte will be taken as the first byte .
25,795
static int compareNullTermByteSubString ( String str , byte [ ] array , int strindex , int aindex ) { byte b = 1 ; int length = str . length ( ) ; while ( b != 0 ) { b = array [ aindex ] ; aindex ++ ; if ( b == 0 ) { break ; } if ( strindex == length || ( str . charAt ( strindex ) != ( char ) ( b & 0xFF ) ) ) { return - 1 ; } strindex ++ ; } return strindex ; }
Compares a null terminated substring from an array of bytes . Substring is a set of non - zero bytes starting from argument start to the next zero byte . if the first byte is a zero the next byte will be taken as the first byte .
25,796
static int skipNullTermByteSubString ( byte [ ] array , int index , int skipcount ) { byte b ; for ( int i = 0 ; i < skipcount ; i ++ ) { b = 1 ; while ( b != 0 ) { b = array [ index ] ; index ++ ; } } return index ; }
Skip null terminated substrings from an array of bytes . Substring is a set of non - zero bytes starting from argument start to the next zero byte . If the first byte is a zero the next byte will be taken as the first byte .
25,797
static int skipByteSubString ( byte [ ] array , int index , int length , byte skipend ) { int result ; byte b ; for ( result = 0 ; result < length ; result ++ ) { b = array [ index + result ] ; if ( b == skipend ) { result ++ ; break ; } } return result ; }
skip substrings from an array of characters where each character is a set of 2 bytes . substring is a set of non - zero bytes starting from argument start to the byte of the argument value . skips up to a max number of characters
25,798
final void nextStream ( ) throws IOException { if ( in != null ) { in . close ( ) ; } if ( e . hasMoreElements ( ) ) { in = ( InputStream ) e . nextElement ( ) ; if ( in == null ) throw new NullPointerException ( ) ; } else in = null ; }
Continues reading in the next stream if an EOF is reached .
25,799
public Object getURLStreamHandler ( String protocol ) { URLStreamHandler handler = ( URLStreamHandler ) handlers . get ( protocol ) ; if ( handler == null ) { boolean checkedWithFactory = false ; if ( factory != null ) { handler = factory . createURLStreamHandler ( protocol ) ; checkedWithFactory = true ; } if ( handler == null ) { final String packagePrefixList = System . getProperty ( PROTOCOL_PATH_PROP , "" ) ; StringTokenizer packagePrefixIter = new StringTokenizer ( packagePrefixList , "|" ) ; while ( handler == null && packagePrefixIter . hasMoreTokens ( ) ) { String packagePrefix = packagePrefixIter . nextToken ( ) . trim ( ) ; try { String clsName = packagePrefix + "." + protocol + ".Handler" ; Class < ? > cls = null ; try { ClassLoader cl = ClassLoader . getSystemClassLoader ( ) ; cls = Class . forName ( clsName , true , cl ) ; } catch ( ClassNotFoundException e ) { ClassLoader contextLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( contextLoader != null ) { cls = Class . forName ( clsName , true , contextLoader ) ; } } if ( cls != null ) { handler = ( URLStreamHandler ) cls . newInstance ( ) ; } } catch ( ReflectiveOperationException ignored ) { } } } if ( handler == null ) { try { if ( protocol . equals ( "file" ) ) { handler = new sun . net . www . protocol . file . Handler ( ) ; } else if ( protocol . equals ( "jar" ) ) { throw new UnsupportedOperationException ( "Jar streams are not supported." ) ; } else if ( protocol . equals ( "http" ) ) { handler = new IosHttpHandler ( ) ; } else if ( protocol . equals ( "https" ) ) { try { String name = "com.google.j2objc.net.IosHttpsHandler" ; handler = ( URLStreamHandler ) Class . forName ( name ) . newInstance ( ) ; } catch ( Exception e ) { throw new LibraryNotLinkedError ( "Https support" , "jre_ssl" , "JavaxNetSslHttpsURLConnection" ) ; } } } catch ( Exception e ) { throw new AssertionError ( e ) ; } } synchronized ( streamHandlerLock ) { URLStreamHandler handler2 = null ; handler2 = ( URLStreamHandler ) handlers . get ( protocol ) ; if ( handler2 != null ) { return handler2 ; } if ( ! checkedWithFactory && factory != null ) { handler2 = factory . createURLStreamHandler ( protocol ) ; } if ( handler2 != null ) { handler = handler2 ; } if ( handler != null ) { handlers . put ( protocol , handler ) ; } } } return handler ; }
Returns the Stream Handler .