idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
27,900 | private void initialize ( ULocale locale ) { ICUResourceBundle bundle = ( ICUResourceBundle ) ICUResourceBundle . getBundleInstance ( ICUData . ICU_ZONE_BASE_NAME , locale ) ; _zoneStrings = ( ICUResourceBundle ) bundle . get ( ZONE_STRINGS_BUNDLE ) ; _tzNamesMap = new ConcurrentHashMap < String , ZNames > ( ) ; _mzNamesMap = new ConcurrentHashMap < String , ZNames > ( ) ; _namesFullyLoaded = false ; _namesTrie = new TextTrieMap < NameInfo > ( true ) ; _namesTrieFullyLoaded = false ; TimeZone tz = TimeZone . getDefault ( ) ; String tzCanonicalID = ZoneMeta . getCanonicalCLDRID ( tz ) ; if ( tzCanonicalID != null ) { loadStrings ( tzCanonicalID ) ; } } | Initialize the transient fields called from the constructor and readObject . |
27,901 | private synchronized void loadStrings ( String tzCanonicalID ) { if ( tzCanonicalID == null || tzCanonicalID . length ( ) == 0 ) { return ; } loadTimeZoneNames ( tzCanonicalID ) ; Set < String > mzIDs = getAvailableMetaZoneIDs ( tzCanonicalID ) ; for ( String mzID : mzIDs ) { loadMetaZoneNames ( mzID ) ; } } | Load all strings used by the specified time zone . This is called from the initializer to load default zone s strings . |
27,902 | private synchronized ZNames loadMetaZoneNames ( String mzID ) { ZNames mznames = _mzNamesMap . get ( mzID ) ; if ( mznames == null ) { ZNamesLoader loader = new ZNamesLoader ( ) ; loader . loadMetaZone ( _zoneStrings , mzID ) ; mznames = ZNames . createMetaZoneAndPutInCache ( _mzNamesMap , loader . getNames ( ) , mzID ) ; } return mznames ; } | Returns a set of names for the given meta zone ID . This method loads the set of names into the internal map and trie for future references . |
27,903 | private synchronized ZNames loadTimeZoneNames ( String tzID ) { ZNames tznames = _tzNamesMap . get ( tzID ) ; if ( tznames == null ) { ZNamesLoader loader = new ZNamesLoader ( ) ; loader . loadTimeZone ( _zoneStrings , tzID ) ; tznames = ZNames . createTimeZoneAndPutInCache ( _tzNamesMap , loader . getNames ( ) , tzID ) ; } return tznames ; } | Returns a set of names for the given time zone ID . This method loads the set of names into the internal map and trie for future references . |
27,904 | public void setStrength ( int value ) { int noStrength = options & ~ STRENGTH_MASK ; switch ( value ) { case Collator . PRIMARY : case Collator . SECONDARY : case Collator . TERTIARY : case Collator . QUATERNARY : case Collator . IDENTICAL : options = noStrength | ( value << STRENGTH_SHIFT ) ; break ; default : throw new IllegalArgumentException ( "illegal strength value " + value ) ; } } | except that this class uses bits in its own bit set for simple values . |
27,905 | public long completeSegmentByteCount ( ) { long result = size ; if ( result == 0 ) return 0 ; Segment tail = head . prev ; if ( tail . limit < Segment . SIZE && tail . owner ) { result -= tail . limit - tail . pos ; } return result ; } | Returns the number of bytes in segments that are not writable . This is the number of bytes that can be flushed immediately to an underlying sink without harming throughput . |
27,906 | List < Integer > segmentSizes ( ) { if ( head == null ) return Collections . emptyList ( ) ; List < Integer > result = new ArrayList < > ( ) ; result . add ( head . limit - head . pos ) ; for ( Segment s = head . next ; s != head ; s = s . next ) { result . add ( s . limit - s . pos ) ; } return result ; } | For testing . This returns the sizes of the segments in this buffer . |
27,907 | public synchronized Set < Map . Entry < Object , Object > > entrySet ( ) { checkInitialized ( ) ; if ( entrySet == null ) { if ( entrySetCallCount ++ == 0 ) entrySet = Collections . unmodifiableMap ( this ) . entrySet ( ) ; else return super . entrySet ( ) ; } if ( entrySetCallCount != 2 ) throw new RuntimeException ( "Internal error." ) ; return entrySet ; } | Returns an unmodifiable Set view of the property entries contained in this Provider . |
27,908 | private void putId ( ) { super . put ( "Provider.id name" , String . valueOf ( name ) ) ; super . put ( "Provider.id version" , String . valueOf ( version ) ) ; super . put ( "Provider.id info" , String . valueOf ( info ) ) ; super . put ( "Provider.id className" , this . getClass ( ) . getName ( ) ) ; } | report to different provider objects as the same |
27,909 | private void implPutAll ( Map t ) { for ( Map . Entry e : ( ( Map < ? , ? > ) t ) . entrySet ( ) ) { implPut ( e . getKey ( ) , e . getValue ( ) ) ; } if ( registered ) { Security . increaseVersion ( ) ; } } | Copies all of the mappings from the specified Map to this provider . Internal method to be called AFTER the security check has been performed . |
27,910 | private void ensureLegacyParsed ( ) { if ( ( legacyChanged == false ) || ( legacyStrings == null ) ) { return ; } serviceSet = null ; if ( legacyMap == null ) { legacyMap = new LinkedHashMap < ServiceKey , Service > ( ) ; } else { legacyMap . clear ( ) ; } for ( Map . Entry < String , String > entry : legacyStrings . entrySet ( ) ) { parseLegacyPut ( entry . getKey ( ) , entry . getValue ( ) ) ; } removeInvalidServices ( legacyMap ) ; legacyChanged = false ; } | Ensure all the legacy String properties are fully parsed into service objects . |
27,911 | private void removeInvalidServices ( Map < ServiceKey , Service > map ) { for ( Iterator t = map . entrySet ( ) . iterator ( ) ; t . hasNext ( ) ; ) { Map . Entry entry = ( Map . Entry ) t . next ( ) ; Service s = ( Service ) entry . getValue ( ) ; if ( s . isValid ( ) == false ) { t . remove ( ) ; } } } | Remove all invalid services from the Map . Invalid services can only occur if the legacy properties are inconsistent or incomplete . |
27,912 | public synchronized Set < Service > getServices ( ) { checkInitialized ( ) ; if ( legacyChanged || servicesChanged ) { serviceSet = null ; } if ( serviceSet == null ) { ensureLegacyParsed ( ) ; Set < Service > set = new LinkedHashSet < > ( ) ; if ( serviceMap != null ) { set . addAll ( serviceMap . values ( ) ) ; } if ( legacyMap != null ) { set . addAll ( legacyMap . values ( ) ) ; } serviceSet = Collections . unmodifiableSet ( set ) ; servicesChanged = false ; } return serviceSet ; } | Get an unmodifiable Set of all services supported by this Provider . |
27,913 | private void putPropertyStrings ( Service s ) { String type = s . getType ( ) ; String algorithm = s . getAlgorithm ( ) ; super . put ( type + "." + algorithm , s . getClassName ( ) ) ; for ( String alias : s . getAliases ( ) ) { super . put ( ALIAS_PREFIX + type + "." + alias , algorithm ) ; } for ( Map . Entry < UString , String > entry : s . attributes . entrySet ( ) ) { String key = type + "." + algorithm + " " + entry . getKey ( ) ; super . put ( key , entry . getValue ( ) ) ; } if ( registered ) { Security . increaseVersion ( ) ; } } | Put the string properties for this Service in this Provider s Hashtable . |
27,914 | private void removePropertyStrings ( Service s ) { String type = s . getType ( ) ; String algorithm = s . getAlgorithm ( ) ; super . remove ( type + "." + algorithm ) ; for ( String alias : s . getAliases ( ) ) { super . remove ( ALIAS_PREFIX + type + "." + alias ) ; } for ( Map . Entry < UString , String > entry : s . attributes . entrySet ( ) ) { String key = type + "." + algorithm + " " + entry . getKey ( ) ; super . remove ( key ) ; } if ( registered ) { Security . increaseVersion ( ) ; } } | Remove the string properties for this Service from this Provider s Hashtable . |
27,915 | public final LongStream asLongStream ( ) { return new LongPipeline . StatelessOp < Integer > ( this , StreamShape . INT_VALUE , StreamOpFlag . NOT_SORTED | StreamOpFlag . NOT_DISTINCT ) { public Sink < Integer > opWrapSink ( int flags , Sink < Long > sink ) { return new Sink . ChainedInt < Long > ( sink ) { public void accept ( int t ) { downstream . accept ( ( long ) t ) ; } } ; } } ; } | Stateless intermediate ops from IntStream |
27,916 | public final IntStream limit ( long maxSize ) { if ( maxSize < 0 ) throw new IllegalArgumentException ( Long . toString ( maxSize ) ) ; return SliceOps . makeInt ( this , 0 , maxSize ) ; } | Stateful intermediate ops from IntStream |
27,917 | public synchronized Object getInstanceIfFree ( ) { if ( ! freeStack . isEmpty ( ) ) { Object result = freeStack . remove ( freeStack . size ( ) - 1 ) ; return result ; } return null ; } | Get an instance of the given object in this pool if available |
27,918 | public XObject getValue ( TransformerImpl transformer , int sourceNode ) throws TransformerException { XObject var ; XPathContext xctxt = transformer . getXPathContext ( ) ; xctxt . pushCurrentNode ( sourceNode ) ; try { if ( null != m_selectPattern ) { var = m_selectPattern . execute ( xctxt , sourceNode , this ) ; var . allowDetachToRelease ( false ) ; } else if ( null == getFirstChildElem ( ) ) { var = XString . EMPTYSTRING ; } else { int df = transformer . transformToRTF ( this ) ; var = new XRTreeFrag ( df , xctxt , this ) ; } } finally { xctxt . popCurrentNode ( ) ; } return var ; } | Get the XObject representation of the variable . |
27,919 | public void parseRules ( String description ) { List < NFRule > tempRules = new ArrayList < NFRule > ( ) ; NFRule predecessor = null ; int oldP = 0 ; int descriptionLen = description . length ( ) ; int p ; do { p = description . indexOf ( ';' , oldP ) ; if ( p < 0 ) { p = descriptionLen ; } NFRule . makeRules ( description . substring ( oldP , p ) , this , predecessor , owner , tempRules ) ; if ( ! tempRules . isEmpty ( ) ) { predecessor = tempRules . get ( tempRules . size ( ) - 1 ) ; } oldP = p + 1 ; } while ( oldP < descriptionLen ) ; long defaultBaseValue = 0 ; for ( NFRule rule : tempRules ) { long baseValue = rule . getBaseValue ( ) ; if ( baseValue == 0 ) { rule . setBaseValue ( defaultBaseValue ) ; } else { if ( baseValue < defaultBaseValue ) { throw new IllegalArgumentException ( "Rules are not in order, base: " + baseValue + " < " + defaultBaseValue ) ; } defaultBaseValue = baseValue ; } if ( ! isFractionRuleSet ) { ++ defaultBaseValue ; } } rules = new NFRule [ tempRules . size ( ) ] ; tempRules . toArray ( rules ) ; } | Construct the subordinate data structures used by this object . This function is called by the RuleBasedNumberFormat constructor after all the rule sets have been created to actually parse the description and build rules from it . Since any rule set can refer to any other rule set we have to have created all of them before we can create anything else . |
27,920 | void setNonNumericalRule ( NFRule rule ) { long baseValue = rule . getBaseValue ( ) ; if ( baseValue == NFRule . NEGATIVE_NUMBER_RULE ) { nonNumericalRules [ NFRuleSet . NEGATIVE_RULE_INDEX ] = rule ; } else if ( baseValue == NFRule . IMPROPER_FRACTION_RULE ) { setBestFractionRule ( NFRuleSet . IMPROPER_FRACTION_RULE_INDEX , rule , true ) ; } else if ( baseValue == NFRule . PROPER_FRACTION_RULE ) { setBestFractionRule ( NFRuleSet . PROPER_FRACTION_RULE_INDEX , rule , true ) ; } else if ( baseValue == NFRule . MASTER_RULE ) { setBestFractionRule ( NFRuleSet . MASTER_RULE_INDEX , rule , true ) ; } else if ( baseValue == NFRule . INFINITY_RULE ) { nonNumericalRules [ NFRuleSet . INFINITY_RULE_INDEX ] = rule ; } else if ( baseValue == NFRule . NAN_RULE ) { nonNumericalRules [ NFRuleSet . NAN_RULE_INDEX ] = rule ; } } | Set one of the non - numerical rules . |
27,921 | private void setBestFractionRule ( int originalIndex , NFRule newRule , boolean rememberRule ) { if ( rememberRule ) { if ( fractionRules == null ) { fractionRules = new LinkedList < NFRule > ( ) ; } fractionRules . add ( newRule ) ; } NFRule bestResult = nonNumericalRules [ originalIndex ] ; if ( bestResult == null ) { nonNumericalRules [ originalIndex ] = newRule ; } else { DecimalFormatSymbols decimalFormatSymbols = owner . getDecimalFormatSymbols ( ) ; if ( decimalFormatSymbols . getDecimalSeparator ( ) == newRule . getDecimalPoint ( ) ) { nonNumericalRules [ originalIndex ] = newRule ; } } } | Determine the best fraction rule to use . Rules matching the decimal point from DecimalFormatSymbols become the main set of rules to use . |
27,922 | public void format ( long number , StringBuilder toInsertInto , int pos , int recursionCount ) { if ( recursionCount >= RECURSION_LIMIT ) { throw new IllegalStateException ( "Recursion limit exceeded when applying ruleSet " + name ) ; } NFRule applicableRule = findNormalRule ( number ) ; applicableRule . doFormat ( number , toInsertInto , pos , ++ recursionCount ) ; } | Formats a long . Selects an appropriate rule and dispatches control to it . |
27,923 | NFRule findRule ( double number ) { if ( isFractionRuleSet ) { return findFractionRuleSetRule ( number ) ; } if ( Double . isNaN ( number ) ) { NFRule rule = nonNumericalRules [ NAN_RULE_INDEX ] ; if ( rule == null ) { rule = owner . getDefaultNaNRule ( ) ; } return rule ; } if ( number < 0 ) { if ( nonNumericalRules [ NEGATIVE_RULE_INDEX ] != null ) { return nonNumericalRules [ NEGATIVE_RULE_INDEX ] ; } else { number = - number ; } } if ( Double . isInfinite ( number ) ) { NFRule rule = nonNumericalRules [ INFINITY_RULE_INDEX ] ; if ( rule == null ) { rule = owner . getDefaultInfinityRule ( ) ; } return rule ; } if ( number != Math . floor ( number ) ) { if ( number < 1 && nonNumericalRules [ PROPER_FRACTION_RULE_INDEX ] != null ) { return nonNumericalRules [ PROPER_FRACTION_RULE_INDEX ] ; } else if ( nonNumericalRules [ IMPROPER_FRACTION_RULE_INDEX ] != null ) { return nonNumericalRules [ IMPROPER_FRACTION_RULE_INDEX ] ; } } if ( nonNumericalRules [ MASTER_RULE_INDEX ] != null ) { return nonNumericalRules [ MASTER_RULE_INDEX ] ; } else { return findNormalRule ( Math . round ( number ) ) ; } } | Selects an appropriate rule for formatting the number . |
27,924 | private static long lcm ( long x , long y ) { long x1 = x ; long y1 = y ; int p2 = 0 ; while ( ( x1 & 1 ) == 0 && ( y1 & 1 ) == 0 ) { ++ p2 ; x1 >>= 1 ; y1 >>= 1 ; } long t ; if ( ( x1 & 1 ) == 1 ) { t = - y1 ; } else { t = x1 ; } while ( t != 0 ) { while ( ( t & 1 ) == 0 ) { t >>= 1 ; } if ( t > 0 ) { x1 = t ; } else { y1 = - t ; } t = x1 - y1 ; } long gcd = x1 << p2 ; return x / gcd * y ; } | Calculates the least common multiple of x and y . |
27,925 | public static String jarVersion ( Class < ? > jarClass ) { String j2objcVersion = null ; String path = jarClass . getProtectionDomain ( ) . getCodeSource ( ) . getLocation ( ) . getPath ( ) ; try ( JarFile jar = new JarFile ( URLDecoder . decode ( path , "UTF-8" ) ) ) { Manifest manifest = jar . getManifest ( ) ; j2objcVersion = manifest . getMainAttributes ( ) . getValue ( "version" ) ; } catch ( IOException e ) { } if ( j2objcVersion == null ) { j2objcVersion = "(j2objc version not available)" ; } String javacVersion = Parser . newParser ( null ) . version ( ) ; return String . format ( "%s (javac %s)" , j2objcVersion , javacVersion ) ; } | Returns the version entry from a jar file s manifest if available . If the class isn t in a jar file or that jar file doesn t define a version entry then a not available string is returned . |
27,926 | public void endVisit ( PropertyAnnotation node ) { FieldDeclaration field = ( FieldDeclaration ) node . getParent ( ) ; TypeMirror fieldType = field . getTypeMirror ( ) ; String getter = node . getGetter ( ) ; String setter = node . getSetter ( ) ; if ( field . getFragments ( ) . size ( ) > 1 ) { if ( getter != null ) { ErrorUtil . error ( field , "@Property getter declared for multiple fields" ) ; return ; } if ( setter != null ) { ErrorUtil . error ( field , "@Property setter declared for multiple fields" ) ; return ; } } else { TypeElement enclosingType = TreeUtil . getEnclosingTypeElement ( node ) ; if ( getter != null ) { if ( ElementUtil . findMethod ( enclosingType , getter ) == null ) { ErrorUtil . error ( field , "Non-existent getter specified: " + getter ) ; } } if ( setter != null ) { if ( ElementUtil . findMethod ( enclosingType , setter , TypeUtil . getQualifiedName ( fieldType ) ) == null ) { ErrorUtil . error ( field , "Non-existent setter specified: " + setter ) ; } } } } | Make sure attempt isn t made to specify an accessor method for fields with multiple fragments since each variable needs unique accessors . |
27,927 | public boolean contains ( Object key ) { return key == null ? ( indexOfNull ( ) >= 0 ) : ( indexOf ( key , key . hashCode ( ) ) >= 0 ) ; } | Check whether a value exists in the set . |
27,928 | public boolean add ( E value ) { final int hash ; int index ; if ( value == null ) { hash = 0 ; index = indexOfNull ( ) ; } else { hash = value . hashCode ( ) ; index = indexOf ( value , hash ) ; } if ( index >= 0 ) { return false ; } index = ~ index ; if ( mSize >= mHashes . length ) { final int n = mSize >= ( BASE_SIZE * 2 ) ? ( mSize + ( mSize >> 1 ) ) : ( mSize >= BASE_SIZE ? ( BASE_SIZE * 2 ) : BASE_SIZE ) ; if ( DEBUG ) Log . d ( TAG , "add: grow from " + mHashes . length + " to " + n ) ; final int [ ] ohashes = mHashes ; final Object [ ] oarray = mArray ; allocArrays ( n ) ; if ( mHashes . length > 0 ) { if ( DEBUG ) Log . d ( TAG , "add: copy 0-" + mSize + " to 0" ) ; System . arraycopy ( ohashes , 0 , mHashes , 0 , ohashes . length ) ; System . arraycopy ( oarray , 0 , mArray , 0 , oarray . length ) ; } freeArrays ( ohashes , oarray , mSize ) ; } if ( index < mSize ) { if ( DEBUG ) Log . d ( TAG , "add: move " + index + "-" + ( mSize - index ) + " to " + ( index + 1 ) ) ; System . arraycopy ( mHashes , index , mHashes , index + 1 , mSize - index ) ; System . arraycopy ( mArray , index , mArray , index + 1 , mSize - index ) ; } mHashes [ index ] = hash ; mArray [ index ] = value ; mSize ++ ; return true ; } | Adds the specified object to this set . The set is not modified if it already contains the object . |
27,929 | public boolean remove ( Object object ) { int index = object == null ? indexOfNull ( ) : indexOf ( object , object . hashCode ( ) ) ; if ( index >= 0 ) { removeAt ( index ) ; return true ; } return false ; } | Removes the specified object from this set . |
27,930 | public final StringBuffer format ( Object obj , StringBuffer appendTo , FieldPosition fieldPosition ) { if ( obj instanceof DateInterval ) { return format ( ( DateInterval ) obj , appendTo , fieldPosition ) ; } else { throw new IllegalArgumentException ( "Cannot format given Object (" + obj . getClass ( ) . getName ( ) + ") as a DateInterval" ) ; } } | Format an object to produce a string . This method handles Formattable objects with a DateInterval type . If a the Formattable object type is not a DateInterval IllegalArgumentException is thrown . |
27,931 | public final synchronized StringBuffer format ( DateInterval dtInterval , StringBuffer appendTo , FieldPosition fieldPosition ) { fFromCalendar . setTimeInMillis ( dtInterval . getFromDate ( ) ) ; fToCalendar . setTimeInMillis ( dtInterval . getToDate ( ) ) ; return format ( fFromCalendar , fToCalendar , appendTo , fieldPosition ) ; } | Format a DateInterval to produce a string . |
27,932 | public void setDateIntervalInfo ( DateIntervalInfo newItvPattern ) { fInfo = ( DateIntervalInfo ) newItvPattern . clone ( ) ; this . isDateIntervalInfoDefault = false ; fInfo . freeze ( ) ; if ( fDateFormat != null ) { initializePattern ( null ) ; } } | Set the date time interval patterns . |
27,933 | public TimeZone getTimeZone ( ) { if ( fDateFormat != null ) { return ( TimeZone ) ( fDateFormat . getTimeZone ( ) . clone ( ) ) ; } return TimeZone . getDefault ( ) ; } | Get the TimeZone |
27,934 | public void setTimeZone ( TimeZone zone ) { TimeZone zoneToSet = ( TimeZone ) zone . clone ( ) ; if ( fDateFormat != null ) { fDateFormat . setTimeZone ( zoneToSet ) ; } if ( fFromCalendar != null ) { fFromCalendar . setTimeZone ( zoneToSet ) ; } if ( fToCalendar != null ) { fToCalendar . setTimeZone ( zoneToSet ) ; } } | Set the TimeZone for the calendar used by this DateIntervalFormat object . |
27,935 | private String getConcatenationPattern ( ULocale locale ) { ICUResourceBundle rb = ( ICUResourceBundle ) UResourceBundle . getBundleInstance ( ICUData . ICU_BASE_NAME , locale ) ; ICUResourceBundle dtPatternsRb = rb . getWithFallback ( "calendar/gregorian/DateTimePatterns" ) ; ICUResourceBundle concatenationPatternRb = ( ICUResourceBundle ) dtPatternsRb . get ( 8 ) ; if ( concatenationPatternRb . getType ( ) == UResourceBundle . STRING ) { return concatenationPatternRb . getString ( ) ; } else { return concatenationPatternRb . getString ( 0 ) ; } } | Retrieves the concatenation DateTime pattern from the resource bundle . |
27,936 | public static < T extends Object & Comparable < ? super T > > boolean hasRelation ( SortedSet < T > a , int allow , SortedSet < T > b ) { if ( allow < NONE || allow > ANY ) { throw new IllegalArgumentException ( "Relation " + allow + " out of range" ) ; } boolean anb = ( allow & A_NOT_B ) != 0 ; boolean ab = ( allow & A_AND_B ) != 0 ; boolean bna = ( allow & B_NOT_A ) != 0 ; switch ( allow ) { case CONTAINS : if ( a . size ( ) < b . size ( ) ) return false ; break ; case ISCONTAINED : if ( a . size ( ) > b . size ( ) ) return false ; break ; case EQUALS : if ( a . size ( ) != b . size ( ) ) return false ; break ; } if ( a . size ( ) == 0 ) { if ( b . size ( ) == 0 ) return true ; return bna ; } else if ( b . size ( ) == 0 ) { return anb ; } Iterator < ? extends T > ait = a . iterator ( ) ; Iterator < ? extends T > bit = b . iterator ( ) ; T aa = ait . next ( ) ; T bb = bit . next ( ) ; while ( true ) { int comp = aa . compareTo ( bb ) ; if ( comp == 0 ) { if ( ! ab ) return false ; if ( ! ait . hasNext ( ) ) { if ( ! bit . hasNext ( ) ) return true ; return bna ; } else if ( ! bit . hasNext ( ) ) { return anb ; } aa = ait . next ( ) ; bb = bit . next ( ) ; } else if ( comp < 0 ) { if ( ! anb ) return false ; if ( ! ait . hasNext ( ) ) { return bna ; } aa = ait . next ( ) ; } else { if ( ! bna ) return false ; if ( ! bit . hasNext ( ) ) { return anb ; } bb = bit . next ( ) ; } } } | Utility that could be on SortedSet . Faster implementation than what is in Java for doing contains equals etc . |
27,937 | final long internalNextLong ( long origin , long bound ) { long r = mix64 ( nextSeed ( ) ) ; if ( origin < bound ) { long n = bound - origin , m = n - 1 ; if ( ( n & m ) == 0L ) r = ( r & m ) + origin ; else if ( n > 0L ) { for ( long u = r >>> 1 ; u + m - ( r = u % n ) < 0L ; u = mix64 ( nextSeed ( ) ) >>> 1 ) ; r += origin ; } else { while ( r < origin || r >= bound ) r = mix64 ( nextSeed ( ) ) ; } } return r ; } | The form of nextLong used by LongStream Spliterators . If origin is greater than bound acts as unbounded form of nextLong else as bounded form . |
27,938 | final int internalNextInt ( int origin , int bound ) { int r = mix32 ( nextSeed ( ) ) ; if ( origin < bound ) { int n = bound - origin , m = n - 1 ; if ( ( n & m ) == 0 ) r = ( r & m ) + origin ; else if ( n > 0 ) { for ( int u = r >>> 1 ; u + m - ( r = u % n ) < 0 ; u = mix32 ( nextSeed ( ) ) >>> 1 ) ; r += origin ; } else { while ( r < origin || r >= bound ) r = mix32 ( nextSeed ( ) ) ; } } return r ; } | The form of nextInt used by IntStream Spliterators . Exactly the same as long version except for types . |
27,939 | final double internalNextDouble ( double origin , double bound ) { double r = ( nextLong ( ) >>> 11 ) * DOUBLE_UNIT ; if ( origin < bound ) { r = r * ( bound - origin ) + origin ; if ( r >= bound ) r = Double . longBitsToDouble ( Double . doubleToLongBits ( bound ) - 1 ) ; } return r ; } | The form of nextDouble used by DoubleStream Spliterators . |
27,940 | public static Currency getInstance ( ULocale locale ) { String currency = locale . getKeywordValue ( "currency" ) ; if ( currency != null ) { return getInstance ( currency ) ; } if ( shim == null ) { return createCurrency ( locale ) ; } return shim . createInstance ( locale ) ; } | Returns a currency object for the default currency in the given locale . |
27,941 | public static String [ ] getAvailableCurrencyCodes ( ULocale loc , Date d ) { String region = ULocale . getRegionForSupplementalData ( loc , false ) ; CurrencyFilter filter = CurrencyFilter . onDate ( d ) . withRegion ( region ) ; List < String > list = getTenderCurrencies ( filter ) ; if ( list . isEmpty ( ) ) { return null ; } return list . toArray ( new String [ list . size ( ) ] ) ; } | Returns an array of Strings which contain the currency identifiers that are valid for the given locale on the given date . If there are no such identifiers returns null . Returned identifiers are in preference order . |
27,942 | public static Set < Currency > getAvailableCurrencies ( ) { CurrencyMetaInfo info = CurrencyMetaInfo . getInstance ( ) ; List < String > list = info . currencies ( CurrencyFilter . all ( ) ) ; HashSet < Currency > resultSet = new HashSet < Currency > ( list . size ( ) ) ; for ( String code : list ) { resultSet . add ( getInstance ( code ) ) ; } return resultSet ; } | Returns the set of available currencies . The returned set of currencies contains all of the available currencies including obsolete ones . The result set can be modified without affecting the available currencies in the runtime . |
27,943 | public static Currency getInstance ( String theISOCode ) { if ( theISOCode == null ) { throw new NullPointerException ( "The input currency code is null." ) ; } if ( ! isAlpha3Code ( theISOCode ) ) { throw new IllegalArgumentException ( "The input currency code is not 3-letter alphabetic code." ) ; } return ( Currency ) MeasureUnit . internalGetInstance ( "currency" , theISOCode . toUpperCase ( Locale . ENGLISH ) ) ; } | Returns a currency object given an ISO 4217 3 - letter code . |
27,944 | public static Object registerInstance ( Currency currency , ULocale locale ) { return getShim ( ) . registerInstance ( currency , locale ) ; } | Registers a new currency for the provided locale . The returned object is a key that can be used to unregister this currency object . |
27,945 | public static String parse ( ULocale locale , String text , int type , ParsePosition pos ) { List < TextTrieMap < CurrencyStringInfo > > currencyTrieVec = CURRENCY_NAME_CACHE . get ( locale ) ; if ( currencyTrieVec == null ) { TextTrieMap < CurrencyStringInfo > currencyNameTrie = new TextTrieMap < CurrencyStringInfo > ( true ) ; TextTrieMap < CurrencyStringInfo > currencySymbolTrie = new TextTrieMap < CurrencyStringInfo > ( false ) ; currencyTrieVec = new ArrayList < TextTrieMap < CurrencyStringInfo > > ( ) ; currencyTrieVec . add ( currencySymbolTrie ) ; currencyTrieVec . add ( currencyNameTrie ) ; setupCurrencyTrieVec ( locale , currencyTrieVec ) ; CURRENCY_NAME_CACHE . put ( locale , currencyTrieVec ) ; } int maxLength = 0 ; String isoResult = null ; TextTrieMap < CurrencyStringInfo > currencyNameTrie = currencyTrieVec . get ( 1 ) ; CurrencyNameResultHandler handler = new CurrencyNameResultHandler ( ) ; currencyNameTrie . find ( text , pos . getIndex ( ) , handler ) ; isoResult = handler . getBestCurrencyISOCode ( ) ; maxLength = handler . getBestMatchLength ( ) ; if ( type != Currency . LONG_NAME ) { TextTrieMap < CurrencyStringInfo > currencySymbolTrie = currencyTrieVec . get ( 0 ) ; handler = new CurrencyNameResultHandler ( ) ; currencySymbolTrie . find ( text , pos . getIndex ( ) , handler ) ; if ( handler . getBestMatchLength ( ) > maxLength ) { isoResult = handler . getBestCurrencyISOCode ( ) ; maxLength = handler . getBestMatchLength ( ) ; } } int start = pos . getIndex ( ) ; pos . setIndex ( start + maxLength ) ; return isoResult ; } | Attempt to parse the given string as a currency either as a display name in the given locale or as a 3 - letter ISO 4217 code . If multiple display names match then the longest one is selected . If both a display name and a 3 - letter ISO code match then the display name is preferred unless it s length is less than 3 . |
27,946 | public int getDefaultFractionDigits ( CurrencyUsage Usage ) { CurrencyMetaInfo info = CurrencyMetaInfo . getInstance ( ) ; CurrencyDigits digits = info . currencyDigits ( subType , Usage ) ; return digits . fractionDigits ; } | Returns the number of the number of fraction digits that should be displayed for this currency with Usage . |
27,947 | public double getRoundingIncrement ( CurrencyUsage Usage ) { CurrencyMetaInfo info = CurrencyMetaInfo . getInstance ( ) ; CurrencyDigits digits = info . currencyDigits ( subType , Usage ) ; int data1 = digits . roundingIncrement ; if ( data1 == 0 ) { return 0.0 ; } int data0 = digits . fractionDigits ; if ( data0 < 0 || data0 >= POW10 . length ) { return 0.0 ; } return ( double ) data1 / POW10 [ data0 ] ; } | Returns the rounding increment for this currency or 0 . 0 if no rounding is done by this currency with the Usage . |
27,948 | private static List < String > getTenderCurrencies ( CurrencyFilter filter ) { CurrencyMetaInfo info = CurrencyMetaInfo . getInstance ( ) ; return info . currencies ( filter . withTender ( ) ) ; } | Returns the list of remaining tender currencies after a filter is applied . |
27,949 | public boolean visitFunction ( ExpressionOwner owner , Function func ) { if ( func instanceof FuncExtFunction ) { String namespace = ( ( FuncExtFunction ) func ) . getNamespace ( ) ; m_sroot . getExtensionNamespacesManager ( ) . registerExtension ( namespace ) ; } else if ( func instanceof FuncExtFunctionAvailable ) { String arg = ( ( FuncExtFunctionAvailable ) func ) . getArg0 ( ) . toString ( ) ; if ( arg . indexOf ( ":" ) > 0 ) { String prefix = arg . substring ( 0 , arg . indexOf ( ":" ) ) ; String namespace = this . m_sroot . getNamespaceForPrefix ( prefix ) ; m_sroot . getExtensionNamespacesManager ( ) . registerExtension ( namespace ) ; } } return true ; } | If the function is an extension function register the namespace . |
27,950 | @ SuppressWarnings ( "fallthrough" ) private boolean findSection ( int offset , Position pos ) { int i = offset , len = rawBytes . length ; int last = offset ; int next ; boolean allBlank = true ; pos . endOfFirstLine = - 1 ; while ( i < len ) { byte b = rawBytes [ i ] ; switch ( b ) { case '\r' : if ( pos . endOfFirstLine == - 1 ) pos . endOfFirstLine = i - 1 ; if ( ( i < len ) && ( rawBytes [ i + 1 ] == '\n' ) ) i ++ ; case '\n' : if ( pos . endOfFirstLine == - 1 ) pos . endOfFirstLine = i - 1 ; if ( allBlank || ( i == len - 1 ) ) { if ( i == len - 1 ) pos . endOfSection = i ; else pos . endOfSection = last ; pos . startOfNext = i + 1 ; return true ; } else { last = i ; allBlank = true ; } break ; default : allBlank = false ; break ; } i ++ ; } return false ; } | find a section in the manifest . |
27,951 | DataBundle get ( ULocale locale ) { DataBundle result = cache . get ( locale ) ; if ( result == null ) { result = load ( locale ) ; cache . put ( locale , result ) ; } return result ; } | Fetch data for a particular locale . Clients must not modify any part of the returned data . Portions of returned data may be shared so modifying it will have unpredictable results . |
27,952 | private static long calculateDivisor ( long power10 , int numZeros ) { long divisor = power10 ; for ( int i = 1 ; i < numZeros ; i ++ ) { divisor /= 10 ; } return divisor ; } | Calculate a divisor based on the magnitude and number of zeros in the template string . |
27,953 | private static void checkForOtherVariants ( Data data , ULocale locale , String style ) { DecimalFormat . Unit [ ] otherByBase = data . units . get ( OTHER ) ; if ( otherByBase == null ) { throw new IllegalArgumentException ( "No 'other' plural variants defined in " + localeAndStyle ( locale , style ) ) ; } for ( Map . Entry < String , Unit [ ] > entry : data . units . entrySet ( ) ) { if ( entry . getKey ( ) == OTHER ) continue ; DecimalFormat . Unit [ ] variantByBase = entry . getValue ( ) ; for ( int log10Value = 0 ; log10Value < MAX_DIGITS ; log10Value ++ ) { if ( variantByBase [ log10Value ] != null && otherByBase [ log10Value ] == null ) { throw new IllegalArgumentException ( "No 'other' plural variant defined for 10^" + log10Value + " but a '" + entry . getKey ( ) + "' variant is defined" + " in " + localeAndStyle ( locale , style ) ) ; } } } } | Checks to make sure that an other variant is present in all powers of 10 . |
27,954 | private static void fillInMissing ( Data result ) { long lastDivisor = 1L ; for ( int i = 0 ; i < result . divisors . length ; i ++ ) { if ( result . units . get ( OTHER ) [ i ] == null ) { result . divisors [ i ] = lastDivisor ; copyFromPreviousIndex ( i , result . units ) ; } else { lastDivisor = result . divisors [ i ] ; propagateOtherToMissing ( i , result . units ) ; } } } | After reading information from resource bundle into a Data object there is guarantee that it is complete . |
27,955 | static DecimalFormat . Unit getUnit ( Map < String , DecimalFormat . Unit [ ] > units , String variant , int base ) { DecimalFormat . Unit [ ] byBase = units . get ( variant ) ; if ( byBase == null ) { byBase = units . get ( CompactDecimalDataCache . OTHER ) ; } return byBase [ base ] ; } | Fetches a prefix or suffix given a plural variant and log10 value . If it can t find the given variant it falls back to other . |
27,956 | public String lookupNamespace ( String prefix ) { String uri = null ; final Stack stack = getPrefixStack ( prefix ) ; if ( stack != null && ! stack . isEmpty ( ) ) { uri = ( ( MappingRecord ) stack . peek ( ) ) . m_uri ; } if ( uri == null ) uri = EMPTYSTRING ; return uri ; } | Use a namespace prefix to lookup a namespace URI . |
27,957 | public String lookupPrefix ( String uri ) { String foundPrefix = null ; Enumeration prefixes = m_namespaces . keys ( ) ; while ( prefixes . hasMoreElements ( ) ) { String prefix = ( String ) prefixes . nextElement ( ) ; String uri2 = lookupNamespace ( prefix ) ; if ( uri2 != null && uri2 . equals ( uri ) ) { foundPrefix = prefix ; break ; } } return foundPrefix ; } | Given a namespace uri and the namespaces mappings for the current element return the current prefix for that uri . |
27,958 | boolean popNamespace ( String prefix ) { if ( prefix . startsWith ( XML_PREFIX ) ) { return false ; } Stack stack ; if ( ( stack = getPrefixStack ( prefix ) ) != null ) { stack . pop ( ) ; return true ; } return false ; } | Undeclare the namespace that is currently pointed to by a given prefix |
27,959 | public boolean pushNamespace ( String prefix , String uri , int elemDepth ) { if ( prefix . startsWith ( XML_PREFIX ) ) { return false ; } Stack stack ; if ( ( stack = ( Stack ) m_namespaces . get ( prefix ) ) == null ) { m_namespaces . put ( prefix , stack = new Stack ( ) ) ; } if ( ! stack . empty ( ) ) { MappingRecord mr = ( MappingRecord ) stack . peek ( ) ; if ( uri . equals ( mr . m_uri ) || elemDepth == mr . m_declarationDepth ) { return false ; } } MappingRecord map = new MappingRecord ( prefix , uri , elemDepth ) ; stack . push ( map ) ; m_nodeStack . push ( map ) ; return true ; } | Declare a mapping of a prefix to namespace URI at the given element depth . |
27,960 | void popNamespaces ( int elemDepth , ContentHandler saxHandler ) { while ( true ) { if ( m_nodeStack . isEmpty ( ) ) return ; MappingRecord map = ( MappingRecord ) ( m_nodeStack . peek ( ) ) ; int depth = map . m_declarationDepth ; if ( elemDepth < 1 || map . m_declarationDepth < elemDepth ) break ; MappingRecord nm1 = ( MappingRecord ) m_nodeStack . pop ( ) ; String prefix = map . m_prefix ; Stack prefixStack = getPrefixStack ( prefix ) ; MappingRecord nm2 = ( MappingRecord ) prefixStack . peek ( ) ; if ( nm1 == nm2 ) { prefixStack . pop ( ) ; if ( saxHandler != null ) { try { saxHandler . endPrefixMapping ( prefix ) ; } catch ( SAXException e ) { } } } } } | Pop or undeclare all namespace definitions that are currently declared at the given element depth or deepter . |
27,961 | private Stack createPrefixStack ( String prefix ) { Stack fs = new Stack ( ) ; m_namespaces . put ( prefix , fs ) ; return fs ; } | A more type - safe way of saving stacks under the m_namespaces Hashtable . |
27,962 | public String [ ] lookupAllPrefixes ( String uri ) { java . util . ArrayList foundPrefixes = new java . util . ArrayList ( ) ; Enumeration prefixes = m_namespaces . keys ( ) ; while ( prefixes . hasMoreElements ( ) ) { String prefix = ( String ) prefixes . nextElement ( ) ; String uri2 = lookupNamespace ( prefix ) ; if ( uri2 != null && uri2 . equals ( uri ) ) { foundPrefixes . add ( prefix ) ; } } String [ ] prefixArray = new String [ foundPrefixes . size ( ) ] ; foundPrefixes . toArray ( prefixArray ) ; return prefixArray ; } | Given a namespace uri get all prefixes bound to the Namespace URI in the current scope . |
27,963 | public CharsetMatch detect ( ) { CharsetMatch matches [ ] = detectAll ( ) ; if ( matches == null || matches . length == 0 ) { return null ; } return matches [ 0 ] ; } | Return the charset that best matches the supplied input data . |
27,964 | public String [ ] getDetectableCharsets ( ) { List < String > csnames = new ArrayList < String > ( ALL_CS_RECOGNIZERS . size ( ) ) ; for ( int i = 0 ; i < ALL_CS_RECOGNIZERS . size ( ) ; i ++ ) { CSRecognizerInfo rcinfo = ALL_CS_RECOGNIZERS . get ( i ) ; boolean active = ( fEnabledRecognizers == null ) ? rcinfo . isDefaultEnabled : fEnabledRecognizers [ i ] ; if ( active ) { csnames . add ( rcinfo . recognizer . getName ( ) ) ; } } return csnames . toArray ( new String [ csnames . size ( ) ] ) ; } | Get the names of charsets that can be recognized by this CharsetDetector instance . |
27,965 | public void reset ( ) { m_flushedStartDoc = false ; m_foundFirstElement = false ; m_outputStream = null ; clearParameters ( ) ; m_result = null ; m_resultContentHandler = null ; m_resultDeclHandler = null ; m_resultDTDHandler = null ; m_resultLexicalHandler = null ; m_serializer = null ; m_systemID = null ; m_URIResolver = null ; m_outputFormat = new OutputProperties ( Method . XML ) ; } | Reset the status of the transformer . |
27,966 | public void setParameter ( String name , Object value ) { if ( value == null ) { throw new IllegalArgumentException ( XSLMessages . createMessage ( XSLTErrorResources . ER_INVALID_SET_PARAM_VALUE , new Object [ ] { name } ) ) ; } if ( null == m_params ) { m_params = new Hashtable ( ) ; } m_params . put ( name , value ) ; } | Add a parameter for the transformation . |
27,967 | public void setOutputProperty ( String name , String value ) throws IllegalArgumentException { if ( ! OutputProperties . isLegalPropertyKey ( name ) ) throw new IllegalArgumentException ( XSLMessages . createMessage ( XSLTErrorResources . ER_OUTPUT_PROPERTY_NOT_RECOGNIZED , new Object [ ] { name } ) ) ; m_outputFormat . setProperty ( name , value ) ; } | Set an output property that will be in effect for the transformation . |
27,968 | public void setDocumentLocator ( Locator locator ) { try { if ( null == m_resultContentHandler ) createResultContentHandler ( m_result ) ; } catch ( TransformerException te ) { throw new org . apache . xml . utils . WrappedRuntimeException ( te ) ; } m_resultContentHandler . setDocumentLocator ( locator ) ; } | Receive a Locator object for document events . |
27,969 | public Segment pop ( ) { Segment result = next != this ? next : null ; prev . next = next ; next . prev = prev ; next = null ; prev = null ; return result ; } | Removes this segment of a circularly - linked list and returns its successor . Returns null if the list is now empty . |
27,970 | public void compact ( ) { if ( prev == this ) throw new IllegalStateException ( ) ; if ( ! prev . owner ) return ; int byteCount = limit - pos ; int availableByteCount = SIZE - prev . limit + ( prev . shared ? 0 : prev . pos ) ; if ( byteCount > availableByteCount ) return ; writeTo ( prev , byteCount ) ; pop ( ) ; SegmentPool . recycle ( this ) ; } | Call this when the tail and its predecessor may both be less than half full . This will copy data so that segments can be recycled . |
27,971 | public static SimpleDateFormat getInstance ( Calendar . FormatConfiguration formatConfig ) { String ostr = formatConfig . getOverrideString ( ) ; boolean useFast = ( ostr != null && ostr . length ( ) > 0 ) ; return new SimpleDateFormat ( formatConfig . getPatternString ( ) , formatConfig . getDateFormatSymbols ( ) , formatConfig . getCalendar ( ) , null , formatConfig . getLocale ( ) , useFast , formatConfig . getOverrideString ( ) ) ; } | Creates an instance of SimpleDateFormat for the given format configuration |
27,972 | private synchronized void initializeTimeZoneFormat ( boolean bForceUpdate ) { if ( bForceUpdate || tzFormat == null ) { tzFormat = TimeZoneFormat . getInstance ( locale ) ; String digits = null ; if ( numberFormat instanceof DecimalFormat ) { DecimalFormatSymbols decsym = ( ( DecimalFormat ) numberFormat ) . getDecimalFormatSymbols ( ) ; digits = new String ( decsym . getDigits ( ) ) ; } else if ( numberFormat instanceof DateNumberFormat ) { digits = new String ( ( ( DateNumberFormat ) numberFormat ) . getDigits ( ) ) ; } if ( digits != null ) { if ( ! tzFormat . getGMTOffsetDigits ( ) . equals ( digits ) ) { if ( tzFormat . isFrozen ( ) ) { tzFormat = tzFormat . cloneAsThawed ( ) ; } tzFormat . setGMTOffsetDigits ( digits ) ; } } } } | Private method lazily instantiate the TimeZoneFormat field |
27,973 | public void setContext ( DisplayContext context ) { super . setContext ( context ) ; if ( capitalizationBrkIter == null && ( context == DisplayContext . CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE || context == DisplayContext . CAPITALIZATION_FOR_UI_LIST_OR_MENU || context == DisplayContext . CAPITALIZATION_FOR_STANDALONE ) ) { capitalizationBrkIter = BreakIterator . getSentenceInstance ( locale ) ; } } | Here we override the DateFormat implementation in order to lazily initialize relevant items |
27,974 | private StringBuffer format ( Calendar cal , DisplayContext capitalizationContext , StringBuffer toAppendTo , FieldPosition pos , List < FieldPosition > attributes ) { pos . setBeginIndex ( 0 ) ; pos . setEndIndex ( 0 ) ; Object [ ] items = getPatternItems ( ) ; for ( int i = 0 ; i < items . length ; i ++ ) { if ( items [ i ] instanceof String ) { toAppendTo . append ( ( String ) items [ i ] ) ; } else { PatternItem item = ( PatternItem ) items [ i ] ; int start = 0 ; if ( attributes != null ) { start = toAppendTo . length ( ) ; } if ( useFastFormat ) { subFormat ( toAppendTo , item . type , item . length , toAppendTo . length ( ) , i , capitalizationContext , pos , cal ) ; } else { toAppendTo . append ( subFormat ( item . type , item . length , toAppendTo . length ( ) , i , capitalizationContext , pos , cal ) ) ; } if ( attributes != null ) { int end = toAppendTo . length ( ) ; if ( end - start > 0 ) { DateFormat . Field attr = patternCharToDateFormatField ( item . type ) ; FieldPosition fp = new FieldPosition ( attr ) ; fp . setBeginIndex ( start ) ; fp . setEndIndex ( end ) ; attributes . add ( fp ) ; } } } } return toAppendTo ; } | then attribute information will be recorded . |
27,975 | protected DateFormat . Field patternCharToDateFormatField ( char ch ) { int patternCharIndex = getIndexFromChar ( ch ) ; if ( patternCharIndex != - 1 ) { return PATTERN_INDEX_TO_DATE_FORMAT_ATTRIBUTE [ patternCharIndex ] ; } return null ; } | Returns a DateFormat . Field constant associated with the specified format pattern character . |
27,976 | protected String subFormat ( char ch , int count , int beginOffset , FieldPosition pos , DateFormatSymbols fmtData , Calendar cal ) throws IllegalArgumentException { return subFormat ( ch , count , beginOffset , 0 , DisplayContext . CAPITALIZATION_NONE , pos , cal ) ; } | Formats a single field given its pattern character . Subclasses may override this method in order to modify or add formatting capabilities . |
27,977 | protected void zeroPaddingNumber ( NumberFormat nf , StringBuffer buf , int value , int minDigits , int maxDigits ) { if ( useLocalZeroPaddingNumberFormat && value >= 0 ) { fastZeroPaddingNumber ( buf , value , minDigits , maxDigits ) ; } else { nf . setMinimumIntegerDigits ( minDigits ) ; nf . setMaximumIntegerDigits ( maxDigits ) ; nf . format ( value , buf , new FieldPosition ( - 1 ) ) ; } } | Internal high - speed method . Reuses a StringBuffer for results instead of creating a String on the heap for each call . |
27,978 | private static final boolean isNumeric ( char formatChar , int count ) { return NUMERIC_FORMAT_CHARS . indexOf ( formatChar ) >= 0 || ( count <= 2 && NUMERIC_FORMAT_CHARS2 . indexOf ( formatChar ) >= 0 ) ; } | Return true if the given format character occuring count times represents a numeric field . |
27,979 | private int matchDayPeriodString ( String text , int start , String [ ] data , int dataLength , Output < DayPeriodRules . DayPeriod > dayPeriod ) { int bestMatchLength = 0 , bestMatch = - 1 ; int matchLength = 0 ; for ( int i = 0 ; i < dataLength ; ++ i ) { if ( data [ i ] != null ) { int length = data [ i ] . length ( ) ; if ( length > bestMatchLength && ( matchLength = regionMatchesWithOptionalDot ( text , start , data [ i ] , length ) ) >= 0 ) { bestMatch = i ; bestMatchLength = matchLength ; } } } if ( bestMatch >= 0 ) { dayPeriod . value = DayPeriodRules . DayPeriod . VALUES [ bestMatch ] ; return start + bestMatchLength ; } return - start ; } | Similar to matchQuarterString but customized for day periods . |
27,980 | private boolean allowNumericFallback ( int patternCharIndex ) { if ( patternCharIndex == 26 || patternCharIndex == 19 || patternCharIndex == 25 || patternCharIndex == 30 || patternCharIndex == 27 || patternCharIndex == 28 ) { return true ; } return false ; } | return true if the pattern specified by patternCharIndex is one that allows numeric fallback regardless of actual pattern size . |
27,981 | private Number parseInt ( String text , ParsePosition pos , boolean allowNegative , NumberFormat fmt ) { return parseInt ( text , - 1 , pos , allowNegative , fmt ) ; } | Parse an integer using numberFormat . This method is semantically const but actually may modify fNumberFormat . |
27,982 | private Number parseInt ( String text , int maxDigits , ParsePosition pos , boolean allowNegative , NumberFormat fmt ) { Number number ; int oldPos = pos . getIndex ( ) ; if ( allowNegative ) { number = fmt . parse ( text , pos ) ; } else { if ( fmt instanceof DecimalFormat ) { String oldPrefix = ( ( DecimalFormat ) fmt ) . getNegativePrefix ( ) ; ( ( DecimalFormat ) fmt ) . setNegativePrefix ( SUPPRESS_NEGATIVE_PREFIX ) ; number = fmt . parse ( text , pos ) ; ( ( DecimalFormat ) fmt ) . setNegativePrefix ( oldPrefix ) ; } else { boolean dateNumberFormat = ( fmt instanceof DateNumberFormat ) ; if ( dateNumberFormat ) { ( ( DateNumberFormat ) fmt ) . setParsePositiveOnly ( true ) ; } number = fmt . parse ( text , pos ) ; if ( dateNumberFormat ) { ( ( DateNumberFormat ) fmt ) . setParsePositiveOnly ( false ) ; } } } if ( maxDigits > 0 ) { int nDigits = pos . getIndex ( ) - oldPos ; if ( nDigits > maxDigits ) { double val = number . doubleValue ( ) ; nDigits -= maxDigits ; while ( nDigits > 0 ) { val /= 10 ; nDigits -- ; } pos . setIndex ( oldPos + maxDigits ) ; number = Integer . valueOf ( ( int ) val ) ; } } return number ; } | Parse an integer using numberFormat up to maxDigits . |
27,983 | private String translatePattern ( String pat , String from , String to ) { StringBuilder result = new StringBuilder ( ) ; boolean inQuote = false ; for ( int i = 0 ; i < pat . length ( ) ; ++ i ) { char c = pat . charAt ( i ) ; if ( inQuote ) { if ( c == '\'' ) inQuote = false ; } else { if ( c == '\'' ) { inQuote = true ; } else if ( isSyntaxChar ( c ) ) { int ci = from . indexOf ( c ) ; if ( ci != - 1 ) { c = to . charAt ( ci ) ; } } } result . append ( c ) ; } if ( inQuote ) { throw new IllegalArgumentException ( "Unfinished quote in pattern" ) ; } return result . toString ( ) ; } | Translate a pattern mapping each character in the from string to the corresponding character in the to string . |
27,984 | public void applyPattern ( String pat ) { this . pattern = pat ; parsePattern ( ) ; setLocale ( null , null ) ; patternItems = null ; } | Apply the given unlocalized pattern string to this date format . |
27,985 | public void applyLocalizedPattern ( String pat ) { this . pattern = translatePattern ( pat , formatData . localPatternChars , DateFormatSymbols . patternChars ) ; setLocale ( null , null ) ; } | Apply the given localized pattern string to this date format . |
27,986 | public AttributedCharacterIterator formatToCharacterIterator ( Object obj ) { Calendar cal = calendar ; if ( obj instanceof Calendar ) { cal = ( Calendar ) obj ; } else if ( obj instanceof Date ) { calendar . setTime ( ( Date ) obj ) ; } else if ( obj instanceof Number ) { calendar . setTimeInMillis ( ( ( Number ) obj ) . longValue ( ) ) ; } else { throw new IllegalArgumentException ( "Cannot format given Object as a Date" ) ; } StringBuffer toAppendTo = new StringBuffer ( ) ; FieldPosition pos = new FieldPosition ( 0 ) ; List < FieldPosition > attributes = new ArrayList < FieldPosition > ( ) ; format ( cal , getContext ( DisplayContext . Type . CAPITALIZATION ) , toAppendTo , pos , attributes ) ; AttributedString as = new AttributedString ( toAppendTo . toString ( ) ) ; for ( int i = 0 ; i < attributes . size ( ) ; i ++ ) { FieldPosition fp = attributes . get ( i ) ; Format . Field attribute = fp . getFieldAttribute ( ) ; as . addAttribute ( attribute , attribute , fp . getBeginIndex ( ) , fp . getEndIndex ( ) ) ; } return as . getIterator ( ) ; } | Format the object to an attributed string and return the corresponding iterator Overrides superclass method . |
27,987 | private boolean diffCalFieldValue ( Calendar fromCalendar , Calendar toCalendar , Object [ ] items , int i ) throws IllegalArgumentException { if ( items [ i ] instanceof String ) { return false ; } PatternItem item = ( PatternItem ) items [ i ] ; char ch = item . type ; int patternCharIndex = getIndexFromChar ( ch ) ; if ( patternCharIndex == - 1 ) { throw new IllegalArgumentException ( "Illegal pattern character " + "'" + ch + "' in \"" + pattern + '"' ) ; } final int field = PATTERN_INDEX_TO_CALENDAR_FIELD [ patternCharIndex ] ; if ( field >= 0 ) { int value = fromCalendar . get ( field ) ; int value_2 = toCalendar . get ( field ) ; if ( value != value_2 ) { return true ; } } return false ; } | check whether the i - th item in 2 calendar is in different value . |
27,988 | private boolean lowerLevel ( Object [ ] items , int i , int level ) throws IllegalArgumentException { if ( items [ i ] instanceof String ) { return false ; } PatternItem item = ( PatternItem ) items [ i ] ; char ch = item . type ; int patternCharIndex = getLevelFromChar ( ch ) ; if ( patternCharIndex == - 1 ) { throw new IllegalArgumentException ( "Illegal pattern character " + "'" + ch + "' in \"" + pattern + '"' ) ; } if ( patternCharIndex >= level ) { return true ; } return false ; } | check whether the i - th item s level is lower than the input level |
27,989 | public void addUniqueAttribute ( String rawName , String value , int flags ) throws SAXException { if ( m_firstTagNotEmitted ) { flush ( ) ; } m_handler . addUniqueAttribute ( rawName , value , flags ) ; } | Adds a unique attribute to the currenly open tag |
27,990 | private String getPrefixPartUnknown ( String qname ) { final int index = qname . indexOf ( ':' ) ; return ( index > 0 ) ? qname . substring ( 0 , index ) : EMPTYSTRING ; } | Utility function to return prefix |
27,991 | public NamespaceMappings getNamespaceMappings ( ) { NamespaceMappings mappings = null ; if ( m_handler != null ) { mappings = m_handler . getNamespaceMappings ( ) ; } return mappings ; } | Get the current namespace mappings . Simply returns the mappings of the wrapped handler . |
27,992 | private void initExtendedTypes ( ) { m_extendedTypes = new ExtendedType [ m_initialSize ] ; for ( int i = 0 ; i < DTM . NTYPES ; i ++ ) { m_extendedTypes [ i ] = m_defaultExtendedTypes [ i ] ; m_table [ i ] = new HashEntry ( m_defaultExtendedTypes [ i ] , i , i , null ) ; } m_nextType = DTM . NTYPES ; } | Initialize the vector of extended types with the basic DOM node types . |
27,993 | public int getExpandedTypeID ( String namespace , String localName , int type ) { return getExpandedTypeID ( namespace , localName , type , false ) ; } | Given an expanded name represented by namespace local name and node type return an ID . If the expanded - name does not exist in the internal tables the entry will be created and the ID will be returned . Any additional nodes that are created that have this expanded name will use this ID . |
27,994 | private void rehash ( ) { int oldCapacity = m_capacity ; HashEntry [ ] oldTable = m_table ; int newCapacity = 2 * oldCapacity + 1 ; m_capacity = newCapacity ; m_threshold = ( int ) ( newCapacity * m_loadFactor ) ; m_table = new HashEntry [ newCapacity ] ; for ( int i = oldCapacity - 1 ; i >= 0 ; i -- ) { for ( HashEntry old = oldTable [ i ] ; old != null ; ) { HashEntry e = old ; old = old . next ; int newIndex = e . hash % newCapacity ; if ( newIndex < 0 ) newIndex = - newIndex ; e . next = m_table [ newIndex ] ; m_table [ newIndex ] = e ; } } } | Increases the capacity of and internally reorganizes the hashtable in order to accommodate and access its entries more efficiently . This method is called when the number of keys in the hashtable exceeds this hashtable s capacity and load factor . |
27,995 | private void expand ( ) { int i ; if ( isCompact ) { byte [ ] tempArray ; hashes = new int [ INDEXCOUNT ] ; tempArray = new byte [ UNICODECOUNT ] ; for ( i = 0 ; i < UNICODECOUNT ; ++ i ) { byte value = elementAt ( ( char ) i ) ; tempArray [ i ] = value ; touchBlock ( i >> BLOCKSHIFT , value ) ; } for ( i = 0 ; i < INDEXCOUNT ; ++ i ) { indices [ i ] = ( char ) ( i << BLOCKSHIFT ) ; } values = null ; values = tempArray ; isCompact = false ; } } | Expanding takes the array back to a 65536 element array . |
27,996 | public void setDecomposition ( int value ) { if ( value < Collator . NO_DECOMPOSITION || value > Collator . FULL_DECOMPOSITION ) { throw new IllegalArgumentException ( ) ; } decomposition = value ; } | Sets decomposition field but is otherwise unused . |
27,997 | public void setStrength ( int value ) { if ( value < Collator . PRIMARY || value > Collator . IDENTICAL ) { throw new IllegalArgumentException ( ) ; } strength = value ; } | Sets strength field but is otherwise unused . |
27,998 | public boolean get ( int index ) throws ArrayIndexOutOfBoundsException { if ( index < 0 || index >= length ) { throw new ArrayIndexOutOfBoundsException ( Integer . toString ( index ) ) ; } return ( repn [ subscript ( index ) ] & position ( index ) ) != 0 ; } | Returns the indexed bit in this BitArray . |
27,999 | public void set ( int index , boolean value ) throws ArrayIndexOutOfBoundsException { if ( index < 0 || index >= length ) { throw new ArrayIndexOutOfBoundsException ( Integer . toString ( index ) ) ; } int idx = subscript ( index ) ; int bit = position ( index ) ; if ( value ) { repn [ idx ] |= bit ; } else { repn [ idx ] &= ~ bit ; } } | Sets the indexed bit in this BitArray . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.