idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
28,000 | public boolean [ ] toBooleanArray ( ) { boolean [ ] bits = new boolean [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { bits [ i ] = get ( i ) ; } return bits ; } | Return a boolean array with the same bit values a this BitArray . |
28,001 | public void getCalendarDateFromFixedDate ( CalendarDate date , long fixedDate ) { Date gdate = ( Date ) date ; int year ; long jan1 ; boolean isLeap ; if ( gdate . hit ( fixedDate ) ) { year = gdate . getCachedYear ( ) ; jan1 = gdate . getCachedJan1 ( ) ; isLeap = isLeapYear ( year ) ; } else { year = getGregorianYearFromFixedDate ( fixedDate ) ; jan1 = getFixedDate ( year , JANUARY , 1 , null ) ; isLeap = isLeapYear ( year ) ; gdate . setCache ( year , jan1 , isLeap ? 366 : 365 ) ; } int priorDays = ( int ) ( fixedDate - jan1 ) ; long mar1 = jan1 + 31 + 28 ; if ( isLeap ) { ++ mar1 ; } if ( fixedDate >= mar1 ) { priorDays += isLeap ? 1 : 2 ; } int month = 12 * priorDays + 373 ; if ( month > 0 ) { month /= 367 ; } else { month = CalendarUtils . floorDivide ( month , 367 ) ; } long month1 = jan1 + ACCUMULATED_DAYS_IN_MONTH [ month ] ; if ( isLeap && month >= MARCH ) { ++ month1 ; } int dayOfMonth = ( int ) ( fixedDate - month1 ) + 1 ; int dayOfWeek = getDayOfWeekFromFixedDate ( fixedDate ) ; assert dayOfWeek > 0 : "negative day of week " + dayOfWeek ; gdate . setNormalizedYear ( year ) ; gdate . setMonth ( month ) ; gdate . setDayOfMonth ( dayOfMonth ) ; gdate . setDayOfWeek ( dayOfWeek ) ; gdate . setLeapYear ( isLeap ) ; gdate . setNormalized ( true ) ; } | should be protected |
28,002 | final int getGregorianYearFromFixedDate ( long fixedDate ) { long d0 ; int d1 , d2 , d3 , d4 ; int n400 , n100 , n4 , n1 ; int year ; if ( fixedDate > 0 ) { d0 = fixedDate - 1 ; n400 = ( int ) ( d0 / 146097 ) ; d1 = ( int ) ( d0 % 146097 ) ; n100 = d1 / 36524 ; d2 = d1 % 36524 ; n4 = d2 / 1461 ; d3 = d2 % 1461 ; n1 = d3 / 365 ; d4 = ( d3 % 365 ) + 1 ; } else { d0 = fixedDate - 1 ; n400 = ( int ) CalendarUtils . floorDivide ( d0 , 146097L ) ; d1 = ( int ) CalendarUtils . mod ( d0 , 146097L ) ; n100 = CalendarUtils . floorDivide ( d1 , 36524 ) ; d2 = CalendarUtils . mod ( d1 , 36524 ) ; n4 = CalendarUtils . floorDivide ( d2 , 1461 ) ; d3 = CalendarUtils . mod ( d2 , 1461 ) ; n1 = CalendarUtils . floorDivide ( d3 , 365 ) ; d4 = CalendarUtils . mod ( d3 , 365 ) + 1 ; } year = 400 * n400 + 100 * n100 + 4 * n4 + n1 ; if ( ! ( n100 == 4 || n1 == 4 ) ) { ++ year ; } return year ; } | Returns the Gregorian year number of the given fixed date . |
28,003 | public void setMaximumFractionDigits ( int newValue ) { maximumFractionDigits = Math . max ( 0 , newValue ) ; if ( maximumFractionDigits < minimumFractionDigits ) { minimumFractionDigits = maximumFractionDigits ; } } | Sets the maximum number of digits allowed in the fraction portion of a number . maximumFractionDigits must be > = minimumFractionDigits . If the new value for maximumFractionDigits is less than the current value of minimumFractionDigits then minimumFractionDigits will also be set to the new value . |
28,004 | private static void adjustForCurrencyDefaultFractionDigits ( DecimalFormat format , DecimalFormatSymbols symbols ) { Currency currency = symbols . getCurrency ( ) ; if ( currency == null ) { try { currency = Currency . getInstance ( symbols . getInternationalCurrencySymbol ( ) ) ; } catch ( IllegalArgumentException e ) { } } if ( currency != null ) { int digits = currency . getDefaultFractionDigits ( ) ; if ( digits != - 1 ) { int oldMinDigits = format . getMinimumFractionDigits ( ) ; if ( oldMinDigits == format . getMaximumFractionDigits ( ) ) { format . setMinimumFractionDigits ( digits ) ; format . setMaximumFractionDigits ( digits ) ; } else { format . setMinimumFractionDigits ( Math . min ( digits , oldMinDigits ) ) ; format . setMaximumFractionDigits ( digits ) ; } } } } | Adjusts the minimum and maximum fraction digits to values that are reasonable for the currency s default fraction digits . |
28,005 | public synchronized void write ( byte [ ] buf , int off , int len ) throws IOException { super . write ( buf , off , len ) ; crc . update ( buf , off , len ) ; } | Writes array of bytes to the compressed output stream . This method will block until all the bytes are written . |
28,006 | public void finish ( ) throws IOException { if ( ! def . finished ( ) ) { def . finish ( ) ; while ( ! def . finished ( ) ) { int len = def . deflate ( buf , 0 , buf . length ) ; if ( def . finished ( ) && len <= buf . length - TRAILER_SIZE ) { writeTrailer ( buf , len ) ; len = len + TRAILER_SIZE ; out . write ( buf , 0 , len ) ; return ; } if ( len > 0 ) out . write ( buf , 0 , len ) ; } byte [ ] trailer = new byte [ TRAILER_SIZE ] ; writeTrailer ( trailer , 0 ) ; out . write ( trailer ) ; } } | Finishes writing compressed data to the output stream without closing the underlying stream . Use this method when applying multiple filters in succession to the same output stream . |
28,007 | public Date firstBetween ( Date start , Date end ) { return doFirstBetween ( start , end ) ; } | Return the first occurrence of this rule on or after the given start date and before the given end date . |
28,008 | public boolean isOn ( Date date ) { synchronized ( calendar ) { calendar . setTime ( date ) ; int dayOfYear = calendar . get ( Calendar . DAY_OF_YEAR ) ; calendar . setTime ( computeInYear ( calendar . getTime ( ) , calendar ) ) ; return calendar . get ( Calendar . DAY_OF_YEAR ) == dayOfYear ; } } | Return true if the given Date is on the same day as Easter |
28,009 | public boolean isBetween ( Date start , Date end ) { return firstBetween ( start , end ) != null ; } | Return true if Easter occurs between the two dates given |
28,010 | private static ZoneRulesProvider getProvider ( String zoneId ) { ZoneRulesProvider provider = ZONES . get ( zoneId ) ; if ( provider == null ) { if ( ZONES . isEmpty ( ) ) { throw new ZoneRulesException ( "No time-zone data files registered" ) ; } throw new ZoneRulesException ( "Unknown time-zone ID: " + zoneId ) ; } return provider ; } | Gets the provider for the zone ID . |
28,011 | public StringBuilder formatMeasurePerUnit ( Measure measure , MeasureUnit perUnit , StringBuilder appendTo , FieldPosition pos ) { MeasureUnit resolvedUnit = MeasureUnit . resolveUnitPerUnit ( measure . getUnit ( ) , perUnit ) ; if ( resolvedUnit != null ) { Measure newMeasure = new Measure ( measure . getNumber ( ) , resolvedUnit ) ; return formatMeasure ( newMeasure , numberFormat , appendTo , pos ) ; } FieldPosition fpos = new FieldPosition ( pos . getFieldAttribute ( ) , pos . getField ( ) ) ; int offset = withPerUnitAndAppend ( formatMeasure ( measure , numberFormat , new StringBuilder ( ) , fpos ) , perUnit , appendTo ) ; if ( fpos . getBeginIndex ( ) != 0 || fpos . getEndIndex ( ) != 0 ) { pos . setBeginIndex ( fpos . getBeginIndex ( ) + offset ) ; pos . setEndIndex ( fpos . getEndIndex ( ) + offset ) ; } return appendTo ; } | Formats a single measure per unit . |
28,012 | public StringBuilder formatMeasures ( StringBuilder appendTo , FieldPosition fieldPosition , Measure ... measures ) { if ( measures . length == 0 ) { return appendTo ; } if ( measures . length == 1 ) { return formatMeasure ( measures [ 0 ] , numberFormat , appendTo , fieldPosition ) ; } if ( formatWidth == FormatWidth . NUMERIC ) { Number [ ] hms = toHMS ( measures ) ; if ( hms != null ) { return formatNumeric ( hms , appendTo ) ; } } ListFormatter listFormatter = ListFormatter . getInstance ( getLocale ( ) , formatWidth . getListFormatterStyle ( ) ) ; if ( fieldPosition != DontCareFieldPosition . INSTANCE ) { return formatMeasuresSlowTrack ( listFormatter , appendTo , fieldPosition , measures ) ; } String [ ] results = new String [ measures . length ] ; for ( int i = 0 ; i < measures . length ; i ++ ) { results [ i ] = formatMeasure ( measures [ i ] , i == measures . length - 1 ? numberFormat : integerFormat ) ; } return appendTo . append ( listFormatter . format ( ( Object [ ] ) results ) ) ; } | Formats a sequence of measures . |
28,013 | private static MeasureFormatData loadLocaleData ( ULocale locale ) { ICUResourceBundle resource = ( ICUResourceBundle ) UResourceBundle . getBundleInstance ( ICUData . ICU_UNIT_BASE_NAME , locale ) ; MeasureFormatData cacheData = new MeasureFormatData ( ) ; UnitDataSink sink = new UnitDataSink ( cacheData ) ; resource . getAllItemsWithFallback ( "" , sink ) ; return cacheData ; } | Returns formatting data for all MeasureUnits except for currency ones . |
28,014 | private static DateFormat loadNumericDurationFormat ( ICUResourceBundle r , String type ) { r = r . getWithFallback ( String . format ( "durationUnits/%s" , type ) ) ; DateFormat result = new SimpleDateFormat ( r . getString ( ) . replace ( "h" , "H" ) ) ; result . setTimeZone ( TimeZone . GMT_ZONE ) ; return result ; } | type is one of hm ms or hms |
28,015 | private static Number [ ] toHMS ( Measure [ ] measures ) { Number [ ] result = new Number [ 3 ] ; int lastIdx = - 1 ; for ( Measure m : measures ) { if ( m . getNumber ( ) . doubleValue ( ) < 0.0 ) { return null ; } Integer idxObj = hmsTo012 . get ( m . getUnit ( ) ) ; if ( idxObj == null ) { return null ; } int idx = idxObj . intValue ( ) ; if ( idx <= lastIdx ) { return null ; } lastIdx = idx ; result [ idx ] = m . getNumber ( ) ; } return result ; } | returned array will be null . |
28,016 | private StringBuilder formatNumeric ( Number [ ] hms , StringBuilder appendable ) { int startIndex = - 1 ; int endIndex = - 1 ; for ( int i = 0 ; i < hms . length ; i ++ ) { if ( hms [ i ] != null ) { endIndex = i ; if ( startIndex == - 1 ) { startIndex = endIndex ; } } else { hms [ i ] = Integer . valueOf ( 0 ) ; } } long millis = ( long ) ( ( ( Math . floor ( hms [ 0 ] . doubleValue ( ) ) * 60.0 + Math . floor ( hms [ 1 ] . doubleValue ( ) ) ) * 60.0 + Math . floor ( hms [ 2 ] . doubleValue ( ) ) ) * 1000.0 ) ; Date d = new Date ( millis ) ; if ( startIndex == 0 && endIndex == 2 ) { return formatNumeric ( d , numericFormatters . getHourMinuteSecond ( ) , DateFormat . Field . SECOND , hms [ endIndex ] , appendable ) ; } if ( startIndex == 1 && endIndex == 2 ) { return formatNumeric ( d , numericFormatters . getMinuteSecond ( ) , DateFormat . Field . SECOND , hms [ endIndex ] , appendable ) ; } if ( startIndex == 0 && endIndex == 1 ) { return formatNumeric ( d , numericFormatters . getHourMinute ( ) , DateFormat . Field . MINUTE , hms [ endIndex ] , appendable ) ; } throw new IllegalStateException ( ) ; } | values in hms with 0 . |
28,017 | private StringBuilder formatNumeric ( Date duration , DateFormat formatter , DateFormat . Field smallestField , Number smallestAmount , StringBuilder appendTo ) { String smallestAmountFormatted ; FieldPosition intFieldPosition = new FieldPosition ( NumberFormat . INTEGER_FIELD ) ; smallestAmountFormatted = numberFormat . format ( smallestAmount , new StringBuffer ( ) , intFieldPosition ) . toString ( ) ; if ( intFieldPosition . getBeginIndex ( ) == 0 && intFieldPosition . getEndIndex ( ) == 0 ) { throw new IllegalStateException ( ) ; } FieldPosition smallestFieldPosition = new FieldPosition ( smallestField ) ; String draft = formatter . format ( duration , new StringBuffer ( ) , smallestFieldPosition ) . toString ( ) ; if ( smallestFieldPosition . getBeginIndex ( ) != 0 || smallestFieldPosition . getEndIndex ( ) != 0 ) { appendTo . append ( draft , 0 , smallestFieldPosition . getBeginIndex ( ) ) ; appendTo . append ( smallestAmountFormatted , 0 , intFieldPosition . getBeginIndex ( ) ) ; appendTo . append ( draft , smallestFieldPosition . getBeginIndex ( ) , smallestFieldPosition . getEndIndex ( ) ) ; appendTo . append ( smallestAmountFormatted , intFieldPosition . getEndIndex ( ) , smallestAmountFormatted . length ( ) ) ; appendTo . append ( draft , smallestFieldPosition . getEndIndex ( ) , draft . length ( ) ) ; } else { appendTo . append ( draft ) ; } return appendTo ; } | appendTo is where the formatted string is appended . |
28,018 | public String getMessage ( ) { String message = super . getMessage ( ) ; if ( message == null && exception != null ) { return exception . getMessage ( ) ; } else { return message ; } } | Return a detail message for this exception . |
28,019 | public static PluralRules parseDescription ( String description ) throws ParseException { description = description . trim ( ) ; return description . length ( ) == 0 ? DEFAULT : new PluralRules ( parseRuleChain ( description ) ) ; } | Parses a plural rules description and returns a PluralRules . |
28,020 | public String select ( double number , int countVisibleFractionDigits , long fractionaldigits ) { return rules . select ( new FixedDecimal ( number , countVisibleFractionDigits , fractionaldigits ) ) ; } | Given a number returns the keyword of the first rule that applies to the number . |
28,021 | public boolean matches ( FixedDecimal sample , String keyword ) { return rules . select ( sample , keyword ) ; } | Given a number information and keyword return whether the keyword would match the number . |
28,022 | boolean canBeWalkedInNaturalDocOrderStatic ( ) { if ( null != m_firstWalker ) { AxesWalker walker = m_firstWalker ; int prevAxis = - 1 ; boolean prevIsSimpleDownAxis = true ; for ( int i = 0 ; null != walker ; i ++ ) { int axis = walker . getAxis ( ) ; if ( walker . isDocOrdered ( ) ) { boolean isSimpleDownAxis = ( ( axis == Axis . CHILD ) || ( axis == Axis . SELF ) || ( axis == Axis . ROOT ) ) ; if ( isSimpleDownAxis || ( axis == - 1 ) ) walker = walker . getNextWalker ( ) ; else { boolean isLastWalker = ( null == walker . getNextWalker ( ) ) ; if ( isLastWalker ) { if ( walker . isDocOrdered ( ) && ( axis == Axis . DESCENDANT || axis == Axis . DESCENDANTORSELF || axis == Axis . DESCENDANTSFROMROOT || axis == Axis . DESCENDANTSORSELFFROMROOT ) || ( axis == Axis . ATTRIBUTE ) ) return true ; } return false ; } } else return false ; } return true ; } return false ; } | Tell if the nodeset can be walked in doc order via static analysis . |
28,023 | public void fixupVariables ( java . util . Vector vars , int globalsSize ) { super . fixupVariables ( vars , globalsSize ) ; int analysis = getAnalysisBits ( ) ; if ( WalkerFactory . isNaturalDocOrder ( analysis ) ) { m_inNaturalOrderStatic = true ; } else { m_inNaturalOrderStatic = false ; } } | This function is used to perform some extra analysis of the iterator . |
28,024 | public final SecretKey translateKey ( SecretKey key ) throws InvalidKeyException { if ( serviceIterator == null ) { return spi . engineTranslateKey ( key ) ; } Exception failure = null ; SecretKeyFactorySpi mySpi = spi ; do { try { return mySpi . engineTranslateKey ( key ) ; } catch ( Exception e ) { if ( failure == null ) { failure = e ; } mySpi = nextSpi ( mySpi ) ; } } while ( mySpi != null ) ; if ( failure instanceof InvalidKeyException ) { throw ( InvalidKeyException ) failure ; } throw new InvalidKeyException ( "Could not translate key" , failure ) ; } | Translates a key object whose provider may be unknown or potentially untrusted into a corresponding key object of this secret - key factory . |
28,025 | private int dowait ( boolean timed , long nanos ) throws InterruptedException , BrokenBarrierException , TimeoutException { final ReentrantLock lock = this . lock ; lock . lock ( ) ; try { final Generation g = generation ; if ( g . broken ) throw new BrokenBarrierException ( ) ; if ( Thread . interrupted ( ) ) { breakBarrier ( ) ; throw new InterruptedException ( ) ; } int index = -- count ; if ( index == 0 ) { boolean ranAction = false ; try { final Runnable command = barrierCommand ; if ( command != null ) command . run ( ) ; ranAction = true ; nextGeneration ( ) ; return 0 ; } finally { if ( ! ranAction ) breakBarrier ( ) ; } } for ( ; ; ) { try { if ( ! timed ) trip . await ( ) ; else if ( nanos > 0L ) nanos = trip . awaitNanos ( nanos ) ; } catch ( InterruptedException ie ) { if ( g == generation && ! g . broken ) { breakBarrier ( ) ; throw ie ; } else { Thread . currentThread ( ) . interrupt ( ) ; } } if ( g . broken ) throw new BrokenBarrierException ( ) ; if ( g != generation ) return index ; if ( timed && nanos <= 0L ) { breakBarrier ( ) ; throw new TimeoutException ( ) ; } } } finally { lock . unlock ( ) ; } } | Main barrier code covering the various policies . |
28,026 | public boolean isBroken ( ) { final ReentrantLock lock = this . lock ; lock . lock ( ) ; try { return generation . broken ; } finally { lock . unlock ( ) ; } } | Queries if this barrier is in a broken state . |
28,027 | public int getNumberWaiting ( ) { final ReentrantLock lock = this . lock ; lock . lock ( ) ; try { return parties - count ; } finally { lock . unlock ( ) ; } } | Returns the number of parties currently waiting at the barrier . This method is primarily useful for debugging and assertions . |
28,028 | long getCEFromOffsetCE32 ( int c , int ce32 ) { long dataCE = ces [ Collation . indexFromCE32 ( ce32 ) ] ; return Collation . makeCE ( Collation . getThreeBytePrimaryForOffsetData ( c , dataCE ) ) ; } | Computes a CE from c s ce32 which has the OFFSET_TAG . |
28,029 | long getSingleCE ( int c ) { CollationData d ; int ce32 = getCE32 ( c ) ; if ( ce32 == Collation . FALLBACK_CE32 ) { d = base ; ce32 = base . getCE32 ( c ) ; } else { d = this ; } while ( Collation . isSpecialCE32 ( ce32 ) ) { switch ( Collation . tagFromCE32 ( ce32 ) ) { case Collation . LATIN_EXPANSION_TAG : case Collation . BUILDER_DATA_TAG : case Collation . PREFIX_TAG : case Collation . CONTRACTION_TAG : case Collation . HANGUL_TAG : case Collation . LEAD_SURROGATE_TAG : throw new UnsupportedOperationException ( String . format ( "there is not exactly one collation element for U+%04X (CE32 0x%08x)" , c , ce32 ) ) ; case Collation . FALLBACK_TAG : case Collation . RESERVED_TAG_3 : throw new AssertionError ( String . format ( "unexpected CE32 tag for U+%04X (CE32 0x%08x)" , c , ce32 ) ) ; case Collation . LONG_PRIMARY_TAG : return Collation . ceFromLongPrimaryCE32 ( ce32 ) ; case Collation . LONG_SECONDARY_TAG : return Collation . ceFromLongSecondaryCE32 ( ce32 ) ; case Collation . EXPANSION32_TAG : if ( Collation . lengthFromCE32 ( ce32 ) == 1 ) { ce32 = d . ce32s [ Collation . indexFromCE32 ( ce32 ) ] ; break ; } else { throw new UnsupportedOperationException ( String . format ( "there is not exactly one collation element for U+%04X (CE32 0x%08x)" , c , ce32 ) ) ; } case Collation . EXPANSION_TAG : { if ( Collation . lengthFromCE32 ( ce32 ) == 1 ) { return d . ces [ Collation . indexFromCE32 ( ce32 ) ] ; } else { throw new UnsupportedOperationException ( String . format ( "there is not exactly one collation element for U+%04X (CE32 0x%08x)" , c , ce32 ) ) ; } } case Collation . DIGIT_TAG : ce32 = d . ce32s [ Collation . indexFromCE32 ( ce32 ) ] ; break ; case Collation . U0000_TAG : assert ( c == 0 ) ; ce32 = d . ce32s [ 0 ] ; break ; case Collation . OFFSET_TAG : return d . getCEFromOffsetCE32 ( c , ce32 ) ; case Collation . IMPLICIT_TAG : return Collation . unassignedCEFromCodePoint ( c ) ; } } return Collation . ceFromSimpleCE32 ( ce32 ) ; } | Returns the single CE that c maps to . Throws UnsupportedOperationException if c does not map to a single CE . |
28,030 | public long getLastPrimaryForGroup ( int script ) { int index = getScriptIndex ( script ) ; if ( index == 0 ) { return 0 ; } long limit = scriptStarts [ index + 1 ] ; return ( limit << 16 ) - 1 ; } | Returns the last primary for the script s reordering group . |
28,031 | public int getGroupForPrimary ( long p ) { p >>= 16 ; if ( p < scriptStarts [ 1 ] || scriptStarts [ scriptStarts . length - 1 ] <= p ) { return - 1 ; } int index = 1 ; while ( p >= scriptStarts [ index + 1 ] ) { ++ index ; } for ( int i = 0 ; i < numScripts ; ++ i ) { if ( scriptsIndex [ i ] == index ) { return i ; } } for ( int i = 0 ; i < MAX_NUM_SPECIAL_REORDER_CODES ; ++ i ) { if ( scriptsIndex [ numScripts + i ] == index ) { return Collator . ReorderCodes . FIRST + i ; } } return - 1 ; } | Finds the reordering group which contains the primary weight . |
28,032 | public static byte [ ] toBigEndianUtf16Bytes ( char [ ] chars , int offset , int length ) { byte [ ] result = new byte [ length * 2 ] ; int end = offset + length ; int resultIndex = 0 ; for ( int i = offset ; i < end ; ++ i ) { char ch = chars [ i ] ; result [ resultIndex ++ ] = ( byte ) ( ch >> 8 ) ; result [ resultIndex ++ ] = ( byte ) ch ; } return result ; } | Returns a new byte array containing the bytes corresponding to the given characters encoded in UTF - 16BE . All characters are representable in UTF - 16BE . |
28,033 | public static void main ( String [ ] args ) { String [ ] word = { "Zero" , "One" , "Two" , "Three" , "Four" , "Five" , "Six" , "Seven" , "Eight" , "Nine" , "Ten" , "Eleven" , "Twelve" , "Thirteen" , "Fourteen" , "Fifteen" , "Sixteen" , "Seventeen" , "Eighteen" , "Nineteen" , "Twenty" , "Twenty-One" , "Twenty-Two" , "Twenty-Three" , "Twenty-Four" , "Twenty-Five" , "Twenty-Six" , "Twenty-Seven" , "Twenty-Eight" , "Twenty-Nine" , "Thirty" , "Thirty-One" , "Thirty-Two" , "Thirty-Three" , "Thirty-Four" , "Thirty-Five" , "Thirty-Six" , "Thirty-Seven" , "Thirty-Eight" , "Thirty-Nine" } ; DTMStringPool pool = new DTMStringPool ( ) ; System . out . println ( "If no complaints are printed below, we passed initial test." ) ; for ( int pass = 0 ; pass <= 1 ; ++ pass ) { int i ; for ( i = 0 ; i < word . length ; ++ i ) { int j = pool . stringToIndex ( word [ i ] ) ; if ( j != i ) System . out . println ( "\tMismatch populating pool: assigned " + j + " for create " + i ) ; } for ( i = 0 ; i < word . length ; ++ i ) { int j = pool . stringToIndex ( word [ i ] ) ; if ( j != i ) System . out . println ( "\tMismatch in stringToIndex: returned " + j + " for lookup " + i ) ; } for ( i = 0 ; i < word . length ; ++ i ) { String w = pool . indexToString ( i ) ; if ( ! word [ i ] . equals ( w ) ) System . out . println ( "\tMismatch in indexToString: returned" + w + " for lookup " + i ) ; } pool . removeAllElements ( ) ; System . out . println ( "\nPass " + pass + " complete\n" ) ; } } | Command - line unit test driver . This test relies on the fact that this version of the pool assigns indices consecutively starting from zero as new unique strings are encountered . |
28,034 | public void close ( ) throws IOException { PipedInputStream stream = target ; if ( stream != null ) { stream . done ( ) ; target = null ; } } | Closes this stream . If this stream is connected to an input stream the input stream is closed and the pipe is disconnected . |
28,035 | public void reset ( ) { synchronized ( zsRef ) { ensureOpen ( ) ; reset ( zsRef . address ( ) ) ; buf = defaultBuf ; finished = false ; needDict = false ; off = len = 0 ; bytesRead = bytesWritten = 0 ; } } | Resets inflater so that a new set of input data can be processed . |
28,036 | public Date getStartInYear ( int year , int prevRawOffset , int prevDSTSavings ) { if ( year < startYear || year > endYear ) { return null ; } long ruleDay ; int type = dateTimeRule . getDateRuleType ( ) ; if ( type == DateTimeRule . DOM ) { ruleDay = Grego . fieldsToDay ( year , dateTimeRule . getRuleMonth ( ) , dateTimeRule . getRuleDayOfMonth ( ) ) ; } else { boolean after = true ; if ( type == DateTimeRule . DOW ) { int weeks = dateTimeRule . getRuleWeekInMonth ( ) ; if ( weeks > 0 ) { ruleDay = Grego . fieldsToDay ( year , dateTimeRule . getRuleMonth ( ) , 1 ) ; ruleDay += 7 * ( weeks - 1 ) ; } else { after = false ; ruleDay = Grego . fieldsToDay ( year , dateTimeRule . getRuleMonth ( ) , Grego . monthLength ( year , dateTimeRule . getRuleMonth ( ) ) ) ; ruleDay += 7 * ( weeks + 1 ) ; } } else { int month = dateTimeRule . getRuleMonth ( ) ; int dom = dateTimeRule . getRuleDayOfMonth ( ) ; if ( type == DateTimeRule . DOW_LEQ_DOM ) { after = false ; if ( month == Calendar . FEBRUARY && dom == 29 && ! Grego . isLeapYear ( year ) ) { dom -- ; } } ruleDay = Grego . fieldsToDay ( year , month , dom ) ; } int dow = Grego . dayOfWeek ( ruleDay ) ; int delta = dateTimeRule . getRuleDayOfWeek ( ) - dow ; if ( after ) { delta = delta < 0 ? delta + 7 : delta ; } else { delta = delta > 0 ? delta - 7 : delta ; } ruleDay += delta ; } long ruleTime = ruleDay * Grego . MILLIS_PER_DAY + dateTimeRule . getRuleMillisInDay ( ) ; if ( dateTimeRule . getTimeRuleType ( ) != DateTimeRule . UTC_TIME ) { ruleTime -= prevRawOffset ; } if ( dateTimeRule . getTimeRuleType ( ) == DateTimeRule . WALL_TIME ) { ruleTime -= prevDSTSavings ; } return new Date ( ruleTime ) ; } | Gets the time when this rule takes effect in the given year . |
28,037 | public ULocale [ ] getAvailableULocales ( ) { Set < String > keys = getLocaleIdToRulesIdMap ( PluralType . CARDINAL ) . keySet ( ) ; ULocale [ ] locales = new ULocale [ keys . size ( ) ] ; int n = 0 ; for ( Iterator < String > iter = keys . iterator ( ) ; iter . hasNext ( ) ; ) { locales [ n ++ ] = ULocale . createCanonical ( iter . next ( ) ) ; } return locales ; } | Returns the locales for which we have plurals data . Utility for testing . |
28,038 | public ULocale getFunctionalEquivalent ( ULocale locale , boolean [ ] isAvailable ) { if ( isAvailable != null && isAvailable . length > 0 ) { String localeId = ULocale . canonicalize ( locale . getBaseName ( ) ) ; Map < String , String > idMap = getLocaleIdToRulesIdMap ( PluralType . CARDINAL ) ; isAvailable [ 0 ] = idMap . containsKey ( localeId ) ; } String rulesId = getRulesIdForLocale ( locale , PluralType . CARDINAL ) ; if ( rulesId == null || rulesId . trim ( ) . length ( ) == 0 ) { return ULocale . ROOT ; } ULocale result = getRulesIdToEquivalentULocaleMap ( ) . get ( rulesId ) ; if ( result == null ) { return ULocale . ROOT ; } return result ; } | Returns the functionally equivalent locale . |
28,039 | private Map < String , String > getLocaleIdToRulesIdMap ( PluralType type ) { checkBuildRulesIdMaps ( ) ; return ( type == PluralType . CARDINAL ) ? localeIdToCardinalRulesId : localeIdToOrdinalRulesId ; } | Returns the lazily - constructed map . |
28,040 | private void checkBuildRulesIdMaps ( ) { boolean haveMap ; synchronized ( this ) { haveMap = localeIdToCardinalRulesId != null ; } if ( ! haveMap ) { Map < String , String > tempLocaleIdToCardinalRulesId ; Map < String , String > tempLocaleIdToOrdinalRulesId ; Map < String , ULocale > tempRulesIdToEquivalentULocale ; try { UResourceBundle pluralb = getPluralBundle ( ) ; UResourceBundle localeb = pluralb . get ( "locales" ) ; tempLocaleIdToCardinalRulesId = new TreeMap < String , String > ( ) ; tempRulesIdToEquivalentULocale = new HashMap < String , ULocale > ( ) ; for ( int i = 0 ; i < localeb . getSize ( ) ; ++ i ) { UResourceBundle b = localeb . get ( i ) ; String id = b . getKey ( ) ; String value = b . getString ( ) . intern ( ) ; tempLocaleIdToCardinalRulesId . put ( id , value ) ; if ( ! tempRulesIdToEquivalentULocale . containsKey ( value ) ) { tempRulesIdToEquivalentULocale . put ( value , new ULocale ( id ) ) ; } } localeb = pluralb . get ( "locales_ordinals" ) ; tempLocaleIdToOrdinalRulesId = new TreeMap < String , String > ( ) ; for ( int i = 0 ; i < localeb . getSize ( ) ; ++ i ) { UResourceBundle b = localeb . get ( i ) ; String id = b . getKey ( ) ; String value = b . getString ( ) . intern ( ) ; tempLocaleIdToOrdinalRulesId . put ( id , value ) ; } } catch ( MissingResourceException e ) { tempLocaleIdToCardinalRulesId = Collections . emptyMap ( ) ; tempLocaleIdToOrdinalRulesId = Collections . emptyMap ( ) ; tempRulesIdToEquivalentULocale = Collections . emptyMap ( ) ; } synchronized ( this ) { if ( localeIdToCardinalRulesId == null ) { localeIdToCardinalRulesId = tempLocaleIdToCardinalRulesId ; localeIdToOrdinalRulesId = tempLocaleIdToOrdinalRulesId ; rulesIdToEquivalentULocale = tempRulesIdToEquivalentULocale ; } } } } | Lazily constructs the localeIdToRulesId and rulesIdToEquivalentULocale maps if necessary . These exactly reflect the contents of the locales resource in plurals . res . |
28,041 | public String getRulesIdForLocale ( ULocale locale , PluralType type ) { Map < String , String > idMap = getLocaleIdToRulesIdMap ( type ) ; String localeId = ULocale . canonicalize ( locale . getBaseName ( ) ) ; String rulesId = null ; while ( null == ( rulesId = idMap . get ( localeId ) ) ) { int ix = localeId . lastIndexOf ( "_" ) ; if ( ix == - 1 ) { break ; } localeId = localeId . substring ( 0 , ix ) ; } return rulesId ; } | Gets the rulesId from the locale with locale fallback . If there is no rulesId return null . The rulesId might be the empty string if the rule is the default rule . |
28,042 | public PluralRules getRulesForRulesId ( String rulesId ) { PluralRules rules = null ; boolean hasRules ; synchronized ( rulesIdToRules ) { hasRules = rulesIdToRules . containsKey ( rulesId ) ; if ( hasRules ) { rules = rulesIdToRules . get ( rulesId ) ; } } if ( ! hasRules ) { try { UResourceBundle pluralb = getPluralBundle ( ) ; UResourceBundle rulesb = pluralb . get ( "rules" ) ; UResourceBundle setb = rulesb . get ( rulesId ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < setb . getSize ( ) ; ++ i ) { UResourceBundle b = setb . get ( i ) ; if ( i > 0 ) { sb . append ( "; " ) ; } sb . append ( b . getKey ( ) ) ; sb . append ( ": " ) ; sb . append ( b . getString ( ) ) ; } rules = PluralRules . parseDescription ( sb . toString ( ) ) ; } catch ( ParseException e ) { } catch ( MissingResourceException e ) { } synchronized ( rulesIdToRules ) { if ( rulesIdToRules . containsKey ( rulesId ) ) { rules = rulesIdToRules . get ( rulesId ) ; } else { rulesIdToRules . put ( rulesId , rules ) ; } } } return rules ; } | Gets the rule from the rulesId . If there is no rule for this rulesId return null . |
28,043 | public UResourceBundle getPluralBundle ( ) throws MissingResourceException { return ICUResourceBundle . getBundleInstance ( ICUData . ICU_BASE_NAME , "plurals" , ICUResourceBundle . ICU_DATA_CLASS_LOADER , true ) ; } | Return the plurals resource . Note MissingResourceException is unchecked listed here for clarity . Callers should handle this exception . |
28,044 | public PluralRules forLocale ( ULocale locale , PluralRules . PluralType type ) { String rulesId = getRulesIdForLocale ( locale , type ) ; if ( rulesId == null || rulesId . trim ( ) . length ( ) == 0 ) { return PluralRules . DEFAULT ; } PluralRules rules = getRulesForRulesId ( rulesId ) ; if ( rules == null ) { rules = PluralRules . DEFAULT ; } return rules ; } | Returns the plural rules for the the locale . If we don t have data android . icu . text . PluralRules . DEFAULT is returned . |
28,045 | public final CharsetDecoder replaceWith ( String newReplacement ) { if ( newReplacement == null ) throw new IllegalArgumentException ( "Null replacement" ) ; int len = newReplacement . length ( ) ; if ( len == 0 ) throw new IllegalArgumentException ( "Empty replacement" ) ; if ( len > maxCharsPerByte ) throw new IllegalArgumentException ( "Replacement too long" ) ; this . replacement = newReplacement ; implReplaceWith ( newReplacement ) ; return this ; } | Changes this decoder s replacement value . |
28,046 | public final CharsetDecoder onUnmappableCharacter ( CodingErrorAction newAction ) { if ( newAction == null ) throw new IllegalArgumentException ( "Null action" ) ; unmappableCharacterAction = newAction ; implOnUnmappableCharacter ( newAction ) ; return this ; } | Changes this decoder s action for unmappable - character errors . |
28,047 | public final CoderResult decode ( ByteBuffer in , CharBuffer out , boolean endOfInput ) { int newState = endOfInput ? ST_END : ST_CODING ; if ( ( state != ST_RESET ) && ( state != ST_CODING ) && ! ( endOfInput && ( state == ST_END ) ) ) throwIllegalStateException ( state , newState ) ; state = newState ; for ( ; ; ) { CoderResult cr ; try { cr = decodeLoop ( in , out ) ; } catch ( BufferUnderflowException x ) { throw new CoderMalfunctionError ( x ) ; } catch ( BufferOverflowException x ) { throw new CoderMalfunctionError ( x ) ; } if ( cr . isOverflow ( ) ) return cr ; if ( cr . isUnderflow ( ) ) { if ( endOfInput && in . hasRemaining ( ) ) { cr = CoderResult . malformedForLength ( in . remaining ( ) ) ; } else { return cr ; } } CodingErrorAction action = null ; if ( cr . isMalformed ( ) ) action = malformedInputAction ; else if ( cr . isUnmappable ( ) ) action = unmappableCharacterAction ; else assert false : cr . toString ( ) ; if ( action == CodingErrorAction . REPORT ) return cr ; if ( action == CodingErrorAction . REPLACE ) { if ( out . remaining ( ) < replacement . length ( ) ) return CoderResult . OVERFLOW ; out . put ( replacement ) ; } if ( ( action == CodingErrorAction . IGNORE ) || ( action == CodingErrorAction . REPLACE ) ) { in . position ( in . position ( ) + cr . length ( ) ) ; continue ; } assert false ; } } | Decodes as many bytes as possible from the given input buffer writing the results to the given output buffer . |
28,048 | public final CoderResult flush ( CharBuffer out ) { if ( state == ST_END ) { CoderResult cr = implFlush ( out ) ; if ( cr . isUnderflow ( ) ) state = ST_FLUSHED ; return cr ; } if ( state != ST_FLUSHED ) throwIllegalStateException ( state , ST_FLUSHED ) ; return CoderResult . UNDERFLOW ; } | Flushes this decoder . |
28,049 | public static int readHeader ( ByteBuffer bytes , int dataFormat , Authenticate authenticate ) throws IOException { assert bytes != null && bytes . position ( ) == 0 ; byte magic1 = bytes . get ( 2 ) ; byte magic2 = bytes . get ( 3 ) ; if ( magic1 != MAGIC1 || magic2 != MAGIC2 ) { throw new IOException ( MAGIC_NUMBER_AUTHENTICATION_FAILED_ ) ; } byte isBigEndian = bytes . get ( 8 ) ; byte charsetFamily = bytes . get ( 9 ) ; byte sizeofUChar = bytes . get ( 10 ) ; if ( isBigEndian < 0 || 1 < isBigEndian || charsetFamily != CHAR_SET_ || sizeofUChar != CHAR_SIZE_ ) { throw new IOException ( HEADER_AUTHENTICATION_FAILED_ ) ; } bytes . order ( isBigEndian != 0 ? ByteOrder . BIG_ENDIAN : ByteOrder . LITTLE_ENDIAN ) ; int headerSize = bytes . getChar ( 0 ) ; int sizeofUDataInfo = bytes . getChar ( 4 ) ; if ( sizeofUDataInfo < 20 || headerSize < ( sizeofUDataInfo + 4 ) ) { throw new IOException ( "Internal Error: Header size error" ) ; } byte [ ] formatVersion = new byte [ ] { bytes . get ( 16 ) , bytes . get ( 17 ) , bytes . get ( 18 ) , bytes . get ( 19 ) } ; if ( bytes . get ( 12 ) != ( byte ) ( dataFormat >> 24 ) || bytes . get ( 13 ) != ( byte ) ( dataFormat >> 16 ) || bytes . get ( 14 ) != ( byte ) ( dataFormat >> 8 ) || bytes . get ( 15 ) != ( byte ) dataFormat || ( authenticate != null && ! authenticate . isDataVersionAcceptable ( formatVersion ) ) ) { throw new IOException ( HEADER_AUTHENTICATION_FAILED_ + String . format ( "; data format %02x%02x%02x%02x, format version %d.%d.%d.%d" , bytes . get ( 12 ) , bytes . get ( 13 ) , bytes . get ( 14 ) , bytes . get ( 15 ) , formatVersion [ 0 ] & 0xff , formatVersion [ 1 ] & 0xff , formatVersion [ 2 ] & 0xff , formatVersion [ 3 ] & 0xff ) ) ; } bytes . position ( headerSize ) ; return ( bytes . get ( 20 ) << 24 ) | ( ( bytes . get ( 21 ) & 0xff ) << 16 ) | ( ( bytes . get ( 22 ) & 0xff ) << 8 ) | ( bytes . get ( 23 ) & 0xff ) ; } | Reads an ICU data header checks the data format and returns the data version . |
28,050 | public static int writeHeader ( int dataFormat , int formatVersion , int dataVersion , DataOutputStream dos ) throws IOException { dos . writeChar ( 32 ) ; dos . writeByte ( MAGIC1 ) ; dos . writeByte ( MAGIC2 ) ; dos . writeChar ( 20 ) ; dos . writeChar ( 0 ) ; dos . writeByte ( 1 ) ; dos . writeByte ( CHAR_SET_ ) ; dos . writeByte ( CHAR_SIZE_ ) ; dos . writeByte ( 0 ) ; dos . writeInt ( dataFormat ) ; dos . writeInt ( formatVersion ) ; dos . writeInt ( dataVersion ) ; dos . writeLong ( 0 ) ; assert dos . size ( ) == 32 ; return 32 ; } | Writes an ICU data header . Does not write a copyright string . |
28,051 | public static ByteBuffer getByteBufferFromInputStreamAndCloseStream ( InputStream is ) throws IOException { try { byte [ ] bytes ; int avail = is . available ( ) ; if ( avail > 32 ) { bytes = new byte [ avail ] ; } else { bytes = new byte [ 128 ] ; } int length = 0 ; for ( ; ; ) { if ( length < bytes . length ) { int numRead = is . read ( bytes , length , bytes . length - length ) ; if ( numRead < 0 ) { break ; } length += numRead ; } else { int nextByte = is . read ( ) ; if ( nextByte < 0 ) { break ; } int capacity = 2 * bytes . length ; if ( capacity < 128 ) { capacity = 128 ; } else if ( capacity < 0x4000 ) { capacity *= 2 ; } byte [ ] newBytes = new byte [ capacity ] ; System . arraycopy ( bytes , 0 , newBytes , 0 , length ) ; bytes = newBytes ; bytes [ length ++ ] = ( byte ) nextByte ; } } return ByteBuffer . wrap ( bytes , 0 , length ) ; } finally { is . close ( ) ; } } | Reads the entire contents from the stream into a byte array and wraps it into a ByteBuffer . Closes the InputStream at the end . |
28,052 | public static int next32 ( CharacterIterator ci ) { int c = ci . current ( ) ; if ( c >= UTF16 . LEAD_SURROGATE_MIN_VALUE && c <= UTF16 . LEAD_SURROGATE_MAX_VALUE ) { c = ci . next ( ) ; if ( c < UTF16 . TRAIL_SURROGATE_MIN_VALUE || c > UTF16 . TRAIL_SURROGATE_MAX_VALUE ) { ci . previous ( ) ; } } c = ci . next ( ) ; if ( c >= UTF16 . LEAD_SURROGATE_MIN_VALUE ) { c = nextTrail32 ( ci , c ) ; } if ( c >= UTF16 . SUPPLEMENTARY_MIN_VALUE && c != DONE32 ) { ci . previous ( ) ; } return c ; } | Move the iterator forward to the next code point and return that code point leaving the iterator positioned at char returned . For Supplementary chars the iterator is left positioned at the lead surrogate . |
28,053 | public StringWriter append ( CharSequence csq , int start , int end ) { CharSequence cs = ( csq == null ? "null" : csq ) ; write ( cs . subSequence ( start , end ) . toString ( ) ) ; return this ; } | Appends a subsequence of the specified character sequence to this writer . |
28,054 | public void init ( Compiler compiler , int opPos , int stepType ) throws javax . xml . transform . TransformerException { initPredicateInfo ( compiler , opPos ) ; } | Initialize an AxesWalker during the parse of the XPath expression . |
28,055 | AxesWalker cloneDeep ( WalkingIterator cloneOwner , Vector cloneList ) throws CloneNotSupportedException { AxesWalker clone = findClone ( this , cloneList ) ; if ( null != clone ) return clone ; clone = ( AxesWalker ) this . clone ( ) ; clone . setLocPathIterator ( cloneOwner ) ; if ( null != cloneList ) { cloneList . addElement ( this ) ; cloneList . addElement ( clone ) ; } if ( wi ( ) . m_lastUsedWalker == this ) cloneOwner . m_lastUsedWalker = clone ; if ( null != m_nextWalker ) clone . m_nextWalker = m_nextWalker . cloneDeep ( cloneOwner , cloneList ) ; if ( null != cloneList ) { if ( null != m_prevWalker ) clone . m_prevWalker = m_prevWalker . cloneDeep ( cloneOwner , cloneList ) ; } else { if ( null != m_nextWalker ) clone . m_nextWalker . m_prevWalker = clone ; } return clone ; } | Do a deep clone of this walker including next and previous walkers . If the this AxesWalker is on the clone list don t clone but return the already cloned version . |
28,056 | static AxesWalker findClone ( AxesWalker key , Vector cloneList ) { if ( null != cloneList ) { int n = cloneList . size ( ) ; for ( int i = 0 ; i < n ; i += 2 ) { if ( key == cloneList . elementAt ( i ) ) return ( AxesWalker ) cloneList . elementAt ( i + 1 ) ; } } return null ; } | Find a clone that corresponds to the key argument . |
28,057 | public void detach ( ) { m_currentNode = DTM . NULL ; m_dtm = null ; m_traverser = null ; m_isFresh = true ; m_root = DTM . NULL ; } | Detaches the walker from the set which it iterated over releasing any computational resources and placing the iterator in the INVALID state . |
28,058 | public int getLastPos ( XPathContext xctxt ) { int pos = getProximityPosition ( ) ; AxesWalker walker ; try { walker = ( AxesWalker ) clone ( ) ; } catch ( CloneNotSupportedException cnse ) { return - 1 ; } walker . setPredicateCount ( m_predicateIndex ) ; walker . setNextWalker ( null ) ; walker . setPrevWalker ( null ) ; WalkingIterator lpi = wi ( ) ; AxesWalker savedWalker = lpi . getLastUsedWalker ( ) ; try { lpi . setLastUsedWalker ( walker ) ; int next ; while ( DTM . NULL != ( next = walker . nextNode ( ) ) ) { pos ++ ; } } finally { lpi . setLastUsedWalker ( savedWalker ) ; } return pos ; } | Get the index of the last node that can be itterated to . |
28,059 | public void callVisitors ( ExpressionOwner owner , XPathVisitor visitor ) { if ( visitor . visitStep ( owner , this ) ) { callPredicateVisitors ( visitor ) ; if ( null != m_nextWalker ) { m_nextWalker . callVisitors ( this , visitor ) ; } } } | This will traverse the heararchy calling the visitor for each member . If the called visitor method returns false the subtree should not be called . |
28,060 | public final Element getDocumentElement ( ) { int dochandle = dtm . getDocument ( ) ; int elementhandle = DTM . NULL ; for ( int kidhandle = dtm . getFirstChild ( dochandle ) ; kidhandle != DTM . NULL ; kidhandle = dtm . getNextSibling ( kidhandle ) ) { switch ( dtm . getNodeType ( kidhandle ) ) { case Node . ELEMENT_NODE : if ( elementhandle != DTM . NULL ) { elementhandle = DTM . NULL ; kidhandle = dtm . getLastChild ( dochandle ) ; } else elementhandle = kidhandle ; break ; case Node . COMMENT_NODE : case Node . PROCESSING_INSTRUCTION_NODE : case Node . DOCUMENT_TYPE_NODE : break ; default : elementhandle = DTM . NULL ; kidhandle = dtm . getLastChild ( dochandle ) ; break ; } } if ( elementhandle == DTM . NULL ) throw new DTMDOMException ( DOMException . NOT_SUPPORTED_ERR ) ; else return ( Element ) ( dtm . getNode ( elementhandle ) ) ; } | This is a bit of a problem in DTM since a DTM may be a Document Fragment and hence not have a clear - cut Document Element . We can make it work in the well - formed cases but would that be confusing for others? |
28,061 | public final Element getOwnerElement ( ) { if ( getNodeType ( ) != Node . ATTRIBUTE_NODE ) return null ; int newnode = dtm . getParent ( node ) ; return ( newnode == DTM . NULL ) ? null : ( Element ) ( dtm . getNode ( newnode ) ) ; } | Get the owner element of an attribute . |
28,062 | public static String getFullName ( String baseName , String localeName ) { if ( baseName == null || baseName . length ( ) == 0 ) { if ( localeName . length ( ) == 0 ) { return localeName = ULocale . getDefault ( ) . toString ( ) ; } return localeName + ICU_RESOURCE_SUFFIX ; } else { if ( baseName . indexOf ( '.' ) == - 1 ) { if ( baseName . charAt ( baseName . length ( ) - 1 ) != '/' ) { return baseName + "/" + localeName + ICU_RESOURCE_SUFFIX ; } else { return baseName + localeName + ICU_RESOURCE_SUFFIX ; } } else { baseName = baseName . replace ( '.' , '/' ) ; if ( localeName . length ( ) == 0 ) { return baseName + ICU_RESOURCE_SUFFIX ; } else { return baseName + "_" + localeName + ICU_RESOURCE_SUFFIX ; } } } } | Gets the full name of the resource with suffix . |
28,063 | public void setAttributeList ( AttributeList atts ) { int count = atts . getLength ( ) ; clear ( ) ; for ( int i = 0 ; i < count ; i ++ ) { addAttribute ( atts . getName ( i ) , atts . getType ( i ) , atts . getValue ( i ) ) ; } } | Set the attribute list discarding previous contents . |
28,064 | public void addAttribute ( String name , String type , String value ) { names . add ( name ) ; types . add ( type ) ; values . add ( value ) ; } | Add an attribute to an attribute list . |
28,065 | private void readObject ( ObjectInputStream stream ) throws IOException , TransformerException { try { stream . defaultReadObject ( ) ; } catch ( ClassNotFoundException cnfe ) { throw new TransformerException ( cnfe ) ; } } | Read the stylesheet from a serialization stream . |
28,066 | public StylesheetComposed getStylesheetComposed ( ) { Stylesheet sheet = this ; while ( ! sheet . isAggregatedType ( ) ) { sheet = sheet . getStylesheetParent ( ) ; } return ( StylesheetComposed ) sheet ; } | Get the owning aggregated stylesheet or this stylesheet if it is aggregated . |
28,067 | public Socket createSocket ( ) throws IOException { UnsupportedOperationException uop = new UnsupportedOperationException ( ) ; SocketException se = new SocketException ( "Unconnected sockets not implemented" ) ; se . initCause ( uop ) ; throw se ; } | Creates an unconnected socket . |
28,068 | public void recompose ( Vector recomposableElements ) throws TransformerException { int n = getIncludeCountComposed ( ) ; for ( int i = - 1 ; i < n ; i ++ ) { Stylesheet included = getIncludeComposed ( i ) ; int s = included . getOutputCount ( ) ; for ( int j = 0 ; j < s ; j ++ ) { recomposableElements . addElement ( included . getOutput ( j ) ) ; } s = included . getAttributeSetCount ( ) ; for ( int j = 0 ; j < s ; j ++ ) { recomposableElements . addElement ( included . getAttributeSet ( j ) ) ; } s = included . getDecimalFormatCount ( ) ; for ( int j = 0 ; j < s ; j ++ ) { recomposableElements . addElement ( included . getDecimalFormat ( j ) ) ; } s = included . getKeyCount ( ) ; for ( int j = 0 ; j < s ; j ++ ) { recomposableElements . addElement ( included . getKey ( j ) ) ; } s = included . getNamespaceAliasCount ( ) ; for ( int j = 0 ; j < s ; j ++ ) { recomposableElements . addElement ( included . getNamespaceAlias ( j ) ) ; } s = included . getTemplateCount ( ) ; for ( int j = 0 ; j < s ; j ++ ) { recomposableElements . addElement ( included . getTemplate ( j ) ) ; } s = included . getVariableOrParamCount ( ) ; for ( int j = 0 ; j < s ; j ++ ) { recomposableElements . addElement ( included . getVariableOrParam ( j ) ) ; } s = included . getStripSpaceCount ( ) ; for ( int j = 0 ; j < s ; j ++ ) { recomposableElements . addElement ( included . getStripSpace ( j ) ) ; } s = included . getPreserveSpaceCount ( ) ; for ( int j = 0 ; j < s ; j ++ ) { recomposableElements . addElement ( included . getPreserveSpace ( j ) ) ; } } } | Adds all recomposable values for this precedence level into the recomposableElements Vector that was passed in as the first parameter . All elements added to the recomposableElements vector should extend ElemTemplateElement . |
28,069 | void recomposeImports ( ) { m_importNumber = getStylesheetRoot ( ) . getImportNumber ( this ) ; StylesheetRoot root = getStylesheetRoot ( ) ; int globalImportCount = root . getGlobalImportCount ( ) ; m_importCountComposed = ( globalImportCount - m_importNumber ) - 1 ; int count = getImportCount ( ) ; if ( count > 0 ) { m_endImportCountComposed += count ; while ( count > 0 ) m_endImportCountComposed += this . getImport ( -- count ) . getEndImportCountComposed ( ) ; } count = getIncludeCountComposed ( ) ; while ( count > 0 ) { int imports = getIncludeComposed ( -- count ) . getImportCount ( ) ; m_endImportCountComposed += imports ; while ( imports > 0 ) m_endImportCountComposed += getIncludeComposed ( count ) . getImport ( -- imports ) . getEndImportCountComposed ( ) ; } } | Recalculate the precedence of this stylesheet in the global import list . The lowest precedence stylesheet is 0 . A higher number has a higher precedence . |
28,070 | void recomposeIncludes ( Stylesheet including ) { int n = including . getIncludeCount ( ) ; if ( n > 0 ) { if ( null == m_includesComposed ) m_includesComposed = new Vector ( ) ; for ( int i = 0 ; i < n ; i ++ ) { Stylesheet included = including . getInclude ( i ) ; m_includesComposed . addElement ( included ) ; recomposeIncludes ( included ) ; } } } | Recompose the value of the composed include list . Builds a composite list of all stylesheets included by this stylesheet to any depth . |
28,071 | public static void compact ( Set < String > source , Adder adder , boolean shorterPairs , boolean moreCompact ) { if ( ! moreCompact ) { String start = null ; String end = null ; int lastCp = 0 ; int prefixLen = 0 ; for ( String s : source ) { if ( start != null ) { if ( s . regionMatches ( 0 , start , 0 , prefixLen ) ) { int currentCp = s . codePointAt ( prefixLen ) ; if ( currentCp == 1 + lastCp && s . length ( ) == prefixLen + Character . charCount ( currentCp ) ) { end = s ; lastCp = currentCp ; continue ; } } adder . add ( start , end == null ? null : ! shorterPairs ? end : end . substring ( prefixLen , end . length ( ) ) ) ; } start = s ; end = null ; lastCp = s . codePointBefore ( s . length ( ) ) ; prefixLen = s . length ( ) - Character . charCount ( lastCp ) ; } adder . add ( start , end == null ? null : ! shorterPairs ? end : end . substring ( prefixLen , end . length ( ) ) ) ; } else { Relation < Integer , Ranges > lengthToArrays = Relation . of ( new TreeMap < Integer , Set < Ranges > > ( ) , TreeSet . class ) ; for ( String s : source ) { Ranges item = new Ranges ( s ) ; lengthToArrays . put ( item . size ( ) , item ) ; } for ( Entry < Integer , Set < Ranges > > entry : lengthToArrays . keyValuesSet ( ) ) { LinkedList < Ranges > compacted = compact ( entry . getKey ( ) , entry . getValue ( ) ) ; for ( Ranges ranges : compacted ) { adder . add ( ranges . start ( ) , ranges . end ( shorterPairs ) ) ; } } } } | Compact the set of strings . |
28,072 | public static void compact ( Set < String > source , Adder adder , boolean shorterPairs ) { compact ( source , adder , shorterPairs , false ) ; } | Faster but not as good compaction . Only looks at final codepoint . |
28,073 | public static int singleWordWangJenkinsHash ( Object k ) { int h = k . hashCode ( ) ; h += ( h << 15 ) ^ 0xffffcd7d ; h ^= ( h >>> 10 ) ; h += ( h << 3 ) ; h ^= ( h >>> 6 ) ; h += ( h << 2 ) + ( h << 14 ) ; return h ^ ( h >>> 16 ) ; } | Based on commit 1424a2a1a9fc53dc8b859a77c02c924 . |
28,074 | public void initXPath ( Compiler compiler , String expression , PrefixResolver namespaceContext ) throws javax . xml . transform . TransformerException { m_ops = compiler ; m_namespaceContext = namespaceContext ; m_functionTable = compiler . getFunctionTable ( ) ; Lexer lexer = new Lexer ( compiler , namespaceContext , this ) ; lexer . tokenize ( expression ) ; m_ops . setOp ( 0 , OpCodes . OP_XPATH ) ; m_ops . setOp ( OpMap . MAPINDEX_LENGTH , 2 ) ; try { nextToken ( ) ; Expr ( ) ; if ( null != m_token ) { String extraTokens = "" ; while ( null != m_token ) { extraTokens += "'" + m_token + "'" ; nextToken ( ) ; if ( null != m_token ) extraTokens += ", " ; } error ( XPATHErrorResources . ER_EXTRA_ILLEGAL_TOKENS , new Object [ ] { extraTokens } ) ; } } catch ( org . apache . xpath . XPathProcessorException e ) { if ( CONTINUE_AFTER_FATAL_ERROR . equals ( e . getMessage ( ) ) ) { initXPath ( compiler , "/.." , namespaceContext ) ; } else throw e ; } compiler . shrink ( ) ; } | Given an string init an XPath object for selections in order that a parse doesn t have to be done each time the expression is evaluated . |
28,075 | final boolean tokenIs ( String s ) { return ( m_token != null ) ? ( m_token . equals ( s ) ) : ( s == null ) ; } | Check whether m_token matches the target string . |
28,076 | private final boolean lookbehind ( char c , int n ) { boolean isToken ; int lookBehindPos = m_queueMark - ( n + 1 ) ; if ( lookBehindPos >= 0 ) { String lookbehind = ( String ) m_ops . m_tokenQueue . elementAt ( lookBehindPos ) ; if ( lookbehind . length ( ) == 1 ) { char c0 = ( lookbehind == null ) ? '|' : lookbehind . charAt ( 0 ) ; isToken = ( c0 == '|' ) ? false : ( c0 == c ) ; } else { isToken = false ; } } else { isToken = false ; } return isToken ; } | Look behind the first character of the current token in order to make a branching decision . |
28,077 | private final boolean lookbehindHasToken ( int n ) { boolean hasToken ; if ( ( m_queueMark - n ) > 0 ) { String lookbehind = ( String ) m_ops . m_tokenQueue . elementAt ( m_queueMark - ( n - 1 ) ) ; char c0 = ( lookbehind == null ) ? '|' : lookbehind . charAt ( 0 ) ; hasToken = ( c0 == '|' ) ? false : true ; } else { hasToken = false ; } return hasToken ; } | look behind the current token in order to see if there is a useable token . |
28,078 | private final void nextToken ( ) { if ( m_queueMark < m_ops . getTokenQueueSize ( ) ) { m_token = ( String ) m_ops . m_tokenQueue . elementAt ( m_queueMark ++ ) ; m_tokenChar = m_token . charAt ( 0 ) ; } else { m_token = null ; m_tokenChar = 0 ; } } | Retrieve the next token from the command and store it in m_token string . |
28,079 | private final String getTokenRelative ( int i ) { String tok ; int relative = m_queueMark + i ; if ( ( relative > 0 ) && ( relative < m_ops . getTokenQueueSize ( ) ) ) { tok = ( String ) m_ops . m_tokenQueue . elementAt ( relative ) ; } else { tok = null ; } return tok ; } | Retrieve a token relative to the current token . |
28,080 | private final void prevToken ( ) { if ( m_queueMark > 0 ) { m_queueMark -- ; m_token = ( String ) m_ops . m_tokenQueue . elementAt ( m_queueMark ) ; m_tokenChar = m_token . charAt ( 0 ) ; } else { m_token = null ; m_tokenChar = 0 ; } } | Retrieve the previous token from the command and store it in m_token string . |
28,081 | private final void consumeExpected ( String expected ) throws javax . xml . transform . TransformerException { if ( tokenIs ( expected ) ) { nextToken ( ) ; } else { error ( XPATHErrorResources . ER_EXPECTED_BUT_FOUND , new Object [ ] { expected , m_token } ) ; throw new XPathProcessorException ( CONTINUE_AFTER_FATAL_ERROR ) ; } } | Consume an expected token throwing an exception if it isn t there . |
28,082 | protected String dumpRemainingTokenQueue ( ) { int q = m_queueMark ; String returnMsg ; if ( q < m_ops . getTokenQueueSize ( ) ) { String msg = "\n Remaining tokens: (" ; while ( q < m_ops . getTokenQueueSize ( ) ) { String t = ( String ) m_ops . m_tokenQueue . elementAt ( q ++ ) ; msg += ( " '" + t + "'" ) ; } returnMsg = msg + ")" ; } else { returnMsg = "" ; } return returnMsg ; } | Dump the remaining token queue . Thanks to Craig for this . |
28,083 | final int getFunctionToken ( String key ) { int tok ; Object id ; try { id = Keywords . lookupNodeTest ( key ) ; if ( null == id ) id = m_functionTable . getFunctionID ( key ) ; tok = ( ( Integer ) id ) . intValue ( ) ; } catch ( NullPointerException npe ) { tok = - 1 ; } catch ( ClassCastException cce ) { tok = - 1 ; } return tok ; } | Given a string return the corresponding function token . |
28,084 | void insertOp ( int pos , int length , int op ) { int totalLen = m_ops . getOp ( OpMap . MAPINDEX_LENGTH ) ; for ( int i = totalLen - 1 ; i >= pos ; i -- ) { m_ops . setOp ( i + length , m_ops . getOp ( i ) ) ; } m_ops . setOp ( pos , op ) ; m_ops . setOp ( OpMap . MAPINDEX_LENGTH , totalLen + length ) ; } | Insert room for operation . This will NOT set the length value of the operation but will update the length value for the total expression . |
28,085 | void appendOp ( int length , int op ) { int totalLen = m_ops . getOp ( OpMap . MAPINDEX_LENGTH ) ; m_ops . setOp ( totalLen , op ) ; m_ops . setOp ( totalLen + OpMap . MAPINDEX_LENGTH , length ) ; m_ops . setOp ( OpMap . MAPINDEX_LENGTH , totalLen + length ) ; } | Insert room for operation . This WILL set the length value of the operation and will update the length value for the total expression . |
28,086 | protected void UnionExpr ( ) throws javax . xml . transform . TransformerException { int opPos = m_ops . getOp ( OpMap . MAPINDEX_LENGTH ) ; boolean continueOrLoop = true ; boolean foundUnion = false ; do { PathExpr ( ) ; if ( tokenIs ( '|' ) ) { if ( false == foundUnion ) { foundUnion = true ; insertOp ( opPos , 2 , OpCodes . OP_UNION ) ; } nextToken ( ) ; } else { break ; } } while ( continueOrLoop ) ; m_ops . setOp ( opPos + OpMap . MAPINDEX_LENGTH , m_ops . getOp ( OpMap . MAPINDEX_LENGTH ) - opPos ) ; } | The context of the right hand side expressions is the context of the left hand side expression . The results of the right hand side expressions are node sets . The result of the left hand side UnionExpr is the union of the results of the right hand side expressions . |
28,087 | protected void Literal ( ) throws javax . xml . transform . TransformerException { int last = m_token . length ( ) - 1 ; char c0 = m_tokenChar ; char cX = m_token . charAt ( last ) ; if ( ( ( c0 == '\"' ) && ( cX == '\"' ) ) || ( ( c0 == '\'' ) && ( cX == '\'' ) ) ) { int tokenQueuePos = m_queueMark - 1 ; m_ops . m_tokenQueue . setElementAt ( null , tokenQueuePos ) ; Object obj = new XString ( m_token . substring ( 1 , last ) ) ; m_ops . m_tokenQueue . setElementAt ( obj , tokenQueuePos ) ; m_ops . setOp ( m_ops . getOp ( OpMap . MAPINDEX_LENGTH ) , tokenQueuePos ) ; m_ops . setOp ( OpMap . MAPINDEX_LENGTH , m_ops . getOp ( OpMap . MAPINDEX_LENGTH ) + 1 ) ; nextToken ( ) ; } else { error ( XPATHErrorResources . ER_PATTERN_LITERAL_NEEDS_BE_QUOTED , new Object [ ] { m_token } ) ; } } | The value of the Literal is the sequence of characters inside the or characters > . |
28,088 | public XMLString newstr ( FastStringBuffer fsb , int start , int length ) { return new XStringForFSB ( fsb , start , length ) ; } | Create a XMLString from a FastStringBuffer . |
28,089 | private List < Statement > getInitLocation ( MethodDeclaration node ) { List < Statement > stmts = node . getBody ( ) . getStatements ( ) ; if ( ! stmts . isEmpty ( ) && stmts . get ( 0 ) instanceof SuperConstructorInvocation ) { return stmts . subList ( 0 , 1 ) ; } assert TypeUtil . isNone ( ElementUtil . getDeclaringClass ( node . getExecutableElement ( ) ) . getSuperclass ( ) ) : "Constructor didn't have a super() call." ; return stmts . subList ( 0 , 0 ) ; } | Finds the location in a constructor where init statements should be added . |
28,090 | public static URIName nameConstraint ( DerValue value ) throws IOException { URI uri ; String name = value . getIA5String ( ) ; try { uri = new URI ( name ) ; } catch ( URISyntaxException use ) { throw new IOException ( "invalid URI name constraint:" + name , use ) ; } if ( uri . getScheme ( ) == null ) { String host = uri . getSchemeSpecificPart ( ) ; try { DNSName hostDNS ; if ( host . charAt ( 0 ) == '.' ) { hostDNS = new DNSName ( host . substring ( 1 ) ) ; } else { hostDNS = new DNSName ( host ) ; } return new URIName ( uri , host , hostDNS ) ; } catch ( IOException ioe ) { throw new IOException ( "invalid URI name constraint:" + name , ioe ) ; } } else { throw new IOException ( "invalid URI name constraint (should not " + "include scheme):" + name ) ; } } | Create the URIName object with the specified name constraint . URI name constraints syntax is different than SubjectAltNames etc . See 4 . 2 . 1 . 11 of RFC 3280 . |
28,091 | private String getAttributeKeyValue ( String key ) { String prefix = key + '=' ; String attribute = getAttribute ( prefix ) ; return attribute != null ? attribute . substring ( prefix . length ( ) ) : null ; } | Return the value for a specified key . Attributes are sequentially searched rather than use a map because most attributes are not key - value pairs . |
28,092 | public static String toAttributeString ( Set < String > attributes ) { List < String > list = new ArrayList < String > ( attributes ) ; Collections . sort ( list , ATTRIBUTES_COMPARATOR ) ; return Joiner . on ( ", " ) . join ( list ) ; } | Return a sorted comma - separated list of the property attributes for this annotation . |
28,093 | public static Extension newExtension ( ObjectIdentifier extensionId , boolean critical , byte [ ] rawExtensionValue ) throws IOException { Extension ext = new Extension ( ) ; ext . extensionId = extensionId ; ext . critical = critical ; ext . extensionValue = rawExtensionValue ; return ext ; } | Constructs an Extension from individual components of ObjectIdentifier criticality and the raw encoded extension value . |
28,094 | public static Set < Currency > getAvailableCurrencies ( ) { Set < Currency > result = new LinkedHashSet < Currency > ( ) ; for ( String currencyCode : availableCurrencyCodes ) { result . add ( Currency . getInstance ( currencyCode ) ) ; } return result ; } | Returns a set of all known currencies . |
28,095 | public int getNumericCode ( ) { try { String name = "com.google.j2objc.util.CurrencyNumericCodesImpl" ; CurrencyNumericCodes cnc = ( CurrencyNumericCodes ) Class . forName ( name ) . newInstance ( ) ; return cnc . getNumericCode ( currencyCode ) ; } catch ( Exception e ) { throw new LibraryNotLinkedError ( "java.util support" , "jre_util" , "ComGoogleJ2objcUtilCurrencyNumericCodesImpl" ) ; } } | Returns the ISO 4217 numeric code of this currency . |
28,096 | public int read ( ) throws IOException { int b = in . read ( ) ; if ( b != - 1 ) { cksum . update ( b ) ; } return b ; } | Reads a byte . Will block if no input is available . |
28,097 | public long skip ( long n ) throws IOException { byte [ ] buf = new byte [ 512 ] ; long total = 0 ; while ( total < n ) { long len = n - total ; len = read ( buf , 0 , len < buf . length ? ( int ) len : buf . length ) ; if ( len == - 1 ) { return total ; } total += len ; } return total ; } | Skips specified number of bytes of input . |
28,098 | private boolean checkConstraints ( Set < CryptoPrimitive > primitives , String algorithm , Key key , AlgorithmParameters parameters ) { if ( key == null ) { throw new IllegalArgumentException ( "The key cannot be null" ) ; } if ( algorithm != null && algorithm . length ( ) != 0 ) { if ( ! permits ( primitives , algorithm , parameters ) ) { return false ; } } if ( ! permits ( primitives , key . getAlgorithm ( ) , null ) ) { return false ; } if ( keySizeConstraints . disables ( key ) ) { return false ; } return true ; } | Check algorithm constraints |
28,099 | private static void loadDisabledAlgorithmsMap ( final String propertyName ) { String property = AccessController . doPrivileged ( new PrivilegedAction < String > ( ) { public String run ( ) { return Security . getProperty ( propertyName ) ; } } ) ; String [ ] algorithmsInProperty = null ; if ( property != null && ! property . isEmpty ( ) ) { if ( property . charAt ( 0 ) == '"' && property . charAt ( property . length ( ) - 1 ) == '"' ) { property = property . substring ( 1 , property . length ( ) - 1 ) ; } algorithmsInProperty = property . split ( "," ) ; for ( int i = 0 ; i < algorithmsInProperty . length ; i ++ ) { algorithmsInProperty [ i ] = algorithmsInProperty [ i ] . trim ( ) ; } } if ( algorithmsInProperty == null ) { algorithmsInProperty = new String [ 0 ] ; } disabledAlgorithmsMap . put ( propertyName , algorithmsInProperty ) ; KeySizeConstraints keySizeConstraints = new KeySizeConstraints ( algorithmsInProperty ) ; keySizeConstraintsMap . put ( propertyName , keySizeConstraints ) ; } | Get disabled algorithm constraints from the specified security property . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.