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 ( methodName . equals ( "hash" ) && methodElement . getReturnType ( ) . getKind ( ) == TypeKind . INT ) { return true ; } return false ; }
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 ( element ) . asType ( ) , "java.lang.Comparable" ) ; if ( comparableType == null ) { return ; } List < ? extends TypeMirror > typeArguments = comparableType . getTypeArguments ( ) ; List < ? extends VariableElement > parameters = element . getParameters ( ) ; if ( typeArguments . size ( ) != 1 || parameters . size ( ) != 1 || ! typeArguments . get ( 0 ) . equals ( parameters . get ( 0 ) . asType ( ) ) ) { return ; } VariableElement param = node . getParameter ( 0 ) . getVariableElement ( ) ; FunctionInvocation castCheck = createCastCheck ( typeArguments . get ( 0 ) , new SimpleName ( param ) ) ; if ( castCheck != null ) { node . getBody ( ) . addStatement ( 0 , new ExpressionStatement ( castCheck ) ) ; } }
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 != 0 ) { long cutoff = Long . MAX_VALUE / multiplier ; if ( cutoff < 0 ) { cutoff = - cutoff ; } useBigInteger = ( number > cutoff ) ; } if ( useBigInteger ) { if ( isNegative ) { number = - number ; } BigInteger bigIntegerValue = BigInteger . valueOf ( number ) ; return format ( bigIntegerValue , result , delegate , true ) ; } number *= multiplier ; if ( number == 0 ) { isNegative = false ; } else { if ( multiplier < 0 ) { number = - number ; isNegative = ! isNegative ; } } synchronized ( digitList ) { int maxIntDigits = super . getMaximumIntegerDigits ( ) ; int minIntDigits = super . getMinimumIntegerDigits ( ) ; int maxFraDigits = super . getMaximumFractionDigits ( ) ; int minFraDigits = super . getMinimumFractionDigits ( ) ; digitList . set ( isNegative , number , useExponentialNotation ? maxIntDigits + maxFraDigits : 0 ) ; return subformat ( result , delegate , isNegative , true , maxIntDigits , minIntDigits , maxFraDigits , minFraDigits ) ; } }
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 ) ) { isFastPath = ( ( minimumIntegerDigits == 1 ) && ( maximumIntegerDigits >= 10 ) ) ; if ( isFastPath ) { if ( isCurrencyFormat ) { if ( ( minimumFractionDigits != 2 ) || ( maximumFractionDigits != 2 ) ) isFastPath = false ; } else if ( ( minimumFractionDigits != 0 ) || ( maximumFractionDigits != 3 ) ) isFastPath = false ; } } else isFastPath = false ; if ( isFastPath ) { if ( fastPathData == null ) fastPathData = new FastPathData ( ) ; fastPathData . zeroDelta = symbols . getZeroDigit ( ) - '0' ; fastPathData . groupingChar = symbols . getGroupingSeparator ( ) ; fastPathData . fractionalMaxIntBound = ( isCurrencyFormat ) ? 99 : 999 ; fastPathData . fractionalScaleFactor = ( isCurrencyFormat ) ? 100.0d : 1000.0d ; fastPathData . positiveAffixesRequired = ( positivePrefix . length ( ) != 0 ) || ( positiveSuffix . length ( ) != 0 ) ; fastPathData . negativeAffixesRequired = ( negativePrefix . length ( ) != 0 ) || ( negativeSuffix . length ( ) != 0 ) ; int maxNbIntegralDigits = 10 ; int maxNbGroups = 3 ; int containerSize = Math . max ( positivePrefix . length ( ) , negativePrefix . length ( ) ) + maxNbIntegralDigits + maxNbGroups + 1 + maximumFractionDigits + Math . max ( positiveSuffix . length ( ) , negativeSuffix . length ( ) ) ; fastPathData . fastPathContainer = new char [ containerSize ] ; fastPathData . charsPositiveSuffix = positiveSuffix . toCharArray ( ) ; fastPathData . charsNegativeSuffix = negativeSuffix . toCharArray ( ) ; fastPathData . charsPositivePrefix = positivePrefix . toCharArray ( ) ; fastPathData . charsNegativePrefix = negativePrefix . toCharArray ( ) ; int longestPrefixLength = Math . max ( positivePrefix . length ( ) , negativePrefix . length ( ) ) ; int decimalPointIndex = maxNbIntegralDigits + maxNbGroups + longestPrefixLength ; fastPathData . integralLastIndex = decimalPointIndex - 1 ; fastPathData . fractionalFirstIndex = decimalPointIndex + 1 ; fastPathData . fastPathContainer [ decimalPointIndex ] = isCurrencyFormat ? symbols . getMonetaryDecimalSeparator ( ) : symbols . getDecimalSeparator ( ) ; } else if ( fastPathWasOn ) { fastPathData . fastPathContainer = null ; fastPathData . charsPositiveSuffix = null ; fastPathData . charsNegativeSuffix = null ; fastPathData . charsPositivePrefix = null ; fastPathData . charsNegativePrefix = null ; } fastPathCheckNeeded = false ; }
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 fractionalPartAsInt = ( int ) scaledFractional ; scaledFractional = scaledFractional - ( double ) fractionalPartAsInt ; boolean roundItUp = false ; if ( scaledFractional >= 0.5d ) { if ( scaledFractional == 0.5d ) roundItUp = exactRoundUp ( exactFractionalPart , fractionalPartAsInt ) ; else roundItUp = true ; if ( roundItUp ) { if ( fractionalPartAsInt < fastPathData . fractionalMaxIntBound ) { fractionalPartAsInt ++ ; } else { fractionalPartAsInt = 0 ; integralPartAsInt ++ ; } } } collectFractionalDigits ( fractionalPartAsInt , container , fastPathData . fractionalFirstIndex ) ; collectIntegralDigits ( integralPartAsInt , container , fastPathData . integralLastIndex ) ; if ( fastPathData . zeroDelta != 0 ) localizeDigits ( container ) ; if ( negative ) { if ( fastPathData . negativeAffixesRequired ) addAffixes ( container , fastPathData . charsNegativePrefix , fastPathData . charsNegativeSuffix ) ; } else if ( fastPathData . positiveAffixesRequired ) addAffixes ( container , fastPathData . charsPositivePrefix , fastPathData . charsPositiveSuffix ) ; }
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 ) ; positiveSuffixFieldPositions = null ; } if ( negPrefixPattern != null ) { negativePrefix = expandAffix ( negPrefixPattern , buffer ) ; negativePrefixFieldPositions = null ; } if ( negSuffixPattern != null ) { negativeSuffix = expandAffix ( negSuffixPattern , buffer ) ; negativeSuffixFieldPositions = null ; } }
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 || affix . indexOf ( symbols . getPercent ( ) ) >= 0 || affix . indexOf ( symbols . getPerMill ( ) ) >= 0 || affix . indexOf ( symbols . getDigit ( ) ) >= 0 || affix . indexOf ( symbols . getPatternSeparator ( ) ) >= 0 || affix . indexOf ( symbols . getMinusSign ( ) ) >= 0 || affix . indexOf ( CURRENCY_SIGN ) >= 0 ; } else { needQuote = affix . indexOf ( PATTERN_ZERO_DIGIT ) >= 0 || affix . indexOf ( PATTERN_GROUPING_SEPARATOR ) >= 0 || affix . indexOf ( PATTERN_DECIMAL_SEPARATOR ) >= 0 || affix . indexOf ( PATTERN_PERCENT ) >= 0 || affix . indexOf ( PATTERN_PER_MILLE ) >= 0 || affix . indexOf ( PATTERN_DIGIT ) >= 0 || affix . indexOf ( PATTERN_SEPARATOR ) >= 0 || affix . indexOf ( PATTERN_MINUS ) >= 0 || affix . indexOf ( CURRENCY_SIGN ) >= 0 ; } if ( needQuote ) buffer . append ( '\'' ) ; if ( affix . indexOf ( '\'' ) < 0 ) buffer . append ( affix ) ; else { for ( int j = 0 ; j < affix . length ( ) ; ++ j ) { char c = affix . charAt ( j ) ; buffer . append ( c ) ; if ( c == '\'' ) buffer . append ( c ) ; } } if ( needQuote ) buffer . append ( '\'' ) ; }
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 = useExponentialNotation ? getMaximumIntegerDigits ( ) : Math . max ( groupingSize + secondaryGroupingSize , getMinimumIntegerDigits ( ) ) + 1 ; for ( i = digitCount ; i > 0 ; -- i ) { if ( i != digitCount && isGroupingUsed ( ) && groupingSize != 0 && ( secondaryGroupingSize > 0 && i > groupingSize ? ( i - groupingSize ) % secondaryGroupingSize == 0 : i % groupingSize == 0 ) ) { result . append ( localized ? symbols . getGroupingSeparator ( ) : PATTERN_GROUPING_SEPARATOR ) ; } result . append ( i <= getMinimumIntegerDigits ( ) ? ( localized ? symbols . getZeroDigit ( ) : PATTERN_ZERO_DIGIT ) : ( localized ? symbols . getDigit ( ) : PATTERN_DIGIT ) ) ; } if ( getMaximumFractionDigits ( ) > 0 || decimalSeparatorAlwaysShown ) result . append ( localized ? symbols . getDecimalSeparator ( ) : PATTERN_DECIMAL_SEPARATOR ) ; for ( i = 0 ; i < getMaximumFractionDigits ( ) ; ++ i ) { if ( i < getMinimumFractionDigits ( ) ) { result . append ( localized ? symbols . getZeroDigit ( ) : PATTERN_ZERO_DIGIT ) ; } else { result . append ( localized ? symbols . getDigit ( ) : PATTERN_DIGIT ) ; } } if ( useExponentialNotation ) { result . append ( localized ? symbols . getExponentSeparator ( ) : PATTERN_EXPONENT ) ; for ( i = 0 ; i < minExponentDigits ; ++ i ) result . append ( localized ? symbols . getZeroDigit ( ) : PATTERN_ZERO_DIGIT ) ; } if ( j == 1 ) { appendAffix ( result , posSuffixPattern , positiveSuffix , localized ) ; if ( ( negSuffixPattern == posSuffixPattern && negativeSuffix . equals ( positiveSuffix ) ) || ( negSuffixPattern != null && negSuffixPattern . equals ( posSuffixPattern ) ) ) { if ( ( negPrefixPattern != null && posPrefixPattern != null && negPrefixPattern . equals ( "'-" + posPrefixPattern ) ) || ( negPrefixPattern == posPrefixPattern && negativePrefix . equals ( symbols . getMinusSign ( ) + positivePrefix ) ) ) break ; } result . append ( localized ? symbols . getPatternSeparator ( ) : PATTERN_SEPARATOR ) ; } else appendAffix ( result , negSuffixPattern , negativeSuffix , localized ) ; } return result . toString ( ) ; }
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 , callerClassLoader ) ) { result . addElement ( aDriver . driver ) ; } else { println ( " skipping: " + aDriver . getClass ( ) . getName ( ) ) ; } } return ( result . elements ( ) ) ; }
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 > source . length ) { throw new IllegalArgumentException ( "bad source start (" + sourceStart + ") or length (" + sourceLength + ") for buffer of length " + source . length ) ; } if ( dest == null && destSize != 0 ) { throw new IllegalArgumentException ( "null dest requires destSize == 0" ) ; } if ( ( destSize != 0 ) && ( destStart < 0 || destSize < 0 || destStart + destSize > dest . length ) ) { throw new IllegalArgumentException ( "bad dest start (" + destStart + ") or size (" + destSize + ") for buffer of length " + dest . length ) ; } if ( ( ( options & TASHKEEL_MASK ) != 0 ) && ! ( ( ( options & TASHKEEL_MASK ) == TASHKEEL_BEGIN ) || ( ( options & TASHKEEL_MASK ) == TASHKEEL_END ) || ( ( options & TASHKEEL_MASK ) == TASHKEEL_RESIZE ) || ( ( options & TASHKEEL_MASK ) == TASHKEEL_REPLACE_BY_TATWEEL ) ) ) { throw new IllegalArgumentException ( "Wrong Tashkeel argument" ) ; } if ( ( ( options & LAMALEF_MASK ) != 0 ) && ! ( ( ( options & LAMALEF_MASK ) == LAMALEF_BEGIN ) || ( ( options & LAMALEF_MASK ) == LAMALEF_END ) || ( ( options & LAMALEF_MASK ) == LAMALEF_RESIZE ) || ( ( options & LAMALEF_MASK ) == LAMALEF_AUTO ) || ( ( options & LAMALEF_MASK ) == LAMALEF_NEAR ) ) ) { throw new IllegalArgumentException ( "Wrong Lam Alef argument" ) ; } if ( ( ( options & TASHKEEL_MASK ) != 0 ) && ( options & LETTERS_MASK ) == LETTERS_UNSHAPE ) { throw new IllegalArgumentException ( "Tashkeel replacement should not be enabled in deshaping mode " ) ; } return internalShape ( source , sourceStart , sourceLength , dest , destStart , destSize ) ; }
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 . length , dest , 0 , dest . length ) ; return new String ( dest , 0 , len ) ; }
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 current value as its first argument and the given update as the second argument .
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 & UNARRIVED_MASK ; if ( unarrived != lastUnarrived && ( lastUnarrived = unarrived ) < NCPU ) spins += SPINS_PER_ARRIVAL ; boolean interrupted = Thread . interrupted ( ) ; if ( interrupted || -- spins < 0 ) { node = new QNode ( this , phase , false , false , 0L ) ; node . wasInterrupted = interrupted ; } } else if ( node . isReleasable ( ) ) break ; else if ( ! queued ) { AtomicReference < QNode > head = ( phase & 1 ) == 0 ? evenQ : oddQ ; QNode q = node . next = head . get ( ) ; if ( ( q == null || q . phase == phase ) && ( int ) ( state >>> PHASE_SHIFT ) == phase ) queued = head . compareAndSet ( q , node ) ; } else { try { ForkJoinPool . managedBlock ( node ) ; } catch ( InterruptedException cantHappen ) { node . wasInterrupted = true ; } } } if ( node != null ) { if ( node . thread != null ) node . thread = null ; if ( node . wasInterrupted && ! node . interruptible ) Thread . currentThread ( ) . interrupt ( ) ; if ( p == phase && ( p = ( int ) ( state >>> PHASE_SHIFT ) ) == phase ) return abortWait ( phase ) ; } releaseWaiters ( phase ) ; return p ; }
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 = findSubMessage ( msgPattern , 0 , keyword ) ; if ( ! msgPattern . jdkAposMode ( ) ) { int msgLimit = msgPattern . getLimitPartIndex ( msgStart ) ; return msgPattern . getPatternString ( ) . substring ( msgPattern . getPart ( msgStart ) . getLimit ( ) , msgPattern . getPatternIndex ( msgLimit ) ) ; } StringBuilder result = null ; int prevIndex = msgPattern . getPart ( msgStart ) . getLimit ( ) ; for ( int i = msgStart ; ; ) { MessagePattern . Part part = msgPattern . getPart ( ++ i ) ; MessagePattern . Part . Type type = part . getType ( ) ; int index = part . getIndex ( ) ; if ( type == MessagePattern . Part . Type . MSG_LIMIT ) { if ( result == null ) { return pattern . substring ( prevIndex , index ) ; } else { return result . append ( pattern , prevIndex , index ) . toString ( ) ; } } else if ( type == MessagePattern . Part . Type . SKIP_SYNTAX ) { if ( result == null ) { result = new StringBuilder ( ) ; } result . append ( pattern , prevIndex , index ) ; prevIndex = part . getLimit ( ) ; } else if ( type == MessagePattern . Part . Type . ARG_START ) { if ( result == null ) { result = new StringBuilder ( ) ; } result . append ( pattern , prevIndex , index ) ; prevIndex = index ; i = msgPattern . getLimitPartIndex ( i ) ; index = msgPattern . getPart ( i ) . getLimit ( ) ; MessagePattern . appendReducedApostrophes ( pattern , prevIndex , index , result ) ; prevIndex = index ; } } }
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 . insertElementAt ( a . elementAt ( i ) , i ) ; else b . setElementAt ( a . elementAt ( i ) , i ) ; } i = l ; for ( j = ( m + 1 ) ; j <= r ; j ++ ) { if ( r + m + 1 - j >= b . size ( ) ) b . insertElementAt ( a . elementAt ( j ) , r + m + 1 - j ) ; else b . setElementAt ( a . elementAt ( j ) , r + m + 1 - j ) ; } j = r ; int compVal ; for ( k = l ; k <= r ; k ++ ) { if ( i == j ) compVal = - 1 ; else compVal = compare ( ( NodeCompareElem ) b . elementAt ( i ) , ( NodeCompareElem ) b . elementAt ( j ) , 0 , support ) ; if ( compVal < 0 ) { a . setElementAt ( b . elementAt ( i ) , k ) ; i ++ ; } else if ( compVal > 0 ) { a . setElementAt ( b . elementAt ( j ) , k ) ; j -- ; } } } }
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 ) ) { return avt ; } } } return null ; }
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 ) { m_namespace = nsa . getResultNamespace ( ) ; String resultPrefix = nsa . getStylesheetPrefix ( ) ; if ( ( null != resultPrefix ) && ( resultPrefix . length ( ) > 0 ) ) m_rawName = resultPrefix + ":" + m_localName ; else m_rawName = m_localName ; } } if ( null != m_avts ) { int n = m_avts . size ( ) ; for ( int i = 0 ; i < n ; i ++ ) { AVT avt = ( AVT ) m_avts . get ( i ) ; String ns = avt . getURI ( ) ; if ( ( null != ns ) && ( ns . length ( ) > 0 ) ) { NamespaceAlias nsa = stylesheet . getNamespaceAliasComposed ( m_namespace ) ; if ( null != nsa ) { String namespace = nsa . getResultNamespace ( ) ; String resultPrefix = nsa . getStylesheetPrefix ( ) ; String rawName = avt . getName ( ) ; if ( ( null != resultPrefix ) && ( resultPrefix . length ( ) > 0 ) ) rawName = resultPrefix + ":" + rawName ; avt . setURI ( namespace ) ; avt . setRawName ( rawName ) ; } } } } }
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 . NEGATIVE_NUMBER_RULE ) { throw new IllegalArgumentException ( "<< not allowed in negative-number rule" ) ; } else if ( rule . getBaseValue ( ) == NFRule . IMPROPER_FRACTION_RULE || rule . getBaseValue ( ) == NFRule . PROPER_FRACTION_RULE || rule . getBaseValue ( ) == NFRule . MASTER_RULE ) { return new IntegralPartSubstitution ( pos , ruleSet , description ) ; } else if ( ruleSet . isFractionSet ( ) ) { return new NumeratorSubstitution ( pos , rule . getBaseValue ( ) , formatter . getDefaultRuleSet ( ) , description ) ; } else { return new MultiplierSubstitution ( pos , rule , ruleSet , description ) ; } case '>' : if ( rule . getBaseValue ( ) == NFRule . NEGATIVE_NUMBER_RULE ) { return new AbsoluteValueSubstitution ( pos , ruleSet , description ) ; } else if ( rule . getBaseValue ( ) == NFRule . IMPROPER_FRACTION_RULE || rule . getBaseValue ( ) == NFRule . PROPER_FRACTION_RULE || rule . getBaseValue ( ) == NFRule . MASTER_RULE ) { return new FractionalPartSubstitution ( pos , ruleSet , description ) ; } else if ( ruleSet . isFractionSet ( ) ) { throw new IllegalArgumentException ( ">> not allowed in fraction rule set" ) ; } else { return new ModulusSubstitution ( pos , rule , rulePredecessor , ruleSet , description ) ; } case '=' : return new SameValueSubstitution ( pos , ruleSet , description ) ; default : throw new IllegalArgumentException ( "Illegal substitution character" ) ; } }
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 , toInsertInto , position + pos , recursionCount ) ; } }
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 , false , upperBound ) ; if ( parsePosition . getIndex ( ) != 0 ) { double result = tempResult . doubleValue ( ) ; result = composeRuleValue ( result , baseValue ) ; if ( result == ( long ) result ) { return Long . valueOf ( ( long ) result ) ; } else { return new Double ( result ) ; } } else { return tempResult ; } } }
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 ( dl . count > Math . max ( 0 , dl . decimalAt ) ) { if ( pad && useSpaces ) { toInsertInto . insert ( position + pos , ' ' ) ; } else { pad = true ; } ruleSet . format ( dl . digits [ -- dl . count ] - '0' , toInsertInto , position + pos , recursionCount ) ; } while ( dl . decimalAt < 0 ) { if ( pad && useSpaces ) { toInsertInto . insert ( position + pos , ' ' ) ; } else { pad = true ; } ruleSet . format ( 0 , toInsertInto , position + pos , recursionCount ) ; ++ dl . decimalAt ; } } }
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 ) ; double result ; int digit ; DigitList dl = new DigitList ( ) ; while ( workText . length ( ) > 0 && workPos . getIndex ( ) != 0 ) { workPos . setIndex ( 0 ) ; digit = ruleSet . parse ( workText , workPos , 10 ) . intValue ( ) ; if ( lenientParse && workPos . getIndex ( ) == 0 ) { Number n = ruleSet . owner . getDecimalFormat ( ) . parse ( workText , workPos ) ; if ( n != null ) { digit = n . intValue ( ) ; } } if ( workPos . getIndex ( ) != 0 ) { dl . append ( '0' + digit ) ; parsePosition . setIndex ( parsePosition . getIndex ( ) + workPos . getIndex ( ) ) ; workText = workText . substring ( workPos . getIndex ( ) ) ; while ( workText . length ( ) > 0 && workText . charAt ( 0 ) == ' ' ) { workText = workText . substring ( 1 ) ; parsePosition . setIndex ( parsePosition . getIndex ( ) + 1 ) ; } } } result = dl . count == 0 ? 0 : dl . getDouble ( ) ; result = composeRuleValue ( result , baseValue ) ; return new Double ( result ) ; } }
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 ) { workPos . setIndex ( 0 ) ; ruleSet . parse ( workText , workPos , 1 ) . intValue ( ) ; if ( workPos . getIndex ( ) == 0 ) { break ; } ++ zeroCount ; parsePosition . setIndex ( parsePosition . getIndex ( ) + workPos . getIndex ( ) ) ; workText = workText . substring ( workPos . getIndex ( ) ) ; while ( workText . length ( ) > 0 && workText . charAt ( 0 ) == ' ' ) { workText = workText . substring ( 1 ) ; parsePosition . setIndex ( parsePosition . getIndex ( ) + 1 ) ; } } text = text . substring ( parsePosition . getIndex ( ) ) ; parsePosition . setIndex ( 0 ) ; } Number result = super . doParse ( text , parsePosition , withZeros ? 1 : baseValue , upperBound , false ) ; if ( withZeros ) { long n = result . longValue ( ) ; long d = 1 ; while ( d <= n ) { d *= 10 ; } while ( zeroCount > 0 ) { d *= 10 ; -- zeroCount ; } result = new Double ( n / ( double ) d ) ; } return result ; }
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 AssertionError ( "Unknown NestingKind" ) ; }
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 ( attributesStr != null ) { attributes . addAll ( Arrays . asList ( attributesStr . split ( ",\\s*" ) ) ) ; attributes . remove ( "" ) ; } return attributes ; }
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" : "get" ; getter = ElementUtil . findMethod ( declaringClass , prefix + NameTable . capitalize ( propertyName ) ) ; } return getter != null && isStatic == isStatic ( getter ) ? getter : null ; }
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 ( Modifier . PROTECTED ) ) { modifiers |= java . lang . reflect . Modifier . PROTECTED ; } if ( set . contains ( Modifier . STATIC ) ) { modifiers |= java . lang . reflect . Modifier . STATIC ; } if ( set . contains ( Modifier . FINAL ) ) { modifiers |= java . lang . reflect . Modifier . FINAL ; } if ( set . contains ( Modifier . SYNCHRONIZED ) ) { modifiers |= java . lang . reflect . Modifier . SYNCHRONIZED ; } if ( set . contains ( Modifier . VOLATILE ) ) { modifiers |= java . lang . reflect . Modifier . VOLATILE ; } if ( set . contains ( Modifier . TRANSIENT ) ) { modifiers |= java . lang . reflect . Modifier . TRANSIENT ; } if ( set . contains ( Modifier . NATIVE ) ) { modifiers |= java . lang . reflect . Modifier . NATIVE ; } if ( set . contains ( Modifier . ABSTRACT ) ) { modifiers |= java . lang . reflect . Modifier . ABSTRACT ; } if ( set . contains ( Modifier . STRICTFP ) ) { modifiers |= java . lang . reflect . Modifier . STRICT ; } return modifiers ; }
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 : ( List < ? extends AnnotationValue > ) getAnnotationValue ( annotation , "value" ) ) { if ( warning . equals ( elem . getValue ( ) ) ) { return true ; } } } return suppressesWarning ( warning , element . getEnclosingElement ( ) ) ; }
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 ; i = i + 2 ; } else if ( currentChar == '\\' ) { buf . setCharAt ( i , '/' ) ; } } return buf . toString ( ) ; }
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 ; break ; } } newConfigs . add ( newConfig ) ; } ProviderConfig [ ] configArray = newConfigs . toArray ( PC0 ) ; return new ProviderList ( configArray , false ) ; }
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 != null ) { n ++ ; } } if ( n == configs . length ) { allLoaded = true ; } return n ; }
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 ; } } return new ProviderList ( newConfigs , true ) ; }
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 ( null , l ) ; break ; case - 1 : if ( last < 0 || ( args != null && last > args . length - 1 ) ) throw new MissingFormatArgumentException ( fs . toString ( ) ) ; fs . print ( ( args == null ? null : args [ last ] ) , l ) ; break ; case 0 : lasto ++ ; last = lasto ; if ( args != null && lasto > args . length - 1 ) throw new MissingFormatArgumentException ( fs . toString ( ) ) ; fs . print ( ( args == null ? null : args [ lasto ] ) , l ) ; break ; default : last = index - 1 ; if ( args != null && last > args . length - 1 ) throw new MissingFormatArgumentException ( fs . toString ( ) ) ; fs . print ( ( args == null ? null : args [ last ] ) , l ) ; break ; } } catch ( IOException x ) { lastException = x ; } } return this ; }
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 ; al . add ( new FixedString ( s . substring ( plainTextStart , plainTextEnd ) ) ) ; i = plainTextEnd ; } else { FormatSpecifierParser fsp = new FormatSpecifierParser ( s , i + 1 ) ; al . add ( fsp . getFormatSpecifier ( ) ) ; i = fsp . getEndIdx ( ) ; } } return al . toArray ( new FormatString [ al . size ( ) ] ) ; }
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 ) ) { RestrictionLevel textRestrictionLevel = getRestrictionLevel ( text ) ; if ( textRestrictionLevel . compareTo ( fRestrictionLevel ) > 0 ) { result |= RESTRICTION_LEVEL ; } if ( checkResult != null ) { checkResult . restrictionLevel = textRestrictionLevel ; } } if ( 0 != ( this . fChecks & MIXED_NUMBERS ) ) { UnicodeSet numerics = new UnicodeSet ( ) ; getNumerics ( text , numerics ) ; if ( numerics . size ( ) > 1 ) { result |= MIXED_NUMBERS ; } if ( checkResult != null ) { checkResult . numerics = numerics ; } } if ( 0 != ( this . fChecks & CHAR_LIMIT ) ) { int i ; int c ; for ( i = 0 ; i < length ; ) { c = Character . codePointAt ( text , i ) ; i = Character . offsetByCodePoints ( text , i , 1 ) ; if ( ! this . fAllowedCharsSet . contains ( c ) ) { result |= CHAR_LIMIT ; break ; } } } if ( 0 != ( this . fChecks & INVISIBLE ) ) { String nfdText = nfdNormalizer . normalize ( text ) ; int i ; int c ; int firstNonspacingMark = 0 ; boolean haveMultipleMarks = false ; UnicodeSet marksSeenSoFar = new UnicodeSet ( ) ; for ( i = 0 ; i < length ; ) { c = Character . codePointAt ( nfdText , i ) ; i = Character . offsetByCodePoints ( nfdText , i , 1 ) ; if ( Character . getType ( c ) != UCharacterCategory . NON_SPACING_MARK ) { firstNonspacingMark = 0 ; if ( haveMultipleMarks ) { marksSeenSoFar . clear ( ) ; haveMultipleMarks = false ; } continue ; } if ( firstNonspacingMark == 0 ) { firstNonspacingMark = c ; continue ; } if ( ! haveMultipleMarks ) { marksSeenSoFar . add ( firstNonspacingMark ) ; haveMultipleMarks = true ; } if ( marksSeenSoFar . contains ( c ) ) { result |= INVISIBLE ; break ; } marksSeenSoFar . add ( c ) ; } } if ( checkResult != null ) { checkResult . checks = result ; } return ( 0 != result ) ; }
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 ; } ScriptSet s1RSS = new ScriptSet ( ) ; getResolvedScriptSet ( s1 , s1RSS ) ; ScriptSet s2RSS = new ScriptSet ( ) ; getResolvedScriptSet ( s2 , s2RSS ) ; int result = 0 ; if ( s1RSS . intersects ( s2RSS ) ) { result |= SINGLE_SCRIPT_CONFUSABLE ; } else { result |= MIXED_SCRIPT_CONFUSABLE ; if ( ! s1RSS . isEmpty ( ) && ! s2RSS . isEmpty ( ) ) { result |= WHOLE_SCRIPT_CONFUSABLE ; } } result &= fChecks ; return result ; }
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 += Character . charCount ( c ) ; this . fSpoofData . confusableLookup ( c , skelSB ) ; } String skelStr = skelSB . toString ( ) ; skelStr = nfdNormalizer . normalize ( skelStr ) ; return skelStr ; }
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 ) ; } if ( result . get ( UScript . HIRAGANA ) ) { result . set ( UScript . JAPANESE ) ; } if ( result . get ( UScript . KATAKANA ) ) { result . set ( UScript . JAPANESE ) ; } if ( result . get ( UScript . HANGUL ) ) { result . set ( UScript . KOREAN ) ; } if ( result . get ( UScript . BOPOMOFO ) ) { result . set ( UScript . HAN_WITH_BOPOMOFO ) ; } if ( result . get ( UScript . COMMON ) || result . get ( UScript . INHERITED ) ) { result . setAll ( ) ; } }
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 . charCount ( codePoint ) ; getAugmentedScriptSet ( codePoint , temp ) ; if ( script == UScript . CODE_LIMIT || ! temp . get ( script ) ) { result . and ( temp ) ; } } }
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 ) == UCharacterCategory . DECIMAL_DIGIT_NUMBER ) { result . add ( codePoint - UCharacter . getNumericValue ( codePoint ) ) ; } } }
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 , resolvedScriptSet ) ; if ( ! resolvedScriptSet . isEmpty ( ) ) { return RestrictionLevel . SINGLE_SCRIPT_RESTRICTIVE ; } ScriptSet resolvedNoLatn = new ScriptSet ( ) ; getResolvedScriptSetWithout ( input , UScript . LATIN , resolvedNoLatn ) ; if ( resolvedNoLatn . get ( UScript . HAN_WITH_BOPOMOFO ) || resolvedNoLatn . get ( UScript . JAPANESE ) || resolvedNoLatn . get ( UScript . KOREAN ) ) { return RestrictionLevel . HIGHLY_RESTRICTIVE ; } if ( ! resolvedNoLatn . isEmpty ( ) && ! resolvedNoLatn . get ( UScript . CYRILLIC ) && ! resolvedNoLatn . get ( UScript . GREEK ) && ! resolvedNoLatn . get ( UScript . CHEROKEE ) ) { return RestrictionLevel . MODERATELY_RESTRICTIVE ; } return RestrictionLevel . MINIMALLY_RESTRICTIVE ; }
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 ) obj ) ; } else if ( obj instanceof X509CRL ) { indexCRL ( ( X509CRL ) obj ) ; } else if ( obj instanceof Certificate ) { if ( otherCertificates == null ) { otherCertificates = new HashSet < Certificate > ( ) ; } otherCertificates . add ( ( Certificate ) obj ) ; } else if ( obj instanceof CRL ) { if ( otherCRLs == null ) { otherCRLs = new HashSet < CRL > ( ) ; } otherCRLs . add ( ( CRL ) obj ) ; } else { } } if ( otherCertificates == null ) { otherCertificates = Collections . < Certificate > emptySet ( ) ; } if ( otherCRLs == null ) { otherCRLs = Collections . < CRL > emptySet ( ) ; } }
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 > list = new ArrayList < > ( 2 ) ; list . add ( cert ) ; list . add ( ( X509Certificate ) oldEntry ) ; certSubjects . put ( subject , list ) ; } else { @ SuppressWarnings ( "unchecked" ) List < X509Certificate > list = ( List < X509Certificate > ) oldEntry ; if ( list . contains ( cert ) == false ) { list . add ( cert ) ; } certSubjects . put ( subject , list ) ; } } }
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 . add ( crl ) ; list . add ( ( X509CRL ) oldEntry ) ; crlIssuers . put ( issuer , list ) ; } else { @ SuppressWarnings ( "unchecked" ) List < X509CRL > list = ( List < X509CRL > ) oldEntry ; if ( list . contains ( crl ) == false ) { list . add ( crl ) ; } crlIssuers . put ( issuer , list ) ; } } }
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 ( "unchecked" ) List < X509Certificate > list = ( List < X509Certificate > ) obj ; for ( X509Certificate cert : list ) { if ( selector . match ( cert ) ) { matches . add ( cert ) ; } } } } }
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 = ( List < X509CRL > ) obj ; for ( X509CRL crl : list ) { if ( selector . match ( crl ) ) { matches . add ( crl ) ; } } } } }
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 || prefix . equals ( "xmlns" ) ) { if ( nodeNamespace . length ( ) > 0 ) { NamespaceMappings prefixMapping = rhandler . getNamespaceMappings ( ) ; prefix = prefixMapping . generateNextPrefix ( ) ; } else prefix = "" ; } } return prefix ; }
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 ( prefixLength ) != '-' ) { return ZoneRegion . ofId ( zoneId , checkAvailable ) ; } try { ZoneOffset offset = ZoneOffset . of ( zoneId . substring ( prefixLength ) ) ; if ( offset == ZoneOffset . UTC ) { return ofOffset ( prefix , offset ) ; } return ofOffset ( prefix , offset ) ; } catch ( DateTimeException ex ) { throw new DateTimeException ( "Invalid ID for offset-based ZoneId: " + zoneId , ex ) ; } }
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 ) ; ( ( ElemFallback ) child ) . executeFallback ( transformer ) ; } finally { transformer . popElemTemplateElement ( ) ; } } } }
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 = out . toByteArray ( ) ; } return 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 ; i < other . names . length ; i ++ ) { if ( ! names [ i ] . equals ( other . names [ i ] ) ) { return false ; } } return true ; }
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 ++ ) { if ( ! names [ i ] . equals ( other . names [ i ] ) ) { if ( i == 0 ) { return null ; } else { break ; } } } RDN [ ] ancestor = new RDN [ i ] ; for ( int j = 0 ; j < i ; j ++ ) { ancestor [ j ] = names [ j ] ; } X500Name commonAncestor = null ; try { commonAncestor = new X500Name ( ancestor ) ; } catch ( IOException ioe ) { return null ; } return commonAncestor ; }
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 . get ( i ) ; byte [ ] manHash = manifestHashes . get ( i ) ; byte [ ] theHash = digest . digest ( ) ; if ( debug != null ) { debug . println ( "Manifest Entry: " + name + " digest=" + digest . getAlgorithm ( ) ) ; debug . println ( " manifest " + toHex ( manHash ) ) ; debug . println ( " computed " + toHex ( theHash ) ) ; debug . println ( ) ; } if ( ! MessageDigest . isEqual ( theHash , manHash ) ) throw new SecurityException ( digest . getAlgorithm ( ) + " digest error for " + name ) ; } signers = sigFileSigners . remove ( name ) ; if ( signers != null ) { verifiedSigners . put ( name , signers ) ; } return signers ; }
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 . setLength ( 0 ) ; m_buff . append ( '{' ) . append ( uri ) . append ( '}' ) . append ( local ) ; String key = m_buff . toString ( ) ; m_indexFromQName . put ( key , i ) ; } }
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 ( ) ; Integer i = ( Integer ) m_indexFromQName . get ( key ) ; if ( i == null ) index = - 1 ; else index = i . intValue ( ) ; return index ; }
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 .