idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
25,900
public static BaseLocale createInstance ( String language , String region ) { BaseLocale base = new BaseLocale ( language , region ) ; CACHE . put ( new Key ( language , region ) , base ) ; return base ; }
validation is performed .
25,901
private void initializeFromReadOnlyPatterns ( DateIntervalInfo dii ) { fFallbackIntervalPattern = dii . fFallbackIntervalPattern ; fFirstDateInPtnIsLaterDate = dii . fFirstDateInPtnIsLaterDate ; fIntervalPatterns = dii . fIntervalPatterns ; fIntervalPatternsReadOnly = true ; }
Initialize this object
25,902
public static PatternInfo genPatternInfo ( String intervalPattern , boolean laterDateFirst ) { int splitPoint = splitPatternInto2Part ( intervalPattern ) ; String firstPart = intervalPattern . substring ( 0 , splitPoint ) ; String secondPart = null ; if ( splitPoint < intervalPattern . length ( ) ) { secondPart = intervalPattern . substring ( splitPoint , intervalPattern . length ( ) ) ; } return new PatternInfo ( firstPart , secondPart , laterDateFirst ) ; }
Break interval patterns as 2 part and save them into pattern info .
25,903
public PatternInfo getIntervalPattern ( String skeleton , int field ) { if ( field > MINIMUM_SUPPORTED_CALENDAR_FIELD ) { throw new IllegalArgumentException ( "no support for field less than SECOND" ) ; } Map < String , PatternInfo > patternsOfOneSkeleton = fIntervalPatterns . get ( skeleton ) ; if ( patternsOfOneSkeleton != null ) { PatternInfo intervalPattern = patternsOfOneSkeleton . get ( CALENDAR_FIELD_TO_PATTERN_LETTER [ field ] ) ; if ( intervalPattern != null ) { return intervalPattern ; } } return null ; }
Get the interval pattern given the largest different calendar field .
25,904
public void setFallbackIntervalPattern ( String fallbackPattern ) { if ( frozen ) { throw new UnsupportedOperationException ( "no modification is allowed after DII is frozen" ) ; } int firstPatternIndex = fallbackPattern . indexOf ( "{0}" ) ; int secondPatternIndex = fallbackPattern . indexOf ( "{1}" ) ; if ( firstPatternIndex == - 1 || secondPatternIndex == - 1 ) { throw new IllegalArgumentException ( "no pattern {0} or pattern {1} in fallbackPattern" ) ; } if ( firstPatternIndex > secondPatternIndex ) { fFirstDateInPtnIsLaterDate = true ; } fFallbackIntervalPattern = fallbackPattern ; }
Re - set the fallback interval pattern .
25,905
static void parseSkeleton ( String skeleton , int [ ] skeletonFieldWidth ) { int PATTERN_CHAR_BASE = 0x41 ; for ( int i = 0 ; i < skeleton . length ( ) ; ++ i ) { ++ skeletonFieldWidth [ skeleton . charAt ( i ) - PATTERN_CHAR_BASE ] ; } }
Parse skeleton save each field s width . It is used for looking for best match skeleton and adjust pattern field width .
25,906
public Map < String , Map < String , PatternInfo > > getRawPatterns ( ) { LinkedHashMap < String , Map < String , PatternInfo > > result = new LinkedHashMap < String , Map < String , PatternInfo > > ( ) ; for ( Entry < String , Map < String , PatternInfo > > entry : fIntervalPatterns . entrySet ( ) ) { result . put ( entry . getKey ( ) , new LinkedHashMap < String , PatternInfo > ( entry . getValue ( ) ) ) ; } return result ; }
Get the internal patterns with a deep clone for safety .
25,907
private void init ( String publicId , String systemId , int lineNumber , int columnNumber ) { this . publicId = publicId ; this . systemId = systemId ; this . lineNumber = lineNumber ; this . columnNumber = columnNumber ; }
Internal initialization method .
25,908
void addExpectedPolicy ( String expectedPolicy ) { if ( isImmutable ) { throw new IllegalStateException ( "PolicyNode is immutable" ) ; } if ( mOriginalExpectedPolicySet ) { mExpectedPolicySet . clear ( ) ; mOriginalExpectedPolicySet = false ; } mExpectedPolicySet . add ( expectedPolicy ) ; }
Adds an expectedPolicy to the expected policy set . If this is the original expected policy set initialized by the constructor then the expected policy set is cleared before the expected policy is added .
25,909
void prune ( int depth ) { if ( isImmutable ) throw new IllegalStateException ( "PolicyNode is immutable" ) ; if ( mChildren . size ( ) == 0 ) return ; Iterator < PolicyNodeImpl > it = mChildren . iterator ( ) ; while ( it . hasNext ( ) ) { PolicyNodeImpl node = it . next ( ) ; node . prune ( depth ) ; if ( ( node . mChildren . size ( ) == 0 ) && ( depth > mDepth + 1 ) ) it . remove ( ) ; } }
Removes all paths which don t reach the specified depth .
25,910
Set < PolicyNodeImpl > getPolicyNodes ( int depth ) { Set < PolicyNodeImpl > set = new HashSet < > ( ) ; getPolicyNodes ( depth , set ) ; return set ; }
Returns all nodes at the specified depth in the tree .
25,911
private void getPolicyNodes ( int depth , Set < PolicyNodeImpl > set ) { if ( mDepth == depth ) { set . add ( this ) ; } else { for ( PolicyNodeImpl node : mChildren ) { node . getPolicyNodes ( depth , set ) ; } } }
Add all nodes at depth depth to set and return the Set . Internal recursion helper .
25,912
Set < PolicyNodeImpl > getPolicyNodesValid ( int depth , String validOID ) { HashSet < PolicyNodeImpl > set = new HashSet < > ( ) ; if ( mDepth < depth ) { for ( PolicyNodeImpl node : mChildren ) { set . addAll ( node . getPolicyNodesValid ( depth , validOID ) ) ; } } else { if ( mValidPolicy . equals ( validOID ) ) set . add ( this ) ; } return set ; }
Finds all nodes at the specified depth that contains the specified valid OID
25,913
String asString ( ) { if ( mParent == null ) { return "anyPolicy ROOT\n" ; } else { StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 , n = getDepth ( ) ; i < n ; i ++ ) { sb . append ( " " ) ; } sb . append ( policyToString ( getValidPolicy ( ) ) ) ; sb . append ( " CRIT: " ) ; sb . append ( isCritical ( ) ) ; sb . append ( " EP: " ) ; for ( String policy : getExpectedPolicies ( ) ) { sb . append ( policyToString ( policy ) ) ; sb . append ( " " ) ; } sb . append ( " (" ) ; sb . append ( getDepth ( ) ) ; sb . append ( ")\n" ) ; return sb . toString ( ) ; } }
Prints out some data on this node .
25,914
Element getElementById ( String name ) { for ( Attr attr : attributes ) { if ( attr . isId ( ) && name . equals ( attr . getValue ( ) ) ) { return this ; } } if ( name . equals ( getAttribute ( "id" ) ) ) { return this ; } for ( NodeImpl node : children ) { if ( node . getNodeType ( ) == Node . ELEMENT_NODE ) { Element element = ( ( ElementImpl ) node ) . getElementById ( name ) ; if ( element != null ) { return element ; } } } return null ; }
This implementation walks the entire document looking for an element with the given ID attribute . We should consider adding an index to speed navigation of large documents .
25,915
private static Locale strip ( Locale locale ) { String language = locale . getLanguage ( ) ; String country = locale . getCountry ( ) ; String variant = locale . getVariant ( ) ; if ( ! variant . isEmpty ( ) ) { variant = "" ; } else if ( ! country . isEmpty ( ) ) { country = "" ; } else if ( ! language . isEmpty ( ) ) { language = "" ; } else { return null ; } return new Locale ( language , country , variant ) ; }
Returns a locale with the most - specific field removed or null if this locale had an empty language country and variant .
25,916
public static byte getBaseDirection ( CharSequence paragraph ) { if ( paragraph == null || paragraph . length ( ) == 0 ) { return NEUTRAL ; } int length = paragraph . length ( ) ; int c ; byte direction ; for ( int i = 0 ; i < length ; ) { c = UCharacter . codePointAt ( paragraph , i ) ; direction = UCharacter . getDirectionality ( c ) ; if ( direction == UCharacterDirection . LEFT_TO_RIGHT ) { return LTR ; } else if ( direction == UCharacterDirection . RIGHT_TO_LEFT || direction == UCharacterDirection . RIGHT_TO_LEFT_ARABIC ) { return RTL ; } i = UCharacter . offsetByCodePoints ( paragraph , i , 1 ) ; } return NEUTRAL ; }
Get the base direction of the text provided according to the Unicode Bidirectional Algorithm . The base direction is derived from the first character in the string with bidirectional character type L R or AL . If the first such character has type L LTR is returned . If the first such character has type R or AL RTL is returned . If the string does not contain any character of these types then NEUTRAL is returned . This is a lightweight function for use when only the base direction is needed and no further bidi processing of the text is needed .
25,917
private byte firstL_R_AL ( ) { byte result = ON ; for ( int i = 0 ; i < prologue . length ( ) ; ) { int uchar = prologue . codePointAt ( i ) ; i += Character . charCount ( uchar ) ; byte dirProp = ( byte ) getCustomizedClass ( uchar ) ; if ( result == ON ) { if ( dirProp == L || dirProp == R || dirProp == AL ) { result = dirProp ; } } else { if ( dirProp == B ) { result = ON ; } } } return result ; }
Returns the directionality of the first strong character after the last B in prologue if any . Requires prologue! = null .
25,918
private byte lastL_R_AL ( ) { for ( int i = prologue . length ( ) ; i > 0 ; ) { int uchar = prologue . codePointBefore ( i ) ; i -= Character . charCount ( uchar ) ; byte dirProp = ( byte ) getCustomizedClass ( uchar ) ; if ( dirProp == L ) { return _L ; } if ( dirProp == R || dirProp == AL ) { return _R ; } if ( dirProp == B ) { return _ON ; } } return _ON ; }
Returns the directionality of the last strong character at the end of the prologue if any . Requires prologue! = null .
25,919
private byte firstL_R_AL_EN_AN ( ) { for ( int i = 0 ; i < epilogue . length ( ) ; ) { int uchar = epilogue . codePointAt ( i ) ; i += Character . charCount ( uchar ) ; byte dirProp = ( byte ) getCustomizedClass ( uchar ) ; if ( dirProp == L ) { return _L ; } if ( dirProp == R || dirProp == AL ) { return _R ; } if ( dirProp == EN ) { return _EN ; } if ( dirProp == AN ) { return _AN ; } } return _ON ; }
Returns the directionality of the first strong character or digit in the epilogue if any . Requires epilogue! = null .
25,920
public BidiRun getParagraphByIndex ( int paraIndex ) { verifyValidParaOrLine ( ) ; verifyRange ( paraIndex , 0 , paraCount ) ; Bidi bidi = paraBidi ; int paraStart ; if ( paraIndex == 0 ) { paraStart = 0 ; } else { paraStart = bidi . paras_limit [ paraIndex - 1 ] ; } BidiRun bidiRun = new BidiRun ( ) ; bidiRun . start = paraStart ; bidiRun . limit = bidi . paras_limit [ paraIndex ] ; bidiRun . level = GetParaLevelAt ( paraStart ) ; return bidiRun ; }
Get a paragraph given the index of this paragraph .
25,921
void getLogicalToVisualRunsMap ( ) { if ( isGoodLogicalToVisualRunsMap ) { return ; } int count = countRuns ( ) ; if ( ( logicalToVisualRunsMap == null ) || ( logicalToVisualRunsMap . length < count ) ) { logicalToVisualRunsMap = new int [ count ] ; } int i ; long [ ] keys = new long [ count ] ; for ( i = 0 ; i < count ; i ++ ) { keys [ i ] = ( ( long ) ( runs [ i ] . start ) << 32 ) + i ; } Arrays . sort ( keys ) ; for ( i = 0 ; i < count ; i ++ ) { logicalToVisualRunsMap [ i ] = ( int ) ( keys [ i ] & 0x00000000FFFFFFFF ) ; } isGoodLogicalToVisualRunsMap = true ; }
Compute the logical to visual run mapping
25,922
public int getRunLevel ( int run ) { verifyValidParaOrLine ( ) ; BidiLine . getRuns ( this ) ; verifyRange ( run , 0 , runCount ) ; getLogicalToVisualRunsMap ( ) ; return runs [ logicalToVisualRunsMap [ run ] ] . level ; }
Return the level of the nth logical run in this line .
25,923
public int getRunStart ( int run ) { verifyValidParaOrLine ( ) ; BidiLine . getRuns ( this ) ; verifyRange ( run , 0 , runCount ) ; getLogicalToVisualRunsMap ( ) ; return runs [ logicalToVisualRunsMap [ run ] ] . start ; }
Return the index of the character at the start of the nth logical run in this line as an offset from the start of the line .
25,924
public int getRunLimit ( int run ) { verifyValidParaOrLine ( ) ; BidiLine . getRuns ( this ) ; verifyRange ( run , 0 , runCount ) ; getLogicalToVisualRunsMap ( ) ; int idx = logicalToVisualRunsMap [ run ] ; int len = idx == 0 ? runs [ idx ] . limit : runs [ idx ] . limit - runs [ idx - 1 ] . limit ; return runs [ idx ] . start + len ; }
Return the index of the character past the end of the nth logical run in this line as an offset from the start of the line . For example this will return the length of the line for the last run on the line .
25,925
public static boolean requiresBidi ( char [ ] text , int start , int limit ) { final int RTLMask = ( 1 << UCharacter . DIRECTIONALITY_RIGHT_TO_LEFT | 1 << UCharacter . DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC | 1 << UCharacter . DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING | 1 << UCharacter . DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE | 1 << UCharacter . DIRECTIONALITY_ARABIC_NUMBER ) ; for ( int i = start ; i < limit ; ++ i ) { if ( ( ( 1 << UCharacter . getDirection ( text [ i ] ) ) & RTLMask ) != 0 ) { return true ; } } return false ; }
Return true if the specified text requires bidi analysis . If this returns false the text will display left - to - right . Clients can then avoid constructing a Bidi object . Text in the Arabic Presentation Forms area of Unicode is presumed to already be shaped and ordered for display and so will not cause this method to return true .
25,926
public static String writeReverse ( String src , int options ) { if ( src == null ) { throw new IllegalArgumentException ( ) ; } if ( src . length ( ) > 0 ) { return BidiWriter . writeReverse ( src , options ) ; } else { return "" ; } }
Reverse a Right - To - Left run of Unicode text .
25,927
private static final int compareInt64AsUnsigned ( long a , long b ) { a += 0x8000000000000000L ; b += 0x8000000000000000L ; if ( a < b ) { return - 1 ; } else if ( a > b ) { return 1 ; } else { return 0 ; } }
Compare two signed long values as if they were unsigned .
25,928
public boolean containsKey ( Object key ) { Object k = maskNull ( key ) ; Object [ ] tab = table ; int len = tab . length ; int i = hash ( k , len ) ; while ( true ) { Object item = tab [ i ] ; if ( item == k ) return true ; if ( item == null ) return false ; i = nextKeyIndex ( i , len ) ; } }
Tests whether the specified object reference is a key in this identity hash map .
25,929
public boolean containsValue ( Object value ) { Object [ ] tab = table ; for ( int i = 1 ; i < tab . length ; i += 2 ) if ( tab [ i ] == value && tab [ i - 1 ] != null ) return true ; return false ; }
Tests whether the specified object reference is a value in this identity hash map .
25,930
private boolean resize ( int newCapacity ) { int newLength = newCapacity * 2 ; Object [ ] oldTable = table ; int oldLength = oldTable . length ; if ( oldLength == 2 * MAXIMUM_CAPACITY ) { if ( size == MAXIMUM_CAPACITY - 1 ) throw new IllegalStateException ( "Capacity exhausted." ) ; return false ; } if ( oldLength >= newLength ) return false ; Object [ ] newTable = new Object [ newLength ] ; for ( int j = 0 ; j < oldLength ; j += 2 ) { Object key = oldTable [ j ] ; if ( key != null ) { Object value = oldTable [ j + 1 ] ; oldTable [ j ] = null ; oldTable [ j + 1 ] = null ; int i = hash ( key , newLength ) ; while ( newTable [ i ] != null ) i = nextKeyIndex ( i , newLength ) ; newTable [ i ] = key ; newTable [ i + 1 ] = value ; } } table = newTable ; return true ; }
Resizes the table if necessary to hold given capacity .
25,931
private boolean removeMapping ( Object key , Object value ) { Object k = maskNull ( key ) ; Object [ ] tab = table ; int len = tab . length ; int i = hash ( k , len ) ; while ( true ) { Object item = tab [ i ] ; if ( item == k ) { if ( tab [ i + 1 ] != value ) return false ; modCount ++ ; size -- ; tab [ i ] = null ; tab [ i + 1 ] = null ; closeDeletion ( i ) ; return true ; } if ( item == null ) return false ; i = nextKeyIndex ( i , len ) ; } }
Removes the specified key - value mapping from the map if it is present .
25,932
private void closeDeletion ( int d ) { Object [ ] tab = table ; int len = tab . length ; Object item ; for ( int i = nextKeyIndex ( d , len ) ; ( item = tab [ i ] ) != null ; i = nextKeyIndex ( i , len ) ) { int r = hash ( item , len ) ; if ( ( i < r && ( r <= d || d <= i ) ) || ( r <= d && d <= i ) ) { tab [ d ] = item ; tab [ d + 1 ] = tab [ i + 1 ] ; tab [ i ] = null ; tab [ i + 1 ] = null ; d = i ; } } }
Rehash all possibly - colliding entries following a deletion . This preserves the linear - probe collision properties required by get put etc .
25,933
private void putForCreate ( K key , V value ) throws java . io . StreamCorruptedException { Object k = maskNull ( key ) ; Object [ ] tab = table ; int len = tab . length ; int i = hash ( k , len ) ; Object item ; while ( ( item = tab [ i ] ) != null ) { if ( item == k ) throw new java . io . StreamCorruptedException ( ) ; i = nextKeyIndex ( i , len ) ; } tab [ i ] = k ; tab [ i + 1 ] = value ; }
The put method for readObject . It does not resize the table update modCount etc .
25,934
public void setAttribute ( String name , Object value ) throws IllegalArgumentException { if ( name . equals ( FEATURE_INCREMENTAL ) ) { if ( value instanceof Boolean ) { m_incremental = ( ( Boolean ) value ) . booleanValue ( ) ; } else if ( value instanceof String ) { m_incremental = ( new Boolean ( ( String ) value ) ) . booleanValue ( ) ; } else { throw new IllegalArgumentException ( XSLMessages . createMessage ( XSLTErrorResources . ER_BAD_VALUE , new Object [ ] { name , value } ) ) ; } } else if ( name . equals ( FEATURE_OPTIMIZE ) ) { if ( value instanceof Boolean ) { m_optimize = ( ( Boolean ) value ) . booleanValue ( ) ; } else if ( value instanceof String ) { m_optimize = ( new Boolean ( ( String ) value ) ) . booleanValue ( ) ; } else { throw new IllegalArgumentException ( XSLMessages . createMessage ( XSLTErrorResources . ER_BAD_VALUE , new Object [ ] { name , value } ) ) ; } } else if ( name . equals ( FEATURE_SOURCE_LOCATION ) ) { if ( value instanceof Boolean ) { m_source_location = ( ( Boolean ) value ) . booleanValue ( ) ; } else if ( value instanceof String ) { m_source_location = ( new Boolean ( ( String ) value ) ) . booleanValue ( ) ; } else { throw new IllegalArgumentException ( XSLMessages . createMessage ( XSLTErrorResources . ER_BAD_VALUE , new Object [ ] { name , value } ) ) ; } } else { throw new IllegalArgumentException ( XSLMessages . createMessage ( XSLTErrorResources . ER_NOT_SUPPORTED , new Object [ ] { name } ) ) ; } }
Allows the user to set specific attributes on the underlying implementation .
25,935
public Object getAttribute ( String name ) throws IllegalArgumentException { if ( name . equals ( FEATURE_INCREMENTAL ) ) { return new Boolean ( m_incremental ) ; } else if ( name . equals ( FEATURE_OPTIMIZE ) ) { return new Boolean ( m_optimize ) ; } else if ( name . equals ( FEATURE_SOURCE_LOCATION ) ) { return new Boolean ( m_source_location ) ; } else throw new IllegalArgumentException ( XSLMessages . createMessage ( XSLTErrorResources . ER_ATTRIB_VALUE_NOT_RECOGNIZED , new Object [ ] { name } ) ) ; }
Allows the user to retrieve specific attributes on the underlying implementation .
25,936
public TransformerHandler newTransformerHandler ( Source src ) throws TransformerConfigurationException { Templates templates = newTemplates ( src ) ; if ( templates == null ) return null ; return newTransformerHandler ( templates ) ; }
Get a TransformerHandler object that can process SAX ContentHandler events into a Result based on the transformation instructions specified by the argument .
25,937
public TransformerHandler newTransformerHandler ( Templates templates ) throws TransformerConfigurationException { try { TransformerImpl transformer = ( TransformerImpl ) templates . newTransformer ( ) ; transformer . setURIResolver ( m_uriResolver ) ; TransformerHandler th = ( TransformerHandler ) transformer . getInputContentHandler ( true ) ; return th ; } catch ( TransformerConfigurationException ex ) { if ( m_errorListener != null ) { try { m_errorListener . fatalError ( ex ) ; return null ; } catch ( TransformerConfigurationException ex1 ) { throw ex1 ; } catch ( TransformerException ex1 ) { throw new TransformerConfigurationException ( ex1 ) ; } } throw ex ; } }
Get a TransformerHandler object that can process SAX ContentHandler events into a Result based on the Templates argument .
25,938
public Transformer newTransformer ( Source source ) throws TransformerConfigurationException { try { Templates tmpl = newTemplates ( source ) ; if ( tmpl == null ) return null ; Transformer transformer = tmpl . newTransformer ( ) ; transformer . setURIResolver ( m_uriResolver ) ; return transformer ; } catch ( TransformerConfigurationException ex ) { if ( m_errorListener != null ) { try { m_errorListener . fatalError ( ex ) ; return null ; } catch ( TransformerConfigurationException ex1 ) { throw ex1 ; } catch ( TransformerException ex1 ) { throw new TransformerConfigurationException ( ex1 ) ; } } throw ex ; } }
Process the source into a Transformer object . Care must be given to know that this object can not be used concurrently in multiple threads .
25,939
public Templates newTemplates ( Source source ) throws TransformerConfigurationException { String baseID = source . getSystemId ( ) ; if ( null != baseID ) { baseID = SystemIDResolver . getAbsoluteURI ( baseID ) ; } if ( source instanceof DOMSource ) { DOMSource dsource = ( DOMSource ) source ; Node node = dsource . getNode ( ) ; if ( null != node ) return processFromNode ( node , baseID ) ; else { String messageStr = XSLMessages . createMessage ( XSLTErrorResources . ER_ILLEGAL_DOMSOURCE_INPUT , null ) ; throw new IllegalArgumentException ( messageStr ) ; } } TemplatesHandler builder = newTemplatesHandler ( ) ; builder . setSystemId ( baseID ) ; try { InputSource isource = SAXSource . sourceToInputSource ( source ) ; isource . setSystemId ( baseID ) ; XMLReader reader = null ; if ( source instanceof SAXSource ) reader = ( ( SAXSource ) source ) . getXMLReader ( ) ; if ( null == reader ) { try { javax . xml . parsers . SAXParserFactory factory = javax . xml . parsers . SAXParserFactory . newInstance ( ) ; factory . setNamespaceAware ( true ) ; if ( m_isSecureProcessing ) { try { factory . setFeature ( XMLConstants . FEATURE_SECURE_PROCESSING , true ) ; } catch ( org . xml . sax . SAXException se ) { } } javax . xml . parsers . SAXParser jaxpParser = factory . newSAXParser ( ) ; reader = jaxpParser . getXMLReader ( ) ; } catch ( javax . xml . parsers . ParserConfigurationException ex ) { throw new org . xml . sax . SAXException ( ex ) ; } catch ( javax . xml . parsers . FactoryConfigurationError ex1 ) { throw new org . xml . sax . SAXException ( ex1 . toString ( ) ) ; } catch ( NoSuchMethodError ex2 ) { } catch ( AbstractMethodError ame ) { } } if ( null == reader ) reader = XMLReaderFactory . createXMLReader ( ) ; reader . setContentHandler ( builder ) ; reader . parse ( isource ) ; } catch ( org . xml . sax . SAXException se ) { if ( m_errorListener != null ) { try { m_errorListener . fatalError ( new TransformerException ( se ) ) ; } catch ( TransformerConfigurationException ex1 ) { throw ex1 ; } catch ( TransformerException ex1 ) { throw new TransformerConfigurationException ( ex1 ) ; } } else { throw new TransformerConfigurationException ( se . getMessage ( ) , se ) ; } } catch ( Exception e ) { if ( m_errorListener != null ) { try { m_errorListener . fatalError ( new TransformerException ( e ) ) ; return null ; } catch ( TransformerConfigurationException ex1 ) { throw ex1 ; } catch ( TransformerException ex1 ) { throw new TransformerConfigurationException ( ex1 ) ; } } else { throw new TransformerConfigurationException ( e . getMessage ( ) , e ) ; } } return builder . getTemplates ( ) ; }
Process the source into a Templates object which is likely a compiled representation of the source . This Templates object may then be used concurrently across multiple threads . Creating a Templates object allows the TransformerFactory to do detailed performance optimization of transformation instructions without penalizing runtime transformation .
25,940
public void setErrorListener ( ErrorListener listener ) throws IllegalArgumentException { if ( null == listener ) throw new IllegalArgumentException ( XSLMessages . createMessage ( XSLTErrorResources . ER_ERRORLISTENER , null ) ) ; m_errorListener = listener ; }
Set an error listener for the TransformerFactory .
25,941
public static Datasubtype isValid ( Datatype datatype , Set < Datasubtype > datasubtypes , String code ) { Map < Datasubtype , ValiditySet > subtable = ValidityData . data . get ( datatype ) ; if ( subtable != null ) { for ( Datasubtype datasubtype : datasubtypes ) { ValiditySet validitySet = subtable . get ( datasubtype ) ; if ( validitySet != null ) { if ( validitySet . contains ( AsciiUtil . toLowerString ( code ) ) ) { return datasubtype ; } } } } return null ; }
Returns the Datasubtype containing the code or null if there is none .
25,942
private void setup ( Parser parser ) { if ( parser == null ) { throw new NullPointerException ( "Parser argument must not be null" ) ; } this . parser = parser ; atts = new AttributesImpl ( ) ; nsSupport = new NamespaceSupport ( ) ; attAdapter = new AttributeListAdapter ( ) ; }
Internal setup method .
25,943
public void setFeature ( String name , boolean value ) throws SAXNotRecognizedException , SAXNotSupportedException { if ( name . equals ( NAMESPACES ) ) { checkNotParsing ( "feature" , name ) ; namespaces = value ; if ( ! namespaces && ! prefixes ) { prefixes = true ; } } else if ( name . equals ( NAMESPACE_PREFIXES ) ) { checkNotParsing ( "feature" , name ) ; prefixes = value ; if ( ! prefixes && ! namespaces ) { namespaces = true ; } } else if ( name . equals ( XMLNS_URIs ) ) { checkNotParsing ( "feature" , name ) ; uris = value ; } else { throw new SAXNotRecognizedException ( "Feature: " + name ) ; } }
Set a feature flag for the parser .
25,944
public boolean getFeature ( String name ) throws SAXNotRecognizedException , SAXNotSupportedException { if ( name . equals ( NAMESPACES ) ) { return namespaces ; } else if ( name . equals ( NAMESPACE_PREFIXES ) ) { return prefixes ; } else if ( name . equals ( XMLNS_URIs ) ) { return uris ; } else { throw new SAXNotRecognizedException ( "Feature: " + name ) ; } }
Check a parser feature flag .
25,945
public void endElement ( String qName ) throws SAXException { if ( ! namespaces ) { if ( contentHandler != null ) { contentHandler . endElement ( "" , "" , qName . intern ( ) ) ; } return ; } String names [ ] = processName ( qName , false , false ) ; if ( contentHandler != null ) { contentHandler . endElement ( names [ 0 ] , names [ 1 ] , names [ 2 ] ) ; Enumeration prefixes = nsSupport . getDeclaredPrefixes ( ) ; while ( prefixes . hasMoreElements ( ) ) { String prefix = ( String ) prefixes . nextElement ( ) ; contentHandler . endPrefixMapping ( prefix ) ; } } nsSupport . popContext ( ) ; }
Adapter implementation method ; do not call . Adapt a SAX1 end element event .
25,946
public void ignorableWhitespace ( char ch [ ] , int start , int length ) throws SAXException { if ( contentHandler != null ) { contentHandler . ignorableWhitespace ( ch , start , length ) ; } }
Adapter implementation method ; do not call . Adapt a SAX1 ignorable whitespace event .
25,947
public void processingInstruction ( String target , String data ) throws SAXException { if ( contentHandler != null ) { contentHandler . processingInstruction ( target , data ) ; } }
Adapter implementation method ; do not call . Adapt a SAX1 processing instruction event .
25,948
private void setupParser ( ) { if ( ! prefixes && ! namespaces ) throw new IllegalStateException ( ) ; nsSupport . reset ( ) ; if ( uris ) nsSupport . setNamespaceDeclUris ( true ) ; if ( entityResolver != null ) { parser . setEntityResolver ( entityResolver ) ; } if ( dtdHandler != null ) { parser . setDTDHandler ( dtdHandler ) ; } if ( errorHandler != null ) { parser . setErrorHandler ( errorHandler ) ; } parser . setDocumentHandler ( this ) ; locator = null ; }
Initialize the parser before each run .
25,949
void reportError ( String message ) throws SAXException { if ( errorHandler != null ) errorHandler . error ( makeException ( message ) ) ; }
Report a non - fatal error .
25,950
private SAXParseException makeException ( String message ) { if ( locator != null ) { return new SAXParseException ( message , locator ) ; } else { return new SAXParseException ( message , null , null , - 1 , - 1 ) ; } }
Construct an exception for the current context .
25,951
private void checkNotParsing ( String type , String name ) throws SAXNotSupportedException { if ( parsing ) { throw new SAXNotSupportedException ( "Cannot change " + type + ' ' + name + " while parsing" ) ; } }
Throw an exception if we are parsing .
25,952
public static boolean isConformantSchemeName ( String p_scheme ) { if ( p_scheme == null || p_scheme . trim ( ) . length ( ) == 0 ) { return false ; } if ( ! isAlpha ( p_scheme . charAt ( 0 ) ) ) { return false ; } char testChar ; for ( int i = 1 ; i < p_scheme . length ( ) ; i ++ ) { testChar = p_scheme . charAt ( i ) ; if ( ! isAlphanum ( testChar ) && SCHEME_CHARACTERS . indexOf ( testChar ) == - 1 ) { return false ; } } return true ; }
Determine whether a scheme conforms to the rules for a scheme name . A scheme is conformant if it starts with an alphanumeric and contains only alphanumerics + - and . .
25,953
private void setBigDecimalDigits ( String stringDigits , int maximumDigits , boolean fixedPoint ) { didRound = false ; set ( stringDigits , stringDigits . length ( ) ) ; round ( fixedPoint ? ( maximumDigits + decimalAt ) : maximumDigits == 0 ? - 1 : maximumDigits ) ; }
Internal method that sets this digit list to represent the given value . The value is given as a String of the format returned by BigDecimal .
25,954
public XObject execute ( XPathContext xctxt , int context ) throws javax . xml . transform . TransformerException { DTMIterator nl = m_functionExpr . asIterator ( xctxt , context ) ; XNumber score = SCORE_NONE ; if ( null != nl ) { int n ; while ( DTM . NULL != ( n = nl . nextNode ( ) ) ) { score = ( n == context ) ? SCORE_OTHER : SCORE_NONE ; if ( score == SCORE_OTHER ) { context = n ; break ; } } } nl . detach ( ) ; return score ; }
Test a node to see if it matches the given node test .
25,955
private void setClassPath ( ) throws IOException { String fullPath = file . getAbsolutePath ( ) ; String rootPath = fullPath . substring ( 0 , fullPath . lastIndexOf ( classFile . getRelativePath ( ) ) ) ; List < File > classPath = new ArrayList < > ( ) ; classPath . add ( new File ( rootPath ) ) ; parserEnv . fileManager ( ) . setLocation ( StandardLocation . CLASS_PATH , classPath ) ; }
Set classpath to the root path of the input file to support typeElement lookup .
25,956
private void convertClassInitializer ( AbstractTypeDeclaration typeDecl ) { EntityDeclaration decl = classFile . getMethod ( "<clinit>" , "()V" ) ; if ( decl == null ) { return ; } MethodTranslator translator = new MethodTranslator ( parserEnv , translationEnv , null , typeDecl , null ) ; Block block = ( Block ) decl . acceptVisitor ( translator , null ) ; for ( Statement stmt : block . getStatements ( ) ) { typeDecl . addClassInitStatement ( stmt . copy ( ) ) ; } }
The clinit method isn t converted into a member element by javac so extract it separately from the classfile .
25,957
protected String toExternalForm ( URL url ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "jar:" ) ; sb . append ( url . getFile ( ) ) ; String ref = url . getRef ( ) ; if ( ref != null ) { sb . append ( ref ) ; } return sb . toString ( ) ; }
Build and return the externalized string representation of url .
25,958
public void encode ( DerOutputStream out ) throws IOException { DerOutputStream seq = new DerOutputStream ( ) ; for ( int i = 0 , n = size ( ) ; i < n ; i ++ ) { get ( i ) . encode ( seq ) ; } out . write ( DerValue . tag_Sequence , seq ) ; }
Encode the GeneralSubtrees .
25,959
private void minimize ( ) { for ( int i = 0 ; i < size ( ) ; i ++ ) { GeneralNameInterface current = getGeneralNameInterface ( i ) ; boolean remove1 = false ; for ( int j = i + 1 ; j < size ( ) ; j ++ ) { GeneralNameInterface subsequent = getGeneralNameInterface ( j ) ; switch ( current . constrains ( subsequent ) ) { case GeneralNameInterface . NAME_DIFF_TYPE : continue ; case GeneralNameInterface . NAME_MATCH : remove1 = true ; break ; case GeneralNameInterface . NAME_NARROWS : remove ( j ) ; j -- ; continue ; case GeneralNameInterface . NAME_WIDENS : remove1 = true ; break ; case GeneralNameInterface . NAME_SAME_TYPE : continue ; } break ; } if ( remove1 ) { remove ( i ) ; i -- ; } } }
minimize this GeneralSubtrees by removing all redundant entries . Internal method used by intersect and reduce .
25,960
private GeneralSubtree createWidestSubtree ( GeneralNameInterface name ) { try { GeneralName newName ; switch ( name . getType ( ) ) { case GeneralNameInterface . NAME_ANY : ObjectIdentifier otherOID = ( ( OtherName ) name ) . getOID ( ) ; newName = new GeneralName ( new OtherName ( otherOID , null ) ) ; break ; case GeneralNameInterface . NAME_RFC822 : newName = new GeneralName ( new RFC822Name ( "" ) ) ; break ; case GeneralNameInterface . NAME_DNS : newName = new GeneralName ( new DNSName ( "" ) ) ; break ; case GeneralNameInterface . NAME_X400 : newName = new GeneralName ( new X400Address ( ( byte [ ] ) null ) ) ; break ; case GeneralNameInterface . NAME_DIRECTORY : newName = new GeneralName ( new X500Name ( "" ) ) ; break ; case GeneralNameInterface . NAME_EDI : newName = new GeneralName ( new EDIPartyName ( "" ) ) ; break ; case GeneralNameInterface . NAME_URI : newName = new GeneralName ( new URIName ( "" ) ) ; break ; case GeneralNameInterface . NAME_IP : newName = new GeneralName ( new IPAddressName ( ( byte [ ] ) null ) ) ; break ; case GeneralNameInterface . NAME_OID : newName = new GeneralName ( new OIDName ( new ObjectIdentifier ( ( int [ ] ) null ) ) ) ; break ; default : throw new IOException ( "Unsupported GeneralNameInterface type: " + name . getType ( ) ) ; } return new GeneralSubtree ( newName , 0 , - 1 ) ; } catch ( IOException e ) { throw new RuntimeException ( "Unexpected error: " + e , e ) ; } }
create a subtree containing an instance of the input name type that widens all other names of that type .
25,961
public void union ( GeneralSubtrees other ) { if ( other != null ) { for ( int i = 0 , n = other . size ( ) ; i < n ; i ++ ) { add ( other . get ( i ) ) ; } minimize ( ) ; } }
construct union of this GeneralSubtrees with other .
25,962
public void reduce ( GeneralSubtrees excluded ) { if ( excluded == null ) { return ; } for ( int i = 0 , n = excluded . size ( ) ; i < n ; i ++ ) { GeneralNameInterface excludedName = excluded . getGeneralNameInterface ( i ) ; for ( int j = 0 ; j < size ( ) ; j ++ ) { GeneralNameInterface permitted = getGeneralNameInterface ( j ) ; switch ( excludedName . constrains ( permitted ) ) { case GeneralNameInterface . NAME_DIFF_TYPE : break ; case GeneralNameInterface . NAME_MATCH : remove ( j ) ; j -- ; break ; case GeneralNameInterface . NAME_NARROWS : remove ( j ) ; j -- ; break ; case GeneralNameInterface . NAME_WIDENS : break ; case GeneralNameInterface . NAME_SAME_TYPE : break ; } } } }
reduce this GeneralSubtrees by contents of another . This function is used in merging excluded NameConstraints with permitted NameConstraints to obtain a minimal form of permitted NameConstraints . It is an optimization and does not affect correctness of the results .
25,963
String getFunctionName ( int funcID ) { if ( funcID < NUM_BUILT_IN_FUNCS ) return m_functions [ funcID ] . getName ( ) ; else return m_functions_customer [ funcID - NUM_BUILT_IN_FUNCS ] . getName ( ) ; }
Return the name of the a function in the static table . Needed to avoid making the table publicly available .
25,964
Function getFunction ( int which ) throws javax . xml . transform . TransformerException { try { if ( which < NUM_BUILT_IN_FUNCS ) return ( Function ) m_functions [ which ] . newInstance ( ) ; else return ( Function ) m_functions_customer [ which - NUM_BUILT_IN_FUNCS ] . newInstance ( ) ; } catch ( IllegalAccessException ex ) { throw new TransformerException ( ex . getMessage ( ) ) ; } catch ( InstantiationException ex ) { throw new TransformerException ( ex . getMessage ( ) ) ; } }
Obtain a new Function object from a function ID .
25,965
Object getFunctionID ( String key ) { Object id = m_functionID_customer . get ( key ) ; if ( null == id ) id = m_functionID . get ( key ) ; return id ; }
Obtain a function ID from a given function name
25,966
public int installFunction ( String name , Class func ) { int funcIndex ; Object funcIndexObj = getFunctionID ( name ) ; if ( null != funcIndexObj ) { funcIndex = ( ( Integer ) funcIndexObj ) . intValue ( ) ; if ( funcIndex < NUM_BUILT_IN_FUNCS ) { funcIndex = m_funcNextFreeIndex ++ ; m_functionID_customer . put ( name , new Integer ( funcIndex ) ) ; } m_functions_customer [ funcIndex - NUM_BUILT_IN_FUNCS ] = func ; } else { funcIndex = m_funcNextFreeIndex ++ ; m_functions_customer [ funcIndex - NUM_BUILT_IN_FUNCS ] = func ; m_functionID_customer . put ( name , new Integer ( funcIndex ) ) ; } return funcIndex ; }
Install a built - in function .
25,967
public boolean functionAvailable ( String methName ) { Object tblEntry = m_functionID . get ( methName ) ; if ( null != tblEntry ) return true ; else { tblEntry = m_functionID_customer . get ( methName ) ; return ( null != tblEntry ) ? true : false ; } }
Tell if a built - in non - namespaced function is available .
25,968
void setExtensionsTable ( StylesheetRoot sroot ) throws javax . xml . transform . TransformerException { try { if ( sroot . getExtensions ( ) != null ) if ( ! sroot . isSecureProcessing ( ) ) m_extensionsTable = new ExtensionsTable ( sroot ) ; } catch ( javax . xml . transform . TransformerException te ) { te . printStackTrace ( ) ; } }
If the stylesheet contains extensions set the extensions table object .
25,969
public boolean functionAvailable ( String ns , String funcName ) throws javax . xml . transform . TransformerException { return getExtensionsTable ( ) . functionAvailable ( ns , funcName ) ; }
== Implementation of the XPath ExtensionsProvider interface .
25,970
public ContentHandler getInputContentHandler ( boolean doDocFrag ) { if ( null == m_inputContentHandler ) { m_inputContentHandler = new TransformerHandlerImpl ( this , doDocFrag , m_urlOfSource ) ; } return m_inputContentHandler ; }
Get a SAX2 ContentHandler for the input .
25,971
public OutputProperties getOutputFormat ( ) { OutputProperties format = ( null == m_outputFormat ) ? getStylesheet ( ) . getOutputComposed ( ) : m_outputFormat ; return format ; }
Get the output properties used for the transformation .
25,972
public void setParameter ( String name , String namespace , Object value ) { VariableStack varstack = getXPathContext ( ) . getVarStack ( ) ; QName qname = new QName ( namespace , name ) ; XObject xobject = XObject . create ( value , getXPathContext ( ) ) ; StylesheetRoot sroot = m_stylesheetRoot ; Vector vars = sroot . getVariablesAndParamsComposed ( ) ; int i = vars . size ( ) ; while ( -- i >= 0 ) { ElemVariable variable = ( ElemVariable ) vars . elementAt ( i ) ; if ( variable . getXSLToken ( ) == Constants . ELEMNAME_PARAMVARIABLE && variable . getName ( ) . equals ( qname ) ) { varstack . setGlobalVariable ( i , xobject ) ; } } }
Set a parameter for the templates .
25,973
public void setParameter ( String name , Object value ) { if ( value == null ) { throw new IllegalArgumentException ( XSLMessages . createMessage ( XSLTErrorResources . ER_INVALID_SET_PARAM_VALUE , new Object [ ] { name } ) ) ; } StringTokenizer tokenizer = new StringTokenizer ( name , "{}" , false ) ; try { String s1 = tokenizer . nextToken ( ) ; String s2 = tokenizer . hasMoreTokens ( ) ? tokenizer . nextToken ( ) : null ; if ( null == m_userParams ) m_userParams = new Vector ( ) ; if ( null == s2 ) { replaceOrPushUserParam ( new QName ( s1 ) , XObject . create ( value , getXPathContext ( ) ) ) ; setParameter ( s1 , null , value ) ; } else { replaceOrPushUserParam ( new QName ( s1 , s2 ) , XObject . create ( value , getXPathContext ( ) ) ) ; setParameter ( s2 , s1 , value ) ; } } catch ( java . util . NoSuchElementException nsee ) { } }
Set a parameter for the transformation .
25,974
private void replaceOrPushUserParam ( QName qname , XObject xval ) { int n = m_userParams . size ( ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { Arg arg = ( Arg ) m_userParams . elementAt ( i ) ; if ( arg . getQName ( ) . equals ( qname ) ) { m_userParams . setElementAt ( new Arg ( qname , xval , true ) , i ) ; return ; } } m_userParams . addElement ( new Arg ( qname , xval , true ) ) ; }
NEEDSDOC Method replaceOrPushUserParam
25,975
public void setParameters ( Properties params ) { clearParameters ( ) ; Enumeration names = params . propertyNames ( ) ; while ( names . hasMoreElements ( ) ) { String name = params . getProperty ( ( String ) names . nextElement ( ) ) ; StringTokenizer tokenizer = new StringTokenizer ( name , "{}" , false ) ; try { String s1 = tokenizer . nextToken ( ) ; String s2 = tokenizer . hasMoreTokens ( ) ? tokenizer . nextToken ( ) : null ; if ( null == s2 ) setParameter ( s1 , null , params . getProperty ( name ) ) ; else setParameter ( s2 , s1 , params . getProperty ( name ) ) ; } catch ( java . util . NoSuchElementException nsee ) { } } }
Set a bag of parameters for the transformation . Note that these will not be additive they will replace the existing set of parameters .
25,976
public void clearParameters ( ) { synchronized ( m_reentryGuard ) { VariableStack varstack = new VariableStack ( ) ; m_xcontext . setVarStack ( varstack ) ; m_userParams = null ; } }
Reset the parameters to a null list .
25,977
public void setContentHandler ( ContentHandler handler ) { if ( handler == null ) { throw new NullPointerException ( XSLMessages . createMessage ( XSLTErrorResources . ER_NULL_CONTENT_HANDLER , null ) ) ; } else { m_outputContentHandler = handler ; if ( null == m_serializationHandler ) { ToXMLSAXHandler h = new ToXMLSAXHandler ( ) ; h . setContentHandler ( handler ) ; h . setTransformer ( this ) ; m_serializationHandler = h ; } else m_serializationHandler . setContentHandler ( handler ) ; } }
Set the content event handler .
25,978
public int transformToGlobalRTF ( ElemTemplateElement templateParent ) throws TransformerException { DTM dtmFrag = m_xcontext . getGlobalRTFDTM ( ) ; return transformToRTF ( templateParent , dtmFrag ) ; }
Given a stylesheet element create a result tree fragment from it s contents . The fragment will also use the shared DTM system but will obtain its space from the global variable pool rather than the dynamic variable stack . This allows late binding of XUnresolvedVariables without the risk that their content will be discarded when the variable stack is popped .
25,979
public String transformToString ( ElemTemplateElement elem ) throws TransformerException { ElemTemplateElement firstChild = elem . getFirstChildElem ( ) ; if ( null == firstChild ) return "" ; if ( elem . hasTextLitOnly ( ) && m_optimizer ) { return ( ( ElemTextLiteral ) firstChild ) . getNodeValue ( ) ; } SerializationHandler savedRTreeHandler = this . m_serializationHandler ; StringWriter sw = ( StringWriter ) m_stringWriterObjectPool . getInstance ( ) ; m_serializationHandler = ( ToTextStream ) m_textResultHandlerObjectPool . getInstance ( ) ; if ( null == m_serializationHandler ) { Serializer serializer = org . apache . xml . serializer . SerializerFactory . getSerializer ( m_textformat . getProperties ( ) ) ; m_serializationHandler = ( SerializationHandler ) serializer ; } m_serializationHandler . setTransformer ( this ) ; m_serializationHandler . setWriter ( sw ) ; String result ; try { executeChildTemplates ( elem , true ) ; this . m_serializationHandler . endDocument ( ) ; result = sw . toString ( ) ; } catch ( org . xml . sax . SAXException se ) { throw new TransformerException ( se ) ; } finally { sw . getBuffer ( ) . setLength ( 0 ) ; try { sw . close ( ) ; } catch ( Exception ioe ) { } m_stringWriterObjectPool . freeInstance ( sw ) ; m_serializationHandler . reset ( ) ; m_textResultHandlerObjectPool . freeInstance ( m_serializationHandler ) ; m_serializationHandler = savedRTreeHandler ; } return result ; }
Take the contents of a template element process it and convert it to a string .
25,980
public void executeChildTemplates ( ElemTemplateElement elem , org . w3c . dom . Node context , QName mode , ContentHandler handler ) throws TransformerException { XPathContext xctxt = m_xcontext ; try { if ( null != mode ) pushMode ( mode ) ; xctxt . pushCurrentNode ( xctxt . getDTMHandleFromNode ( context ) ) ; executeChildTemplates ( elem , handler ) ; } finally { xctxt . popCurrentNode ( ) ; if ( null != mode ) popMode ( ) ; } }
Execute each of the children of a template element . This method is only for extension use .
25,981
public boolean isRecursiveAttrSet ( ElemAttributeSet attrSet ) { if ( null == m_attrSetStack ) { m_attrSetStack = new Stack ( ) ; } if ( ! m_attrSetStack . empty ( ) ) { int loc = m_attrSetStack . search ( attrSet ) ; if ( loc > - 1 ) { return true ; } } return false ; }
Check to see if this is a recursive attribute definition .
25,982
public void setErrorListener ( ErrorListener listener ) throws IllegalArgumentException { synchronized ( m_reentryGuard ) { if ( listener == null ) throw new IllegalArgumentException ( XSLMessages . createMessage ( XSLTErrorResources . ER_NULL_ERROR_HANDLER , null ) ) ; m_errorHandler = listener ; } }
Set the error event listener .
25,983
public void waitTransformThread ( ) throws SAXException { Thread transformThread = this . getTransformThread ( ) ; if ( null != transformThread ) { try { ThreadControllerWrapper . waitThread ( transformThread , this ) ; if ( ! this . hasTransformThreadErrorCatcher ( ) ) { Exception e = this . getExceptionThrown ( ) ; if ( null != e ) { e . printStackTrace ( ) ; throw new org . xml . sax . SAXException ( e ) ; } } this . setTransformThread ( null ) ; } catch ( InterruptedException ie ) { } } }
Used by SourceTreeHandler to wait until the transform completes
25,984
public void run ( ) { m_hasBeenReset = false ; try { try { transformNode ( m_doc ) ; } catch ( Exception e ) { if ( null != m_transformThread ) postExceptionFromThread ( e ) ; else throw new RuntimeException ( e . getMessage ( ) ) ; } finally { if ( m_inputContentHandler instanceof TransformerHandlerImpl ) { ( ( TransformerHandlerImpl ) m_inputContentHandler ) . clearCoRoutine ( ) ; } } } catch ( Exception e ) { if ( null != m_transformThread ) postExceptionFromThread ( e ) ; else throw new RuntimeException ( e . getMessage ( ) ) ; } }
Run the transform thread .
25,985
public void init ( ToXMLSAXHandler h , Transformer transformer , ContentHandler realHandler ) { h . setTransformer ( transformer ) ; h . setContentHandler ( realHandler ) ; }
Initializer method .
25,986
public void write ( Writer writer ) throws IOException { BufferedWriter bw = new BufferedWriter ( writer ) ; if ( vtzlines != null ) { for ( String line : vtzlines ) { if ( line . startsWith ( ICAL_TZURL + COLON ) ) { if ( tzurl != null ) { bw . write ( ICAL_TZURL ) ; bw . write ( COLON ) ; bw . write ( tzurl ) ; bw . write ( NEWLINE ) ; } } else if ( line . startsWith ( ICAL_LASTMOD + COLON ) ) { if ( lastmod != null ) { bw . write ( ICAL_LASTMOD ) ; bw . write ( COLON ) ; bw . write ( getUTCDateTimeString ( lastmod . getTime ( ) ) ) ; bw . write ( NEWLINE ) ; } } else { bw . write ( line ) ; bw . write ( NEWLINE ) ; } } bw . flush ( ) ; } else { String [ ] customProperties = null ; if ( olsonzid != null && ICU_TZVERSION != null ) { customProperties = new String [ 1 ] ; customProperties [ 0 ] = ICU_TZINFO_PROP + COLON + olsonzid + "[" + ICU_TZVERSION + "]" ; } writeZone ( writer , tz , customProperties ) ; } }
Writes RFC2445 VTIMEZONE data for this time zone
25,987
public void write ( Writer writer , long start ) throws IOException { TimeZoneRule [ ] rules = tz . getTimeZoneRules ( start ) ; RuleBasedTimeZone rbtz = new RuleBasedTimeZone ( tz . getID ( ) , ( InitialTimeZoneRule ) rules [ 0 ] ) ; for ( int i = 1 ; i < rules . length ; i ++ ) { rbtz . addTransitionRule ( rules [ i ] ) ; } String [ ] customProperties = null ; if ( olsonzid != null && ICU_TZVERSION != null ) { customProperties = new String [ 1 ] ; customProperties [ 0 ] = ICU_TZINFO_PROP + COLON + olsonzid + "[" + ICU_TZVERSION + "/Partial@" + start + "]" ; } writeZone ( writer , rbtz , customProperties ) ; }
Writes RFC2445 VTIMEZONE data applicable for dates after the specified start time .
25,988
public int getOffset ( int era , int year , int month , int day , int dayOfWeek , int millis ) { long calc = ( year / 400 ) * MILLISECONDS_PER_400_YEARS ; year %= 400 ; calc += year * ( 365 * MILLISECONDS_PER_DAY ) ; calc += ( ( year + 3 ) / 4 ) * MILLISECONDS_PER_DAY ; if ( year > 0 ) { calc -= ( ( year - 1 ) / 100 ) * MILLISECONDS_PER_DAY ; } boolean isLeap = ( year == 0 || ( year % 4 == 0 && year % 100 != 0 ) ) ; int [ ] mlen = isLeap ? LEAP : NORMAL ; calc += mlen [ month ] * MILLISECONDS_PER_DAY ; calc += ( day - 1 ) * MILLISECONDS_PER_DAY ; calc += millis ; calc -= rawOffset ; calc -= UNIX_OFFSET ; return getOffset ( calc ) ; }
This implementation is adapted from libcore s ZoneInfo .
25,989
public XObject execute ( XPathContext xctxt ) throws javax . xml . transform . TransformerException { return operate ( m_right . execute ( xctxt ) ) ; }
Execute the operand and apply the unary operation to the result .
25,990
public String formatDuration ( Object obj ) { javax . xml . datatype . DatatypeConstants . Field inFields [ ] = { javax . xml . datatype . DatatypeConstants . YEARS , javax . xml . datatype . DatatypeConstants . MONTHS , javax . xml . datatype . DatatypeConstants . DAYS , javax . xml . datatype . DatatypeConstants . HOURS , javax . xml . datatype . DatatypeConstants . MINUTES , javax . xml . datatype . DatatypeConstants . SECONDS , } ; TimeUnit outFields [ ] = { TimeUnit . YEAR , TimeUnit . MONTH , TimeUnit . DAY , TimeUnit . HOUR , TimeUnit . MINUTE , TimeUnit . SECOND , } ; javax . xml . datatype . Duration inDuration = ( javax . xml . datatype . Duration ) obj ; Period p = null ; javax . xml . datatype . Duration duration = inDuration ; boolean inPast = false ; if ( inDuration . getSign ( ) < 0 ) { duration = inDuration . negate ( ) ; inPast = true ; } boolean sawNonZero = false ; for ( int i = 0 ; i < inFields . length ; i ++ ) { if ( duration . isSet ( inFields [ i ] ) ) { Number n = duration . getField ( inFields [ i ] ) ; if ( n . intValue ( ) == 0 && ! sawNonZero ) { continue ; } else { sawNonZero = true ; } float floatVal = n . floatValue ( ) ; TimeUnit alternateUnit = null ; float alternateVal = 0 ; if ( outFields [ i ] == TimeUnit . SECOND ) { double fullSeconds = floatVal ; double intSeconds = Math . floor ( floatVal ) ; double millis = ( fullSeconds - intSeconds ) * 1000.0 ; if ( millis > 0.0 ) { alternateUnit = TimeUnit . MILLISECOND ; alternateVal = ( float ) millis ; floatVal = ( float ) intSeconds ; } } if ( p == null ) { p = Period . at ( floatVal , outFields [ i ] ) ; } else { p = p . and ( floatVal , outFields [ i ] ) ; } if ( alternateUnit != null ) { p = p . and ( alternateVal , alternateUnit ) ; } } } if ( p == null ) { return formatDurationFromNow ( 0 ) ; } else { if ( inPast ) { p = p . inPast ( ) ; } else { p = p . inFuture ( ) ; } } return pformatter . format ( p ) ; }
JDK 1 . 5 + only
25,991
public static Calendar getInstance ( TimeZone zone , Locale aLocale ) { return getInstanceInternal ( zone , ULocale . forLocale ( aLocale ) ) ; }
Returns a calendar with the specified time zone and locale .
25,992
public final void set ( int field , int value ) { if ( areFieldsVirtuallySet ) { computeFields ( ) ; } fields [ field ] = value ; if ( nextStamp == STAMP_MAX ) { recalculateStamp ( ) ; } stamp [ field ] = nextStamp ++ ; isTimeSet = areFieldsSet = areFieldsVirtuallySet = false ; }
Sets the time field with the given value .
25,993
private static int gregoYearFromIslamicStart ( int year ) { int cycle , offset , shift = 0 ; if ( year >= 1397 ) { cycle = ( year - 1397 ) / 67 ; offset = ( year - 1397 ) % 67 ; shift = 2 * cycle + ( ( offset >= 33 ) ? 1 : 0 ) ; } else { cycle = ( year - 1396 ) / 67 - 1 ; offset = - ( year - 1396 ) % 67 ; shift = 2 * cycle + ( ( offset <= 33 ) ? 1 : 0 ) ; } return year + 579 - shift ; }
utility function for getRelatedYear
25,994
private static int firstIslamicStartYearFromGrego ( int year ) { int cycle , offset , shift = 0 ; if ( year >= 1977 ) { cycle = ( year - 1977 ) / 65 ; offset = ( year - 1977 ) % 65 ; shift = 2 * cycle + ( ( offset >= 32 ) ? 1 : 0 ) ; } else { cycle = ( year - 1976 ) / 65 - 1 ; offset = - ( year - 1976 ) % 65 ; shift = 2 * cycle + ( ( offset <= 32 ) ? 1 : 0 ) ; } return year - 579 + shift ; }
utility function for setRelatedYear
25,995
public final void clear ( int field ) { if ( areFieldsVirtuallySet ) { computeFields ( ) ; } fields [ field ] = 0 ; stamp [ field ] = UNSET ; isTimeSet = areFieldsSet = areAllFieldsSet = areFieldsVirtuallySet = false ; }
Clears the value in the given time field .
25,996
private long compare ( Object that ) { long thatMs ; if ( that instanceof Calendar ) { thatMs = ( ( Calendar ) that ) . getTimeInMillis ( ) ; } else if ( that instanceof Date ) { thatMs = ( ( Date ) that ) . getTime ( ) ; } else { throw new IllegalArgumentException ( that + "is not a Calendar or Date" ) ; } return getTimeInMillis ( ) - thatMs ; }
Returns the difference in milliseconds between the moment this calendar is set to and the moment the given calendar or Date object is set to .
25,997
protected void prepareGetActual ( int field , boolean isMinimum ) { set ( MILLISECONDS_IN_DAY , 0 ) ; switch ( field ) { case YEAR : case EXTENDED_YEAR : set ( DAY_OF_YEAR , getGreatestMinimum ( DAY_OF_YEAR ) ) ; break ; case YEAR_WOY : set ( WEEK_OF_YEAR , getGreatestMinimum ( WEEK_OF_YEAR ) ) ; break ; case MONTH : set ( DAY_OF_MONTH , getGreatestMinimum ( DAY_OF_MONTH ) ) ; break ; case DAY_OF_WEEK_IN_MONTH : set ( DAY_OF_MONTH , 1 ) ; set ( DAY_OF_WEEK , get ( DAY_OF_WEEK ) ) ; break ; case WEEK_OF_MONTH : case WEEK_OF_YEAR : { int dow = firstDayOfWeek ; if ( isMinimum ) { dow = ( dow + 6 ) % 7 ; if ( dow < SUNDAY ) { dow += 7 ; } } set ( DAY_OF_WEEK , dow ) ; } break ; } set ( field , getGreatestMinimum ( field ) ) ; }
Prepare this calendar for computing the actual minimum or maximum . This method modifies this calendar s fields ; it is called on a temporary calendar .
25,998
private static PatternData getPatternData ( ULocale locale , String calType ) { ICUResourceBundle rb = ( ICUResourceBundle ) UResourceBundle . getBundleInstance ( ICUData . ICU_BASE_NAME , locale ) ; ICUResourceBundle dtPatternsRb = rb . findWithFallback ( "calendar/" + calType + "/DateTimePatterns" ) ; if ( dtPatternsRb == null ) { dtPatternsRb = rb . getWithFallback ( "calendar/gregorian/DateTimePatterns" ) ; } int patternsSize = dtPatternsRb . getSize ( ) ; String [ ] dateTimePatterns = new String [ patternsSize ] ; String [ ] dateTimePatternsOverrides = new String [ patternsSize ] ; for ( int i = 0 ; i < patternsSize ; i ++ ) { ICUResourceBundle concatenationPatternRb = ( ICUResourceBundle ) dtPatternsRb . get ( i ) ; switch ( concatenationPatternRb . getType ( ) ) { case UResourceBundle . STRING : dateTimePatterns [ i ] = concatenationPatternRb . getString ( ) ; break ; case UResourceBundle . ARRAY : dateTimePatterns [ i ] = concatenationPatternRb . getString ( 0 ) ; dateTimePatternsOverrides [ i ] = concatenationPatternRb . getString ( 1 ) ; break ; } } return new PatternData ( dateTimePatterns , dateTimePatternsOverrides ) ; }
Retrieves the DateTime patterns and overrides from the resource bundle and generates a new PatternData object .
25,999
public void setMinimalDaysInFirstWeek ( int value ) { if ( value < 1 ) { value = 1 ; } else if ( value > 7 ) { value = 7 ; } if ( minimalDaysInFirstWeek != value ) { minimalDaysInFirstWeek = value ; areFieldsSet = false ; } }
Sets what the minimal days required in the first week of the year are . For example if the first week is defined as one that contains the first day of the first month of a year call the method with value 1 . If it must be a full week use value 7 .