idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
26,200 | protected BitArray getKey ( ) { this . bitStringKey = new BitArray ( this . key . length * 8 - this . unusedBits , this . key ) ; return ( BitArray ) bitStringKey . clone ( ) ; } | Gets the key . The key may or may not be byte aligned . |
26,201 | public static PublicKey parse ( DerValue in ) throws IOException { AlgorithmId algorithm ; PublicKey subjectKey ; if ( in . tag != DerValue . tag_Sequence ) throw new IOException ( "corrupt subject key" ) ; algorithm = AlgorithmId . parse ( in . data . getDerValue ( ) ) ; try { subjectKey = buildX509Key ( algorithm , in . data . getUnalignedBitString ( ) ) ; } catch ( InvalidKeyException e ) { throw new IOException ( "subject key, " + e . getMessage ( ) , e ) ; } if ( in . data . available ( ) != 0 ) throw new IOException ( "excess subject key" ) ; return subjectKey ; } | Construct X . 509 subject public key from a DER value . If the runtime environment is configured with a specific class for this kind of key a subclass is returned . Otherwise a generic X509Key object is returned . |
26,202 | private void readObject ( ObjectInputStream stream ) throws IOException { try { decode ( stream ) ; } catch ( InvalidKeyException e ) { e . printStackTrace ( ) ; throw new IOException ( "deserialized key is invalid: " + e . getMessage ( ) ) ; } } | Serialization read ... X . 509 keys serialize as themselves and they re parsed when they get read back . |
26,203 | public void valid ( Date now ) throws CertificateNotYetValidException , CertificateExpiredException { if ( notBefore . after ( now ) ) { throw new CertificateNotYetValidException ( "NotBefore: " + notBefore . toString ( ) ) ; } if ( notAfter . before ( now ) ) { throw new CertificateExpiredException ( "NotAfter: " + notAfter . toString ( ) ) ; } } | Verify that that the passed time is within the validity period . |
26,204 | public boolean getFeature ( String name ) throws SAXNotRecognizedException , SAXNotSupportedException { if ( name == null ) { throw new NullPointerException ( "name == null" ) ; } throw new SAXNotRecognizedException ( name ) ; } | Look up the value of a feature flag . |
26,205 | public void setFeature ( String name , boolean value ) throws SAXNotRecognizedException , SAXNotSupportedException { if ( name == null ) { throw new NullPointerException ( "name == null" ) ; } throw new SAXNotRecognizedException ( name ) ; } | Set the value of a feature flag . |
26,206 | private final void internalBuildTailoring ( String rules ) throws Exception { CollationTailoring base = CollationRoot . getRoot ( ) ; ClassLoader classLoader = ClassLoaderUtil . getClassLoader ( getClass ( ) ) ; CollationTailoring t ; try { Class < ? > builderClass = classLoader . loadClass ( "android.icu.impl.coll.CollationBuilder" ) ; Object builder = builderClass . getConstructor ( CollationTailoring . class ) . newInstance ( base ) ; Method parseAndBuild = builderClass . getMethod ( "parseAndBuild" , String . class ) ; t = ( CollationTailoring ) parseAndBuild . invoke ( builder , rules ) ; } catch ( InvocationTargetException e ) { throw ( Exception ) e . getTargetException ( ) ; } t . actualLocale = null ; adoptTailoring ( t ) ; } | Implements from - rule constructors . |
26,207 | public CollationElementIterator getCollationElementIterator ( CharacterIterator source ) { initMaxExpansions ( ) ; CharacterIterator newsource = ( CharacterIterator ) source . clone ( ) ; return new CollationElementIterator ( newsource , this ) ; } | Return a CollationElementIterator for the given CharacterIterator . The source iterator s integrity will be preserved since a new copy will be created for use . |
26,208 | public Collator freeze ( ) { if ( ! isFrozen ( ) ) { frozenLock = new ReentrantLock ( ) ; if ( collationBuffer == null ) { collationBuffer = new CollationBuffer ( data ) ; } } return this ; } | Freezes the collator . |
26,209 | public RuleBasedCollator cloneAsThawed ( ) { try { RuleBasedCollator result = ( RuleBasedCollator ) super . clone ( ) ; result . settings = settings . clone ( ) ; result . collationBuffer = null ; result . frozenLock = null ; return result ; } catch ( CloneNotSupportedException e ) { return null ; } } | Provides for the clone operation . Any clone is initially unfrozen . |
26,210 | public void setUpperCaseFirst ( boolean upperfirst ) { checkNotFrozen ( ) ; if ( upperfirst == isUpperCaseFirst ( ) ) { return ; } CollationSettings ownedSettings = getOwnedSettings ( ) ; ownedSettings . setCaseFirst ( upperfirst ? CollationSettings . CASE_FIRST_AND_UPPER_MASK : 0 ) ; setFastLatinOptions ( ownedSettings ) ; } | Sets whether uppercase characters sort before lowercase characters or vice versa in strength TERTIARY . The default mode is false and so lowercase characters sort before uppercase characters . If true sort upper case characters first . |
26,211 | public void setLowerCaseFirst ( boolean lowerfirst ) { checkNotFrozen ( ) ; if ( lowerfirst == isLowerCaseFirst ( ) ) { return ; } CollationSettings ownedSettings = getOwnedSettings ( ) ; ownedSettings . setCaseFirst ( lowerfirst ? CollationSettings . CASE_FIRST : 0 ) ; setFastLatinOptions ( ownedSettings ) ; } | Sets the orders of lower cased characters to sort before upper cased characters in strength TERTIARY . The default mode is false . If true is set the RuleBasedCollator will sort lower cased characters before the upper cased ones . Otherwise if false is set the RuleBasedCollator will ignore case preferences . |
26,212 | public void setNumericCollationDefault ( ) { checkNotFrozen ( ) ; CollationSettings defaultSettings = getDefaultSettings ( ) ; if ( settings . readOnly ( ) == defaultSettings ) { return ; } CollationSettings ownedSettings = getOwnedSettings ( ) ; ownedSettings . setFlagDefault ( CollationSettings . NUMERIC , defaultSettings . options ) ; setFastLatinOptions ( ownedSettings ) ; } | Method to set numeric collation to its default value . |
26,213 | public void setDecomposition ( int decomposition ) { checkNotFrozen ( ) ; boolean flag ; switch ( decomposition ) { case NO_DECOMPOSITION : flag = false ; break ; case CANONICAL_DECOMPOSITION : flag = true ; break ; default : throw new IllegalArgumentException ( "Wrong decomposition mode." ) ; } if ( flag == settings . readOnly ( ) . getFlag ( CollationSettings . CHECK_FCD ) ) { return ; } CollationSettings ownedSettings = getOwnedSettings ( ) ; ownedSettings . setFlag ( CollationSettings . CHECK_FCD , flag ) ; setFastLatinOptions ( ownedSettings ) ; } | Sets the decomposition mode of this Collator . Setting this decomposition attribute with CANONICAL_DECOMPOSITION allows the Collator to handle un - normalized text properly producing the same results as if the text were normalized . If NO_DECOMPOSITION is set it is the user s responsibility to insure that all text is already in the appropriate form before a comparison or before getting a CollationKey . Adjusting decomposition mode allows the user to select between faster and more complete collation behavior . |
26,214 | public void setStrength ( int newStrength ) { checkNotFrozen ( ) ; if ( newStrength == getStrength ( ) ) { return ; } CollationSettings ownedSettings = getOwnedSettings ( ) ; ownedSettings . setStrength ( newStrength ) ; setFastLatinOptions ( ownedSettings ) ; } | Sets this Collator s strength attribute . The strength attribute determines the minimum level of difference considered significant during comparison . |
26,215 | public UnicodeSet getTailoredSet ( ) { UnicodeSet tailored = new UnicodeSet ( ) ; if ( data . base != null ) { new TailoredSet ( tailored ) . forData ( data ) ; } return tailored ; } | Get a UnicodeSet that contains all the characters and sequences tailored in this collator . |
26,216 | void internalAddContractions ( int c , UnicodeSet set ) { new ContractionsAndExpansions ( set , null , null , false ) . forCodePoint ( data , c ) ; } | Adds the contractions that start with character c to the set . Ignores prefixes . Used by AlphabeticIndex . |
26,217 | public RawCollationKey getRawCollationKey ( String source , RawCollationKey key ) { if ( source == null ) { return null ; } CollationBuffer buffer = null ; try { buffer = getCollationBuffer ( ) ; return getRawCollationKey ( source , key , buffer ) ; } finally { releaseCollationBuffer ( buffer ) ; } } | Gets the simpler form of a CollationKey for the String source following the rules of this Collator and stores the result into the user provided argument key . If key has a internal byte array of length that s too small for the result the internal byte array will be grown to the exact required size . |
26,218 | public long [ ] internalGetCEs ( CharSequence str ) { CollationBuffer buffer = null ; try { buffer = getCollationBuffer ( ) ; boolean numeric = settings . readOnly ( ) . isNumeric ( ) ; CollationIterator iter ; if ( settings . readOnly ( ) . dontCheckFCD ( ) ) { buffer . leftUTF16CollIter . setText ( numeric , str , 0 ) ; iter = buffer . leftUTF16CollIter ; } else { buffer . leftFCDUTF16Iter . setText ( numeric , str , 0 ) ; iter = buffer . leftFCDUTF16Iter ; } int length = iter . fetchCEs ( ) - 1 ; assert length >= 0 && iter . getCE ( length ) == Collation . NO_CE ; long [ ] ces = new long [ length ] ; System . arraycopy ( iter . getCEs ( ) , 0 , ces , 0 , length ) ; return ces ; } finally { releaseCollationBuffer ( buffer ) ; } } | Returns the CEs for the string . |
26,219 | public VersionInfo getVersion ( ) { int version = tailoring . version ; int rtVersion = VersionInfo . UCOL_RUNTIME_VERSION . getMajor ( ) ; return VersionInfo . getInstance ( ( version >>> 24 ) + ( rtVersion << 4 ) + ( rtVersion >> 4 ) , ( ( version >> 16 ) & 0xff ) , ( ( version >> 8 ) & 0xff ) , ( version & 0xff ) ) ; } | Get the version of this collator object . |
26,220 | public VersionInfo getUCAVersion ( ) { VersionInfo v = getVersion ( ) ; return VersionInfo . getInstance ( v . getMinor ( ) >> 3 , v . getMinor ( ) & 7 , v . getMilli ( ) >> 6 , 0 ) ; } | Get the UCA version of this collator object . |
26,221 | public void decodeBuffer ( InputStream aStream , OutputStream bStream ) throws IOException { int i ; int totalBytes = 0 ; PushbackInputStream ps = new PushbackInputStream ( aStream ) ; decodeBufferPrefix ( ps , bStream ) ; while ( true ) { int length ; try { length = decodeLinePrefix ( ps , bStream ) ; for ( i = 0 ; ( i + bytesPerAtom ( ) ) < length ; i += bytesPerAtom ( ) ) { decodeAtom ( ps , bStream , bytesPerAtom ( ) ) ; totalBytes += bytesPerAtom ( ) ; } if ( ( i + bytesPerAtom ( ) ) == length ) { decodeAtom ( ps , bStream , bytesPerAtom ( ) ) ; totalBytes += bytesPerAtom ( ) ; } else { decodeAtom ( ps , bStream , length - i ) ; totalBytes += ( length - i ) ; } decodeLineSuffix ( ps , bStream ) ; } catch ( CEStreamExhausted e ) { break ; } } decodeBufferSuffix ( ps , bStream ) ; } | Decode the text from the InputStream and write the decoded octets to the OutputStream . This method runs until the stream is exhausted . |
26,222 | public byte decodeBuffer ( String inputString ) [ ] throws IOException { byte inputBuffer [ ] = new byte [ inputString . length ( ) ] ; ByteArrayInputStream inStream ; ByteArrayOutputStream outStream ; inputString . getBytes ( 0 , inputString . length ( ) , inputBuffer , 0 ) ; inStream = new ByteArrayInputStream ( inputBuffer ) ; outStream = new ByteArrayOutputStream ( ) ; decodeBuffer ( inStream , outStream ) ; return ( outStream . toByteArray ( ) ) ; } | Alternate decode interface that takes a String containing the encoded buffer and returns a byte array containing the data . |
26,223 | public byte decodeBuffer ( InputStream in ) [ ] throws IOException { ByteArrayOutputStream outStream = new ByteArrayOutputStream ( ) ; decodeBuffer ( in , outStream ) ; return ( outStream . toByteArray ( ) ) ; } | Decode the contents of the inputstream into a buffer . |
26,224 | protected void closeCDATA ( ) throws org . xml . sax . SAXException { try { m_writer . write ( CDATA_DELIMITER_CLOSE ) ; m_cdataTagOpen = false ; } catch ( IOException e ) { throw new SAXException ( e ) ; } } | This helper method to writes out ]] > when closing a CDATA section . |
26,225 | protected final void flushWriter ( ) throws org . xml . sax . SAXException { final java . io . Writer writer = m_writer ; if ( null != writer ) { try { if ( writer instanceof WriterToUTF8Buffered ) { if ( m_shouldFlush ) ( ( WriterToUTF8Buffered ) writer ) . flush ( ) ; else ( ( WriterToUTF8Buffered ) writer ) . flushBuffer ( ) ; } if ( writer instanceof WriterToASCI ) { if ( m_shouldFlush ) writer . flush ( ) ; } else { writer . flush ( ) ; } } catch ( IOException ioe ) { throw new org . xml . sax . SAXException ( ioe ) ; } } } | Flush the formatter s result stream . |
26,226 | public Properties getOutputFormat ( ) { Properties def = new Properties ( ) ; { Set s = getOutputPropDefaultKeys ( ) ; Iterator i = s . iterator ( ) ; while ( i . hasNext ( ) ) { String key = ( String ) i . next ( ) ; String val = getOutputPropertyDefault ( key ) ; def . put ( key , val ) ; } } Properties props = new Properties ( def ) ; { Set s = getOutputPropKeys ( ) ; Iterator i = s . iterator ( ) ; while ( i . hasNext ( ) ) { String key = ( String ) i . next ( ) ; String val = getOutputPropertyNonDefault ( key ) ; if ( val != null ) props . put ( key , val ) ; } } return props ; } | Returns the output format for this serializer . |
26,227 | protected boolean escapingNotNeeded ( char ch ) { final boolean ret ; if ( ch < 127 ) { if ( ch >= CharInfo . S_SPACE || ( CharInfo . S_LINEFEED == ch || CharInfo . S_CARRIAGERETURN == ch || CharInfo . S_HORIZONAL_TAB == ch ) ) ret = true ; else ret = false ; } else { ret = m_encodingInfo . isInEncoding ( ch ) ; } return ret ; } | Tell if this character can be written without escaping . |
26,228 | int accumDefaultEntity ( java . io . Writer writer , char ch , int i , char [ ] chars , int len , boolean fromTextNode , boolean escLF ) throws IOException { if ( ! escLF && CharInfo . S_LINEFEED == ch ) { writer . write ( m_lineSep , 0 , m_lineSepLen ) ; } else { if ( ( fromTextNode && m_charInfo . shouldMapTextChar ( ch ) ) || ( ! fromTextNode && m_charInfo . shouldMapAttrChar ( ch ) ) ) { String outputStringForChar = m_charInfo . getOutputStringForChar ( ch ) ; if ( null != outputStringForChar ) { writer . write ( outputStringForChar ) ; } else return i ; } else return i ; } return i + 1 ; } | Handle one of the default entities return false if it is not a default entity . |
26,229 | void writeNormalizedChars ( char ch [ ] , int start , int length , boolean isCData , boolean useSystemLineSeparator ) throws IOException , org . xml . sax . SAXException { final java . io . Writer writer = m_writer ; int end = start + length ; for ( int i = start ; i < end ; i ++ ) { char c = ch [ i ] ; if ( CharInfo . S_LINEFEED == c && useSystemLineSeparator ) { writer . write ( m_lineSep , 0 , m_lineSepLen ) ; } else if ( isCData && ( ! escapingNotNeeded ( c ) ) ) { if ( m_cdataTagOpen ) closeCDATA ( ) ; if ( Encodings . isHighUTF16Surrogate ( c ) ) { writeUTF16Surrogate ( c , ch , i , end ) ; i ++ ; } else { writer . write ( "&#" ) ; String intStr = Integer . toString ( ( int ) c ) ; writer . write ( intStr ) ; writer . write ( ';' ) ; } } else if ( isCData && ( ( i < ( end - 2 ) ) && ( ']' == c ) && ( ']' == ch [ i + 1 ] ) && ( '>' == ch [ i + 2 ] ) ) ) { writer . write ( CDATA_CONTINUE ) ; i += 2 ; } else { if ( escapingNotNeeded ( c ) ) { if ( isCData && ! m_cdataTagOpen ) { writer . write ( CDATA_DELIMITER_OPEN ) ; m_cdataTagOpen = true ; } writer . write ( c ) ; } else if ( Encodings . isHighUTF16Surrogate ( c ) ) { if ( m_cdataTagOpen ) closeCDATA ( ) ; writeUTF16Surrogate ( c , ch , i , end ) ; i ++ ; } else { if ( m_cdataTagOpen ) closeCDATA ( ) ; writer . write ( "&#" ) ; String intStr = Integer . toString ( ( int ) c ) ; writer . write ( intStr ) ; writer . write ( ';' ) ; } } } } | Normalize the characters but don t escape . |
26,230 | private int processDirty ( char [ ] chars , int end , int i , char ch , int lastDirty , boolean fromTextNode ) throws IOException { int startClean = lastDirty + 1 ; if ( i > startClean ) { int lengthClean = i - startClean ; m_writer . write ( chars , startClean , lengthClean ) ; } if ( CharInfo . S_LINEFEED == ch && fromTextNode ) { m_writer . write ( m_lineSep , 0 , m_lineSepLen ) ; } else { startClean = accumDefaultEscape ( m_writer , ( char ) ch , i , chars , end , fromTextNode , false ) ; i = startClean - 1 ; } return i ; } | Process a dirty character and any preeceding clean characters that were not yet processed . |
26,231 | private int accumDefaultEscape ( Writer writer , char ch , int i , char [ ] chars , int len , boolean fromTextNode , boolean escLF ) throws IOException { int pos = accumDefaultEntity ( writer , ch , i , chars , len , fromTextNode , escLF ) ; if ( i == pos ) { if ( Encodings . isHighUTF16Surrogate ( ch ) ) { char next ; int codePoint = 0 ; if ( i + 1 >= len ) { throw new IOException ( Utils . messages . createMessage ( MsgKey . ER_INVALID_UTF16_SURROGATE , new Object [ ] { Integer . toHexString ( ch ) } ) ) ; } else { next = chars [ ++ i ] ; if ( ! ( Encodings . isLowUTF16Surrogate ( next ) ) ) throw new IOException ( Utils . messages . createMessage ( MsgKey . ER_INVALID_UTF16_SURROGATE , new Object [ ] { Integer . toHexString ( ch ) + " " + Integer . toHexString ( next ) } ) ) ; codePoint = Encodings . toCodePoint ( ch , next ) ; } writer . write ( "&#" ) ; writer . write ( Integer . toString ( codePoint ) ) ; writer . write ( ';' ) ; pos += 2 ; } else { if ( isCharacterInC0orC1Range ( ch ) || isNELorLSEPCharacter ( ch ) ) { writer . write ( "&#" ) ; writer . write ( Integer . toString ( ch ) ) ; writer . write ( ';' ) ; } else if ( ( ! escapingNotNeeded ( ch ) || ( ( fromTextNode && m_charInfo . shouldMapTextChar ( ch ) ) || ( ! fromTextNode && m_charInfo . shouldMapAttrChar ( ch ) ) ) ) && m_elemContext . m_currentElemDepth > 0 ) { writer . write ( "&#" ) ; writer . write ( Integer . toString ( ch ) ) ; writer . write ( ';' ) ; } else { writer . write ( ch ) ; } pos ++ ; } } return pos ; } | Escape and writer . write a character . |
26,232 | public void startElement ( String elementNamespaceURI , String elementLocalName , String elementName ) throws SAXException { startElement ( elementNamespaceURI , elementLocalName , elementName , null ) ; } | Receive notification of the beginning of an element additional namespace or attribute information can occur before or after this call that is associated with this element . |
26,233 | public void startPrefixMapping ( String prefix , String uri ) throws org . xml . sax . SAXException { startPrefixMapping ( prefix , uri , true ) ; } | Begin the scope of a prefix - URI Namespace mapping just before another element is about to start . This call will close any open tags so that the prefix mapping will not apply to the current element but the up comming child . |
26,234 | public void startEntity ( String name ) throws org . xml . sax . SAXException { if ( name . equals ( "[dtd]" ) ) m_inExternalDTD = true ; if ( ! m_expandDTDEntities && ! m_inExternalDTD ) { startNonEscaping ( ) ; characters ( "&" + name + ';' ) ; endNonEscaping ( ) ; } m_inEntityRef = true ; } | Report the beginning of an entity . |
26,235 | public void setCdataSectionElements ( Vector URI_and_localNames ) { if ( URI_and_localNames != null ) { final int len = URI_and_localNames . size ( ) - 1 ; if ( len > 0 ) { final StringBuffer sb = new StringBuffer ( ) ; for ( int i = 0 ; i < len ; i += 2 ) { if ( i != 0 ) sb . append ( ' ' ) ; final String uri = ( String ) URI_and_localNames . elementAt ( i ) ; final String localName = ( String ) URI_and_localNames . elementAt ( i + 1 ) ; if ( uri != null ) { sb . append ( '{' ) ; sb . append ( uri ) ; sb . append ( '}' ) ; } sb . append ( localName ) ; } m_StringOfCDATASections = sb . toString ( ) ; } } initCdataElems ( m_StringOfCDATASections ) ; } | Remembers the cdata sections specified in the cdata - section - elements . The official way to set URI and localName pairs . This method should be used by both Xalan and XSLTC . |
26,236 | protected String ensureAttributesNamespaceIsDeclared ( String ns , String localName , String rawName ) throws org . xml . sax . SAXException { if ( ns != null && ns . length ( ) > 0 ) { int index = 0 ; String prefixFromRawName = ( index = rawName . indexOf ( ":" ) ) < 0 ? "" : rawName . substring ( 0 , index ) ; if ( index > 0 ) { String uri = m_prefixMap . lookupNamespace ( prefixFromRawName ) ; if ( uri != null && uri . equals ( ns ) ) { return null ; } else { this . startPrefixMapping ( prefixFromRawName , ns , false ) ; this . addAttribute ( "http://www.w3.org/2000/xmlns/" , prefixFromRawName , "xmlns:" + prefixFromRawName , "CDATA" , ns , false ) ; return prefixFromRawName ; } } else { String prefix = m_prefixMap . lookupPrefix ( ns ) ; if ( prefix == null ) { prefix = m_prefixMap . generateNextPrefix ( ) ; this . startPrefixMapping ( prefix , ns , false ) ; this . addAttribute ( "http://www.w3.org/2000/xmlns/" , prefix , "xmlns:" + prefix , "CDATA" , ns , false ) ; } return prefix ; } } return null ; } | Makes sure that the namespace URI for the given qualified attribute name is declared . |
26,237 | protected void firePseudoAttributes ( ) { if ( m_tracer != null ) { try { m_writer . flush ( ) ; StringBuffer sb = new StringBuffer ( ) ; int nAttrs = m_attributes . getLength ( ) ; if ( nAttrs > 0 ) { java . io . Writer writer = new ToStream . WritertoStringBuffer ( sb ) ; processAttributes ( writer , nAttrs ) ; } sb . append ( '>' ) ; char ch [ ] = sb . toString ( ) . toCharArray ( ) ; m_tracer . fireGenerateEvent ( SerializerTrace . EVENTTYPE_OUTPUT_PSEUDO_CHARACTERS , ch , 0 , ch . length ) ; } catch ( IOException ioe ) { } catch ( SAXException se ) { } } } | To fire off the pseudo characters of attributes as they currently exist . This method should be called everytime an attribute is added or when an attribute value is changed or an element is created . |
26,238 | private void resetToStream ( ) { this . m_cdataStartCalled = false ; this . m_disableOutputEscapingStates . clear ( ) ; this . m_escaping = true ; this . m_expandDTDEntities = true ; this . m_inDoctype = false ; this . m_ispreserve = false ; this . m_isprevtext = false ; this . m_isUTF8 = false ; this . m_lineSep = s_systemLineSep ; this . m_lineSepLen = s_systemLineSep . length ; this . m_lineSepUse = true ; this . m_preserves . clear ( ) ; this . m_shouldFlush = true ; this . m_spaceBeforeClose = false ; this . m_startNewLine = false ; this . m_writer_set_by_user = false ; } | Reset all of the fields owned by ToStream class |
26,239 | public void notationDecl ( String name , String pubID , String sysID ) throws SAXException { try { DTDprolog ( ) ; m_writer . write ( "<!NOTATION " ) ; m_writer . write ( name ) ; if ( pubID != null ) { m_writer . write ( " PUBLIC \"" ) ; m_writer . write ( pubID ) ; } else { m_writer . write ( " SYSTEM \"" ) ; m_writer . write ( sysID ) ; } m_writer . write ( "\" >" ) ; m_writer . write ( m_lineSep , 0 , m_lineSepLen ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } | If this method is called the serializer is used as a DTDHandler which changes behavior how the serializer handles document entities . |
26,240 | private void DTDprolog ( ) throws SAXException , IOException { final java . io . Writer writer = m_writer ; if ( m_needToOutputDocTypeDecl ) { outputDocTypeDecl ( m_elemContext . m_elementName , false ) ; m_needToOutputDocTypeDecl = false ; } if ( m_inDoctype ) { writer . write ( " [" ) ; writer . write ( m_lineSep , 0 , m_lineSepLen ) ; m_inDoctype = false ; } } | A private helper method to output the |
26,241 | public void addCdataSectionElements ( String URI_and_localNames ) { if ( URI_and_localNames != null ) initCdataElems ( URI_and_localNames ) ; if ( m_StringOfCDATASections == null ) m_StringOfCDATASections = URI_and_localNames ; else m_StringOfCDATASections += ( " " + URI_and_localNames ) ; } | Remembers the cdata sections specified in the cdata - section - elements by appending the given cdata section elements to the list . This method can be called multiple times but once an element is put in the list of cdata section elements it can not be removed . This method should be used by both Xalan and XSLTC . |
26,242 | public final void reset ( ) { m_currentCodepoint_ = 0 ; m_nextCodepoint_ = 0 ; m_nextIndex_ = 0 ; m_nextBlock_ = m_trie_ . m_index_ [ 0 ] << Trie . INDEX_STAGE_2_SHIFT_ ; if ( m_nextBlock_ == m_trie_ . m_dataOffset_ ) { m_nextValue_ = m_initialValue_ ; } else { m_nextValue_ = extract ( m_trie_ . getValue ( m_nextBlock_ ) ) ; } m_nextBlockIndex_ = 0 ; m_nextTrailIndexOffset_ = TRAIL_SURROGATE_INDEX_BLOCK_LENGTH_ ; } | Resets the iterator to the beginning of the iteration |
26,243 | private final void setResult ( Element element , int start , int limit , int value ) { element . start = start ; element . limit = limit ; element . value = value ; } | Set the result values |
26,244 | private final boolean checkNullNextTrailIndex ( ) { if ( m_nextIndex_ <= 0 ) { m_nextCodepoint_ += TRAIL_SURROGATE_COUNT_ - 1 ; int nextLead = UTF16 . getLeadSurrogate ( m_nextCodepoint_ ) ; int leadBlock = m_trie_ . m_index_ [ nextLead >> Trie . INDEX_STAGE_1_SHIFT_ ] << Trie . INDEX_STAGE_2_SHIFT_ ; if ( m_trie_ . m_dataManipulate_ == null ) { throw new NullPointerException ( "The field DataManipulate in this Trie is null" ) ; } m_nextIndex_ = m_trie_ . m_dataManipulate_ . getFoldingOffset ( m_trie_ . getValue ( leadBlock + ( nextLead & Trie . INDEX_STAGE_3_MASK_ ) ) ) ; m_nextIndex_ -- ; m_nextBlockIndex_ = DATA_BLOCK_LENGTH_ ; return true ; } return false ; } | Checks if we are beginning at the start of a initial block . If we are then the rest of the codepoints in this initial block has the same values . We increment m_nextCodepoint_ and relevant data members if so . This is used only in for the supplementary codepoints because the offset to the trail indexes could be 0 . |
26,245 | public int [ ] toIntArray ( ) { int length = encoding . length ; int [ ] result = new int [ 20 ] ; int which = 0 ; int fromPos = 0 ; for ( int i = 0 ; i < length ; i ++ ) { if ( ( encoding [ i ] & 0x80 ) == 0 ) { if ( i - fromPos + 1 > 4 ) { BigInteger big = new BigInteger ( pack ( encoding , fromPos , i - fromPos + 1 , 7 , 8 ) ) ; if ( fromPos == 0 ) { result [ which ++ ] = 2 ; BigInteger second = big . subtract ( BigInteger . valueOf ( 80 ) ) ; if ( second . compareTo ( BigInteger . valueOf ( Integer . MAX_VALUE ) ) == 1 ) { return null ; } else { result [ which ++ ] = second . intValue ( ) ; } } else { if ( big . compareTo ( BigInteger . valueOf ( Integer . MAX_VALUE ) ) == 1 ) { return null ; } else { result [ which ++ ] = big . intValue ( ) ; } } } else { int retval = 0 ; for ( int j = fromPos ; j <= i ; j ++ ) { retval <<= 7 ; byte tmp = encoding [ j ] ; retval |= ( tmp & 0x07f ) ; } if ( fromPos == 0 ) { if ( retval < 80 ) { result [ which ++ ] = retval / 40 ; result [ which ++ ] = retval % 40 ; } else { result [ which ++ ] = 2 ; result [ which ++ ] = retval - 80 ; } } else { result [ which ++ ] = retval ; } } fromPos = i + 1 ; } if ( which >= result . length ) { result = Arrays . copyOf ( result , which + 10 ) ; } } return Arrays . copyOf ( result , which ) ; } | Private helper method for serialization . To be compatible with old versions of JDK . |
26,246 | private static int pack7Oid ( int input , byte [ ] out , int ooffset ) { byte [ ] b = new byte [ 4 ] ; b [ 0 ] = ( byte ) ( input >> 24 ) ; b [ 1 ] = ( byte ) ( input >> 16 ) ; b [ 2 ] = ( byte ) ( input >> 8 ) ; b [ 3 ] = ( byte ) ( input ) ; return pack7Oid ( b , 0 , 4 , out , ooffset ) ; } | Pack the int into a OID sub - identifier DER encoding |
26,247 | private static int pack7Oid ( BigInteger input , byte [ ] out , int ooffset ) { byte [ ] b = input . toByteArray ( ) ; return pack7Oid ( b , 0 , b . length , out , ooffset ) ; } | Pack the BigInteger into a OID subidentifier DER encoding |
26,248 | private static void check ( byte [ ] encoding ) throws IOException { int length = encoding . length ; if ( length < 1 || ( encoding [ length - 1 ] & 0x80 ) != 0 ) { throw new IOException ( "ObjectIdentifier() -- " + "Invalid DER encoding, not ended" ) ; } for ( int i = 0 ; i < length ; i ++ ) { if ( encoding [ i ] == ( byte ) 0x80 && ( i == 0 || ( encoding [ i - 1 ] & 0x80 ) == 0 ) ) { throw new IOException ( "ObjectIdentifier() -- " + "Invalid DER encoding, useless extra octet detected" ) ; } } } | Check the DER encoding . Since DER encoding defines that the integer bits are unsigned so there s no need to check the MSB . |
26,249 | public void parseForClass ( GenericDeclaration genericDecl , String signature ) { setInput ( genericDecl , signature ) ; if ( ! eof ) { parseClassSignature ( ) ; } else { if ( genericDecl instanceof Class ) { Class c = ( Class ) genericDecl ; this . formalTypeParameters = EmptyArray . TYPE_VARIABLE ; this . superclassType = c . getSuperclass ( ) ; Class < ? > [ ] interfaces = c . getInterfaces ( ) ; if ( interfaces . length == 0 ) { this . interfaceTypes = ListOfTypes . EMPTY ; } else { this . interfaceTypes = new ListOfTypes ( interfaces ) ; } } else { this . formalTypeParameters = EmptyArray . TYPE_VARIABLE ; this . superclassType = Object . class ; this . interfaceTypes = ListOfTypes . EMPTY ; } } } | Parses the generic signature of a class and creates the data structure representing the signature . |
26,250 | public void parseForMethod ( GenericDeclaration genericDecl , String signature , Class < ? > [ ] rawExceptionTypes ) { setInput ( genericDecl , signature ) ; if ( ! eof ) { parseMethodTypeSignature ( rawExceptionTypes ) ; } else { Method m = ( Method ) genericDecl ; this . formalTypeParameters = EmptyArray . TYPE_VARIABLE ; Class < ? > [ ] parameterTypes = m . getParameterTypes ( ) ; if ( parameterTypes . length == 0 ) { this . parameterTypes = ListOfTypes . EMPTY ; } else { this . parameterTypes = new ListOfTypes ( parameterTypes ) ; } Class < ? > [ ] exceptionTypes = m . getExceptionTypes ( ) ; if ( exceptionTypes . length == 0 ) { this . exceptionTypes = ListOfTypes . EMPTY ; } else { this . exceptionTypes = new ListOfTypes ( exceptionTypes ) ; } this . returnType = m . getReturnType ( ) ; } } | Parses the generic signature of a method and creates the data structure representing the signature . |
26,251 | public void parseForConstructor ( GenericDeclaration genericDecl , String signature , Class < ? > [ ] rawExceptionTypes ) { setInput ( genericDecl , signature ) ; if ( ! eof ) { parseMethodTypeSignature ( rawExceptionTypes ) ; } else { Constructor c = ( Constructor ) genericDecl ; this . formalTypeParameters = EmptyArray . TYPE_VARIABLE ; Class < ? > [ ] parameterTypes = c . getParameterTypes ( ) ; if ( parameterTypes . length == 0 ) { this . parameterTypes = ListOfTypes . EMPTY ; } else { this . parameterTypes = new ListOfTypes ( parameterTypes ) ; } Class < ? > [ ] exceptionTypes = c . getExceptionTypes ( ) ; if ( exceptionTypes . length == 0 ) { this . exceptionTypes = ListOfTypes . EMPTY ; } else { this . exceptionTypes = new ListOfTypes ( exceptionTypes ) ; } } } | Parses the generic signature of a constructor and creates the data structure representing the signature . |
26,252 | public void parseForField ( GenericDeclaration genericDecl , String signature ) { setInput ( genericDecl , signature ) ; if ( ! eof ) { this . fieldType = parseFieldTypeSignature ( ) ; } } | Parses the generic signature of a field and creates the data structure representing the signature . |
26,253 | private < T > T doInvokeAny ( Collection < ? extends Callable < T > > tasks , boolean timed , long nanos ) throws InterruptedException , ExecutionException , TimeoutException { if ( tasks == null ) throw new NullPointerException ( ) ; int ntasks = tasks . size ( ) ; if ( ntasks == 0 ) throw new IllegalArgumentException ( ) ; ArrayList < Future < T > > futures = new ArrayList < > ( ntasks ) ; ExecutorCompletionService < T > ecs = new ExecutorCompletionService < T > ( this ) ; try { ExecutionException ee = null ; final long deadline = timed ? System . nanoTime ( ) + nanos : 0L ; Iterator < ? extends Callable < T > > it = tasks . iterator ( ) ; futures . add ( ecs . submit ( it . next ( ) ) ) ; -- ntasks ; int active = 1 ; for ( ; ; ) { Future < T > f = ecs . poll ( ) ; if ( f == null ) { if ( ntasks > 0 ) { -- ntasks ; futures . add ( ecs . submit ( it . next ( ) ) ) ; ++ active ; } else if ( active == 0 ) break ; else if ( timed ) { f = ecs . poll ( nanos , NANOSECONDS ) ; if ( f == null ) throw new TimeoutException ( ) ; nanos = deadline - System . nanoTime ( ) ; } else f = ecs . take ( ) ; } if ( f != null ) { -- active ; try { return f . get ( ) ; } catch ( ExecutionException eex ) { ee = eex ; } catch ( RuntimeException rex ) { ee = new ExecutionException ( rex ) ; } } } if ( ee == null ) ee = new ExecutionException ( ) ; throw ee ; } finally { cancelAll ( futures ) ; } } | the main mechanics of invokeAny . |
26,254 | private static < T > void cancelAll ( ArrayList < Future < T > > futures , int j ) { for ( int size = futures . size ( ) ; j < size ; j ++ ) futures . get ( j ) . cancel ( true ) ; } | Cancels all futures with index at least j . |
26,255 | public File extractZipEntry ( File dir , ZipFile zipFile , ZipEntry entry ) throws IOException { File outputFile = new File ( dir , entry . getName ( ) ) ; File parentFile = outputFile . getParentFile ( ) ; if ( ! outputFile . getCanonicalPath ( ) . startsWith ( dir . getCanonicalPath ( ) + File . separator ) || ( ! parentFile . isDirectory ( ) && ! parentFile . mkdirs ( ) ) ) { throw new IOException ( "Could not extract " + entry . getName ( ) + " to " + dir . getPath ( ) ) ; } try ( InputStream inputStream = zipFile . getInputStream ( entry ) ; FileOutputStream outputStream = new FileOutputStream ( outputFile ) ) { byte [ ] buf = new byte [ 1024 ] ; int n ; while ( ( n = inputStream . read ( buf ) ) > 0 ) { outputStream . write ( buf , 0 , n ) ; } } return outputFile ; } | Extract a ZipEntry to the specified directory . |
26,256 | private boolean isSimpleEnum ( EnumDeclaration node ) { TypeElement type = node . getTypeElement ( ) ; for ( EnumConstantDeclaration constant : node . getEnumConstants ( ) ) { ExecutableElement method = constant . getExecutableElement ( ) ; if ( method . getParameters ( ) . size ( ) > 0 || method . isVarArgs ( ) ) { return false ; } if ( ElementUtil . hasAnnotation ( method , ObjectiveCName . class ) ) { return false ; } TypeElement valueType = ElementUtil . getDeclaringClass ( method ) ; if ( valueType != type ) { return false ; } } return true ; } | Returns true if an enum doesn t have custom or renamed constructors vararg constructors or constants with anonymous class extensions . |
26,257 | private void addArcInitialization ( EnumDeclaration node ) { String enumClassName = nameTable . getFullName ( node . getTypeElement ( ) ) ; List < Statement > stmts = node . getClassInitStatements ( ) . subList ( 0 , 0 ) ; int i = 0 ; for ( EnumConstantDeclaration constant : node . getEnumConstants ( ) ) { VariableElement varElement = constant . getVariableElement ( ) ; ClassInstanceCreation creation = new ClassInstanceCreation ( constant . getExecutablePair ( ) ) ; TreeUtil . copyList ( constant . getArguments ( ) , creation . getArguments ( ) ) ; Expression constName = options . stripEnumConstants ( ) ? new StringLiteral ( "JAVA_LANG_ENUM_NAME_STRIPPED" , typeUtil ) : new NativeExpression ( UnicodeUtils . format ( "JreEnumConstantName(%s_class_(), %d)" , enumClassName , i ) , typeUtil . getJavaString ( ) . asType ( ) ) ; creation . addArgument ( constName ) ; creation . addArgument ( new NumberLiteral ( i ++ , typeUtil ) ) ; creation . setHasRetainedResult ( true ) ; stmts . add ( new ExpressionStatement ( new Assignment ( new SimpleName ( varElement ) , creation ) ) ) ; } } | the shared allocation optimization . |
26,258 | private long monthRange ( ) { ValueRange startRange = chrono . range ( MONTH_OF_YEAR ) ; if ( startRange . isFixed ( ) && startRange . isIntValue ( ) ) { return startRange . getMaximum ( ) - startRange . getMinimum ( ) + 1 ; } return - 1 ; } | Calculates the range of months . |
26,259 | private Expression getRetainedWithTarget ( Assignment node , VariableElement var ) { Expression lhs = node . getLeftHandSide ( ) ; if ( ! ( lhs instanceof FieldAccess ) ) { return new ThisExpression ( ElementUtil . getDeclaringClass ( var ) . asType ( ) ) ; } FieldAccess fieldAccess = ( FieldAccess ) lhs ; Expression target = fieldAccess . getExpression ( ) ; VariableElement targetVar = GeneratedVariableElement . newLocalVar ( "__rw$" + rwCount ++ , target . getTypeMirror ( ) , null ) ; TreeUtil . asStatementList ( TreeUtil . getOwningStatement ( lhs ) ) . add ( 0 , new VariableDeclarationStatement ( targetVar , null ) ) ; fieldAccess . setExpression ( new SimpleName ( targetVar ) ) ; CommaExpression commaExpr = new CommaExpression ( new Assignment ( new SimpleName ( targetVar ) , target ) ) ; node . replaceWith ( commaExpr ) ; commaExpr . addExpression ( node ) ; return new SimpleName ( targetVar ) ; } | Gets the target object for a call to the RetainedWith wrapper . |
26,260 | private static String getPromotionSuffix ( Assignment node ) { if ( ! needsPromotionSuffix ( node . getOperator ( ) ) ) { return "" ; } TypeKind lhsKind = node . getLeftHandSide ( ) . getTypeMirror ( ) . getKind ( ) ; TypeKind rhsKind = node . getRightHandSide ( ) . getTypeMirror ( ) . getKind ( ) ; if ( lhsKind == TypeKind . DOUBLE || rhsKind == TypeKind . DOUBLE ) { return "D" ; } if ( lhsKind == TypeKind . FLOAT || rhsKind == TypeKind . FLOAT ) { return "F" ; } if ( lhsKind == TypeKind . LONG || rhsKind == TypeKind . LONG ) { return "J" ; } return "I" ; } | Some operator functions are given a suffix indicating the promotion type of the operands according to JLS 5 . 6 . 2 . |
26,261 | public static String join ( CharSequence delimiter , Iterable tokens ) { StringBuilder sb = new StringBuilder ( ) ; boolean firstTime = true ; for ( Object token : tokens ) { if ( firstTime ) { firstTime = false ; } else { sb . append ( delimiter ) ; } sb . append ( token ) ; } return sb . toString ( ) ; } | Returns a string containing the tokens joined by delimiters . |
26,262 | public static void dumpSpans ( CharSequence cs , Printer printer , String prefix ) { if ( cs instanceof Spanned ) { Spanned sp = ( Spanned ) cs ; Object [ ] os = sp . getSpans ( 0 , cs . length ( ) , Object . class ) ; for ( int i = 0 ; i < os . length ; i ++ ) { Object o = os [ i ] ; printer . println ( prefix + cs . subSequence ( sp . getSpanStart ( o ) , sp . getSpanEnd ( o ) ) + ": " + Integer . toHexString ( System . identityHashCode ( o ) ) + " " + o . getClass ( ) . getCanonicalName ( ) + " (" + sp . getSpanStart ( o ) + "-" + sp . getSpanEnd ( o ) + ") fl=#" + sp . getSpanFlags ( o ) ) ; } } else { printer . println ( prefix + cs + ": (no spans)" ) ; } } | Debugging tool to print the spans in a CharSequence . The output will be printed one span per line . If the CharSequence is not a Spanned then the entire string will be printed on a single line . |
26,263 | public static CharSequence expandTemplate ( CharSequence template , CharSequence ... values ) { if ( values . length > 9 ) { throw new IllegalArgumentException ( "max of 9 values are supported" ) ; } SpannableStringBuilder ssb = new SpannableStringBuilder ( template ) ; try { int i = 0 ; while ( i < ssb . length ( ) ) { if ( ssb . charAt ( i ) == '^' ) { char next = ssb . charAt ( i + 1 ) ; if ( next == '^' ) { ssb . delete ( i + 1 , i + 2 ) ; ++ i ; continue ; } else if ( Character . isDigit ( next ) ) { int which = Character . getNumericValue ( next ) - 1 ; if ( which < 0 ) { throw new IllegalArgumentException ( "template requests value ^" + ( which + 1 ) ) ; } if ( which >= values . length ) { throw new IllegalArgumentException ( "template requests value ^" + ( which + 1 ) + "; only " + values . length + " provided" ) ; } ssb . replace ( i , i + 2 , values [ which ] ) ; i += values [ which ] . length ( ) ; continue ; } } ++ i ; } } catch ( IndexOutOfBoundsException ignore ) { } return ssb ; } | Return a new CharSequence in which each of the source strings is replaced by the corresponding element of the destinations . |
26,264 | public static String htmlEncode ( String s ) { StringBuilder sb = new StringBuilder ( ) ; char c ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { c = s . charAt ( i ) ; switch ( c ) { case '<' : sb . append ( "<" ) ; break ; case '>' : sb . append ( ">" ) ; break ; case '&' : sb . append ( "&" ) ; break ; case '\'' : sb . append ( "'" ) ; break ; case '"' : sb . append ( """ ) ; break ; default : sb . append ( c ) ; } } return sb . toString ( ) ; } | Html - encode the string . |
26,265 | public static CharSequence concat ( CharSequence ... text ) { if ( text . length == 0 ) { return "" ; } if ( text . length == 1 ) { return text [ 0 ] ; } boolean spanned = false ; for ( int i = 0 ; i < text . length ; i ++ ) { if ( text [ i ] instanceof Spanned ) { spanned = true ; break ; } } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < text . length ; i ++ ) { sb . append ( text [ i ] ) ; } if ( ! spanned ) { return sb . toString ( ) ; } SpannableString ss = new SpannableString ( sb ) ; int off = 0 ; for ( int i = 0 ; i < text . length ; i ++ ) { int len = text [ i ] . length ( ) ; if ( text [ i ] instanceof Spanned ) { copySpansFrom ( ( Spanned ) text [ i ] , 0 , len , Object . class , ss , off ) ; } off += len ; } return new SpannedString ( ss ) ; } | Returns a CharSequence concatenating the specified CharSequences retaining their spans if any . |
26,266 | public static boolean isGraphic ( CharSequence str ) { final int len = str . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { int gc = Character . getType ( str . charAt ( i ) ) ; if ( gc != Character . CONTROL && gc != Character . FORMAT && gc != Character . SURROGATE && gc != Character . UNASSIGNED && gc != Character . LINE_SEPARATOR && gc != Character . PARAGRAPH_SEPARATOR && gc != Character . SPACE_SEPARATOR ) { return true ; } } return false ; } | Returns whether the given CharSequence contains any printable characters . |
26,267 | public static boolean isGraphic ( char c ) { int gc = Character . getType ( c ) ; return gc != Character . CONTROL && gc != Character . FORMAT && gc != Character . SURROGATE && gc != Character . UNASSIGNED && gc != Character . LINE_SEPARATOR && gc != Character . PARAGRAPH_SEPARATOR && gc != Character . SPACE_SEPARATOR ; } | Returns whether this character is a printable character . |
26,268 | public static boolean isDigitsOnly ( CharSequence str ) { final int len = str . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( ! Character . isDigit ( str . charAt ( i ) ) ) { return false ; } } return true ; } | Returns whether the given CharSequence contains only digits . |
26,269 | public static void appendToRule ( StringBuffer rule , UnicodeMatcher matcher , boolean escapeUnprintable , StringBuffer quoteBuf ) { if ( matcher != null ) { appendToRule ( rule , matcher . toPattern ( escapeUnprintable ) , true , escapeUnprintable , quoteBuf ) ; } } | Given a matcher reference which may be null append its pattern as a literal to the given rule . |
26,270 | private void encodeThis ( ) throws IOException { if ( names == null || names . isEmpty ( ) ) { this . extensionValue = null ; return ; } DerOutputStream os = new DerOutputStream ( ) ; names . encode ( os ) ; this . extensionValue = os . toByteArray ( ) ; } | Encode this extension |
26,271 | public void startElement ( StylesheetHandler handler , String uri , String localName , String rawName , Attributes attributes ) throws SAXException { String msg = "" ; if ( ! ( handler . getElemTemplateElement ( ) instanceof Stylesheet ) ) { msg = "func:function element must be top level." ; handler . error ( msg , new SAXException ( msg ) ) ; } super . startElement ( handler , uri , localName , rawName , attributes ) ; String val = attributes . getValue ( "name" ) ; int indexOfColon = val . indexOf ( ":" ) ; if ( indexOfColon > 0 ) { } else { msg = "func:function name must have namespace" ; handler . error ( msg , new SAXException ( msg ) ) ; } } | Start an ElemExsltFunction . Verify that it is top level and that it has a name attribute with a namespace . |
26,272 | protected void appendAndPush ( StylesheetHandler handler , ElemTemplateElement elem ) throws SAXException { super . appendAndPush ( handler , elem ) ; elem . setDOMBackPointer ( handler . getOriginatingNode ( ) ) ; handler . getStylesheet ( ) . setTemplate ( ( ElemTemplate ) elem ) ; } | Must include ; super doesn t suffice! |
26,273 | public void endElement ( StylesheetHandler handler , String uri , String localName , String rawName ) throws SAXException { ElemTemplateElement function = handler . getElemTemplateElement ( ) ; validate ( function , handler ) ; super . endElement ( handler , uri , localName , rawName ) ; } | End an ElemExsltFunction and verify its validity . |
26,274 | boolean ancestorIsOk ( ElemTemplateElement child ) { while ( child . getParentElem ( ) != null && ! ( child . getParentElem ( ) instanceof ElemExsltFunction ) ) { ElemTemplateElement parent = child . getParentElem ( ) ; if ( parent instanceof ElemExsltFuncResult || parent instanceof ElemVariable || parent instanceof ElemParam || parent instanceof ElemMessage ) return true ; child = parent ; } return false ; } | Verify that a literal result belongs to a result element a variable or a parameter . |
26,275 | private void readObject ( ObjectInputStream s ) throws IOException , ClassNotFoundException , InvalidObjectException { s . defaultReadObject ( ) ; if ( firstDayOfWeek == null ) { throw new InvalidObjectException ( "firstDayOfWeek is null" ) ; } if ( minimalDays < 1 || minimalDays > 7 ) { throw new InvalidObjectException ( "Minimal number of days is invalid" ) ; } } | Restore the state of a WeekFields from the stream . Check that the values are valid . |
26,276 | private final Object slotExchange ( Object item , boolean timed , long ns ) { Node p = participant . get ( ) ; Thread t = Thread . currentThread ( ) ; if ( t . isInterrupted ( ) ) return null ; for ( Node q ; ; ) { if ( ( q = slot ) != null ) { if ( U . compareAndSwapObject ( this , SLOT , q , null ) ) { Object v = q . item ; q . match = item ; Thread w = q . parked ; if ( w != null ) U . unpark ( w ) ; return v ; } if ( NCPU > 1 && bound == 0 && U . compareAndSwapInt ( this , BOUND , 0 , SEQ ) ) arena = new Node [ ( FULL + 2 ) << ASHIFT ] ; } else if ( arena != null ) return null ; else { p . item = item ; if ( U . compareAndSwapObject ( this , SLOT , null , p ) ) break ; p . item = null ; } } int h = p . hash ; long end = timed ? System . nanoTime ( ) + ns : 0L ; int spins = ( NCPU > 1 ) ? SPINS : 1 ; Object v ; while ( ( v = p . match ) == null ) { if ( spins > 0 ) { h ^= h << 1 ; h ^= h >>> 3 ; h ^= h << 10 ; if ( h == 0 ) h = SPINS | ( int ) t . getId ( ) ; else if ( h < 0 && ( -- spins & ( ( SPINS >>> 1 ) - 1 ) ) == 0 ) Thread . yield ( ) ; } else if ( slot != p ) spins = SPINS ; else if ( ! t . isInterrupted ( ) && arena == null && ( ! timed || ( ns = end - System . nanoTime ( ) ) > 0L ) ) { U . putObject ( t , BLOCKER , this ) ; p . parked = t ; if ( slot == p ) U . park ( false , ns ) ; p . parked = null ; U . putObject ( t , BLOCKER , null ) ; } else if ( U . compareAndSwapObject ( this , SLOT , p , null ) ) { v = timed && ns <= 0L && ! t . isInterrupted ( ) ? TIMED_OUT : null ; break ; } } U . putOrderedObject ( p , MATCH , null ) ; p . item = null ; p . hash = h ; return v ; } | Exchange function used until arenas enabled . See above for explanation . |
26,277 | public static StreamDecoder forInputStreamReader ( InputStream in , Object lock , String charsetName ) throws UnsupportedEncodingException { String csn = charsetName ; if ( csn == null ) csn = Charset . defaultCharset ( ) . name ( ) ; try { if ( Charset . isSupported ( csn ) ) return new StreamDecoder ( in , lock , Charset . forName ( csn ) ) ; } catch ( IllegalCharsetNameException x ) { } throw new UnsupportedEncodingException ( csn ) ; } | Factories for java . io . InputStreamReader |
26,278 | public static StreamDecoder forDecoder ( ReadableByteChannel ch , CharsetDecoder dec , int minBufferCap ) { return new StreamDecoder ( ch , dec , minBufferCap ) ; } | Factory for java . nio . channels . Channels . newReader |
26,279 | public static void run ( List < String > fileArgs , Options options ) { File preProcessorTempDir = null ; File strippedSourcesDir = null ; Parser parser = null ; try { List < ProcessingContext > inputs = Lists . newArrayList ( ) ; GenerationBatch batch = new GenerationBatch ( options ) ; batch . processFileArgs ( fileArgs ) ; inputs . addAll ( batch . getInputs ( ) ) ; if ( ErrorUtil . errorCount ( ) > 0 ) { return ; } parser = createParser ( options ) ; Parser . ProcessingResult processingResult = parser . processAnnotations ( fileArgs , inputs ) ; List < ProcessingContext > generatedInputs = processingResult . getGeneratedSources ( ) ; inputs . addAll ( generatedInputs ) ; preProcessorTempDir = processingResult . getSourceOutputDirectory ( ) ; if ( ErrorUtil . errorCount ( ) > 0 ) { return ; } if ( preProcessorTempDir != null ) { parser . addSourcepathEntry ( preProcessorTempDir . getAbsolutePath ( ) ) ; } InputFilePreprocessor inputFilePreprocessor = new InputFilePreprocessor ( parser ) ; inputFilePreprocessor . processInputs ( inputs ) ; if ( ErrorUtil . errorCount ( ) > 0 ) { return ; } strippedSourcesDir = inputFilePreprocessor . getStrippedSourcesDir ( ) ; if ( strippedSourcesDir != null ) { parser . prependSourcepathEntry ( strippedSourcesDir . getPath ( ) ) ; } options . getHeaderMap ( ) . loadMappings ( ) ; TranslationProcessor translationProcessor = new TranslationProcessor ( parser , loadDeadCodeMap ( ) ) ; translationProcessor . processInputs ( inputs ) ; if ( ErrorUtil . errorCount ( ) > 0 ) { return ; } translationProcessor . postProcess ( ) ; options . getHeaderMap ( ) . printMappings ( ) ; } finally { if ( parser != null ) { try { parser . close ( ) ; } catch ( IOException e ) { ErrorUtil . error ( e . getMessage ( ) ) ; } } Set < String > tempDirs = options . fileUtil ( ) . getTempDirs ( ) ; for ( String dir : tempDirs ) { FileUtil . deleteTempDir ( new File ( dir ) ) ; } FileUtil . deleteTempDir ( preProcessorTempDir ) ; FileUtil . deleteTempDir ( strippedSourcesDir ) ; } } | Runs the entire J2ObjC pipeline . |
26,280 | public void CopyFrom ( ToXMLStream xmlListener ) { setWriter ( xmlListener . m_writer ) ; String encoding = xmlListener . getEncoding ( ) ; setEncoding ( encoding ) ; setOmitXMLDeclaration ( xmlListener . getOmitXMLDeclaration ( ) ) ; m_ispreserve = xmlListener . m_ispreserve ; m_preserves = xmlListener . m_preserves ; m_isprevtext = xmlListener . m_isprevtext ; m_doIndent = xmlListener . m_doIndent ; setIndentAmount ( xmlListener . getIndentAmount ( ) ) ; m_startNewLine = xmlListener . m_startNewLine ; m_needToOutputDocTypeDecl = xmlListener . m_needToOutputDocTypeDecl ; setDoctypeSystem ( xmlListener . getDoctypeSystem ( ) ) ; setDoctypePublic ( xmlListener . getDoctypePublic ( ) ) ; setStandalone ( xmlListener . getStandalone ( ) ) ; setMediaType ( xmlListener . getMediaType ( ) ) ; m_encodingInfo = xmlListener . m_encodingInfo ; m_spaceBeforeClose = xmlListener . m_spaceBeforeClose ; m_cdataStartCalled = xmlListener . m_cdataStartCalled ; } | Copy properties from another SerializerToXML . |
26,281 | public void endPreserving ( ) throws org . xml . sax . SAXException { m_ispreserve = m_preserves . isEmpty ( ) ? false : m_preserves . pop ( ) ; } | Ends a whitespace preserving section . |
26,282 | public void addAttribute ( String uri , String localName , String rawName , String type , String value , boolean xslAttribute ) throws SAXException { if ( m_elemContext . m_startTagOpen ) { boolean was_added = addAttributeAlways ( uri , localName , rawName , type , value , xslAttribute ) ; if ( was_added && ! xslAttribute && ! rawName . startsWith ( "xmlns" ) ) { String prefixUsed = ensureAttributesNamespaceIsDeclared ( uri , localName , rawName ) ; if ( prefixUsed != null && rawName != null && ! rawName . startsWith ( prefixUsed ) ) { rawName = prefixUsed + ":" + localName ; } } addAttributeAlways ( uri , localName , rawName , type , value , xslAttribute ) ; } else { String msg = Utils . messages . createMessage ( MsgKey . ER_ILLEGAL_ATTRIBUTE_POSITION , new Object [ ] { localName } ) ; try { Transformer tran = super . getTransformer ( ) ; ErrorListener errHandler = tran . getErrorListener ( ) ; if ( null != errHandler && m_sourceLocator != null ) errHandler . warning ( new TransformerException ( msg , m_sourceLocator ) ) ; else System . out . println ( msg ) ; } catch ( TransformerException e ) { SAXException se = new SAXException ( e ) ; throw se ; } } } | Add an attribute to the current element . |
26,283 | protected boolean pushNamespace ( String prefix , String uri ) { try { if ( m_prefixMap . pushNamespace ( prefix , uri , m_elemContext . m_currentElemDepth ) ) { startPrefixMapping ( prefix , uri ) ; return true ; } } catch ( SAXException e ) { } return false ; } | From XSLTC Declare a prefix to point to a namespace URI . Inform SAX handler if this is a new prefix mapping . |
26,284 | private String getXMLVersion ( ) { String xmlVersion = getVersion ( ) ; if ( xmlVersion == null || xmlVersion . equals ( XMLVERSION10 ) ) { xmlVersion = XMLVERSION10 ; } else if ( xmlVersion . equals ( XMLVERSION11 ) ) { xmlVersion = XMLVERSION11 ; } else { String msg = Utils . messages . createMessage ( MsgKey . ER_XML_VERSION_NOT_SUPPORTED , new Object [ ] { xmlVersion } ) ; try { Transformer tran = super . getTransformer ( ) ; ErrorListener errHandler = tran . getErrorListener ( ) ; if ( null != errHandler && m_sourceLocator != null ) errHandler . warning ( new TransformerException ( msg , m_sourceLocator ) ) ; else System . out . println ( msg ) ; } catch ( Exception e ) { } xmlVersion = XMLVERSION10 ; } return xmlVersion ; } | This method checks for the XML version of output document . If XML version of output document is not specified then output document is of version XML 1 . 0 . If XML version of output doucment is specified but it is not either XML 1 . 0 or XML 1 . 1 a warning message is generated the XML Version of output document is set to XML 1 . 0 and processing continues . |
26,285 | public void append ( char digit ) { if ( count == digits . length ) { char [ ] data = new char [ count + 100 ] ; System . arraycopy ( digits , 0 , data , 0 , count ) ; digits = data ; } digits [ count ++ ] = digit ; } | Appends a digit to the list extending the list when necessary . |
26,286 | boolean fitsIntoLong ( boolean isPositive , boolean ignoreNegativeZero ) { while ( count > 0 && digits [ count - 1 ] == '0' ) { -- count ; } if ( count == 0 ) { return isPositive || ignoreNegativeZero ; } if ( decimalAt < count || decimalAt > MAX_COUNT ) { return false ; } if ( decimalAt < MAX_COUNT ) return true ; for ( int i = 0 ; i < count ; ++ i ) { char dig = digits [ i ] , max = LONG_MIN_REP [ i ] ; if ( dig > max ) return false ; if ( dig < max ) return true ; } if ( count < decimalAt ) return true ; return ! isPositive ; } | Return true if the number represented by this object can fit into a long . |
26,287 | final void set ( boolean isNegative , double source , int maximumDigits , boolean fixedPoint ) { set ( isNegative , Double . toString ( source ) , maximumDigits , fixedPoint ) ; } | Set the digit list to a representation of the given double value . This method supports both fixed - point and exponential notation . |
26,288 | private final void round ( int maximumDigits ) { if ( maximumDigits >= 0 && maximumDigits < count ) { if ( shouldRoundUp ( maximumDigits ) ) { for ( ; ; ) { -- maximumDigits ; if ( maximumDigits < 0 ) { digits [ 0 ] = '1' ; ++ decimalAt ; maximumDigits = 0 ; break ; } ++ digits [ maximumDigits ] ; if ( digits [ maximumDigits ] <= '9' ) break ; } ++ maximumDigits ; } count = maximumDigits ; while ( count > 1 && digits [ count - 1 ] == '0' ) { -- count ; } } } | Round the representation to the given number of digits . |
26,289 | public final void set ( boolean isNegative , long source , int maximumDigits ) { this . isNegative = isNegative ; if ( source <= 0 ) { if ( source == Long . MIN_VALUE ) { decimalAt = count = MAX_COUNT ; System . arraycopy ( LONG_MIN_REP , 0 , digits , 0 , count ) ; } else { decimalAt = count = 0 ; } } else { int left = MAX_COUNT ; int right ; while ( source > 0 ) { digits [ -- left ] = ( char ) ( '0' + ( source % 10 ) ) ; source /= 10 ; } decimalAt = MAX_COUNT - left ; for ( right = MAX_COUNT - 1 ; digits [ right ] == '0' ; -- right ) ; count = right - left + 1 ; System . arraycopy ( digits , left , digits , 0 , count ) ; } if ( maximumDigits > 0 ) round ( maximumDigits ) ; } | Set the digit list to a representation of the given long value . |
26,290 | final void set ( boolean isNegative , BigDecimal source , int maximumDigits , boolean fixedPoint ) { String s = source . toString ( ) ; extendDigits ( s . length ( ) ) ; set ( isNegative , s , maximumDigits , fixedPoint ) ; } | Set the digit list to a representation of the given BigDecimal value . This method supports both fixed - point and exponential notation . |
26,291 | final void set ( boolean isNegative , BigInteger source , int maximumDigits ) { this . isNegative = isNegative ; String s = source . toString ( ) ; int len = s . length ( ) ; extendDigits ( len ) ; s . getChars ( 0 , len , digits , 0 ) ; decimalAt = len ; int right ; for ( right = len - 1 ; right >= 0 && digits [ right ] == '0' ; -- right ) ; count = right + 1 ; if ( maximumDigits > 0 ) { round ( maximumDigits ) ; } } | Set the digit list to a representation of the given BigInteger value . |
26,292 | public void execute ( TransformerImpl transformer ) throws TransformerException { if ( transformer . isRecursiveAttrSet ( this ) ) { throw new TransformerException ( XSLMessages . createMessage ( XSLTErrorResources . ER_XSLATTRSET_USED_ITSELF , new Object [ ] { m_qname . getLocalPart ( ) } ) ) ; } transformer . pushElemAttributeSet ( this ) ; super . execute ( transformer ) ; ElemAttribute attr = ( ElemAttribute ) getFirstChildElem ( ) ; while ( null != attr ) { attr . execute ( transformer ) ; attr = ( ElemAttribute ) attr . getNextSiblingElem ( ) ; } transformer . popElemAttributeSet ( ) ; } | Apply a set of attributes to the element . |
26,293 | final Node < E > pred ( Node < E > p ) { Node < E > q = p . prev ; return ( sentinel ( ) == q ) ? last ( ) : q ; } | Returns the predecessor of p or the last node if p . prev has been linked to self which will only be true if traversing with a stale pointer that is now off the list . |
26,294 | public String getCanonicalID ( ) { if ( canonicalID == null ) { synchronized ( this ) { if ( canonicalID == null ) { canonicalID = getCanonicalID ( getID ( ) ) ; assert ( canonicalID != null ) ; if ( canonicalID == null ) { canonicalID = getID ( ) ; } } } } return canonicalID ; } | Returns the canonical ID of this system time zone |
26,295 | private void constructEmpty ( ) { transitionCount = 0 ; transitionTimes64 = null ; typeMapData = null ; typeCount = 1 ; typeOffsets = new int [ ] { 0 , 0 } ; finalZone = null ; finalStartYear = Integer . MAX_VALUE ; finalStartMillis = Double . MAX_VALUE ; transitionRulesInitialized = false ; } | Construct a GMT + 0 zone with no transitions . This is done when a constructor fails so the resultant object is well - behaved . |
26,296 | public static long fieldsToDay ( int year , int month , int dom ) { int y = year - 1 ; long julian = 365 * y + floorDivide ( y , 4 ) + ( JULIAN_1_CE - 3 ) + floorDivide ( y , 400 ) - floorDivide ( y , 100 ) + 2 + DAYS_BEFORE [ month + ( isLeapYear ( year ) ? 12 : 0 ) ] + dom ; return julian - JULIAN_1970_CE ; } | Convert a year month and day - of - month given in the proleptic Gregorian calendar to 1970 epoch days . |
26,297 | public static String timeToString ( long time ) { int [ ] fields = timeToFields ( time , null ) ; int millis = fields [ 5 ] ; int hour = millis / MILLIS_PER_HOUR ; millis = millis % MILLIS_PER_HOUR ; int min = millis / MILLIS_PER_MINUTE ; millis = millis % MILLIS_PER_MINUTE ; int sec = millis / MILLIS_PER_SECOND ; millis = millis % MILLIS_PER_SECOND ; return String . format ( ( Locale ) null , "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ" , fields [ 0 ] , fields [ 1 ] + 1 , fields [ 2 ] , hour , min , sec , millis ) ; } | Convenient method for formatting time to ISO 8601 style date string . |
26,298 | public final int getCodePointValue ( int ch ) { int offset ; if ( 0 <= ch && ch < UTF16 . LEAD_SURROGATE_MIN_VALUE ) { offset = ( m_index_ [ ch >> INDEX_STAGE_1_SHIFT_ ] << INDEX_STAGE_2_SHIFT_ ) + ( ch & INDEX_STAGE_3_MASK_ ) ; return m_data_ [ offset ] ; } offset = getCodePointOffset ( ch ) ; return ( offset >= 0 ) ? m_data_ [ offset ] : m_initialValue_ ; } | Gets the value associated with the codepoint . If no value is associated with the codepoint a default value will be returned . |
26,299 | public static Object create ( Delegate delegate , int bufferSize ) { if ( bufferSize < 1 ) { throw new IllegalArgumentException ( "Invalid buffer size: " + bufferSize ) ; } if ( delegate == null ) { throw new IllegalArgumentException ( "Delegate must not be null" ) ; } return nativeCreate ( delegate , bufferSize ) ; } | Creates a native NSInputStream that is piped to a NSOutpuStream which in turn requests data from the supplied delegate asynchronously . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.