idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
27,700
private final void copyMembers ( DateFormatSymbols src , DateFormatSymbols dst ) { dst . eras = Arrays . copyOf ( src . eras , src . eras . length ) ; dst . months = Arrays . copyOf ( src . months , src . months . length ) ; dst . shortMonths = Arrays . copyOf ( src . shortMonths , src . shortMonths . length ) ; dst . weekdays = Arrays . copyOf ( src . weekdays , src . weekdays . length ) ; dst . shortWeekdays = Arrays . copyOf ( src . shortWeekdays , src . shortWeekdays . length ) ; dst . ampms = Arrays . copyOf ( src . ampms , src . ampms . length ) ; if ( src . zoneStrings != null ) { dst . zoneStrings = src . getZoneStringsImpl ( true ) ; } else { dst . zoneStrings = null ; } dst . localPatternChars = src . localPatternChars ; dst . tinyMonths = src . tinyMonths ; dst . tinyWeekdays = src . tinyWeekdays ; dst . standAloneMonths = src . standAloneMonths ; dst . shortStandAloneMonths = src . shortStandAloneMonths ; dst . tinyStandAloneMonths = src . tinyStandAloneMonths ; dst . standAloneWeekdays = src . standAloneWeekdays ; dst . shortStandAloneWeekdays = src . shortStandAloneWeekdays ; dst . tinyStandAloneWeekdays = src . tinyStandAloneWeekdays ; }
Clones all the data members from the source DateFormatSymbols to the target DateFormatSymbols . This is only for subclasses .
27,701
private void setNameConstraints ( byte [ ] bytes ) { if ( bytes == null ) { ncBytes = null ; nc = null ; } else { ncBytes = bytes . clone ( ) ; try { nc = new NameConstraintsExtension ( Boolean . FALSE , bytes ) ; } catch ( IOException ioe ) { IllegalArgumentException iae = new IllegalArgumentException ( ioe . getMessage ( ) ) ; iae . initCause ( ioe ) ; throw iae ; } } }
Decode the name constraints and clone them if not null .
27,702
public void put ( E e ) throws InterruptedException { if ( e == null ) throw new NullPointerException ( ) ; if ( transferer . transfer ( e , false , 0 ) == null ) { Thread . interrupted ( ) ; throw new InterruptedException ( ) ; } }
Adds the specified element to this queue waiting if necessary for another thread to receive it .
27,703
public boolean offer ( E e , long timeout , TimeUnit unit ) throws InterruptedException { if ( e == null ) throw new NullPointerException ( ) ; if ( transferer . transfer ( e , true , unit . toNanos ( timeout ) ) != null ) return true ; if ( ! Thread . interrupted ( ) ) return false ; throw new InterruptedException ( ) ; }
Inserts the specified element into this queue waiting if necessary up to the specified wait time for another thread to receive it .
27,704
public boolean offer ( E e ) { if ( e == null ) throw new NullPointerException ( ) ; return transferer . transfer ( e , true , 0 ) != null ; }
Inserts the specified element into this queue if another thread is waiting to receive it .
27,705
public E take ( ) throws InterruptedException { E e = transferer . transfer ( null , false , 0 ) ; if ( e != null ) return e ; Thread . interrupted ( ) ; throw new InterruptedException ( ) ; }
Retrieves and removes the head of this queue waiting if necessary for another thread to insert it .
27,706
public E poll ( long timeout , TimeUnit unit ) throws InterruptedException { E e = transferer . transfer ( null , true , unit . toNanos ( timeout ) ) ; if ( e != null || ! Thread . interrupted ( ) ) return e ; throw new InterruptedException ( ) ; }
Retrieves and removes the head of this queue waiting if necessary up to the specified wait time for another thread to insert it .
27,707
public static synchronized int insertProviderAt ( Provider provider , int position ) { String providerName = provider . getName ( ) ; check ( "insertProvider." + providerName ) ; ProviderList list = Providers . getFullProviderList ( ) ; ProviderList newList = ProviderList . insertAt ( list , provider , position - 1 ) ; if ( list == newList ) { return - 1 ; } increaseVersion ( ) ; Providers . setProviderList ( newList ) ; return newList . getIndex ( providerName ) + 1 ; }
Adds a new provider at a specified position . The position is the preference order in which providers are searched for requested algorithms . The position is 1 - based that is 1 is most preferred followed by 2 and so on .
27,708
public static synchronized void removeProvider ( String name ) { check ( "removeProvider." + name ) ; ProviderList list = Providers . getFullProviderList ( ) ; ProviderList newList = ProviderList . remove ( list , name ) ; Providers . setProviderList ( newList ) ; increaseVersion ( ) ; }
Removes the provider with the specified name .
27,709
public static String getProperty ( String key ) { SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) { sm . checkPermission ( new SecurityPermission ( "getProperty." + key ) ) ; } String name = props . getProperty ( key ) ; if ( name != null ) name = name . trim ( ) ; return name ; }
Gets a security property value .
27,710
public static void setProperty ( String key , String datum ) { check ( "setProperty." + key ) ; props . put ( key , datum ) ; increaseVersion ( ) ; invalidateSMCache ( key ) ; }
Sets a security property value .
27,711
byte [ ] getBytesUTF8 ( String s ) { if ( isUTF8 ) return getBytes ( s ) ; if ( utf8 == null ) utf8 = new ZipCoder ( StandardCharsets . UTF_8 ) ; return utf8 . getBytes ( s ) ; }
assume invoked only if this is not utf8
27,712
private void validateChrono ( TemporalAccessor temporal ) { Objects . requireNonNull ( temporal , "temporal" ) ; Chronology temporalChrono = temporal . query ( TemporalQueries . chronology ( ) ) ; if ( temporalChrono != null && IsoChronology . INSTANCE . equals ( temporalChrono ) == false ) { throw new DateTimeException ( "Chronology mismatch, expected: ISO, actual: " + temporalChrono . getId ( ) ) ; } }
Validates that the temporal has the correct chronology .
27,713
private StringBuffer format ( Date date , StringBuffer toAppendTo , FieldDelegate delegate ) { calendar . setTime ( date ) ; boolean useDateFormatSymbols = useDateFormatSymbols ( ) ; for ( int i = 0 ; i < compiledPattern . length ; ) { int tag = compiledPattern [ i ] >>> 8 ; int count = compiledPattern [ i ++ ] & 0xff ; if ( count == 255 ) { count = compiledPattern [ i ++ ] << 16 ; count |= compiledPattern [ i ++ ] ; } switch ( tag ) { case TAG_QUOTE_ASCII_CHAR : toAppendTo . append ( ( char ) count ) ; break ; case TAG_QUOTE_CHARS : toAppendTo . append ( compiledPattern , i , count ) ; i += count ; break ; default : subFormat ( tag , count , delegate , toAppendTo , useDateFormatSymbols ) ; break ; } } return toAppendTo ; }
Called from Format after creating a FieldDelegate
27,714
private int matchString ( String text , int start , int field , String [ ] data , CalendarBuilder calb ) { int i = 0 ; int count = data . length ; if ( field == Calendar . DAY_OF_WEEK ) i = 1 ; int bestMatchLength = 0 , bestMatch = - 1 ; for ( ; i < count ; ++ i ) { int length = data [ i ] . length ( ) ; if ( length > bestMatchLength && text . regionMatches ( true , start , data [ i ] , 0 , length ) ) { bestMatch = i ; bestMatchLength = length ; } if ( ( data [ i ] . charAt ( length - 1 ) == '.' ) && ( ( length - 1 ) > bestMatchLength ) && text . regionMatches ( true , start , data [ i ] , 0 , length - 1 ) ) { bestMatch = i ; bestMatchLength = ( length - 1 ) ; } } if ( bestMatch >= 0 ) { calb . set ( field , bestMatch ) ; return start + bestMatchLength ; } return - start ; }
Private code - size reduction function used by subParse .
27,715
private int subParseZoneString ( String text , int start , CalendarBuilder calb ) { boolean useSameName = false ; TimeZone currentTimeZone = getTimeZone ( ) ; int zoneIndex = formatData . getZoneIndex ( currentTimeZone . getID ( ) ) ; TimeZone tz = null ; String [ ] [ ] zoneStrings = formatData . getZoneStringsWrapper ( ) ; String [ ] zoneNames = null ; int nameIndex = 0 ; if ( zoneIndex != - 1 ) { zoneNames = zoneStrings [ zoneIndex ] ; if ( ( nameIndex = matchZoneString ( text , start , zoneNames ) ) > 0 ) { if ( nameIndex <= 2 ) { useSameName = zoneNames [ nameIndex ] . equalsIgnoreCase ( zoneNames [ nameIndex + 2 ] ) ; } tz = TimeZone . getTimeZone ( zoneNames [ 0 ] ) ; } } if ( tz == null ) { zoneIndex = formatData . getZoneIndex ( TimeZone . getDefault ( ) . getID ( ) ) ; if ( zoneIndex != - 1 ) { zoneNames = zoneStrings [ zoneIndex ] ; if ( ( nameIndex = matchZoneString ( text , start , zoneNames ) ) > 0 ) { if ( nameIndex <= 2 ) { useSameName = zoneNames [ nameIndex ] . equalsIgnoreCase ( zoneNames [ nameIndex + 2 ] ) ; } tz = TimeZone . getTimeZone ( zoneNames [ 0 ] ) ; } } } if ( tz == null ) { int len = zoneStrings . length ; for ( int i = 0 ; i < len ; i ++ ) { zoneNames = zoneStrings [ i ] ; if ( ( nameIndex = matchZoneString ( text , start , zoneNames ) ) > 0 ) { if ( nameIndex <= 2 ) { useSameName = zoneNames [ nameIndex ] . equalsIgnoreCase ( zoneNames [ nameIndex + 2 ] ) ; } tz = TimeZone . getTimeZone ( zoneNames [ 0 ] ) ; break ; } } } if ( tz != null ) { if ( ! tz . equals ( currentTimeZone ) ) { setTimeZone ( tz ) ; } int dstAmount = ( nameIndex >= 3 ) ? tz . getDSTSavings ( ) : 0 ; if ( ! ( useSameName || ( nameIndex >= 3 && dstAmount == 0 ) ) ) { calb . clear ( Calendar . ZONE_OFFSET ) . set ( Calendar . DST_OFFSET , dstAmount ) ; } return ( start + zoneNames [ nameIndex ] . length ( ) ) ; } return 0 ; }
find time zone text matched zoneStrings and set to internal calendar .
27,716
public void applyLocalizedPattern ( String pattern ) { String p = translatePattern ( pattern , formatData . getLocalPatternChars ( ) , DateFormatSymbols . patternChars ) ; compiledPattern = compile ( p ) ; this . pattern = p ; }
Applies the given localized pattern string to this date format .
27,717
public void offerData ( OutputStream stream ) { byte [ ] next = null ; try { next = queue . poll ( timeoutMillis , TimeUnit . MILLISECONDS ) ; } catch ( InterruptedException ignored ) { } try { if ( next != null && next != CLOSED ) { stream . write ( next ) ; return ; } } catch ( IOException ignored ) { } try { stream . close ( ) ; } catch ( IOException ignored ) { } }
Offers data from the queue to the OutputStream piped to the adapted NSInputStream .
27,718
private void eliminateDeadCode ( TypeElement type , AbstractTypeDeclaration node ) { List < BodyDeclaration > decls = node . getBodyDeclarations ( ) ; String clazz = elementUtil . getBinaryName ( type ) ; if ( deadCodeMap . containsClass ( clazz ) ) { stripClass ( node ) ; } else { removeDeadMethods ( clazz , decls ) ; removeDeadFields ( clazz , decls ) ; } }
Remove dead members from a type .
27,719
private void removeDeadMethods ( String clazz , List < BodyDeclaration > declarations ) { Iterator < BodyDeclaration > declarationsIter = declarations . iterator ( ) ; while ( declarationsIter . hasNext ( ) ) { BodyDeclaration declaration = declarationsIter . next ( ) ; if ( declaration instanceof MethodDeclaration ) { MethodDeclaration method = ( MethodDeclaration ) declaration ; ExecutableElement elem = method . getExecutableElement ( ) ; String name = typeUtil . getReferenceName ( elem ) ; String signature = typeUtil . getReferenceSignature ( elem ) ; if ( deadCodeMap . containsMethod ( clazz , name , signature ) ) { if ( method . isConstructor ( ) ) { deadCodeMap . addConstructorRemovedClass ( clazz ) ; } if ( Modifier . isNative ( method . getModifiers ( ) ) ) { removeMethodOCNI ( method ) ; } declarationsIter . remove ( ) ; } } } }
Remove dead methods from a type s body declarations .
27,720
private void removeMethodOCNI ( MethodDeclaration method ) { int methodStart = method . getStartPosition ( ) ; String src = unit . getSource ( ) . substring ( methodStart , methodStart + method . getLength ( ) ) ; if ( src . contains ( "/*-[" ) ) { int ocniStart = methodStart + src . indexOf ( "/*-[" ) ; Iterator < Comment > commentsIter = unit . getCommentList ( ) . iterator ( ) ; while ( commentsIter . hasNext ( ) ) { Comment comment = commentsIter . next ( ) ; if ( comment . isBlockComment ( ) && comment . getStartPosition ( ) == ocniStart ) { commentsIter . remove ( ) ; break ; } } } }
Remove the OCNI comment associated with a native method if it exists .
27,721
private void removeDeadFields ( String clazz , List < BodyDeclaration > declarations ) { Iterator < BodyDeclaration > declarationsIter = declarations . iterator ( ) ; while ( declarationsIter . hasNext ( ) ) { BodyDeclaration declaration = declarationsIter . next ( ) ; if ( declaration instanceof FieldDeclaration ) { FieldDeclaration field = ( FieldDeclaration ) declaration ; Iterator < VariableDeclarationFragment > fragmentsIter = field . getFragments ( ) . iterator ( ) ; while ( fragmentsIter . hasNext ( ) ) { VariableDeclarationFragment fragment = fragmentsIter . next ( ) ; VariableElement var = fragment . getVariableElement ( ) ; if ( var . getConstantValue ( ) == null && deadCodeMap . containsField ( clazz , ElementUtil . getName ( var ) ) ) { fragmentsIter . remove ( ) ; } } if ( field . getFragments ( ) . isEmpty ( ) ) { declarationsIter . remove ( ) ; } } } }
Deletes non - constant dead fields from a type s body declarations list .
27,722
public static void removeDeadClasses ( CompilationUnit unit , CodeReferenceMap deadCodeMap ) { ElementUtil elementUtil = unit . getEnv ( ) . elementUtil ( ) ; Iterator < AbstractTypeDeclaration > iter = unit . getTypes ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { AbstractTypeDeclaration type = iter . next ( ) ; TypeElement typeElement = type . getTypeElement ( ) ; if ( ! ElementUtil . isGeneratedAnnotation ( typeElement ) ) { if ( deadCodeMap . containsClass ( typeElement , elementUtil ) ) { type . setDeadClass ( true ) ; } else { if ( typeElement . getInterfaces ( ) . size ( ) > 0 ) { GeneratedTypeElement replacement = GeneratedTypeElement . mutableCopy ( typeElement ) ; for ( TypeElement intrface : ElementUtil . getInterfaces ( typeElement ) ) { if ( ! deadCodeMap . containsClass ( intrface , elementUtil ) ) { replacement . addInterface ( intrface . asType ( ) ) ; } } if ( typeElement . getInterfaces ( ) . size ( ) > replacement . getInterfaces ( ) . size ( ) ) { type . setTypeElement ( replacement ) ; } } } } } }
Remove empty classes marked as dead . This needs to be done after translation to avoid inner class references in the AST returned by DeadCodeEliminator .
27,723
public static < T > void moveList ( List < T > fromList , List < T > toList ) { for ( Iterator < T > iter = fromList . iterator ( ) ; iter . hasNext ( ) ; ) { T elem = iter . next ( ) ; iter . remove ( ) ; toList . add ( elem ) ; } }
Moves nodes from one list to another ensuring that they are not double - parented in the process .
27,724
public static Expression trimParentheses ( Expression node ) { while ( node instanceof ParenthesizedExpression ) { node = ( ( ParenthesizedExpression ) node ) . getExpression ( ) ; } return node ; }
Returns the first descendant of the given node that is not a ParenthesizedExpression .
27,725
public static Element getDeclaredElement ( TreeNode node ) { if ( node instanceof AbstractTypeDeclaration ) { return ( ( AbstractTypeDeclaration ) node ) . getTypeElement ( ) ; } else if ( node instanceof MethodDeclaration ) { return ( ( MethodDeclaration ) node ) . getExecutableElement ( ) ; } else if ( node instanceof VariableDeclaration ) { return ( ( VariableDeclaration ) node ) . getVariableElement ( ) ; } return null ; }
Gets the element that is declared by this node .
27,726
public static VariableElement getVariableElement ( Expression node ) { node = trimParentheses ( node ) ; switch ( node . getKind ( ) ) { case FIELD_ACCESS : return ( ( FieldAccess ) node ) . getVariableElement ( ) ; case SUPER_FIELD_ACCESS : return ( ( SuperFieldAccess ) node ) . getVariableElement ( ) ; case QUALIFIED_NAME : case SIMPLE_NAME : return getVariableElement ( ( Name ) node ) ; default : return null ; } }
Gets a variable element for the given expression if the expression represents a variable . Returns null otherwise .
27,727
public static String getQualifiedMainTypeName ( CompilationUnit unit ) { PackageDeclaration pkg = unit . getPackage ( ) ; if ( pkg . isDefaultPackage ( ) ) { return unit . getMainTypeName ( ) ; } else { return pkg . getName ( ) . getFullyQualifiedName ( ) + '.' + unit . getMainTypeName ( ) ; } }
Gets the fully qualified name of the main type in this compilation unit .
27,728
public static List < Statement > asStatementList ( Statement node ) { if ( node instanceof Block ) { return ( ( Block ) node ) . getStatements ( ) ; } TreeNode parent = node . getParent ( ) ; if ( parent instanceof Block ) { List < Statement > stmts = ( ( Block ) parent ) . getStatements ( ) ; for ( int i = 0 ; i < stmts . size ( ) ; i ++ ) { if ( stmts . get ( i ) == node ) { return stmts . subList ( i , i + 1 ) ; } } } return new LonelyStatementList ( node ) ; }
Returns the given statement as a list of statements that can be added to . If node is a Block then returns it s statement list . If node is the direct child of a Block returns the sublist containing node as the only element . Otherwise creates a new Block node in the place of node and returns its list of statements .
27,729
public boolean handleError ( DOMError error ) { boolean fail = true ; String severity = null ; if ( error . getSeverity ( ) == DOMError . SEVERITY_WARNING ) { fail = false ; severity = "[Warning]" ; } else if ( error . getSeverity ( ) == DOMError . SEVERITY_ERROR ) { severity = "[Error]" ; } else if ( error . getSeverity ( ) == DOMError . SEVERITY_FATAL_ERROR ) { severity = "[Fatal Error]" ; } System . err . println ( severity + ": " + error . getMessage ( ) + "\t" ) ; System . err . println ( "Type : " + error . getType ( ) + "\t" + "Related Data: " + error . getRelatedData ( ) + "\t" + "Related Exception: " + error . getRelatedException ( ) ) ; return fail ; }
Implementation of DOMErrorHandler . handleError that adds copy of error to list for later retrieval .
27,730
public static void main ( String [ ] args ) { String icuApiVer ; if ( ICU_VERSION . getMajor ( ) <= 4 ) { if ( ICU_VERSION . getMinor ( ) % 2 != 0 ) { int major = ICU_VERSION . getMajor ( ) ; int minor = ICU_VERSION . getMinor ( ) + 1 ; if ( minor >= 10 ) { minor -= 10 ; major ++ ; } icuApiVer = "" + major + "." + minor + "M" + ICU_VERSION . getMilli ( ) ; } else { icuApiVer = ICU_VERSION . getVersionString ( 2 , 2 ) ; } } else { if ( ICU_VERSION . getMinor ( ) == 0 ) { icuApiVer = "" + ICU_VERSION . getMajor ( ) + "M" + ICU_VERSION . getMilli ( ) ; } else { icuApiVer = ICU_VERSION . getVersionString ( 2 , 2 ) ; } } System . out . println ( "International Components for Unicode for Java " + icuApiVer ) ; System . out . println ( "" ) ; System . out . println ( "Implementation Version: " + ICU_VERSION . getVersionString ( 2 , 4 ) ) ; System . out . println ( "Unicode Data Version: " + UNICODE_VERSION . getVersionString ( 2 , 4 ) ) ; System . out . println ( "CLDR Data Version: " + LocaleData . getCLDRVersion ( ) . getVersionString ( 2 , 4 ) ) ; System . out . println ( "Time Zone Data Version: " + getTZDataVersion ( ) ) ; }
Main method prints out ICU version information
27,731
public static NumberingSystem getInstance ( ULocale locale ) { boolean nsResolved = true ; String numbersKeyword = locale . getKeywordValue ( "numbers" ) ; if ( numbersKeyword != null ) { for ( String keyword : OTHER_NS_KEYWORDS ) { if ( numbersKeyword . equals ( keyword ) ) { nsResolved = false ; break ; } } } else { numbersKeyword = "default" ; nsResolved = false ; } if ( nsResolved ) { NumberingSystem ns = getInstanceByName ( numbersKeyword ) ; if ( ns != null ) { return ns ; } numbersKeyword = "default" ; } String baseName = locale . getBaseName ( ) ; String key = baseName + "@numbers=" + numbersKeyword ; LocaleLookupData localeLookupData = new LocaleLookupData ( locale , numbersKeyword ) ; return cachedLocaleData . getInstance ( key , localeLookupData ) ; }
Returns the default numbering system for the specified ULocale .
27,732
public static String [ ] getAvailableNames ( ) { UResourceBundle numberingSystemsInfo = UResourceBundle . getBundleInstance ( ICUData . ICU_BASE_NAME , "numberingSystems" ) ; UResourceBundle nsCurrent = numberingSystemsInfo . get ( "numberingSystems" ) ; UResourceBundle temp ; String nsName ; ArrayList < String > output = new ArrayList < String > ( ) ; UResourceBundleIterator it = nsCurrent . getIterator ( ) ; while ( it . hasNext ( ) ) { temp = it . next ( ) ; nsName = temp . getKey ( ) ; output . add ( nsName ) ; } return output . toArray ( new String [ output . size ( ) ] ) ; }
Returns a string array containing a list of the names of numbering systems currently known to ICU .
27,733
private Object readLiteral ( ) throws JSONException { String literal = nextToInternal ( "{}[]/\\:,=;# \t\f" ) ; if ( literal . length ( ) == 0 ) { throw syntaxError ( "Expected literal value" ) ; } else if ( "null" . equalsIgnoreCase ( literal ) ) { return JSONObject . NULL ; } else if ( "true" . equalsIgnoreCase ( literal ) ) { return Boolean . TRUE ; } else if ( "false" . equalsIgnoreCase ( literal ) ) { return Boolean . FALSE ; } if ( literal . indexOf ( '.' ) == - 1 ) { int base = 10 ; String number = literal ; if ( number . startsWith ( "0x" ) || number . startsWith ( "0X" ) ) { number = number . substring ( 2 ) ; base = 16 ; } else if ( number . startsWith ( "0" ) && number . length ( ) > 1 ) { number = number . substring ( 1 ) ; base = 8 ; } try { long longValue = Long . parseLong ( number , base ) ; if ( longValue <= Integer . MAX_VALUE && longValue >= Integer . MIN_VALUE ) { return ( int ) longValue ; } else { return longValue ; } } catch ( NumberFormatException e ) { } } try { return Double . valueOf ( literal ) ; } catch ( NumberFormatException ignored ) { } return new String ( literal ) ; }
Reads a null boolean numeric or unquoted string literal value . Numeric values will be returned as an Integer Long or Double in that order of preference .
27,734
private String nextToInternal ( String excluded ) { int start = pos ; for ( ; pos < in . length ( ) ; pos ++ ) { char c = in . charAt ( pos ) ; if ( c == '\r' || c == '\n' || excluded . indexOf ( c ) != - 1 ) { return in . substring ( start , pos ) ; } } return in . substring ( start ) ; }
Returns the string up to but not including any of the given characters or a newline character . This does not consume the excluded character .
27,735
private static synchronized boolean cancelScheduledTimeout ( AsyncTimeout node ) { for ( AsyncTimeout prev = head ; prev != null ; prev = prev . next ) { if ( prev . next == node ) { prev . next = node . next ; node . next = null ; return false ; } } return true ; }
Returns true if the timeout occurred .
27,736
void offerData ( byte [ ] chunk ) { if ( chunk == null || chunk . length == 0 ) { throw new IllegalArgumentException ( "chunk must have at least one byte of data" ) ; } if ( closed ) { return ; } queue . offer ( chunk ) ; }
Offers a chunk of data to the queue .
27,737
void endOffering ( IOException exception ) { if ( closed ) { return ; } if ( this . exception == null ) { this . exception = exception ; } queue . offer ( CLOSED ) ; }
Signals that no more data is available and an exception should be thrown .
27,738
public synchronized int read ( byte [ ] buf , int offset , int length ) throws IOException { if ( buf == null ) { throw new IllegalArgumentException ( "buf must not be null" ) ; } if ( ! ( offset >= 0 && length > 0 && offset < buf . length && length <= ( buf . length - offset ) ) ) { throw new IllegalArgumentException ( "invalid offset and lengeth" ) ; } if ( closed ) { if ( exception != null ) { throw exception ; } return - 1 ; } if ( currentChunk == null ) { if ( currentChunkReadPos != - 1 ) { throw new IllegalStateException ( "currentChunk is null but currentChunkReadPos is not -1" ) ; } byte [ ] next = null ; try { if ( timeoutMillis >= 0 ) { next = queue . poll ( timeoutMillis , TimeUnit . MILLISECONDS ) ; } else { next = queue . take ( ) ; } } catch ( InterruptedException e ) { throw new AssertionError ( e ) ; } if ( next == null ) { closed = true ; SocketTimeoutException timeoutException = new SocketTimeoutException ( ) ; if ( exception == null ) { exception = timeoutException ; } throw timeoutException ; } if ( next == CLOSED ) { closed = true ; if ( exception != null ) { throw exception ; } return - 1 ; } currentChunk = next ; currentChunkReadPos = 0 ; } int available = currentChunk . length - currentChunkReadPos ; if ( length < available ) { System . arraycopy ( currentChunk , currentChunkReadPos , buf , offset , length ) ; currentChunkReadPos += length ; return length ; } else { System . arraycopy ( currentChunk , currentChunkReadPos , buf , offset , available ) ; currentChunk = null ; currentChunkReadPos = - 1 ; return available ; } }
Reads from the current chunk or polls a next chunk from the queue . This is synchronized to allow reads to be used on different thread while still guaranteeing their sequentiality .
27,739
private YearMonth with ( int newYear , int newMonth ) { if ( year == newYear && month == newMonth ) { return this ; } return new YearMonth ( newYear , newMonth ) ; }
Returns a copy of this year - month with the new year and month checking to see if a new object is in fact required .
27,740
public int matches ( Replaceable text , int [ ] offset , int limit , boolean incremental ) { int start = offset [ 0 ] ; int count = 0 ; while ( count < maxCount ) { int pos = offset [ 0 ] ; int m = matcher . matches ( text , offset , limit , incremental ) ; if ( m == U_MATCH ) { ++ count ; if ( pos == offset [ 0 ] ) { break ; } } else if ( incremental && m == U_PARTIAL_MATCH ) { return U_PARTIAL_MATCH ; } else { break ; } } if ( incremental && offset [ 0 ] == limit ) { return U_PARTIAL_MATCH ; } if ( count >= minCount ) { return U_MATCH ; } offset [ 0 ] = start ; return U_MISMATCH ; }
Implement UnicodeMatcher API .
27,741
public String toPattern ( boolean escapeUnprintable ) { StringBuilder result = new StringBuilder ( ) ; result . append ( matcher . toPattern ( escapeUnprintable ) ) ; if ( minCount == 0 ) { if ( maxCount == 1 ) { return result . append ( '?' ) . toString ( ) ; } else if ( maxCount == MAX ) { return result . append ( '*' ) . toString ( ) ; } } else if ( minCount == 1 && maxCount == MAX ) { return result . append ( '+' ) . toString ( ) ; } result . append ( '{' ) ; result . append ( Utility . hex ( minCount , 1 ) ) ; result . append ( ',' ) ; if ( maxCount != MAX ) { result . append ( Utility . hex ( maxCount , 1 ) ) ; } result . append ( '}' ) ; return result . toString ( ) ; }
Implement UnicodeMatcher API
27,742
public void encode ( DerOutputStream out ) throws IOException { DerOutputStream theChoice = new DerOutputStream ( ) ; if ( fullName != null ) { fullName . encode ( theChoice ) ; out . writeImplicit ( DerValue . createTag ( DerValue . TAG_CONTEXT , true , TAG_FULL_NAME ) , theChoice ) ; } else { relativeName . encode ( theChoice ) ; out . writeImplicit ( DerValue . createTag ( DerValue . TAG_CONTEXT , true , TAG_RELATIVE_NAME ) , theChoice ) ; } }
Encodes the distribution point name and writes it to the DerOutputStream .
27,743
public void split ( ) { if ( ! needsSplitting ( ) ) { return ; } Node parent = getParentNode ( ) ; String [ ] parts = getData ( ) . split ( "\\]\\]>" ) ; parent . insertBefore ( new CDATASectionImpl ( document , parts [ 0 ] + "]]" ) , this ) ; for ( int p = 1 ; p < parts . length - 1 ; p ++ ) { parent . insertBefore ( new CDATASectionImpl ( document , ">" + parts [ p ] + "]]" ) , this ) ; } setData ( ">" + parts [ parts . length - 1 ] ) ; }
Splits this CDATA node into parts that do not contain a ]] > sequence . Any newly created nodes will be inserted before this node .
27,744
public TextImpl replaceWithText ( ) { TextImpl replacement = new TextImpl ( document , getData ( ) ) ; parent . insertBefore ( replacement , this ) ; parent . removeChild ( this ) ; return replacement ; }
Replaces this node with a semantically equivalent text node . This node will be removed from the DOM tree and the new node inserted in its place .
27,745
public void fixupVariables ( java . util . Vector vars , int globalsSize ) { for ( int i = 0 ; i < m_patterns . length ; i ++ ) { m_patterns [ i ] . fixupVariables ( vars , globalsSize ) ; } }
No arguments to process so this does nothing .
27,746
public void setPatterns ( StepPattern [ ] patterns ) { m_patterns = patterns ; if ( null != patterns ) { for ( int i = 0 ; i < patterns . length ; i ++ ) { patterns [ i ] . exprSetParent ( this ) ; } } }
Set the contained step patterns to be tested .
27,747
public XObject execute ( XPathContext xctxt ) throws javax . xml . transform . TransformerException { XObject bestScore = null ; int n = m_patterns . length ; for ( int i = 0 ; i < n ; i ++ ) { XObject score = m_patterns [ i ] . execute ( xctxt ) ; if ( score != NodeTest . SCORE_NONE ) { if ( null == bestScore ) bestScore = score ; else if ( score . num ( ) > bestScore . num ( ) ) bestScore = score ; } } if ( null == bestScore ) { bestScore = NodeTest . SCORE_NONE ; } return bestScore ; }
Test a node to see if it matches any of the patterns in the union .
27,748
private void addPackageJavadoc ( CompilationUnit unit , String qualifiedMainType ) { Javadoc javadoc = unit . getPackage ( ) . getJavadoc ( ) ; if ( javadoc == null ) { return ; } SourceBuilder builder = new SourceBuilder ( false ) ; JavadocGenerator . printDocComment ( builder , javadoc ) ; javadocBlocks . put ( qualifiedMainType , builder . toString ( ) ) ; }
Collect javadoc from the package declarations to display in the header .
27,749
public static < U , W > AtomicReferenceFieldUpdater < U , W > newUpdater ( Class < U > tclass , Class < W > vclass , String fieldName ) { return new AtomicReferenceFieldUpdaterImpl < U , W > ( tclass , vclass , fieldName , null ) ; }
Creates and returns an updater for objects with the given field . The Class arguments are needed to check that reflective types and generic types match .
27,750
public void setText ( Replaceable rep ) { this . rep = rep ; limit = contextLimit = rep . length ( ) ; cpStart = cpLimit = index = contextStart = 0 ; dir = 0 ; reachedLimit = false ; }
Set the text for iteration .
27,751
public int nextCaseMapCP ( ) { int c ; if ( cpLimit < limit ) { cpStart = cpLimit ; c = rep . char32At ( cpLimit ) ; cpLimit += UTF16 . getCharCount ( c ) ; return c ; } else { return - 1 ; } }
Iterate forward through the string to fetch the next code point to be case - mapped and set the context indexes for it .
27,752
public int replace ( String text ) { int delta = text . length ( ) - ( cpLimit - cpStart ) ; rep . replace ( cpStart , cpLimit , text ) ; cpLimit += delta ; limit += delta ; contextLimit += delta ; return delta ; }
Replace the current code point by its case mapping and update the indexes .
27,753
public void reset ( int direction ) { if ( direction > 0 ) { this . dir = 1 ; index = cpLimit ; } else if ( direction < 0 ) { this . dir = - 1 ; index = cpStart ; } else { this . dir = 0 ; index = 0 ; } reachedLimit = false ; }
implement UCaseProps . ContextIterator
27,754
static int codePointAtImpl ( char [ ] a , int index , int limit ) { char c1 = a [ index ] ; if ( isHighSurrogate ( c1 ) && ++ index < limit ) { char c2 = a [ index ] ; if ( isLowSurrogate ( c2 ) ) { return toCodePoint ( c1 , c2 ) ; } } return c1 ; }
throws ArrayIndexOutOfBoundsException if index out of bounds
27,755
static int codePointBeforeImpl ( char [ ] a , int index , int start ) { char c2 = a [ -- index ] ; if ( isLowSurrogate ( c2 ) && index > start ) { char c1 = a [ -- index ] ; if ( isHighSurrogate ( c1 ) ) { return toCodePoint ( c1 , c2 ) ; } } return c2 ; }
throws ArrayIndexOutOfBoundsException if index - 1 out of bounds
27,756
public static int getType ( int codePoint ) { int type = getTypeImpl ( codePoint ) ; if ( type <= Character . FORMAT ) { return type ; } return ( type + 1 ) ; }
Returns a value indicating a character s general category .
27,757
public static String getCalendarType ( ULocale loc ) { String calType = loc . getKeywordValue ( CALKEY ) ; if ( calType != null ) { return calType ; } ULocale canonical = ULocale . createCanonical ( loc . toString ( ) ) ; calType = canonical . getKeywordValue ( CALKEY ) ; if ( calType != null ) { return calType ; } String region = ULocale . getRegionForSupplementalData ( canonical , true ) ; return CalendarPreferences . INSTANCE . getCalendarTypeForRegion ( region ) ; }
Returns a calendar type for the given locale . When the given locale has calendar keyword the value of calendar keyword is returned . Otherwise the default calendar type for the locale is returned .
27,758
public ZipEntry getNextEntry ( ) throws IOException { ensureOpen ( ) ; if ( entry != null ) { closeEntry ( ) ; } crc . reset ( ) ; inf . reset ( ) ; if ( ( entry = readLOC ( ) ) == null ) { return null ; } if ( entry . method == STORED || entry . method == DEFLATED ) { remaining = entry . size ; } entryEOF = false ; return entry ; }
Reads the next ZIP file entry and positions the stream at the beginning of the entry data .
27,759
public long skip ( long n ) throws IOException { if ( n < 0 ) { throw new IllegalArgumentException ( "negative skip length" ) ; } ensureOpen ( ) ; int max = ( int ) Math . min ( n , Integer . MAX_VALUE ) ; int total = 0 ; while ( total < max ) { int len = max - total ; if ( len > tmpbuf . length ) { len = tmpbuf . length ; } len = read ( tmpbuf , 0 , len ) ; if ( len == - 1 ) { entryEOF = true ; break ; } total += len ; } return total ; }
Skips specified number of bytes in the current ZIP entry .
27,760
public ElemTemplateElement appendChild ( ElemTemplateElement elem ) { if ( m_selectPattern != null ) { error ( XSLTErrorResources . ER_CANT_HAVE_CONTENT_AND_SELECT , new Object [ ] { "xsl:" + this . getNodeName ( ) } ) ; return null ; } return super . appendChild ( elem ) ; }
Add a child to the child list . If the select attribute is present an error will be raised .
27,761
public String toPattern ( ) { if ( customFormatArgStarts != null ) { throw new IllegalStateException ( "toPattern() is not supported after custom Format objects " + "have been set via setFormat() or similar APIs" ) ; } if ( msgPattern == null ) { return "" ; } String originalPattern = msgPattern . getPatternString ( ) ; return originalPattern == null ? "" : originalPattern ; }
Returns the applied pattern string .
27,762
private int nextTopLevelArgStart ( int partIndex ) { if ( partIndex != 0 ) { partIndex = msgPattern . getLimitPartIndex ( partIndex ) ; } for ( ; ; ) { MessagePattern . Part . Type type = msgPattern . getPartType ( ++ partIndex ) ; if ( type == MessagePattern . Part . Type . ARG_START ) { return partIndex ; } if ( type == MessagePattern . Part . Type . MSG_LIMIT ) { return - 1 ; } } }
Returns the part index of the next ARG_START after partIndex or - 1 if there is none more .
27,763
private String getLiteralStringUntilNextArgument ( int from ) { StringBuilder b = new StringBuilder ( ) ; String msgString = msgPattern . getPatternString ( ) ; int prevIndex = msgPattern . getPart ( from ) . getLimit ( ) ; for ( int i = from + 1 ; ; ++ i ) { Part part = msgPattern . getPart ( i ) ; Part . Type type = part . getType ( ) ; int index = part . getIndex ( ) ; b . append ( msgString , prevIndex , index ) ; if ( type == Part . Type . ARG_START || type == Part . Type . MSG_LIMIT ) { return b . toString ( ) ; } assert type == Part . Type . SKIP_SYNTAX || type == Part . Type . INSERT_CHAR : "Unexpected Part " + part + " in parsed message." ; prevIndex = part . getLimit ( ) ; } }
Read as much literal string from the pattern string as possible . This stops as soon as it finds an argument or it reaches the end of the string .
27,764
private static int findChoiceSubMessage ( MessagePattern pattern , int partIndex , double number ) { int count = pattern . countParts ( ) ; int msgStart ; partIndex += 2 ; for ( ; ; ) { msgStart = partIndex ; partIndex = pattern . getLimitPartIndex ( partIndex ) ; if ( ++ partIndex >= count ) { break ; } Part part = pattern . getPart ( partIndex ++ ) ; Part . Type type = part . getType ( ) ; if ( type == Part . Type . ARG_LIMIT ) { break ; } assert type . hasNumericValue ( ) ; double boundary = pattern . getNumericValue ( part ) ; int selectorIndex = pattern . getPatternIndex ( partIndex ++ ) ; char boundaryChar = pattern . getPatternString ( ) . charAt ( selectorIndex ) ; if ( boundaryChar == '<' ? ! ( number > boundary ) : ! ( number >= boundary ) ) { break ; } } return msgStart ; }
Finds the ChoiceFormat sub - message for the given number .
27,765
private static int matchStringUntilLimitPart ( MessagePattern pattern , int partIndex , int limitPartIndex , String source , int sourceOffset ) { int matchingSourceLength = 0 ; String msgString = pattern . getPatternString ( ) ; int prevIndex = pattern . getPart ( partIndex ) . getLimit ( ) ; for ( ; ; ) { Part part = pattern . getPart ( ++ partIndex ) ; if ( partIndex == limitPartIndex || part . getType ( ) == Part . Type . SKIP_SYNTAX ) { int index = part . getIndex ( ) ; int length = index - prevIndex ; if ( length != 0 && ! source . regionMatches ( sourceOffset , msgString , prevIndex , length ) ) { return - 1 ; } matchingSourceLength += length ; if ( partIndex == limitPartIndex ) { return matchingSourceLength ; } prevIndex = part . getLimit ( ) ; } } }
Matches the pattern string from the end of the partIndex to the beginning of the limitPartIndex including all syntax except SKIP_SYNTAX against the source string starting at sourceOffset . If they match returns the length of the source string match . Otherwise returns - 1 .
27,766
private int findOtherSubMessage ( int partIndex ) { int count = msgPattern . countParts ( ) ; MessagePattern . Part part = msgPattern . getPart ( partIndex ) ; if ( part . getType ( ) . hasNumericValue ( ) ) { ++ partIndex ; } do { part = msgPattern . getPart ( partIndex ++ ) ; MessagePattern . Part . Type type = part . getType ( ) ; if ( type == MessagePattern . Part . Type . ARG_LIMIT ) { break ; } assert type == MessagePattern . Part . Type . ARG_SELECTOR ; if ( msgPattern . partSubstringMatches ( part , "other" ) ) { return partIndex ; } if ( msgPattern . getPartType ( partIndex ) . hasNumericValue ( ) ) { ++ partIndex ; } partIndex = msgPattern . getLimitPartIndex ( partIndex ) ; } while ( ++ partIndex < count ) ; return 0 ; }
Finds the other sub - message .
27,767
private int findFirstPluralNumberArg ( int msgStart , String argName ) { for ( int i = msgStart + 1 ; ; ++ i ) { Part part = msgPattern . getPart ( i ) ; Part . Type type = part . getType ( ) ; if ( type == Part . Type . MSG_LIMIT ) { return 0 ; } if ( type == Part . Type . REPLACE_NUMBER ) { return - 1 ; } if ( type == Part . Type . ARG_START ) { ArgType argType = part . getArgType ( ) ; if ( argName . length ( ) != 0 && ( argType == ArgType . NONE || argType == ArgType . SIMPLE ) ) { part = msgPattern . getPart ( i + 1 ) ; if ( msgPattern . partSubstringMatches ( part , argName ) ) { return i ; } } i = msgPattern . getLimitPartIndex ( i ) ; } } }
Returns the ARG_START index of the first occurrence of the plural number in a sub - message . Returns - 1 if it is a REPLACE_NUMBER . Returns 0 if there is neither .
27,768
private void format ( Object [ ] arguments , Map < String , Object > argsMap , AppendableWrapper dest , FieldPosition fp ) { if ( arguments != null && msgPattern . hasNamedArguments ( ) ) { throw new IllegalArgumentException ( "This method is not available in MessageFormat objects " + "that use alphanumeric argument names." ) ; } format ( 0 , null , arguments , argsMap , dest , fp ) ; }
Internal routine used by format .
27,769
private static final int findKeyword ( String s , String [ ] list ) { s = PatternProps . trimWhiteSpace ( s ) . toLowerCase ( rootLocale ) ; for ( int i = 0 ; i < list . length ; ++ i ) { if ( s . equals ( list [ i ] ) ) return i ; } return - 1 ; }
Locale . ROOT only
27,770
private void writeObject ( java . io . ObjectOutputStream out ) throws IOException { out . defaultWriteObject ( ) ; out . writeObject ( ulocale . toLanguageTag ( ) ) ; if ( msgPattern == null ) { msgPattern = new MessagePattern ( ) ; } out . writeObject ( msgPattern . getApostropheMode ( ) ) ; out . writeObject ( msgPattern . getPatternString ( ) ) ; if ( customFormatArgStarts == null || customFormatArgStarts . isEmpty ( ) ) { out . writeInt ( 0 ) ; } else { out . writeInt ( customFormatArgStarts . size ( ) ) ; int formatIndex = 0 ; for ( int partIndex = 0 ; ( partIndex = nextTopLevelArgStart ( partIndex ) ) >= 0 ; ) { if ( customFormatArgStarts . contains ( partIndex ) ) { out . writeInt ( formatIndex ) ; out . writeObject ( cachedFormatters . get ( partIndex ) ) ; } ++ formatIndex ; } } out . writeInt ( 0 ) ; }
Custom serialization new in ICU 4 . 8 . We do not want to use default serialization because we only have a small amount of persistent state which is better expressed explicitly rather than via writing field objects .
27,771
private void setArgStartFormat ( int argStart , Format formatter ) { if ( cachedFormatters == null ) { cachedFormatters = new HashMap < Integer , Format > ( ) ; } cachedFormatters . put ( argStart , formatter ) ; }
Sets a formatter for a MessagePattern ARG_START part index .
27,772
public static synchronized SocketFactory getDefault ( ) { if ( defaultSocketFactory != null && lastVersion == Security . getVersion ( ) ) { return defaultSocketFactory ; } lastVersion = Security . getVersion ( ) ; SSLSocketFactory previousDefaultSocketFactory = defaultSocketFactory ; defaultSocketFactory = null ; String clsName = getSecurityProperty ( "ssl.SocketFactory.provider" ) ; if ( clsName != null ) { if ( previousDefaultSocketFactory != null && clsName . equals ( previousDefaultSocketFactory . getClass ( ) . getName ( ) ) ) { defaultSocketFactory = previousDefaultSocketFactory ; return defaultSocketFactory ; } log ( "setting up default SSLSocketFactory" ) ; try { Class cls = null ; try { cls = Class . forName ( clsName ) ; } catch ( ClassNotFoundException e ) { ClassLoader cl = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( cl == null ) { cl = ClassLoader . getSystemClassLoader ( ) ; } if ( cl != null ) { cls = Class . forName ( clsName , true , cl ) ; } } log ( "class " + clsName + " is loaded" ) ; defaultSocketFactory = ( SSLSocketFactory ) cls . newInstance ( ) ; log ( "instantiated an instance of class " + clsName ) ; if ( defaultSocketFactory != null ) { return defaultSocketFactory ; } } catch ( Exception e ) { log ( "SSLSocketFactory instantiation failed: " + e . toString ( ) ) ; } } try { SSLContext context = SSLContext . getDefault ( ) ; if ( context != null ) { defaultSocketFactory = context . getSocketFactory ( ) ; } } catch ( NoSuchAlgorithmException e ) { } if ( defaultSocketFactory == null ) { defaultSocketFactory = new DefaultSSLSocketFactory ( new IllegalStateException ( "No factory found." ) ) ; } return defaultSocketFactory ; }
Returns the default SSL socket factory .
27,773
private Map < String , Factory > getVisibleIDMap ( ) { synchronized ( this ) { if ( idcache == null ) { try { factoryLock . acquireRead ( ) ; Map < String , Factory > mutableMap = new HashMap < String , Factory > ( ) ; ListIterator < Factory > lIter = factories . listIterator ( factories . size ( ) ) ; while ( lIter . hasPrevious ( ) ) { Factory f = lIter . previous ( ) ; f . updateVisibleIDs ( mutableMap ) ; } this . idcache = Collections . unmodifiableMap ( mutableMap ) ; } finally { factoryLock . releaseRead ( ) ; } } } return idcache ; }
Return a map from visible ids to factories .
27,774
public String getDisplayName ( String id , ULocale locale ) { Map < String , Factory > m = getVisibleIDMap ( ) ; Factory f = m . get ( id ) ; if ( f != null ) { return f . getDisplayName ( id , locale ) ; } Key key = createKey ( id ) ; while ( key . fallback ( ) ) { f = m . get ( key . currentID ( ) ) ; if ( f != null ) { return f . getDisplayName ( id , locale ) ; } } return null ; }
Given a visible id return the display name in the requested locale . If there is no directly supported id corresponding to this id return null .
27,775
public SortedMap < String , String > getDisplayNames ( ULocale locale , Comparator < Object > com , String matchID ) { SortedMap < String , String > dncache = null ; LocaleRef ref = dnref ; if ( ref != null ) { dncache = ref . get ( locale , com ) ; } while ( dncache == null ) { synchronized ( this ) { if ( ref == dnref || dnref == null ) { dncache = new TreeMap < String , String > ( com ) ; Map < String , Factory > m = getVisibleIDMap ( ) ; Iterator < Entry < String , Factory > > ei = m . entrySet ( ) . iterator ( ) ; while ( ei . hasNext ( ) ) { Entry < String , Factory > e = ei . next ( ) ; String id = e . getKey ( ) ; Factory f = e . getValue ( ) ; dncache . put ( f . getDisplayName ( id , locale ) , id ) ; } dncache = Collections . unmodifiableSortedMap ( dncache ) ; dnref = new LocaleRef ( dncache , locale , com ) ; } else { ref = dnref ; dncache = ref . get ( locale , com ) ; } } } Key matchKey = createKey ( matchID ) ; if ( matchKey == null ) { return dncache ; } SortedMap < String , String > result = new TreeMap < String , String > ( dncache ) ; Iterator < Entry < String , String > > iter = result . entrySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { Entry < String , String > e = iter . next ( ) ; if ( ! matchKey . isFallbackOf ( e . getValue ( ) ) ) { iter . remove ( ) ; } } return result ; }
Return a snapshot of the mapping from display names to visible IDs for this service . This set will not change as factories are added or removed but the supported ids will so there is no guarantee that all and only the ids in the returned map will be visible and supported by the service in subsequent calls nor is there any guarantee that the current display names match those in the set . The display names are sorted based on the comparator provided .
27,776
public final List < Factory > factories ( ) { try { factoryLock . acquireRead ( ) ; return new ArrayList < Factory > ( factories ) ; } finally { factoryLock . releaseRead ( ) ; } }
Return a snapshot of the currently registered factories . There is no guarantee that the list will still match the current factory list of the service subsequent to this call .
27,777
public Factory registerObject ( Object obj , String id , boolean visible ) { String canonicalID = createKey ( id ) . canonicalID ( ) ; return registerFactory ( new SimpleFactory ( obj , canonicalID , visible ) ) ; }
Register an object with the provided id . The id will be canonicalized . The canonicalized ID will be returned by getVisibleIDs if visible is true .
27,778
public final Factory registerFactory ( Factory factory ) { if ( factory == null ) { throw new NullPointerException ( ) ; } try { factoryLock . acquireWrite ( ) ; factories . add ( 0 , factory ) ; clearCaches ( ) ; } finally { factoryLock . releaseWrite ( ) ; } notifyChanged ( ) ; return factory ; }
Register a Factory . Returns the factory if the service accepts the factory otherwise returns null . The default implementation accepts all factories .
27,779
public final boolean unregisterFactory ( Factory factory ) { if ( factory == null ) { throw new NullPointerException ( ) ; } boolean result = false ; try { factoryLock . acquireWrite ( ) ; if ( factories . remove ( factory ) ) { result = true ; clearCaches ( ) ; } } finally { factoryLock . releaseWrite ( ) ; } if ( result ) { notifyChanged ( ) ; } return result ; }
Unregister a factory . The first matching registered factory will be removed from the list . Returns true if a matching factory was removed .
27,780
public String stats ( ) { ICURWLock . Stats stats = factoryLock . resetStats ( ) ; if ( stats != null ) { return stats . toString ( ) ; } return "no stats" ; }
When the statistics for this service is already enabled return the log and resets he statistics . When the statistics is not enabled this method enable the statistics . Used for debugging purposes .
27,781
public void calcTargetString ( ) { int whatToShow = getWhatToShow ( ) ; switch ( whatToShow ) { case DTMFilter . SHOW_COMMENT : m_targetString = PsuedoNames . PSEUDONAME_COMMENT ; break ; case DTMFilter . SHOW_TEXT : case DTMFilter . SHOW_CDATA_SECTION : case ( DTMFilter . SHOW_TEXT | DTMFilter . SHOW_CDATA_SECTION ) : m_targetString = PsuedoNames . PSEUDONAME_TEXT ; break ; case DTMFilter . SHOW_ALL : m_targetString = PsuedoNames . PSEUDONAME_ANY ; break ; case DTMFilter . SHOW_DOCUMENT : case DTMFilter . SHOW_DOCUMENT | DTMFilter . SHOW_DOCUMENT_FRAGMENT : m_targetString = PsuedoNames . PSEUDONAME_ROOT ; break ; case DTMFilter . SHOW_ELEMENT : if ( this . WILD == m_name ) m_targetString = PsuedoNames . PSEUDONAME_ANY ; else m_targetString = m_name ; break ; default : m_targetString = PsuedoNames . PSEUDONAME_ANY ; break ; } }
Calculate the local name or psuedo name of the node that this pattern will test for hash table lookup optimization .
27,782
public void setPredicates ( Expression [ ] predicates ) { m_predicates = predicates ; if ( null != predicates ) { for ( int i = 0 ; i < predicates . length ; i ++ ) { predicates [ i ] . exprSetParent ( this ) ; } } calcScore ( ) ; }
Set the predicates for this match pattern step .
27,783
public void calcScore ( ) { if ( ( getPredicateCount ( ) > 0 ) || ( null != m_relativePathPattern ) ) { m_score = SCORE_OTHER ; } else super . calcScore ( ) ; if ( null == m_targetString ) calcTargetString ( ) ; }
Static calc of match score .
27,784
private final boolean checkProximityPosition ( XPathContext xctxt , int predPos , DTM dtm , int context , int pos ) { try { DTMAxisTraverser traverser = dtm . getAxisTraverser ( Axis . PRECEDINGSIBLING ) ; for ( int child = traverser . first ( context ) ; DTM . NULL != child ; child = traverser . next ( context , child ) ) { try { xctxt . pushCurrentNode ( child ) ; if ( NodeTest . SCORE_NONE != super . execute ( xctxt , child ) ) { boolean pass = true ; try { xctxt . pushSubContextList ( this ) ; for ( int i = 0 ; i < predPos ; i ++ ) { xctxt . pushPredicatePos ( i ) ; try { XObject pred = m_predicates [ i ] . execute ( xctxt ) ; try { if ( XObject . CLASS_NUMBER == pred . getType ( ) ) { throw new Error ( "Why: Should never have been called" ) ; } else if ( ! pred . boolWithSideEffects ( ) ) { pass = false ; break ; } } finally { pred . detach ( ) ; } } finally { xctxt . popPredicatePos ( ) ; } } } finally { xctxt . popSubContextList ( ) ; } if ( pass ) pos -- ; if ( pos < 1 ) return false ; } } finally { xctxt . popCurrentNode ( ) ; } } } catch ( javax . xml . transform . TransformerException se ) { throw new java . lang . RuntimeException ( se . getMessage ( ) ) ; } return ( pos == 1 ) ; }
New Method to check whether the current node satisfies a position predicate
27,785
protected final boolean executePredicates ( XPathContext xctxt , DTM dtm , int currentNode ) throws javax . xml . transform . TransformerException { boolean result = true ; boolean positionAlreadySeen = false ; int n = getPredicateCount ( ) ; try { xctxt . pushSubContextList ( this ) ; for ( int i = 0 ; i < n ; i ++ ) { xctxt . pushPredicatePos ( i ) ; try { XObject pred = m_predicates [ i ] . execute ( xctxt ) ; try { if ( XObject . CLASS_NUMBER == pred . getType ( ) ) { int pos = ( int ) pred . num ( ) ; if ( positionAlreadySeen ) { result = ( pos == 1 ) ; break ; } else { positionAlreadySeen = true ; if ( ! checkProximityPosition ( xctxt , i , dtm , currentNode , pos ) ) { result = false ; break ; } } } else if ( ! pred . boolWithSideEffects ( ) ) { result = false ; break ; } } finally { pred . detach ( ) ; } } finally { xctxt . popPredicatePos ( ) ; } } } finally { xctxt . popSubContextList ( ) ; } return result ; }
Execute the predicates on this step to determine if the current node should be filtered or accepted .
27,786
protected void callSubtreeVisitors ( XPathVisitor visitor ) { if ( null != m_predicates ) { int n = m_predicates . length ; for ( int i = 0 ; i < n ; i ++ ) { ExpressionOwner predOwner = new PredOwner ( i ) ; if ( visitor . visitPredicate ( predOwner , m_predicates [ i ] ) ) { m_predicates [ i ] . callVisitors ( predOwner , visitor ) ; } } } if ( null != m_relativePathPattern ) { m_relativePathPattern . callVisitors ( this , visitor ) ; } }
Call the visitors on the subtree . Factored out from callVisitors so it may be called by derived classes .
27,787
public static FileChannel newFileChannel ( Closeable ioObject , FileDescriptor fd , int mode ) { ChannelFactory factory = ChannelFactory . INSTANCE ; if ( factory == null ) { throw new LibraryNotLinkedError ( "Channel support" , "jre_channels" , "JavaNioChannelFactoryImpl" ) ; } return factory . newFileChannel ( ioObject , fd , mode ) ; }
Helps bridge between io and nio .
27,788
public void recompose ( ) throws TransformerException { Vector recomposableElements = new Vector ( ) ; if ( null == m_globalImportList ) { Vector importList = new Vector ( ) ; addImports ( this , true , importList ) ; m_globalImportList = new StylesheetComposed [ importList . size ( ) ] ; for ( int i = 0 , j = importList . size ( ) - 1 ; i < importList . size ( ) ; i ++ ) { m_globalImportList [ j ] = ( StylesheetComposed ) importList . elementAt ( i ) ; m_globalImportList [ j ] . recomposeIncludes ( m_globalImportList [ j ] ) ; m_globalImportList [ j -- ] . recomposeImports ( ) ; } } int n = getGlobalImportCount ( ) ; for ( int i = 0 ; i < n ; i ++ ) { StylesheetComposed imported = getGlobalImport ( i ) ; imported . recompose ( recomposableElements ) ; } QuickSort2 ( recomposableElements , 0 , recomposableElements . size ( ) - 1 ) ; m_outputProperties = new OutputProperties ( org . apache . xml . serializer . Method . UNKNOWN ) ; m_attrSets = new HashMap ( ) ; m_decimalFormatSymbols = new Hashtable ( ) ; m_keyDecls = new Vector ( ) ; m_namespaceAliasComposed = new Hashtable ( ) ; m_templateList = new TemplateList ( ) ; m_variables = new Vector ( ) ; for ( int i = recomposableElements . size ( ) - 1 ; i >= 0 ; i -- ) ( ( ElemTemplateElement ) recomposableElements . elementAt ( i ) ) . recompose ( this ) ; initComposeState ( ) ; m_templateList . compose ( this ) ; m_outputProperties . compose ( this ) ; m_outputProperties . endCompose ( this ) ; n = getGlobalImportCount ( ) ; for ( int i = 0 ; i < n ; i ++ ) { StylesheetComposed imported = this . getGlobalImport ( i ) ; int includedCount = imported . getIncludeCountComposed ( ) ; for ( int j = - 1 ; j < includedCount ; j ++ ) { Stylesheet included = imported . getIncludeComposed ( j ) ; composeTemplates ( included ) ; } } if ( m_extNsMgr != null ) m_extNsMgr . registerUnregisteredNamespaces ( ) ; clearComposeState ( ) ; }
Recompose the values of all composed properties meaning properties that need to be combined or calculated from the combination of imported and included stylesheets . This method determines the proper import precedence of all imported stylesheets . It then iterates through all of the elements and properties in the proper order and triggers the individual recompose methods .
27,789
void composeTemplates ( ElemTemplateElement templ ) throws TransformerException { templ . compose ( this ) ; for ( ElemTemplateElement child = templ . getFirstChildElem ( ) ; child != null ; child = child . getNextSiblingElem ( ) ) { composeTemplates ( child ) ; } templ . endCompose ( this ) ; }
Call the compose function for each ElemTemplateElement .
27,790
public int getImportNumber ( StylesheetComposed sheet ) { if ( this == sheet ) return 0 ; int n = getGlobalImportCount ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( sheet == getGlobalImport ( i ) ) return i ; } return - 1 ; }
Given a stylesheet return the number of the stylesheet in the global import list .
27,791
void recomposeAttributeSets ( ElemAttributeSet attrSet ) { ArrayList attrSetList = ( ArrayList ) m_attrSets . get ( attrSet . getName ( ) ) ; if ( null == attrSetList ) { attrSetList = new ArrayList ( ) ; m_attrSets . put ( attrSet . getName ( ) , attrSetList ) ; } attrSetList . add ( attrSet ) ; }
Recompose the attribute - set declarations .
27,792
void recomposeDecimalFormats ( DecimalFormatProperties dfp ) { DecimalFormatSymbols oldDfs = ( DecimalFormatSymbols ) m_decimalFormatSymbols . get ( dfp . getName ( ) ) ; if ( null == oldDfs ) { m_decimalFormatSymbols . put ( dfp . getName ( ) , dfp . getDecimalFormatSymbols ( ) ) ; } else if ( ! dfp . getDecimalFormatSymbols ( ) . equals ( oldDfs ) ) { String themsg ; if ( dfp . getName ( ) . equals ( new QName ( "" ) ) ) { themsg = XSLMessages . createWarning ( XSLTErrorResources . WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED , new Object [ 0 ] ) ; } else { themsg = XSLMessages . createWarning ( XSLTErrorResources . WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE , new Object [ ] { dfp . getName ( ) } ) ; } error ( themsg ) ; } }
Recompose the decimal - format declarations .
27,793
void recomposeVariables ( ElemVariable elemVar ) { if ( getVariableOrParamComposed ( elemVar . getName ( ) ) == null ) { elemVar . setIsTopLevel ( true ) ; elemVar . setIndex ( m_variables . size ( ) ) ; m_variables . addElement ( elemVar ) ; } }
Recompose the top level variable and parameter declarations .
27,794
void recomposeWhiteSpaceInfo ( WhiteSpaceInfo wsi ) { if ( null == m_whiteSpaceInfoList ) m_whiteSpaceInfoList = new TemplateList ( ) ; m_whiteSpaceInfoList . setTemplate ( wsi ) ; }
Recompose the strip - space and preserve - space declarations .
27,795
private void initDefaultRule ( ErrorListener errorListener ) throws TransformerException { m_defaultRule = new ElemTemplate ( ) ; m_defaultRule . setStylesheet ( this ) ; XPath defMatch = new XPath ( "*" , this , this , XPath . MATCH , errorListener ) ; m_defaultRule . setMatch ( defMatch ) ; ElemApplyTemplates childrenElement = new ElemApplyTemplates ( ) ; childrenElement . setIsDefaultTemplate ( true ) ; childrenElement . setSelect ( m_selectDefault ) ; m_defaultRule . appendChild ( childrenElement ) ; m_startRule = m_defaultRule ; m_defaultTextRule = new ElemTemplate ( ) ; m_defaultTextRule . setStylesheet ( this ) ; defMatch = new XPath ( "text() | @*" , this , this , XPath . MATCH , errorListener ) ; m_defaultTextRule . setMatch ( defMatch ) ; ElemValueOf elemValueOf = new ElemValueOf ( ) ; m_defaultTextRule . appendChild ( elemValueOf ) ; XPath selectPattern = new XPath ( "." , this , this , XPath . SELECT , errorListener ) ; elemValueOf . setSelect ( selectPattern ) ; m_defaultRootRule = new ElemTemplate ( ) ; m_defaultRootRule . setStylesheet ( this ) ; defMatch = new XPath ( "/" , this , this , XPath . MATCH , errorListener ) ; m_defaultRootRule . setMatch ( defMatch ) ; childrenElement = new ElemApplyTemplates ( ) ; childrenElement . setIsDefaultTemplate ( true ) ; m_defaultRootRule . appendChild ( childrenElement ) ; childrenElement . setSelect ( m_selectDefault ) ; }
Create the default rule if needed .
27,796
protected void clearCoRoutine ( SAXException ex ) { if ( null != ex ) m_transformer . setExceptionThrown ( ex ) ; if ( m_dtm instanceof SAX2DTM ) { if ( DEBUG ) System . err . println ( "In clearCoRoutine..." ) ; try { SAX2DTM sax2dtm = ( ( SAX2DTM ) m_dtm ) ; if ( null != m_contentHandler && m_contentHandler instanceof IncrementalSAXSource_Filter ) { IncrementalSAXSource_Filter sp = ( IncrementalSAXSource_Filter ) m_contentHandler ; sp . deliverMoreNodes ( false ) ; } sax2dtm . clearCoRoutine ( true ) ; m_contentHandler = null ; m_dtdHandler = null ; m_entityResolver = null ; m_errorHandler = null ; m_lexicalHandler = null ; } catch ( Throwable throwable ) { throwable . printStackTrace ( ) ; } if ( DEBUG ) System . err . println ( "...exiting clearCoRoutine" ) ; } }
Do what needs to be done to shut down the CoRoutine management .
27,797
public InputSource resolveEntity ( String publicId , String systemId ) throws SAXException , IOException { if ( m_entityResolver != null ) { return m_entityResolver . resolveEntity ( publicId , systemId ) ; } else { return null ; } }
Filter an external entity resolution .
27,798
public void notationDecl ( String name , String publicId , String systemId ) throws SAXException { if ( m_dtdHandler != null ) { m_dtdHandler . notationDecl ( name , publicId , systemId ) ; } }
Filter a notation declaration event .
27,799
public void setDocumentLocator ( Locator locator ) { if ( DEBUG ) System . out . println ( "TransformerHandlerImpl#setDocumentLocator: " + locator . getSystemId ( ) ) ; this . m_locator = locator ; if ( null == m_baseSystemID ) { setSystemId ( locator . getSystemId ( ) ) ; } if ( m_contentHandler != null ) { m_contentHandler . setDocumentLocator ( locator ) ; } }
Filter a new document locator event .