idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
25,800
private boolean returnValueNeedsIntCast ( Expression arg ) { ExecutableElement methodElement = TreeUtil . getExecutableElement ( arg ) ; assert methodElement != null ; if ( arg . getParent ( ) instanceof ExpressionStatement ) { return false ; } String methodName = nameTable . getMethodSelector ( methodElement ) ; if ( ...
Some native objective - c methods are declared to return NSUInteger .
25,801
public void endVisit ( MethodDeclaration node ) { ExecutableElement element = node . getExecutableElement ( ) ; if ( ! ElementUtil . getName ( element ) . equals ( "compareTo" ) || node . getBody ( ) == null ) { return ; } DeclaredType comparableType = typeUtil . findSupertype ( ElementUtil . getDeclaringClass ( elemen...
Adds a cast check to compareTo methods . This helps Comparable types behave well in sorted collections which rely on Java s runtime type checking .
25,802
private StringBuffer format ( long number , StringBuffer result , FieldDelegate delegate ) { boolean isNegative = ( number < 0 ) ; if ( isNegative ) { number = - number ; } boolean useBigInteger = false ; if ( number < 0 ) { if ( multiplier != 0 ) { useBigInteger = true ; } } else if ( multiplier != 1 && multiplier != ...
Format a long to produce a string .
25,803
private void checkAndSetFastPathStatus ( ) { boolean fastPathWasOn = isFastPath ; if ( ( roundingMode == RoundingMode . HALF_EVEN ) && ( isGroupingUsed ( ) ) && ( groupingSize == 3 ) && ( secondaryGroupingSize == 0 ) && ( multiplier == 1 ) && ( ! decimalSeparatorAlwaysShown ) && ( ! useExponentialNotation ) ) { isFastP...
Check validity of using fast - path for this instance . If fast - path is valid for this instance sets fast - path state as true and initializes fast - path utility fields as needed .
25,804
private void fastDoubleFormat ( double d , boolean negative ) { char [ ] container = fastPathData . fastPathContainer ; int integralPartAsInt = ( int ) d ; double exactFractionalPart = d - ( double ) integralPartAsInt ; double scaledFractional = exactFractionalPart * fastPathData . fractionalScaleFactor ; int fractiona...
This is the main entry point for the fast - path format algorithm .
25,805
public void setDecimalFormatSymbols ( DecimalFormatSymbols newSymbols ) { try { symbols = ( DecimalFormatSymbols ) newSymbols . clone ( ) ; expandAffixes ( ) ; fastPathCheckNeeded = true ; } catch ( Exception foo ) { } }
Sets the decimal format symbols which is generally not changed by the programmer or user .
25,806
private void expandAffixes ( ) { StringBuffer buffer = new StringBuffer ( ) ; if ( posPrefixPattern != null ) { positivePrefix = expandAffix ( posPrefixPattern , buffer ) ; positivePrefixFieldPositions = null ; } if ( posSuffixPattern != null ) { positiveSuffix = expandAffix ( posSuffixPattern , buffer ) ; positiveSuff...
Expand the affix pattern strings into the expanded affix strings . If any affix pattern string is null do not expand it . This method should be called any time the symbols or the affix patterns change in order to keep the expanded affix strings up to date .
25,807
private void appendAffix ( StringBuffer buffer , String affix , boolean localized ) { boolean needQuote ; if ( localized ) { needQuote = affix . indexOf ( symbols . getZeroDigit ( ) ) >= 0 || affix . indexOf ( symbols . getGroupingSeparator ( ) ) >= 0 || affix . indexOf ( symbols . getDecimalSeparator ( ) ) >= 0 || aff...
Append an affix to the given StringBuffer using quotes if there are special characters . Single quotes themselves must be escaped in either case .
25,808
private String toPattern ( boolean localized ) { StringBuffer result = new StringBuffer ( ) ; for ( int j = 1 ; j >= 0 ; -- j ) { if ( j == 1 ) appendAffix ( result , posPrefixPattern , positivePrefix , localized ) ; else appendAffix ( result , negPrefixPattern , negativePrefix , localized ) ; int i ; int digitCount = ...
Does the real work of generating a pattern .
25,809
private static final long getNegDivMod ( int number , int factor ) { int modulo = number % factor ; long result = number / factor ; if ( modulo < 0 ) { -- result ; modulo += factor ; } return ( result << 32 ) | modulo ; }
Integer division and modulo with negative numerators yields negative modulo results and quotients that are one more than what we need here .
25,810
public static java . util . Enumeration < Driver > getDrivers ( ) { java . util . Vector < Driver > result = new java . util . Vector < Driver > ( ) ; ClassLoader callerClassLoader = ClassLoader . getSystemClassLoader ( ) ; for ( DriverInfo aDriver : registeredDrivers ) { if ( isDriverAllowed ( aDriver . driver , calle...
Retrieves an Enumeration with all of the currently loaded JDBC drivers to which the current caller has access .
25,811
public static void println ( String message ) { synchronized ( logSync ) { if ( logWriter != null ) { logWriter . println ( message ) ; logWriter . flush ( ) ; } } }
Prints a message to the current JDBC log stream .
25,812
public int shape ( char [ ] source , int sourceStart , int sourceLength , char [ ] dest , int destStart , int destSize ) throws ArabicShapingException { if ( source == null ) { throw new IllegalArgumentException ( "source can not be null" ) ; } if ( sourceStart < 0 || sourceLength < 0 || sourceStart + sourceLength > so...
Convert a range of text in the source array putting the result into a range of text in the destination array and return the number of characters written .
25,813
public void shape ( char [ ] source , int start , int length ) throws ArabicShapingException { if ( ( options & LAMALEF_MASK ) == LAMALEF_RESIZE ) { throw new ArabicShapingException ( "Cannot shape in place with length option resize." ) ; } shape ( source , start , length , source , start , length ) ; }
Convert a range of text in place . This may only be used if the Length option does not grow or shrink the text .
25,814
public String shape ( String text ) throws ArabicShapingException { char [ ] src = text . toCharArray ( ) ; char [ ] dest = src ; if ( ( ( options & LAMALEF_MASK ) == LAMALEF_RESIZE ) && ( ( options & LETTERS_MASK ) == LETTERS_UNSHAPE ) ) { dest = new char [ src . length * 2 ] ; } int len = shape ( src , 0 , src . leng...
Convert a string returning the new string .
25,815
public final int accumulateAndGet ( int x , IntBinaryOperator accumulatorFunction ) { int prev , next ; do { prev = get ( ) ; next = accumulatorFunction . applyAsInt ( prev , x ) ; } while ( ! compareAndSet ( prev , next ) ) ; return next ; }
Atomically updates the current value with the results of applying the given function to the current and given values returning the updated value . The function should be side - effect - free since it may be re - applied when attempted updates fail due to contention among threads . The function is applied with the curre...
25,816
private int internalAwaitAdvance ( int phase , QNode node ) { releaseWaiters ( phase - 1 ) ; boolean queued = false ; int lastUnarrived = 0 ; int spins = SPINS_PER_ARRIVAL ; long s ; int p ; while ( ( p = ( int ) ( ( s = state ) >>> PHASE_SHIFT ) ) == phase ) { if ( node == null ) { int unarrived = ( int ) s & UNARRIVE...
Possibly blocks and waits for phase to advance unless aborted . Call only on root phaser .
25,817
public void applyPattern ( String pattern ) { this . pattern = pattern ; if ( msgPattern == null ) { msgPattern = new MessagePattern ( ) ; } try { msgPattern . parseSelectStyle ( pattern ) ; } catch ( RuntimeException e ) { reset ( ) ; throw e ; } }
Sets the pattern used by this select format . Patterns and their interpretation are specified in the class description .
25,818
public final String format ( String keyword ) { if ( ! PatternProps . isIdentifier ( keyword ) ) { throw new IllegalArgumentException ( "Invalid formatting argument." ) ; } if ( msgPattern == null || msgPattern . countParts ( ) == 0 ) { throw new IllegalStateException ( "Invalid format error." ) ; } int msgStart = find...
Selects the phrase for the given keyword .
25,819
void mergesort ( Vector a , Vector b , int l , int r , XPathContext support ) throws TransformerException { if ( ( r - l ) > 0 ) { int m = ( r + l ) / 2 ; mergesort ( a , b , l , m , support ) ; mergesort ( a , b , m + 1 , r , support ) ; int i , j , k ; for ( i = m ; i >= l ; i -- ) { if ( i >= b . size ( ) ) b . inse...
This implements a standard Mergesort as described in Robert Sedgewick s Algorithms book . This is a better sort for our purpose than the Quicksort because it maintains the original document order of the input if the order isn t changed by the sort .
25,820
protected int chunkSize ( int n ) { int power = ( n == 0 || n == 1 ) ? initialChunkPower : Math . min ( initialChunkPower + n - 1 , AbstractSpinedBuffer . MAX_CHUNK_POWER ) ; return 1 << power ; }
How big should the nth chunk be?
25,821
public AVT getLiteralResultAttributeNS ( String namespaceURI , String localName ) { if ( null != m_avts ) { int nAttrs = m_avts . size ( ) ; for ( int i = ( nAttrs - 1 ) ; i >= 0 ; i -- ) { AVT avt = ( AVT ) m_avts . get ( i ) ; if ( avt . getName ( ) . equals ( localName ) && avt . getURI ( ) . equals ( namespaceURI )...
Get a literal result attribute by name .
25,822
public void resolvePrefixTables ( ) throws TransformerException { super . resolvePrefixTables ( ) ; StylesheetRoot stylesheet = getStylesheetRoot ( ) ; if ( ( null != m_namespace ) && ( m_namespace . length ( ) > 0 ) ) { NamespaceAlias nsa = stylesheet . getNamespaceAliasComposed ( m_namespace ) ; if ( null != nsa ) { ...
Augment resolvePrefixTables resolving the namespace aliases once the superclass has resolved the tables .
25,823
boolean needToCheckExclude ( ) { if ( null == m_excludeResultPrefixes && null == getPrefixTable ( ) && m_ExtensionElementURIs == null ) return false ; else { if ( null == getPrefixTable ( ) ) setPrefixTable ( new java . util . ArrayList ( ) ) ; return true ; } }
Return whether we need to check namespace prefixes against the exclude result prefixes or extensions lists . Note that this will create a new prefix table if one has not been created already .
25,824
public String getPrefix ( ) { int len = m_rawName . length ( ) - m_localName . length ( ) - 1 ; return ( len > 0 ) ? m_rawName . substring ( 0 , len ) : "" ; }
Get the prefix part of the raw name of the Literal Result Element .
25,825
public void throwDOMException ( short code , String msg ) { String themsg = XSLMessages . createMessage ( msg , null ) ; throw new DOMException ( code , themsg ) ; }
Throw a DOMException
25,826
public static NFSubstitution makeSubstitution ( int pos , NFRule rule , NFRule rulePredecessor , NFRuleSet ruleSet , RuleBasedNumberFormat formatter , String description ) { if ( description . length ( ) == 0 ) { return null ; } switch ( description . charAt ( 0 ) ) { case '<' : if ( rule . getBaseValue ( ) == NFRule ....
Parses the description creates the right kind of substitution and initializes it based on the description .
25,827
public void setDivisor ( int radix , short exponent ) { divisor = NFRule . power ( radix , exponent ) ; if ( divisor == 0 ) { throw new IllegalStateException ( "Substitution with divisor 0" ) ; } }
Sets the substitution s divisor based on the values passed in .
25,828
public void doSubstitution ( long number , StringBuilder toInsertInto , int position , int recursionCount ) { if ( ruleToUse == null ) { super . doSubstitution ( number , toInsertInto , position , recursionCount ) ; } else { long numberToFormat = transformNumber ( number ) ; ruleToUse . doFormat ( numberToFormat , toIn...
If this is a &gt ; &gt ; &gt ; substitution use ruleToUse to fill in the substitution . Otherwise just use the superclass function .
25,829
public Number doParse ( String text , ParsePosition parsePosition , double baseValue , double upperBound , boolean lenientParse ) { if ( ruleToUse == null ) { return super . doParse ( text , parsePosition , baseValue , upperBound , lenientParse ) ; } else { Number tempResult = ruleToUse . doParse ( text , parsePosition...
If this is a &gt ; &gt ; &gt ; substitution match only against ruleToUse . Otherwise use the superclass function .
25,830
public void doSubstitution ( double number , StringBuilder toInsertInto , int position , int recursionCount ) { if ( ! byDigits ) { super . doSubstitution ( number , toInsertInto , position , recursionCount ) ; } else { DigitList dl = new DigitList ( ) ; dl . set ( number , 20 , true ) ; boolean pad = false ; while ( d...
If in by digits mode fills in the substitution one decimal digit at a time using the rule set containing this substitution . Otherwise uses the superclass function .
25,831
public Number doParse ( String text , ParsePosition parsePosition , double baseValue , double upperBound , boolean lenientParse ) { if ( ! byDigits ) { return super . doParse ( text , parsePosition , baseValue , 0 , lenientParse ) ; } else { String workText = text ; ParsePosition workPos = new ParsePosition ( 1 ) ; dou...
If in by digits mode parses the string as if it were a string of individual digits ; otherwise uses the superclass function .
25,832
public Number doParse ( String text , ParsePosition parsePosition , double baseValue , double upperBound , boolean lenientParse ) { int zeroCount = 0 ; if ( withZeros ) { String workText = text ; ParsePosition workPos = new ParsePosition ( 1 ) ; while ( workText . length ( ) > 0 && workPos . getIndex ( ) != 0 ) { workP...
Dispatches to the inherited version of this function but makes sure that lenientParse is off .
25,833
public DTMAxisIterator cloneIterator ( ) { try { final DTMAxisIteratorBase clone = ( DTMAxisIteratorBase ) super . clone ( ) ; clone . _isRestartable = false ; return clone ; } catch ( CloneNotSupportedException e ) { throw new org . apache . xml . utils . WrappedRuntimeException ( e ) ; } }
Returns a deep copy of this iterator . Cloned iterators may not be restartable . The iterator being cloned may or may not become non - restartable as a side effect of this operation .
25,834
public int getNodeByPosition ( int position ) { if ( position > 0 ) { final int pos = isReverse ( ) ? getLast ( ) - position + 1 : position ; int node ; while ( ( node = next ( ) ) != DTMAxisIterator . END ) { if ( pos == getPosition ( ) ) { return node ; } } } return END ; }
Return the node at the given position .
25,835
public static boolean isPrivateInnerType ( TypeElement type ) { switch ( type . getNestingKind ( ) ) { case ANONYMOUS : case LOCAL : return true ; case MEMBER : return isPrivate ( type ) || isPrivateInnerType ( ( TypeElement ) type . getEnclosingElement ( ) ) ; case TOP_LEVEL : return isPrivate ( type ) ; } throw new A...
Tests if this type element is private to it s source file . A public type declared within a private type is considered private .
25,836
public static boolean hasOuterContext ( TypeElement type ) { switch ( type . getNestingKind ( ) ) { case ANONYMOUS : case LOCAL : return ! isStatic ( type . getEnclosingElement ( ) ) ; case MEMBER : return ! isStatic ( type ) ; case TOP_LEVEL : return false ; } throw new AssertionError ( "Unknown NestingKind" ) ; }
Determines if a type element can access fields and methods from an outer class .
25,837
public static Set < String > parsePropertyAttribute ( AnnotationMirror annotation ) { assert getName ( annotation . getAnnotationType ( ) . asElement ( ) ) . equals ( "Property" ) ; String attributesStr = ( String ) getAnnotationValue ( annotation , "value" ) ; Set < String > attributes = new HashSet < > ( ) ; if ( att...
Returns the attributes of a Property annotation .
25,838
public static ExecutableElement findGetterMethod ( String propertyName , TypeMirror propertyType , TypeElement declaringClass , boolean isStatic ) { ExecutableElement getter = ElementUtil . findMethod ( declaringClass , propertyName ) ; if ( getter == null ) { String prefix = TypeUtil . isBoolean ( propertyType ) ? "is...
Locate method which matches either Java or Objective C getter name patterns .
25,839
public static int fromModifierSet ( Set < Modifier > set ) { int modifiers = 0 ; if ( set . contains ( Modifier . PUBLIC ) ) { modifiers |= java . lang . reflect . Modifier . PUBLIC ; } if ( set . contains ( Modifier . PRIVATE ) ) { modifiers |= java . lang . reflect . Modifier . PRIVATE ; } if ( set . contains ( Modif...
This conversion is lossy because there is no bit for default the JVM spec .
25,840
public static boolean hasNamedAnnotation ( AnnotatedConstruct ac , String name ) { for ( AnnotationMirror annotation : ac . getAnnotationMirrors ( ) ) { if ( getName ( annotation . getAnnotationType ( ) . asElement ( ) ) . equals ( name ) ) { return true ; } } return false ; }
Less strict version of the above where we don t care about the annotation s package .
25,841
public static boolean hasNamedAnnotation ( AnnotatedConstruct ac , Pattern pattern ) { for ( AnnotationMirror annotation : ac . getAnnotationMirrors ( ) ) { if ( pattern . matcher ( getName ( annotation . getAnnotationType ( ) . asElement ( ) ) ) . matches ( ) ) { return true ; } } return false ; }
Similar to the above but matches against a pattern .
25,842
public static List < ExecutableElement > getSortedAnnotationMembers ( TypeElement annotation ) { List < ExecutableElement > members = Lists . newArrayList ( getMethods ( annotation ) ) ; Collections . sort ( members , ( m1 , m2 ) -> getName ( m1 ) . compareTo ( getName ( m2 ) ) ) ; return members ; }
Returns an alphabetically sorted list of an annotation type s members . This is necessary since an annotation s values can be specified in any order but the annotation s constructor needs to be invoked using its declaration order .
25,843
@ SuppressWarnings ( "unchecked" ) public static boolean suppressesWarning ( String warning , Element element ) { if ( element == null || isPackage ( element ) ) { return false ; } AnnotationMirror annotation = getAnnotation ( element , SuppressWarnings . class ) ; if ( annotation != null ) { for ( AnnotationValue elem...
Returns true if there s a SuppressedWarning annotation with the specified warning . The SuppressWarnings annotation can be inherited from the owning method or class but does not have package scope .
25,844
public TypeMirror getType ( Element element ) { return elementTypeMap . containsKey ( element ) ? elementTypeMap . get ( element ) : element . asType ( ) ; }
Returns the associated type mirror for an element .
25,845
public static boolean isNonnull ( Element element , boolean parametersNonnullByDefault ) { return hasNonnullAnnotation ( element ) || isConstructor ( element ) || ( isParameter ( element ) && parametersNonnullByDefault && ! ( ( VariableElement ) element ) . asType ( ) . getKind ( ) . isPrimitive ( ) ) ; }
Returns whether an element is marked as always being non - null . Field method and parameter elements can be defined as non - null with a Nonnull annotation . Method parameters can also be defined as non - null by annotating the owning package or type element with the ParametersNonnullByDefault annotation .
25,846
public static String getSourceFile ( TypeElement type ) { if ( type instanceof ClassSymbol ) { JavaFileObject srcFile = ( ( ClassSymbol ) type ) . sourcefile ; if ( srcFile != null ) { return srcFile . getName ( ) ; } } return null ; }
Returns the source file name for a type element . Returns null if the element isn t a javac ClassSymbol or if it is defined by a classfile which was compiled without a source attribute .
25,847
public static boolean isAbsolutePath ( String systemId ) { if ( systemId == null ) return false ; final File file = new File ( systemId ) ; return file . isAbsolute ( ) ; }
Return true if the local path is an absolute path .
25,848
private static String replaceChars ( String str ) { StringBuffer buf = new StringBuffer ( str ) ; int length = buf . length ( ) ; for ( int i = 0 ; i < length ; i ++ ) { char currentChar = buf . charAt ( i ) ; if ( currentChar == ' ' ) { buf . setCharAt ( i , '%' ) ; buf . insert ( i + 1 , "20" ) ; length = length + 2 ...
Replace spaces with %20 and backslashes with forward slashes in the input string to generate a well - formed URI string .
25,849
public static ProviderList newList ( Provider ... providers ) { ProviderConfig [ ] configs = new ProviderConfig [ providers . length ] ; for ( int i = 0 ; i < providers . length ; i ++ ) { configs [ i ] = new ProviderConfig ( providers [ i ] ) ; } return new ProviderList ( configs , true ) ; }
This method is for use by SunJSSE .
25,850
ProviderList getJarList ( String [ ] jarClassNames ) { List < ProviderConfig > newConfigs = new ArrayList < > ( ) ; for ( String className : jarClassNames ) { ProviderConfig newConfig = new ProviderConfig ( className ) ; for ( ProviderConfig config : configs ) { if ( config . equals ( newConfig ) ) { newConfig = config...
Construct a special ProviderList for JAR verification . It consists of the providers specified via jarClassNames which must be on the bootclasspath and cannot be in signed JAR files . This is to avoid possible recursion and deadlock during verification .
25,851
Provider getProvider ( int index ) { Provider p = configs [ index ] . getProvider ( ) ; return ( p != null ) ? p : EMPTY_PROVIDER ; }
Return the Provider at the specified index . Returns EMPTY_PROVIDER if the provider could not be loaded at this time .
25,852
public Provider getProvider ( String name ) { ProviderConfig config = getProviderConfig ( name ) ; return ( config == null ) ? null : config . getProvider ( ) ; }
return the Provider with the specified name or null
25,853
public int getIndex ( String name ) { for ( int i = 0 ; i < configs . length ; i ++ ) { Provider p = getProvider ( i ) ; if ( p . getName ( ) . equals ( name ) ) { return i ; } } return - 1 ; }
Return the index at which the provider with the specified name is installed or - 1 if it is not present in this ProviderList .
25,854
private int loadAll ( ) { if ( allLoaded ) { return configs . length ; } if ( debug != null ) { debug . println ( "Loading all providers" ) ; new Exception ( "Call trace" ) . printStackTrace ( ) ; } int n = 0 ; for ( int i = 0 ; i < configs . length ; i ++ ) { Provider p = configs [ i ] . getProvider ( ) ; if ( p != nu...
attempt to load all Providers not already loaded
25,855
ProviderList removeInvalid ( ) { int n = loadAll ( ) ; if ( n == configs . length ) { return this ; } ProviderConfig [ ] newConfigs = new ProviderConfig [ n ] ; for ( int i = 0 , j = 0 ; i < configs . length ; i ++ ) { ProviderConfig config = configs [ i ] ; if ( config . isLoaded ( ) ) { newConfigs [ j ++ ] = config ;...
Try to load all Providers and return the ProviderList . If one or more Providers could not be loaded a new ProviderList with those entries removed is returned . Otherwise the method returns this .
25,856
public Service getService ( String type , String name ) { for ( int i = 0 ; i < configs . length ; i ++ ) { Provider p = getProvider ( i ) ; Service s = p . getService ( type , name ) ; if ( s != null ) { return s ; } } return null ; }
Return a Service describing an implementation of the specified algorithm from the Provider with the highest precedence that supports that algorithm . Return null if no Provider supports this algorithm .
25,857
public List < Service > getServices ( String type , String algorithm ) { return new ServiceList ( type , algorithm ) ; }
Return a List containing all the Services describing implementations of the specified algorithms in precedence order . If no implementation exists this method returns an empty List .
25,858
public Formatter format ( String format , Object ... args ) { return format ( l , format , args ) ; }
Writes a formatted string to this object s destination using the specified format string and arguments . The locale used is the one defined during the construction of this formatter .
25,859
public Formatter format ( Locale l , String format , Object ... args ) { ensureOpen ( ) ; int last = - 1 ; int lasto = - 1 ; FormatString [ ] fsa = parse ( format ) ; for ( int i = 0 ; i < fsa . length ; i ++ ) { FormatString fs = fsa [ i ] ; int index = fs . index ( ) ; try { switch ( index ) { case - 2 : fs . print (...
Writes a formatted string to this object s destination using the specified locale format string and arguments .
25,860
private FormatString [ ] parse ( String s ) { ArrayList < FormatString > al = new ArrayList < > ( ) ; for ( int i = 0 , len = s . length ( ) ; i < len ; ) { int nextPercent = s . indexOf ( '%' , i ) ; if ( s . charAt ( i ) != '%' ) { int plainTextStart = i ; int plainTextEnd = ( nextPercent == - 1 ) ? len : nextPercent...
Finds format specifiers in the format string .
25,861
public boolean failsChecks ( String text , CheckResult checkResult ) { int length = text . length ( ) ; int result = 0 ; if ( checkResult != null ) { checkResult . position = 0 ; checkResult . numerics = null ; checkResult . restrictionLevel = null ; } if ( 0 != ( this . fChecks & RESTRICTION_LEVEL ) ) { RestrictionLev...
Check the specified string for possible security issues . The text to be checked will typically be an identifier of some sort . The set of checks to be performed was specified when building the SpoofChecker .
25,862
public int areConfusable ( String s1 , String s2 ) { if ( ( this . fChecks & CONFUSABLE ) == 0 ) { throw new IllegalArgumentException ( "No confusable checks are enabled." ) ; } String s1Skeleton = getSkeleton ( s1 ) ; String s2Skeleton = getSkeleton ( s2 ) ; if ( ! s1Skeleton . equals ( s2Skeleton ) ) { return 0 ; } S...
Check the whether two specified strings are visually confusable . The types of confusability to be tested - single script mixed script or whole script - are determined by the check options set for the SpoofChecker .
25,863
public String getSkeleton ( CharSequence str ) { String nfdId = nfdNormalizer . normalize ( str ) ; int normalizedLen = nfdId . length ( ) ; StringBuilder skelSB = new StringBuilder ( ) ; for ( int inputIndex = 0 ; inputIndex < normalizedLen ; ) { int c = Character . codePointAt ( nfdId , inputIndex ) ; inputIndex += C...
Get the skeleton for an identifier string . Skeletons are a transformation of the input string ; Two strings are confusable if their skeletons are identical . See Unicode UAX 39 for additional information .
25,864
private static void getAugmentedScriptSet ( int codePoint , ScriptSet result ) { result . clear ( ) ; UScript . getScriptExtensions ( codePoint , result ) ; if ( result . get ( UScript . HAN ) ) { result . set ( UScript . HAN_WITH_BOPOMOFO ) ; result . set ( UScript . JAPANESE ) ; result . set ( UScript . KOREAN ) ; } ...
Computes the augmented script set for a code point according to UTS 39 section 5 . 1 .
25,865
private void getResolvedScriptSet ( CharSequence input , ScriptSet result ) { getResolvedScriptSetWithout ( input , UScript . CODE_LIMIT , result ) ; }
Computes the resolved script set for a string according to UTS 39 section 5 . 1 .
25,866
private void getResolvedScriptSetWithout ( CharSequence input , int script , ScriptSet result ) { result . setAll ( ) ; ScriptSet temp = new ScriptSet ( ) ; for ( int utf16Offset = 0 ; utf16Offset < input . length ( ) ; ) { int codePoint = Character . codePointAt ( input , utf16Offset ) ; utf16Offset += Character . cha...
Computes the resolved script set for a string omitting characters having the specified script . If UScript . CODE_LIMIT is passed as the second argument all characters are included .
25,867
private void getNumerics ( String input , UnicodeSet result ) { result . clear ( ) ; for ( int utf16Offset = 0 ; utf16Offset < input . length ( ) ; ) { int codePoint = Character . codePointAt ( input , utf16Offset ) ; utf16Offset += Character . charCount ( codePoint ) ; if ( UCharacter . getType ( codePoint ) == UChara...
Computes the set of numerics for a string according to UTS 39 section 5 . 3 .
25,868
private RestrictionLevel getRestrictionLevel ( String input ) { if ( ! fAllowedCharsSet . containsAll ( input ) ) { return RestrictionLevel . UNRESTRICTIVE ; } if ( ASCII . containsAll ( input ) ) { return RestrictionLevel . ASCII ; } ScriptSet resolvedScriptSet = new ScriptSet ( ) ; getResolvedScriptSet ( input , reso...
Computes the restriction level of a string according to UTS 39 section 5 . 2 .
25,869
private void buildIndex ( Collection < ? > coll ) { certSubjects = new HashMap < X500Principal , Object > ( ) ; crlIssuers = new HashMap < X500Principal , Object > ( ) ; otherCertificates = null ; otherCRLs = null ; for ( Object obj : coll ) { if ( obj instanceof X509Certificate ) { indexCertificate ( ( X509Certificate...
Index the specified Collection copying all references to Certificates and CRLs .
25,870
private void indexCertificate ( X509Certificate cert ) { X500Principal subject = cert . getSubjectX500Principal ( ) ; Object oldEntry = certSubjects . put ( subject , cert ) ; if ( oldEntry != null ) { if ( oldEntry instanceof X509Certificate ) { if ( cert . equals ( oldEntry ) ) { return ; } List < X509Certificate > l...
Add an X509Certificate to the index .
25,871
private void indexCRL ( X509CRL crl ) { X500Principal issuer = crl . getIssuerX500Principal ( ) ; Object oldEntry = crlIssuers . put ( issuer , crl ) ; if ( oldEntry != null ) { if ( oldEntry instanceof X509CRL ) { if ( crl . equals ( oldEntry ) ) { return ; } List < X509CRL > list = new ArrayList < > ( 2 ) ; list . ad...
Add an X509CRL to the index .
25,872
private void matchX509Certs ( CertSelector selector , Collection < Certificate > matches ) { for ( Object obj : certSubjects . values ( ) ) { if ( obj instanceof X509Certificate ) { X509Certificate cert = ( X509Certificate ) obj ; if ( selector . match ( cert ) ) { matches . add ( cert ) ; } } else { @ SuppressWarnings...
Iterate through all the X509Certificates and add matches to the collection .
25,873
private void matchX509CRLs ( CRLSelector selector , Collection < CRL > matches ) { for ( Object obj : crlIssuers . values ( ) ) { if ( obj instanceof X509CRL ) { X509CRL crl = ( X509CRL ) obj ; if ( selector . match ( crl ) ) { matches . add ( crl ) ; } } else { @ SuppressWarnings ( "unchecked" ) List < X509CRL > list ...
Iterate through all the X509CRLs and add matches to the collection .
25,874
public Node renameNode ( Node n , String namespaceURI , String name ) throws DOMException { return n ; }
DOM Level 3 Renaming node
25,875
protected String resolvePrefix ( SerializationHandler rhandler , String prefix , String nodeNamespace ) throws TransformerException { if ( null != prefix && ( prefix . length ( ) == 0 || prefix . equals ( "xmlns" ) ) ) { prefix = rhandler . getPrefix ( nodeNamespace ) ; if ( null == prefix || prefix . length ( ) == 0 |...
Resolve the namespace into a prefix . At this level if no prefix exists then return a manufactured prefix .
25,876
protected boolean validateNodeName ( String nodeName ) { if ( null == nodeName ) return false ; if ( nodeName . equals ( "xmlns" ) ) return false ; return XML11Char . isXML11ValidQName ( nodeName ) ; }
Validate that the node name is good .
25,877
public final DoubleStream limit ( long maxSize ) { if ( maxSize < 0 ) throw new IllegalArgumentException ( Long . toString ( maxSize ) ) ; return SliceOps . makeDouble ( this , ( long ) 0 , maxSize ) ; }
Stateful intermediate ops from DoubleStream
25,878
private void grow ( ) { m_allocatedSize *= 2 ; boolean newVector [ ] = new boolean [ m_allocatedSize ] ; System . arraycopy ( m_values , 0 , newVector , 0 , m_index + 1 ) ; m_values = newVector ; }
Grows the size of the stack
25,879
public String getMessage ( ) { String gaiName = OsConstants . gaiName ( error ) ; if ( gaiName == null ) { gaiName = "GAI_ error " + error ; } String description = NetworkOs . gai_strerror ( error ) ; return functionName + " failed: " + gaiName + " (" + description + ")" ; }
Converts the stashed function name and error value to a human - readable string . We do this here rather than in the constructor so that callers only pay for this if they need it .
25,880
private static ZoneId ofWithPrefix ( String zoneId , int prefixLength , boolean checkAvailable ) { String prefix = zoneId . substring ( 0 , prefixLength ) ; if ( zoneId . length ( ) == prefixLength ) { return ofOffset ( prefix , ZoneOffset . UTC ) ; } if ( zoneId . charAt ( prefixLength ) != '+' && zoneId . charAt ( pr...
Parse once a prefix is established .
25,881
private void executeFallbacks ( TransformerImpl transformer ) throws TransformerException { for ( ElemTemplateElement child = m_firstChild ; child != null ; child = child . m_nextSibling ) { if ( child . getXSLToken ( ) == Constants . ELEMNAME_FALLBACK ) { try { transformer . pushElemTemplateElement ( child ) ; ( ( Ele...
Execute the fallbacks when an extension is not available .
25,882
public void execute ( TransformerImpl transformer ) throws TransformerException { try { if ( hasFallbackChildren ( ) ) { executeFallbacks ( transformer ) ; } else { } } catch ( TransformerException e ) { transformer . getErrorListener ( ) . fatalError ( e ) ; } }
Execute an unknown element . Execute fallback if fallback child exists or do nothing
25,883
public void close ( ) throws IOException { synchronized ( lock ) { if ( encoder != null ) { drainEncoder ( ) ; flushBytes ( false ) ; out . close ( ) ; encoder = null ; bytes = null ; } } }
Closes this writer . This implementation flushes the buffer as well as the target stream . The target stream is then closed and the resources for the buffer and converter are released .
25,884
public List < RDN > rdns ( ) { List < RDN > list = rdnList ; if ( list == null ) { list = Collections . unmodifiableList ( Arrays . asList ( names ) ) ; rdnList = list ; } return list ; }
Return an immutable List of all RDNs in this X500Name .
25,885
public List < AVA > allAvas ( ) { List < AVA > list = allAvaList ; if ( list == null ) { list = new ArrayList < AVA > ( ) ; for ( int i = 0 ; i < names . length ; i ++ ) { list . addAll ( names [ i ] . avas ( ) ) ; } } return list ; }
Return an immutable List of the the AVAs contained in all the RDNs of this X500Name .
25,886
public boolean isEmpty ( ) { int n = names . length ; if ( n == 0 ) { return true ; } for ( int i = 0 ; i < n ; i ++ ) { if ( names [ i ] . assertion . length != 0 ) { return false ; } } return true ; }
Return whether this X500Name is empty . An X500Name is not empty if it has at least one RDN containing at least one AVA .
25,887
public void encode ( DerOutputStream out ) throws IOException { DerOutputStream tmp = new DerOutputStream ( ) ; for ( int i = 0 ; i < names . length ; i ++ ) { names [ i ] . encode ( tmp ) ; } out . write ( DerValue . tag_Sequence , tmp ) ; }
Encodes the name in DER - encoded form .
25,888
public byte [ ] getEncodedInternal ( ) throws IOException { if ( encoded == null ) { DerOutputStream out = new DerOutputStream ( ) ; DerOutputStream tmp = new DerOutputStream ( ) ; for ( int i = 0 ; i < names . length ; i ++ ) { names [ i ] . encode ( tmp ) ; } out . write ( DerValue . tag_Sequence , tmp ) ; encoded = ...
Returned the encoding as an uncloned byte array . Callers must guarantee that they neither modify it not expose it to untrusted code .
25,889
private void checkNoNewLinesNorTabsAtBeginningOfDN ( String input ) { for ( int i = 0 ; i < input . length ( ) ; i ++ ) { char c = input . charAt ( i ) ; if ( c != ' ' ) { if ( c == '\t' || c == '\n' ) { throw new IllegalArgumentException ( "DN cannot start with newline nor tab" ) ; } break ; } } }
Disallow new lines and tabs at the beginning of DN .
25,890
private boolean isWithinSubtree ( X500Name other ) { if ( this == other ) { return true ; } if ( other == null ) { return false ; } if ( other . names . length == 0 ) { return true ; } if ( this . names . length == 0 ) { return false ; } if ( names . length < other . names . length ) { return false ; } for ( int i = 0 ...
Compares this name with another and determines if it is within the subtree of the other . Useful for checking against the name constraints extension .
25,891
public X500Name commonAncestor ( X500Name other ) { if ( other == null ) { return null ; } int otherLen = other . names . length ; int thisLen = this . names . length ; if ( thisLen == 0 || otherLen == 0 ) { return null ; } int minLen = ( thisLen < otherLen ) ? thisLen : otherLen ; int i = 0 ; for ( ; i < minLen ; i ++...
Return lowest common ancestor of this name and other name
25,892
public X500Principal asX500Principal ( ) { if ( x500Principal == null ) { try { Object [ ] args = new Object [ ] { this } ; x500Principal = ( X500Principal ) principalConstructor . newInstance ( args ) ; } catch ( Exception e ) { throw new RuntimeException ( "Unexpected exception" , e ) ; } } return x500Principal ; }
Get an X500Principal backed by this X500Name .
25,893
public static X500Name asX500Name ( X500Principal p ) { try { X500Name name = ( X500Name ) principalField . get ( p ) ; name . x500Principal = p ; return name ; } catch ( Exception e ) { throw new RuntimeException ( "Unexpected exception" , e ) ; } }
Get the X500Name contained in the given X500Principal .
25,894
public final int updateAndGet ( T obj , IntUnaryOperator updateFunction ) { int prev , next ; do { prev = get ( obj ) ; next = updateFunction . applyAsInt ( prev ) ; } while ( ! compareAndSet ( obj , prev , next ) ) ; return next ; }
Atomically updates the field of the given object managed by this updater with the results of applying the given function returning the updated value . The function should be side - effect - free since it may be re - applied when attempted updates fail due to contention among threads .
25,895
public CodeSigner [ ] verify ( Hashtable < String , CodeSigner [ ] > verifiedSigners , Hashtable < String , CodeSigner [ ] > sigFileSigners ) throws JarException { if ( skip ) { return null ; } if ( signers != null ) return signers ; for ( int i = 0 ; i < digests . size ( ) ; i ++ ) { MessageDigest digest = digests . g...
go through all the digests calculating the final digest and comparing it to the one in the manifest . If this is the first time we have verified this object remove its code signers from sigFileSigners and place in verifiedSigners .
25,896
public final int getIndex ( String qname ) { int index ; if ( super . getLength ( ) < MAX ) { index = super . getIndex ( qname ) ; return index ; } Integer i = ( Integer ) m_indexFromQName . get ( qname ) ; if ( i == null ) index = - 1 ; else index = i . intValue ( ) ; return index ; }
This method gets the index of an attribute given its qName .
25,897
private void switchOverToHash ( int numAtts ) { for ( int index = 0 ; index < numAtts ; index ++ ) { String qName = super . getQName ( index ) ; Integer i = new Integer ( index ) ; m_indexFromQName . put ( qName , i ) ; String uri = super . getURI ( index ) ; String local = super . getLocalName ( index ) ; m_buff . set...
We are switching over to having a hash table for quick look up of attributes but up until now we haven t kept any information in the Hashtable so we now update the Hashtable . Future additional attributes will update the Hashtable as they are added .
25,898
public final int getIndex ( String uri , String localName ) { int index ; if ( super . getLength ( ) < MAX ) { index = super . getIndex ( uri , localName ) ; return index ; } m_buff . setLength ( 0 ) ; m_buff . append ( '{' ) . append ( uri ) . append ( '}' ) . append ( localName ) ; String key = m_buff . toString ( ) ...
This method gets the index of an attribute given its uri and locanName .
25,899
public CRLReason getReasonCode ( ) { if ( reasonCode > 0 && reasonCode < values . length ) { return values [ reasonCode ] ; } else { return CRLReason . UNSPECIFIED ; } }
Return the reason as a CRLReason enum .