idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
26,700 | public void replace ( int start , int limit , char [ ] chars , int charsStart , int charsLen ) { buf . delete ( start , limit ) ; buf . insert ( start , chars , charsStart , charsLen ) ; } | Replace a substring of this object with the given text . |
26,701 | public final void validate ( ) { this . accept ( new TreeVisitor ( ) { public boolean preVisit ( TreeNode node ) { node . validateInner ( ) ; return true ; } } ) ; } | Validates the tree to preemptively catch errors . |
26,702 | public int compare ( Object object1 , Object object2 ) { return compare ( ( String ) object1 , ( String ) object2 ) ; } | Compares two objects to determine their relative order . The objects must be strings . |
26,703 | public static QName getQNameFromString ( String name ) { StringTokenizer tokenizer = new StringTokenizer ( name , "{}" , false ) ; QName qname ; String s1 = tokenizer . nextToken ( ) ; String s2 = tokenizer . hasMoreTokens ( ) ? tokenizer . nextToken ( ) : null ; if ( null == s2 ) qname = new QName ( null , s1 ) ; else qname = new QName ( s1 , s2 ) ; return qname ; } | Given a string create and return a QName object |
26,704 | public static String getPrefixFromXMLNSDecl ( String attRawName ) { int index = attRawName . indexOf ( ':' ) ; return ( index >= 0 ) ? attRawName . substring ( index + 1 ) : "" ; } | This function tells if a raw attribute name is a xmlns attribute . |
26,705 | String convertNumberToI18N ( String numericText ) { if ( zeroDigit == '0' ) { return numericText ; } int diff = zeroDigit - '0' ; char [ ] array = numericText . toCharArray ( ) ; for ( int i = 0 ; i < array . length ; i ++ ) { array [ i ] = ( char ) ( array [ i ] + diff ) ; } return new String ( array ) ; } | Converts the input numeric text to the internationalized form using the zero character . |
26,706 | private void checkReadPrimitiveTypes ( ) throws IOException { if ( primitiveData == input || primitiveData . available ( ) > 0 ) { return ; } do { int next = 0 ; if ( hasPushbackTC ) { hasPushbackTC = false ; } else { next = input . read ( ) ; pushbackTC = ( byte ) next ; } switch ( pushbackTC ) { case TC_BLOCKDATA : primitiveData = new ByteArrayInputStream ( readBlockData ( ) ) ; return ; case TC_BLOCKDATALONG : primitiveData = new ByteArrayInputStream ( readBlockDataLong ( ) ) ; return ; case TC_RESET : resetState ( ) ; break ; default : if ( next != - 1 ) { pushbackTC ( ) ; } return ; } } while ( true ) ; } | Checks to if it is ok to read primitive types from this stream at this point . One is not supposed to read primitive types when about to read an object for example so an exception has to be thrown . |
26,707 | public void defaultReadObject ( ) throws IOException , ClassNotFoundException , NotActiveException { if ( currentObject != null || ! mustResolve ) { readFieldValues ( currentObject , currentClass ) ; } else { throw new NotActiveException ( ) ; } } | Default method to read objects from this stream . Serializable fields defined in the object s class and superclasses are read from the source stream . |
26,708 | private void discardData ( ) throws ClassNotFoundException , IOException { primitiveData = emptyStream ; boolean resolve = mustResolve ; mustResolve = false ; do { byte tc = nextTC ( ) ; if ( tc == TC_ENDBLOCKDATA ) { mustResolve = resolve ; return ; } readContent ( tc ) ; } while ( true ) ; } | Reads and discards block data and objects until TC_ENDBLOCKDATA is found . |
26,709 | public GetField readFields ( ) throws IOException , ClassNotFoundException , NotActiveException { if ( currentObject == null ) { throw new NotActiveException ( ) ; } EmulatedFieldsForLoading result = new EmulatedFieldsForLoading ( currentClass ) ; readFieldValues ( result ) ; return result ; } | Reads the persistent fields of the object that is currently being read from the source stream . The values read are stored in a GetField object that provides access to the persistent fields . This GetField object is then returned . |
26,710 | protected ObjectStreamClass readClassDescriptor ( ) throws IOException , ClassNotFoundException { ObjectStreamClass newClassDesc = new ObjectStreamClass ( ) ; String name = input . readUTF ( ) ; if ( name . length ( ) == 0 ) { throw new IOException ( "The stream is corrupted" ) ; } newClassDesc . setName ( name ) ; newClassDesc . setSerialVersionUID ( input . readLong ( ) ) ; newClassDesc . setFlags ( input . readByte ( ) ) ; if ( descriptorHandle == - 1 ) { descriptorHandle = nextHandle ( ) ; } registerObjectRead ( newClassDesc , descriptorHandle , false ) ; readFieldDescriptors ( newClassDesc ) ; return newClassDesc ; } | Reads a class descriptor from the source stream . |
26,711 | private Object readNewLongString ( boolean unshared ) throws IOException { long length = input . readLong ( ) ; Object result = input . decodeUTF ( ( int ) length ) ; if ( enableResolve ) { result = resolveObject ( result ) ; } registerObjectRead ( result , nextHandle ( ) , unshared ) ; return result ; } | Read a new String in UTF format from the receiver . Return the string read . |
26,712 | protected void readStreamHeader ( ) throws IOException , StreamCorruptedException { if ( input . readShort ( ) == STREAM_MAGIC && input . readShort ( ) == STREAM_VERSION ) { return ; } throw new StreamCorruptedException ( ) ; } | Reads and validates the ObjectInputStream header from the source stream . |
26,713 | private Object registeredObjectRead ( int handle ) throws InvalidObjectException { Object res = objectsRead . get ( handle - ObjectStreamConstants . baseWireHandle ) ; if ( res == UNSHARED_OBJ ) { throw new InvalidObjectException ( "Cannot read back reference to unshared object" ) ; } return res ; } | Returns the previously - read object corresponding to the given serialization handle . |
26,714 | private void registerObjectRead ( Object obj , int handle , boolean unshared ) throws IOException { if ( unshared ) { obj = UNSHARED_OBJ ; } int index = handle - ObjectStreamConstants . baseWireHandle ; int size = objectsRead . size ( ) ; while ( index > size ) { objectsRead . add ( null ) ; ++ size ; } if ( index == size ) { objectsRead . add ( obj ) ; } else { objectsRead . set ( index , obj ) ; } } | Associates a read object with the its serialization handle . |
26,715 | private static void checkedSetSuperClassDesc ( ObjectStreamClass desc , ObjectStreamClass superDesc ) throws StreamCorruptedException { if ( desc . equals ( superDesc ) ) { throw new StreamCorruptedException ( ) ; } desc . setSuperclass ( superDesc ) ; } | Avoid recursive defining . |
26,716 | public static boolean isRecognizedEncoding ( String encoding ) { EncodingInfo ei ; String normalizedEncoding = encoding . toUpperCase ( ) ; ei = ( EncodingInfo ) _encodingTableKeyJava . get ( normalizedEncoding ) ; if ( ei == null ) ei = ( EncodingInfo ) _encodingTableKeyMime . get ( normalizedEncoding ) ; if ( ei != null ) return true ; return false ; } | Determines if the encoding specified was recognized by the serializer or not . |
26,717 | private static EncodingInfo [ ] loadEncodingInfo ( ) { try { InputStream is ; SecuritySupport ss = SecuritySupport . getInstance ( ) ; is = ss . getResourceAsStream ( ObjectFactory . findClassLoader ( ) , ENCODINGS_FILE ) ; if ( is == null ) { is = new ByteArrayInputStream ( ENCODINGS_FILE_STR . getBytes ( StandardCharsets . UTF_8 ) ) ; } Properties props = new Properties ( ) ; if ( is != null ) { props . load ( is ) ; is . close ( ) ; } else { } int totalEntries = props . size ( ) ; List encodingInfo_list = new ArrayList ( ) ; Enumeration keys = props . keys ( ) ; for ( int i = 0 ; i < totalEntries ; ++ i ) { String javaName = ( String ) keys . nextElement ( ) ; String val = props . getProperty ( javaName ) ; int len = lengthOfMimeNames ( val ) ; String mimeName ; char highChar ; if ( len == 0 ) { mimeName = javaName ; highChar = '\u0000' ; } else { try { final String highVal = val . substring ( len ) . trim ( ) ; highChar = ( char ) Integer . decode ( highVal ) . intValue ( ) ; } catch ( NumberFormatException e ) { highChar = 0 ; } String mimeNames = val . substring ( 0 , len ) ; StringTokenizer st = new StringTokenizer ( mimeNames , "," ) ; for ( boolean first = true ; st . hasMoreTokens ( ) ; first = false ) { mimeName = st . nextToken ( ) ; EncodingInfo ei = new EncodingInfo ( mimeName , javaName , highChar ) ; encodingInfo_list . add ( ei ) ; _encodingTableKeyMime . put ( mimeName . toUpperCase ( ) , ei ) ; if ( first ) _encodingTableKeyJava . put ( javaName . toUpperCase ( ) , ei ) ; } } } EncodingInfo [ ] ret_ei = new EncodingInfo [ encodingInfo_list . size ( ) ] ; encodingInfo_list . toArray ( ret_ei ) ; return ret_ei ; } catch ( java . net . MalformedURLException mue ) { throw new org . apache . xml . serializer . utils . WrappedRuntimeException ( mue ) ; } catch ( java . io . IOException ioe ) { throw new org . apache . xml . serializer . utils . WrappedRuntimeException ( ioe ) ; } } | Load a list of all the supported encodings . |
26,718 | private static int lengthOfMimeNames ( String val ) { int len = val . indexOf ( ' ' ) ; if ( len < 0 ) len = val . length ( ) ; return len ; } | Get the length of the Mime names within the property value |
26,719 | static private String zeros ( int n ) { if ( n < 1 ) return "" ; char [ ] buf = new char [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { buf [ i ] = '0' ; } return new String ( buf ) ; } | Return a string of 0 of the given length |
26,720 | @ SuppressWarnings ( "unchecked" ) private V report ( int s ) throws ExecutionException { Object x = outcome ; if ( s == NORMAL ) return ( V ) x ; if ( s >= CANCELLED ) throw new CancellationException ( ) ; throw new ExecutionException ( ( Throwable ) x ) ; } | Returns result or throws exception for completed task . |
26,721 | protected void set ( V v ) { if ( U . compareAndSwapInt ( this , STATE , NEW , COMPLETING ) ) { outcome = v ; U . putOrderedInt ( this , STATE , NORMAL ) ; finishCompletion ( ) ; } } | Sets the result of this future to the given value unless this future has already been set or has been cancelled . |
26,722 | private int awaitDone ( boolean timed , long nanos ) throws InterruptedException { long startTime = 0L ; WaitNode q = null ; boolean queued = false ; for ( ; ; ) { int s = state ; if ( s > COMPLETING ) { if ( q != null ) q . thread = null ; return s ; } else if ( s == COMPLETING ) Thread . yield ( ) ; else if ( Thread . interrupted ( ) ) { removeWaiter ( q ) ; throw new InterruptedException ( ) ; } else if ( q == null ) { if ( timed && nanos <= 0L ) return s ; q = new WaitNode ( ) ; } else if ( ! queued ) queued = U . compareAndSwapObject ( this , WAITERS , q . next = waiters , q ) ; else if ( timed ) { final long parkNanos ; if ( startTime == 0L ) { startTime = System . nanoTime ( ) ; if ( startTime == 0L ) startTime = 1L ; parkNanos = nanos ; } else { long elapsed = System . nanoTime ( ) - startTime ; if ( elapsed >= nanos ) { removeWaiter ( q ) ; return state ; } parkNanos = nanos - elapsed ; } if ( state < COMPLETING ) LockSupport . parkNanos ( this , parkNanos ) ; } else LockSupport . park ( this ) ; } } | Awaits completion or aborts on interrupt or timeout . |
26,723 | private void removeWaiter ( WaitNode node ) { if ( node != null ) { node . thread = null ; retry : for ( ; ; ) { for ( WaitNode pred = null , q = waiters , s ; q != null ; q = s ) { s = q . next ; if ( q . thread != null ) pred = q ; else if ( pred != null ) { pred . next = s ; if ( pred . thread == null ) continue retry ; } else if ( ! U . compareAndSwapObject ( this , WAITERS , q , s ) ) continue retry ; } break ; } } } | Tries to unlink a timed - out or interrupted wait node to avoid accumulating garbage . Internal nodes are simply unspliced without CAS since it is harmless if they are traversed anyway by releasers . To avoid effects of unsplicing from already removed nodes the list is retraversed in case of an apparent race . This is slow when there are a lot of nodes but we don t expect lists to be long enough to outweigh higher - overhead schemes . |
26,724 | static < T > Stream < T > makeRef ( AbstractPipeline < ? , T , ? > upstream , Comparator < ? super T > comparator ) { return new OfRef < > ( upstream , comparator ) ; } | Appends a sorted operation to the provided stream . |
26,725 | public void setComment ( String comment ) { if ( comment != null ) { this . comment = zc . getBytes ( comment ) ; if ( this . comment . length > 0xffff ) throw new IllegalArgumentException ( "ZIP file comment too long." ) ; } } | Sets the ZIP file comment . |
26,726 | public void putNextEntry ( ZipEntry e ) throws IOException { ensureOpen ( ) ; if ( current != null ) { closeEntry ( ) ; } if ( e . time == - 1 ) { e . setTime ( System . currentTimeMillis ( ) ) ; } if ( e . method == - 1 ) { e . method = method ; } e . flag = 0 ; switch ( e . method ) { case DEFLATED : if ( e . size == - 1 || e . csize == - 1 || e . crc == - 1 ) e . flag = 8 ; break ; case STORED : if ( e . size == - 1 ) { e . size = e . csize ; } else if ( e . csize == - 1 ) { e . csize = e . size ; } else if ( e . size != e . csize ) { throw new ZipException ( "STORED entry where compressed != uncompressed size" ) ; } if ( e . size == - 1 || e . crc == - 1 ) { throw new ZipException ( "STORED entry missing size, compressed size, or crc-32" ) ; } break ; default : throw new ZipException ( "unsupported compression method" ) ; } if ( ! names . add ( e . name ) ) { throw new ZipException ( "duplicate entry: " + e . name ) ; } if ( zc . isUTF8 ( ) ) e . flag |= EFS ; current = new XEntry ( e , written ) ; xentries . add ( current ) ; writeLOC ( current ) ; } | Begins writing a new ZIP file entry and positions the stream to the start of the entry data . Closes the current entry if still active . The default compression method will be used if no compression method was specified for the entry and the current time will be used if the entry has no set modification time . |
26,727 | public void closeEntry ( ) throws IOException { ensureOpen ( ) ; if ( current != null ) { ZipEntry e = current . entry ; switch ( e . method ) { case DEFLATED : def . finish ( ) ; while ( ! def . finished ( ) ) { deflate ( ) ; } if ( ( e . flag & 8 ) == 0 ) { if ( e . size != def . getBytesRead ( ) ) { throw new ZipException ( "invalid entry size (expected " + e . size + " but got " + def . getBytesRead ( ) + " bytes)" ) ; } if ( e . csize != def . getBytesWritten ( ) ) { throw new ZipException ( "invalid entry compressed size (expected " + e . csize + " but got " + def . getBytesWritten ( ) + " bytes)" ) ; } if ( e . crc != crc . getValue ( ) ) { throw new ZipException ( "invalid entry CRC-32 (expected 0x" + Long . toHexString ( e . crc ) + " but got 0x" + Long . toHexString ( crc . getValue ( ) ) + ")" ) ; } } else { e . size = def . getBytesRead ( ) ; e . csize = def . getBytesWritten ( ) ; e . crc = crc . getValue ( ) ; writeEXT ( e ) ; } def . reset ( ) ; written += e . csize ; break ; case STORED : if ( e . size != written - locoff ) { throw new ZipException ( "invalid entry size (expected " + e . size + " but got " + ( written - locoff ) + " bytes)" ) ; } if ( e . crc != crc . getValue ( ) ) { throw new ZipException ( "invalid entry crc-32 (expected 0x" + Long . toHexString ( e . crc ) + " but got 0x" + Long . toHexString ( crc . getValue ( ) ) + ")" ) ; } break ; default : throw new ZipException ( "invalid compression method" ) ; } crc . reset ( ) ; current = null ; } } | Closes the current ZIP entry and positions the stream for writing the next entry . |
26,728 | public synchronized void write ( byte [ ] b , int off , int len ) throws IOException { ensureOpen ( ) ; if ( off < 0 || len < 0 || off > b . length - len ) { throw new IndexOutOfBoundsException ( ) ; } else if ( len == 0 ) { return ; } if ( current == null ) { throw new ZipException ( "no current ZIP entry" ) ; } ZipEntry entry = current . entry ; switch ( entry . method ) { case DEFLATED : super . write ( b , off , len ) ; break ; case STORED : written += len ; if ( written - locoff > entry . size ) { throw new ZipException ( "attempt to write past end of STORED entry" ) ; } out . write ( b , off , len ) ; break ; default : throw new ZipException ( "invalid compression method" ) ; } crc . update ( b , off , len ) ; } | Writes an array of bytes to the current ZIP entry data . This method will block until all the bytes are written . |
26,729 | public void finish ( ) throws IOException { ensureOpen ( ) ; if ( finished ) { return ; } if ( xentries . isEmpty ( ) ) { throw new ZipException ( "No entries" ) ; } if ( current != null ) { closeEntry ( ) ; } long off = written ; for ( XEntry xentry : xentries ) writeCEN ( xentry ) ; writeEND ( off , written - off ) ; finished = true ; } | Finishes writing the contents of the ZIP output stream without closing the underlying stream . Use this method when applying multiple filters in succession to the same output stream . |
26,730 | public String getDisplayName ( TimeZone tz , GenericNameType type , long date ) { String name = null ; String tzCanonicalID = null ; switch ( type ) { case LOCATION : tzCanonicalID = ZoneMeta . getCanonicalCLDRID ( tz ) ; if ( tzCanonicalID != null ) { name = getGenericLocationName ( tzCanonicalID ) ; } break ; case LONG : case SHORT : name = formatGenericNonLocationName ( tz , type , date ) ; if ( name == null ) { tzCanonicalID = ZoneMeta . getCanonicalCLDRID ( tz ) ; if ( tzCanonicalID != null ) { name = getGenericLocationName ( tzCanonicalID ) ; } } break ; } return name ; } | Returns the display name of the time zone for the given name type at the given date or null if the display name is not available . |
26,731 | public String getGenericLocationName ( String canonicalTzID ) { if ( canonicalTzID == null || canonicalTzID . length ( ) == 0 ) { return null ; } String name = _genericLocationNamesMap . get ( canonicalTzID ) ; if ( name != null ) { if ( name . length ( ) == 0 ) { return null ; } return name ; } Output < Boolean > isPrimary = new Output < Boolean > ( ) ; String countryCode = ZoneMeta . getCanonicalCountry ( canonicalTzID , isPrimary ) ; if ( countryCode != null ) { if ( isPrimary . value ) { String country = getLocaleDisplayNames ( ) . regionDisplayName ( countryCode ) ; name = formatPattern ( Pattern . REGION_FORMAT , country ) ; } else { String city = _tznames . getExemplarLocationName ( canonicalTzID ) ; name = formatPattern ( Pattern . REGION_FORMAT , city ) ; } } if ( name == null ) { _genericLocationNamesMap . putIfAbsent ( canonicalTzID . intern ( ) , "" ) ; } else { synchronized ( this ) { canonicalTzID = canonicalTzID . intern ( ) ; String tmp = _genericLocationNamesMap . putIfAbsent ( canonicalTzID , name . intern ( ) ) ; if ( tmp == null ) { NameInfo info = new NameInfo ( canonicalTzID , GenericNameType . LOCATION ) ; _gnamesTrie . put ( name , info ) ; } else { name = tmp ; } } } return name ; } | Returns the generic location name for the given canonical time zone ID . |
26,732 | private synchronized String formatPattern ( Pattern pat , String ... args ) { if ( _patternFormatters == null ) { _patternFormatters = new MessageFormat [ Pattern . values ( ) . length ] ; } int idx = pat . ordinal ( ) ; if ( _patternFormatters [ idx ] == null ) { String patText ; try { ICUResourceBundle bundle = ( ICUResourceBundle ) ICUResourceBundle . getBundleInstance ( ICUData . ICU_ZONE_BASE_NAME , _locale ) ; patText = bundle . getStringWithFallback ( "zoneStrings/" + pat . key ( ) ) ; } catch ( MissingResourceException e ) { patText = pat . defaultValue ( ) ; } _patternFormatters [ idx ] = new MessageFormat ( patText ) ; } return _patternFormatters [ idx ] . format ( args ) ; } | Private simple pattern formatter used for formatting generic location names and partial location names . We intentionally use JDK MessageFormat for performance reason . |
26,733 | private synchronized LocaleDisplayNames getLocaleDisplayNames ( ) { LocaleDisplayNames locNames = null ; if ( _localeDisplayNamesRef != null ) { locNames = _localeDisplayNamesRef . get ( ) ; } if ( locNames == null ) { locNames = LocaleDisplayNames . getInstance ( _locale ) ; _localeDisplayNamesRef = new WeakReference < LocaleDisplayNames > ( locNames ) ; } return locNames ; } | Private method returning LocaleDisplayNames instance for the locale of this instance . Because LocaleDisplayNames is only used for generic location formant and partial location format the LocaleDisplayNames is instantiated lazily . |
26,734 | public GenericMatchInfo findBestMatch ( String text , int start , EnumSet < GenericNameType > genericTypes ) { if ( text == null || text . length ( ) == 0 || start < 0 || start >= text . length ( ) ) { throw new IllegalArgumentException ( "bad input text or range" ) ; } GenericMatchInfo bestMatch = null ; Collection < MatchInfo > tznamesMatches = findTimeZoneNames ( text , start , genericTypes ) ; if ( tznamesMatches != null ) { MatchInfo longestMatch = null ; for ( MatchInfo match : tznamesMatches ) { if ( longestMatch == null || match . matchLength ( ) > longestMatch . matchLength ( ) ) { longestMatch = match ; } } if ( longestMatch != null ) { bestMatch = createGenericMatchInfo ( longestMatch ) ; if ( bestMatch . matchLength ( ) == ( text . length ( ) - start ) ) { if ( bestMatch . timeType != TimeType . STANDARD ) { return bestMatch ; } } } } Collection < GenericMatchInfo > localMatches = findLocal ( text , start , genericTypes ) ; if ( localMatches != null ) { for ( GenericMatchInfo match : localMatches ) { if ( bestMatch == null || match . matchLength ( ) >= bestMatch . matchLength ( ) ) { bestMatch = match ; } } } return bestMatch ; } | Returns the best match of time zone display name for the specified types in the given text at the given offset . |
26,735 | public Collection < GenericMatchInfo > find ( String text , int start , EnumSet < GenericNameType > genericTypes ) { if ( text == null || text . length ( ) == 0 || start < 0 || start >= text . length ( ) ) { throw new IllegalArgumentException ( "bad input text or range" ) ; } Collection < GenericMatchInfo > results = findLocal ( text , start , genericTypes ) ; Collection < MatchInfo > tznamesMatches = findTimeZoneNames ( text , start , genericTypes ) ; if ( tznamesMatches != null ) { for ( MatchInfo match : tznamesMatches ) { if ( results == null ) { results = new LinkedList < GenericMatchInfo > ( ) ; } results . add ( createGenericMatchInfo ( match ) ) ; } } return results ; } | Returns a collection of time zone display name matches for the specified types in the given text at the given offset . |
26,736 | private Collection < MatchInfo > findTimeZoneNames ( String text , int start , EnumSet < GenericNameType > types ) { Collection < MatchInfo > tznamesMatches = null ; EnumSet < NameType > nameTypes = EnumSet . noneOf ( NameType . class ) ; if ( types . contains ( GenericNameType . LONG ) ) { nameTypes . add ( NameType . LONG_GENERIC ) ; nameTypes . add ( NameType . LONG_STANDARD ) ; } if ( types . contains ( GenericNameType . SHORT ) ) { nameTypes . add ( NameType . SHORT_GENERIC ) ; nameTypes . add ( NameType . SHORT_STANDARD ) ; } if ( ! nameTypes . isEmpty ( ) ) { tznamesMatches = _tznames . find ( text , start , nameTypes ) ; } return tznamesMatches ; } | Returns a collection of time zone display name matches for the specified types in the given text at the given offset . This method only finds matches from the TimeZoneNames used by this object . |
26,737 | protected boolean applyFilter ( Node node , int nodeType ) { if ( fFilter != null && ( fWhatToShowFilter & nodeType ) != 0 ) { short code = fFilter . acceptNode ( node ) ; switch ( code ) { case NodeFilter . FILTER_REJECT : case NodeFilter . FILTER_SKIP : return false ; default : } } return true ; } | Applies a filter on the node to serialize |
26,738 | protected void serializeDocType ( DocumentType node , boolean bStart ) throws SAXException { String docTypeName = node . getNodeName ( ) ; String publicId = node . getPublicId ( ) ; String systemId = node . getSystemId ( ) ; String internalSubset = node . getInternalSubset ( ) ; if ( internalSubset != null && ! "" . equals ( internalSubset ) ) { if ( bStart ) { try { Writer writer = fSerializer . getWriter ( ) ; StringBuffer dtd = new StringBuffer ( ) ; dtd . append ( "<!DOCTYPE " ) ; dtd . append ( docTypeName ) ; if ( null != publicId ) { dtd . append ( " PUBLIC \"" ) ; dtd . append ( publicId ) ; dtd . append ( '\"' ) ; } if ( null != systemId ) { if ( null == publicId ) { dtd . append ( " SYSTEM \"" ) ; } else { dtd . append ( " \"" ) ; } dtd . append ( systemId ) ; dtd . append ( '\"' ) ; } dtd . append ( " [ " ) ; dtd . append ( fNewLine ) ; dtd . append ( internalSubset ) ; dtd . append ( "]>" ) ; dtd . append ( new String ( fNewLine ) ) ; writer . write ( dtd . toString ( ) ) ; writer . flush ( ) ; } catch ( IOException e ) { throw new SAXException ( Utils . messages . createMessage ( MsgKey . ER_WRITING_INTERNAL_SUBSET , null ) , e ) ; } } } else { if ( bStart ) { if ( fLexicalHandler != null ) { fLexicalHandler . startDTD ( docTypeName , publicId , systemId ) ; } } else { if ( fLexicalHandler != null ) { fLexicalHandler . endDTD ( ) ; } } } } | Serializes a Document Type Node . |
26,739 | protected void serializeComment ( Comment node ) throws SAXException { if ( ( fFeatures & COMMENTS ) != 0 ) { String data = node . getData ( ) ; if ( ( fFeatures & WELLFORMED ) != 0 ) { isCommentWellFormed ( data ) ; } if ( fLexicalHandler != null ) { if ( ! applyFilter ( node , NodeFilter . SHOW_COMMENT ) ) { return ; } fLexicalHandler . comment ( data . toCharArray ( ) , 0 , data . length ( ) ) ; } } } | Serializes a Comment Node . |
26,740 | protected void serializeElement ( Element node , boolean bStart ) throws SAXException { if ( bStart ) { fElementDepth ++ ; if ( ( fFeatures & WELLFORMED ) != 0 ) { isElementWellFormed ( node ) ; } if ( ! applyFilter ( node , NodeFilter . SHOW_ELEMENT ) ) { return ; } if ( ( fFeatures & NAMESPACES ) != 0 ) { fNSBinder . pushContext ( ) ; fLocalNSBinder . reset ( ) ; recordLocalNSDecl ( node ) ; fixupElementNS ( node ) ; } fSerializer . startElement ( node . getNamespaceURI ( ) , node . getLocalName ( ) , node . getNodeName ( ) ) ; serializeAttList ( node ) ; } else { fElementDepth -- ; if ( ! applyFilter ( node , NodeFilter . SHOW_ELEMENT ) ) { return ; } this . fSerializer . endElement ( node . getNamespaceURI ( ) , node . getLocalName ( ) , node . getNodeName ( ) ) ; if ( ( fFeatures & NAMESPACES ) != 0 ) { fNSBinder . popContext ( ) ; } } } | Serializes an Element Node . |
26,741 | protected void serializePI ( ProcessingInstruction node ) throws SAXException { ProcessingInstruction pi = node ; String name = pi . getNodeName ( ) ; if ( ( fFeatures & WELLFORMED ) != 0 ) { isPIWellFormed ( node ) ; } if ( ! applyFilter ( node , NodeFilter . SHOW_PROCESSING_INSTRUCTION ) ) { return ; } if ( name . equals ( "xslt-next-is-raw" ) ) { fNextIsRaw = true ; } else { this . fSerializer . processingInstruction ( name , pi . getData ( ) ) ; } } | Serializes an ProcessingInstruction Node . |
26,742 | protected void serializeCDATASection ( CDATASection node ) throws SAXException { if ( ( fFeatures & WELLFORMED ) != 0 ) { isCDATASectionWellFormed ( node ) ; } if ( ( fFeatures & CDATA ) != 0 ) { String nodeValue = node . getNodeValue ( ) ; int endIndex = nodeValue . indexOf ( "]]>" ) ; if ( ( fFeatures & SPLITCDATA ) != 0 ) { if ( endIndex >= 0 ) { String relatedData = nodeValue . substring ( 0 , endIndex + 2 ) ; String msg = Utils . messages . createMessage ( MsgKey . ER_CDATA_SECTIONS_SPLIT , null ) ; if ( fErrorHandler != null ) { fErrorHandler . handleError ( new DOMErrorImpl ( DOMError . SEVERITY_WARNING , msg , MsgKey . ER_CDATA_SECTIONS_SPLIT , null , relatedData , null ) ) ; } } } else { if ( endIndex >= 0 ) { String relatedData = nodeValue . substring ( 0 , endIndex + 2 ) ; String msg = Utils . messages . createMessage ( MsgKey . ER_CDATA_SECTIONS_SPLIT , null ) ; if ( fErrorHandler != null ) { fErrorHandler . handleError ( new DOMErrorImpl ( DOMError . SEVERITY_ERROR , msg , MsgKey . ER_CDATA_SECTIONS_SPLIT ) ) ; } return ; } } if ( ! applyFilter ( node , NodeFilter . SHOW_CDATA_SECTION ) ) { return ; } if ( fLexicalHandler != null ) { fLexicalHandler . startCDATA ( ) ; } dispatachChars ( node ) ; if ( fLexicalHandler != null ) { fLexicalHandler . endCDATA ( ) ; } } else { dispatachChars ( node ) ; } } | Serializes an CDATASection Node . |
26,743 | protected void serializeText ( Text node ) throws SAXException { if ( fNextIsRaw ) { fNextIsRaw = false ; fSerializer . processingInstruction ( javax . xml . transform . Result . PI_DISABLE_OUTPUT_ESCAPING , "" ) ; dispatachChars ( node ) ; fSerializer . processingInstruction ( javax . xml . transform . Result . PI_ENABLE_OUTPUT_ESCAPING , "" ) ; } else { boolean bDispatch = false ; if ( ( fFeatures & WELLFORMED ) != 0 ) { isTextWellFormed ( node ) ; } boolean isElementContentWhitespace = false ; if ( fIsLevel3DOM ) { isElementContentWhitespace = node . isElementContentWhitespace ( ) ; } if ( isElementContentWhitespace ) { if ( ( fFeatures & ELEM_CONTENT_WHITESPACE ) != 0 ) { bDispatch = true ; } } else { bDispatch = true ; } if ( ! applyFilter ( node , NodeFilter . SHOW_TEXT ) ) { return ; } if ( bDispatch ) { dispatachChars ( node ) ; } } } | Serializes an Text Node . |
26,744 | protected void serializeEntityReference ( EntityReference node , boolean bStart ) throws SAXException { if ( bStart ) { EntityReference eref = node ; if ( ( fFeatures & ENTITIES ) != 0 ) { if ( ( fFeatures & WELLFORMED ) != 0 ) { isEntityReferneceWellFormed ( node ) ; } if ( ( fFeatures & NAMESPACES ) != 0 ) { checkUnboundPrefixInEntRef ( node ) ; } } if ( fLexicalHandler != null ) { fLexicalHandler . startEntity ( eref . getNodeName ( ) ) ; } } else { EntityReference eref = node ; if ( fLexicalHandler != null ) { fLexicalHandler . endEntity ( eref . getNodeName ( ) ) ; } } } | Serializes an EntityReference Node . |
26,745 | protected boolean isWFXMLChar ( String chardata , Character refInvalidChar ) { if ( chardata == null || ( chardata . length ( ) == 0 ) ) { return true ; } char [ ] dataarray = chardata . toCharArray ( ) ; int datalength = dataarray . length ; if ( fIsXMLVersion11 ) { int i = 0 ; while ( i < datalength ) { if ( XML11Char . isXML11Invalid ( dataarray [ i ++ ] ) ) { char ch = dataarray [ i - 1 ] ; if ( XMLChar . isHighSurrogate ( ch ) && i < datalength ) { char ch2 = dataarray [ i ++ ] ; if ( XMLChar . isLowSurrogate ( ch2 ) && XMLChar . isSupplemental ( XMLChar . supplemental ( ch , ch2 ) ) ) { continue ; } } refInvalidChar = new Character ( ch ) ; return false ; } } } else { int i = 0 ; while ( i < datalength ) { if ( XMLChar . isInvalid ( dataarray [ i ++ ] ) ) { char ch = dataarray [ i - 1 ] ; if ( XMLChar . isHighSurrogate ( ch ) && i < datalength ) { char ch2 = dataarray [ i ++ ] ; if ( XMLChar . isLowSurrogate ( ch2 ) && XMLChar . isSupplemental ( XMLChar . supplemental ( ch , ch2 ) ) ) { continue ; } } refInvalidChar = new Character ( ch ) ; return false ; } } } return true ; } | Checks if a XML character is well - formed |
26,746 | protected void isCommentWellFormed ( String data ) { if ( data == null || ( data . length ( ) == 0 ) ) { return ; } char [ ] dataarray = data . toCharArray ( ) ; int datalength = dataarray . length ; if ( fIsXMLVersion11 ) { int i = 0 ; while ( i < datalength ) { char c = dataarray [ i ++ ] ; if ( XML11Char . isXML11Invalid ( c ) ) { if ( XMLChar . isHighSurrogate ( c ) && i < datalength ) { char c2 = dataarray [ i ++ ] ; if ( XMLChar . isLowSurrogate ( c2 ) && XMLChar . isSupplemental ( XMLChar . supplemental ( c , c2 ) ) ) { continue ; } } String msg = Utils . messages . createMessage ( MsgKey . ER_WF_INVALID_CHARACTER_IN_COMMENT , new Object [ ] { new Character ( c ) } ) ; if ( fErrorHandler != null ) { fErrorHandler . handleError ( new DOMErrorImpl ( DOMError . SEVERITY_FATAL_ERROR , msg , MsgKey . ER_WF_INVALID_CHARACTER , null , null , null ) ) ; } } else if ( c == '-' && i < datalength && dataarray [ i ] == '-' ) { String msg = Utils . messages . createMessage ( MsgKey . ER_WF_DASH_IN_COMMENT , null ) ; if ( fErrorHandler != null ) { fErrorHandler . handleError ( new DOMErrorImpl ( DOMError . SEVERITY_FATAL_ERROR , msg , MsgKey . ER_WF_INVALID_CHARACTER , null , null , null ) ) ; } } } } else { int i = 0 ; while ( i < datalength ) { char c = dataarray [ i ++ ] ; if ( XMLChar . isInvalid ( c ) ) { if ( XMLChar . isHighSurrogate ( c ) && i < datalength ) { char c2 = dataarray [ i ++ ] ; if ( XMLChar . isLowSurrogate ( c2 ) && XMLChar . isSupplemental ( XMLChar . supplemental ( c , c2 ) ) ) { continue ; } } String msg = Utils . messages . createMessage ( MsgKey . ER_WF_INVALID_CHARACTER_IN_COMMENT , new Object [ ] { new Character ( c ) } ) ; if ( fErrorHandler != null ) { fErrorHandler . handleError ( new DOMErrorImpl ( DOMError . SEVERITY_FATAL_ERROR , msg , MsgKey . ER_WF_INVALID_CHARACTER , null , null , null ) ) ; } } else if ( c == '-' && i < datalength && dataarray [ i ] == '-' ) { String msg = Utils . messages . createMessage ( MsgKey . ER_WF_DASH_IN_COMMENT , null ) ; if ( fErrorHandler != null ) { fErrorHandler . handleError ( new DOMErrorImpl ( DOMError . SEVERITY_FATAL_ERROR , msg , MsgKey . ER_WF_INVALID_CHARACTER , null , null , null ) ) ; } } } } return ; } | Checks if a comment node is well - formed |
26,747 | protected void isElementWellFormed ( Node node ) { boolean isNameWF = false ; if ( ( fFeatures & NAMESPACES ) != 0 ) { isNameWF = isValidQName ( node . getPrefix ( ) , node . getLocalName ( ) , fIsXMLVersion11 ) ; } else { isNameWF = isXMLName ( node . getNodeName ( ) , fIsXMLVersion11 ) ; } if ( ! isNameWF ) { String msg = Utils . messages . createMessage ( MsgKey . ER_WF_INVALID_CHARACTER_IN_NODE_NAME , new Object [ ] { "Element" , node . getNodeName ( ) } ) ; if ( fErrorHandler != null ) { fErrorHandler . handleError ( new DOMErrorImpl ( DOMError . SEVERITY_FATAL_ERROR , msg , MsgKey . ER_WF_INVALID_CHARACTER_IN_NODE_NAME , null , null , null ) ) ; } } } | Checks if an element node is well - formed by checking its Name for well - formedness . |
26,748 | protected void isAttributeWellFormed ( Node node ) { boolean isNameWF = false ; if ( ( fFeatures & NAMESPACES ) != 0 ) { isNameWF = isValidQName ( node . getPrefix ( ) , node . getLocalName ( ) , fIsXMLVersion11 ) ; } else { isNameWF = isXMLName ( node . getNodeName ( ) , fIsXMLVersion11 ) ; } if ( ! isNameWF ) { String msg = Utils . messages . createMessage ( MsgKey . ER_WF_INVALID_CHARACTER_IN_NODE_NAME , new Object [ ] { "Attr" , node . getNodeName ( ) } ) ; if ( fErrorHandler != null ) { fErrorHandler . handleError ( new DOMErrorImpl ( DOMError . SEVERITY_FATAL_ERROR , msg , MsgKey . ER_WF_INVALID_CHARACTER_IN_NODE_NAME , null , null , null ) ) ; } } String value = node . getNodeValue ( ) ; if ( value . indexOf ( '<' ) >= 0 ) { String msg = Utils . messages . createMessage ( MsgKey . ER_WF_LT_IN_ATTVAL , new Object [ ] { ( ( Attr ) node ) . getOwnerElement ( ) . getNodeName ( ) , node . getNodeName ( ) } ) ; if ( fErrorHandler != null ) { fErrorHandler . handleError ( new DOMErrorImpl ( DOMError . SEVERITY_FATAL_ERROR , msg , MsgKey . ER_WF_LT_IN_ATTVAL , null , null , null ) ) ; } } NodeList children = node . getChildNodes ( ) ; for ( int i = 0 ; i < children . getLength ( ) ; i ++ ) { Node child = children . item ( i ) ; if ( child == null ) { continue ; } switch ( child . getNodeType ( ) ) { case Node . TEXT_NODE : isTextWellFormed ( ( Text ) child ) ; break ; case Node . ENTITY_REFERENCE_NODE : isEntityReferneceWellFormed ( ( EntityReference ) child ) ; break ; default : } } } | Checks if an attr node is well - formed by checking it s Name and value for well - formedness . |
26,749 | protected void isPIWellFormed ( ProcessingInstruction node ) { if ( ! isXMLName ( node . getNodeName ( ) , fIsXMLVersion11 ) ) { String msg = Utils . messages . createMessage ( MsgKey . ER_WF_INVALID_CHARACTER_IN_NODE_NAME , new Object [ ] { "ProcessingInstruction" , node . getTarget ( ) } ) ; if ( fErrorHandler != null ) { fErrorHandler . handleError ( new DOMErrorImpl ( DOMError . SEVERITY_FATAL_ERROR , msg , MsgKey . ER_WF_INVALID_CHARACTER_IN_NODE_NAME , null , null , null ) ) ; } } Character invalidChar = isWFXMLChar ( node . getData ( ) ) ; if ( invalidChar != null ) { String msg = Utils . messages . createMessage ( MsgKey . ER_WF_INVALID_CHARACTER_IN_PI , new Object [ ] { Integer . toHexString ( Character . getNumericValue ( invalidChar . charValue ( ) ) ) } ) ; if ( fErrorHandler != null ) { fErrorHandler . handleError ( new DOMErrorImpl ( DOMError . SEVERITY_FATAL_ERROR , msg , MsgKey . ER_WF_INVALID_CHARACTER , null , null , null ) ) ; } } } | Checks if a PI node is well - formed by checking it s Name and data for well - formedness . |
26,750 | protected void isCDATASectionWellFormed ( CDATASection node ) { Character invalidChar = isWFXMLChar ( node . getData ( ) ) ; if ( invalidChar != null ) { String msg = Utils . messages . createMessage ( MsgKey . ER_WF_INVALID_CHARACTER_IN_CDATA , new Object [ ] { Integer . toHexString ( Character . getNumericValue ( invalidChar . charValue ( ) ) ) } ) ; if ( fErrorHandler != null ) { fErrorHandler . handleError ( new DOMErrorImpl ( DOMError . SEVERITY_FATAL_ERROR , msg , MsgKey . ER_WF_INVALID_CHARACTER , null , null , null ) ) ; } } } | Checks if an CDATASection node is well - formed by checking it s data for well - formedness . Note that the presence of a CDATA termination mark in the contents of a CDATASection is handled by the parameter spli - cdata - sections |
26,751 | protected void isTextWellFormed ( Text node ) { Character invalidChar = isWFXMLChar ( node . getData ( ) ) ; if ( invalidChar != null ) { String msg = Utils . messages . createMessage ( MsgKey . ER_WF_INVALID_CHARACTER_IN_TEXT , new Object [ ] { Integer . toHexString ( Character . getNumericValue ( invalidChar . charValue ( ) ) ) } ) ; if ( fErrorHandler != null ) { fErrorHandler . handleError ( new DOMErrorImpl ( DOMError . SEVERITY_FATAL_ERROR , msg , MsgKey . ER_WF_INVALID_CHARACTER , null , null , null ) ) ; } } } | Checks if an Text node is well - formed by checking if it contains invalid XML characters . |
26,752 | protected void isEntityReferneceWellFormed ( EntityReference node ) { if ( ! isXMLName ( node . getNodeName ( ) , fIsXMLVersion11 ) ) { String msg = Utils . messages . createMessage ( MsgKey . ER_WF_INVALID_CHARACTER_IN_NODE_NAME , new Object [ ] { "EntityReference" , node . getNodeName ( ) } ) ; if ( fErrorHandler != null ) { fErrorHandler . handleError ( new DOMErrorImpl ( DOMError . SEVERITY_FATAL_ERROR , msg , MsgKey . ER_WF_INVALID_CHARACTER_IN_NODE_NAME , null , null , null ) ) ; } } Node parent = node . getParentNode ( ) ; DocumentType docType = node . getOwnerDocument ( ) . getDoctype ( ) ; if ( docType != null ) { NamedNodeMap entities = docType . getEntities ( ) ; for ( int i = 0 ; i < entities . getLength ( ) ; i ++ ) { Entity ent = ( Entity ) entities . item ( i ) ; String nodeName = node . getNodeName ( ) == null ? "" : node . getNodeName ( ) ; String nodeNamespaceURI = node . getNamespaceURI ( ) == null ? "" : node . getNamespaceURI ( ) ; String entName = ent . getNodeName ( ) == null ? "" : ent . getNodeName ( ) ; String entNamespaceURI = ent . getNamespaceURI ( ) == null ? "" : ent . getNamespaceURI ( ) ; if ( parent . getNodeType ( ) == Node . ELEMENT_NODE ) { if ( entNamespaceURI . equals ( nodeNamespaceURI ) && entName . equals ( nodeName ) ) { if ( ent . getNotationName ( ) != null ) { String msg = Utils . messages . createMessage ( MsgKey . ER_WF_REF_TO_UNPARSED_ENT , new Object [ ] { node . getNodeName ( ) } ) ; if ( fErrorHandler != null ) { fErrorHandler . handleError ( new DOMErrorImpl ( DOMError . SEVERITY_FATAL_ERROR , msg , MsgKey . ER_WF_REF_TO_UNPARSED_ENT , null , null , null ) ) ; } } } } if ( parent . getNodeType ( ) == Node . ATTRIBUTE_NODE ) { if ( entNamespaceURI . equals ( nodeNamespaceURI ) && entName . equals ( nodeName ) ) { if ( ent . getPublicId ( ) != null || ent . getSystemId ( ) != null || ent . getNotationName ( ) != null ) { String msg = Utils . messages . createMessage ( MsgKey . ER_WF_REF_TO_EXTERNAL_ENT , new Object [ ] { node . getNodeName ( ) } ) ; if ( fErrorHandler != null ) { fErrorHandler . handleError ( new DOMErrorImpl ( DOMError . SEVERITY_FATAL_ERROR , msg , MsgKey . ER_WF_REF_TO_EXTERNAL_ENT , null , null , null ) ) ; } } } } } } } | Checks if an EntityRefernece node is well - formed by checking it s node name . Then depending on whether it is referenced in Element content or in an Attr Node checks if the EntityReference references an unparsed entity or a external entity and if so throws raises the appropriate well - formedness error . |
26,753 | protected void checkUnboundPrefixInEntRef ( Node node ) { Node child , next ; for ( child = node . getFirstChild ( ) ; child != null ; child = next ) { next = child . getNextSibling ( ) ; if ( child . getNodeType ( ) == Node . ELEMENT_NODE ) { String prefix = child . getPrefix ( ) ; if ( prefix != null && fNSBinder . getURI ( prefix ) == null ) { String msg = Utils . messages . createMessage ( MsgKey . ER_ELEM_UNBOUND_PREFIX_IN_ENTREF , new Object [ ] { node . getNodeName ( ) , child . getNodeName ( ) , prefix } ) ; if ( fErrorHandler != null ) { fErrorHandler . handleError ( new DOMErrorImpl ( DOMError . SEVERITY_FATAL_ERROR , msg , MsgKey . ER_ELEM_UNBOUND_PREFIX_IN_ENTREF , null , null , null ) ) ; } } NamedNodeMap attrs = child . getAttributes ( ) ; for ( int i = 0 ; i < attrs . getLength ( ) ; i ++ ) { String attrPrefix = attrs . item ( i ) . getPrefix ( ) ; if ( attrPrefix != null && fNSBinder . getURI ( attrPrefix ) == null ) { String msg = Utils . messages . createMessage ( MsgKey . ER_ATTR_UNBOUND_PREFIX_IN_ENTREF , new Object [ ] { node . getNodeName ( ) , child . getNodeName ( ) , attrs . item ( i ) } ) ; if ( fErrorHandler != null ) { fErrorHandler . handleError ( new DOMErrorImpl ( DOMError . SEVERITY_FATAL_ERROR , msg , MsgKey . ER_ATTR_UNBOUND_PREFIX_IN_ENTREF , null , null , null ) ) ; } } } } if ( child . hasChildNodes ( ) ) { checkUnboundPrefixInEntRef ( child ) ; } } } | If the configuration parameter namespaces is set to true this methods checks if an entity whose replacement text contains unbound namespace prefixes is referenced in a location where there are no bindings for the namespace prefixes and if so raises a LSException with the error - type unbound - prefix - in - entity - reference |
26,754 | protected void recordLocalNSDecl ( Node node ) { NamedNodeMap atts = ( ( Element ) node ) . getAttributes ( ) ; int length = atts . getLength ( ) ; for ( int i = 0 ; i < length ; i ++ ) { Node attr = atts . item ( i ) ; String localName = attr . getLocalName ( ) ; String attrPrefix = attr . getPrefix ( ) ; String attrValue = attr . getNodeValue ( ) ; String attrNS = attr . getNamespaceURI ( ) ; localName = localName == null || XMLNS_PREFIX . equals ( localName ) ? "" : localName ; attrPrefix = attrPrefix == null ? "" : attrPrefix ; attrValue = attrValue == null ? "" : attrValue ; attrNS = attrNS == null ? "" : attrNS ; if ( XMLNS_URI . equals ( attrNS ) ) { if ( XMLNS_URI . equals ( attrValue ) ) { String msg = Utils . messages . createMessage ( MsgKey . ER_NS_PREFIX_CANNOT_BE_BOUND , new Object [ ] { attrPrefix , XMLNS_URI } ) ; if ( fErrorHandler != null ) { fErrorHandler . handleError ( new DOMErrorImpl ( DOMError . SEVERITY_ERROR , msg , MsgKey . ER_NS_PREFIX_CANNOT_BE_BOUND , null , null , null ) ) ; } } else { if ( XMLNS_PREFIX . equals ( attrPrefix ) ) { if ( attrValue . length ( ) != 0 ) { fNSBinder . declarePrefix ( localName , attrValue ) ; } else { } } else { fNSBinder . declarePrefix ( "" , attrValue ) ; } } } } } | Records local namespace declarations to be used for normalization later |
26,755 | protected void fixupElementNS ( Node node ) throws SAXException { String namespaceURI = ( ( Element ) node ) . getNamespaceURI ( ) ; String prefix = ( ( Element ) node ) . getPrefix ( ) ; String localName = ( ( Element ) node ) . getLocalName ( ) ; if ( namespaceURI != null ) { prefix = prefix == null ? "" : prefix ; String inScopeNamespaceURI = fNSBinder . getURI ( prefix ) ; if ( ( inScopeNamespaceURI != null && inScopeNamespaceURI . equals ( namespaceURI ) ) ) { } else { if ( ( fFeatures & NAMESPACEDECLS ) != 0 ) { if ( "" . equals ( prefix ) || "" . equals ( namespaceURI ) ) { ( ( Element ) node ) . setAttributeNS ( XMLNS_URI , XMLNS_PREFIX , namespaceURI ) ; } else { ( ( Element ) node ) . setAttributeNS ( XMLNS_URI , XMLNS_PREFIX + ":" + prefix , namespaceURI ) ; } } fLocalNSBinder . declarePrefix ( prefix , namespaceURI ) ; fNSBinder . declarePrefix ( prefix , namespaceURI ) ; } } else { if ( localName == null || "" . equals ( localName ) ) { String msg = Utils . messages . createMessage ( MsgKey . ER_NULL_LOCAL_ELEMENT_NAME , new Object [ ] { node . getNodeName ( ) } ) ; if ( fErrorHandler != null ) { fErrorHandler . handleError ( new DOMErrorImpl ( DOMError . SEVERITY_ERROR , msg , MsgKey . ER_NULL_LOCAL_ELEMENT_NAME , null , null , null ) ) ; } } else { namespaceURI = fNSBinder . getURI ( "" ) ; if ( namespaceURI != null && namespaceURI . length ( ) > 0 ) { ( ( Element ) node ) . setAttributeNS ( XMLNS_URI , XMLNS_PREFIX , "" ) ; fLocalNSBinder . declarePrefix ( "" , "" ) ; fNSBinder . declarePrefix ( "" , "" ) ; } } } } | Fixes an element s namespace |
26,756 | protected void initProperties ( Properties properties ) { for ( Enumeration keys = properties . keys ( ) ; keys . hasMoreElements ( ) ; ) { final String key = ( String ) keys . nextElement ( ) ; final Object iobj = s_propKeys . get ( key ) ; if ( iobj != null ) { if ( iobj instanceof Integer ) { final int BITFLAG = ( ( Integer ) iobj ) . intValue ( ) ; if ( ( properties . getProperty ( key ) . endsWith ( "yes" ) ) ) { fFeatures = fFeatures | BITFLAG ; } else { fFeatures = fFeatures & ~ BITFLAG ; } } else { if ( ( DOMConstants . S_DOM3_PROPERTIES_NS + DOMConstants . DOM_FORMAT_PRETTY_PRINT ) . equals ( key ) ) { if ( ( properties . getProperty ( key ) . endsWith ( "yes" ) ) ) { fSerializer . setIndent ( true ) ; fSerializer . setIndentAmount ( 3 ) ; } else { fSerializer . setIndent ( false ) ; } } else if ( ( DOMConstants . S_XSL_OUTPUT_OMIT_XML_DECL ) . equals ( key ) ) { if ( ( properties . getProperty ( key ) . endsWith ( "yes" ) ) ) { fSerializer . setOmitXMLDeclaration ( true ) ; } else { fSerializer . setOmitXMLDeclaration ( false ) ; } } else if ( ( DOMConstants . S_XERCES_PROPERTIES_NS + DOMConstants . S_XML_VERSION ) . equals ( key ) ) { String version = properties . getProperty ( key ) ; if ( "1.1" . equals ( version ) ) { fIsXMLVersion11 = true ; fSerializer . setVersion ( version ) ; } else { fSerializer . setVersion ( "1.0" ) ; } } else if ( ( DOMConstants . S_XSL_OUTPUT_ENCODING ) . equals ( key ) ) { String encoding = properties . getProperty ( key ) ; if ( encoding != null ) { fSerializer . setEncoding ( encoding ) ; } } else if ( ( DOMConstants . S_XERCES_PROPERTIES_NS + DOMConstants . DOM_ENTITIES ) . equals ( key ) ) { if ( ( properties . getProperty ( key ) . endsWith ( "yes" ) ) ) { fSerializer . setDTDEntityExpansion ( false ) ; } else { fSerializer . setDTDEntityExpansion ( true ) ; } } else { } } } } if ( fNewLine != null ) { fSerializer . setOutputProperty ( OutputPropertiesFactory . S_KEY_LINE_SEPARATOR , fNewLine ) ; } } | Initializes fFeatures based on the DOMConfiguration Parameters set . |
26,757 | private void tryInitialize ( boolean checkTermination ) { if ( runState == 0 ) { int p = config & SMASK ; int n = ( p > 1 ) ? p - 1 : 1 ; n |= n >>> 1 ; n |= n >>> 2 ; n |= n >>> 4 ; n |= n >>> 8 ; n |= n >>> 16 ; n = ( ( n + 1 ) << 1 ) & SMASK ; AuxState aux = new AuxState ( ) ; WorkQueue [ ] ws = new WorkQueue [ n ] ; synchronized ( modifyThreadPermission ) { if ( runState == 0 ) { workQueues = ws ; auxState = aux ; runState = STARTED ; } } } if ( checkTermination && runState < 0 ) { tryTerminate ( false , false ) ; throw new RejectedExecutionException ( ) ; } } | Instantiates fields upon first submission or upon shutdown if no submissions . If checkTermination true also responds to termination by external calls submitting tasks . |
26,758 | private boolean createWorker ( boolean isSpare ) { ForkJoinWorkerThreadFactory fac = factory ; Throwable ex = null ; ForkJoinWorkerThread wt = null ; WorkQueue q ; try { if ( fac != null && ( wt = fac . newThread ( this ) ) != null ) { if ( isSpare && ( q = wt . workQueue ) != null ) q . config |= SPARE_WORKER ; wt . start ( ) ; return true ; } } catch ( Throwable rex ) { ex = rex ; } deregisterWorker ( wt , ex ) ; return false ; } | Tries to construct and start one worker . Assumes that total count has already been incremented as a reservation . Invokes deregisterWorker on any failure . |
26,759 | private void tryAddWorker ( long c ) { do { long nc = ( ( AC_MASK & ( c + AC_UNIT ) ) | ( TC_MASK & ( c + TC_UNIT ) ) ) ; if ( ctl == c && U . compareAndSwapLong ( this , CTL , c , nc ) ) { createWorker ( false ) ; break ; } } while ( ( ( c = ctl ) & ADD_WORKER ) != 0L && ( int ) c == 0 ) ; } | Tries to add one worker incrementing ctl counts before doing so relying on createWorker to back out on failure . |
26,760 | final void deregisterWorker ( ForkJoinWorkerThread wt , Throwable ex ) { WorkQueue w = null ; if ( wt != null && ( w = wt . workQueue ) != null ) { AuxState aux ; WorkQueue [ ] ws ; int idx = w . config & SMASK ; int ns = w . nsteals ; if ( ( aux = auxState ) != null ) { aux . lock ( ) ; try { if ( ( ws = workQueues ) != null && ws . length > idx && ws [ idx ] == w ) ws [ idx ] = null ; aux . stealCount += ns ; } finally { aux . unlock ( ) ; } } } if ( w == null || ( w . config & UNREGISTERED ) == 0 ) { long c ; do { } while ( ! U . compareAndSwapLong ( this , CTL , c = ctl , ( ( AC_MASK & ( c - AC_UNIT ) ) | ( TC_MASK & ( c - TC_UNIT ) ) | ( SP_MASK & c ) ) ) ) ; } if ( w != null ) { w . currentSteal = null ; w . qlock = - 1 ; w . cancelAll ( ) ; } while ( tryTerminate ( false , false ) >= 0 ) { WorkQueue [ ] ws ; int wl , sp ; long c ; if ( w == null || w . array == null || ( ws = workQueues ) == null || ( wl = ws . length ) <= 0 ) break ; else if ( ( sp = ( int ) ( c = ctl ) ) != 0 ) { if ( tryRelease ( c , ws [ ( wl - 1 ) & sp ] , AC_UNIT ) ) break ; } else if ( ex != null && ( c & ADD_WORKER ) != 0L ) { tryAddWorker ( c ) ; break ; } else break ; } if ( ex == null ) ForkJoinTask . helpExpungeStaleExceptions ( ) ; else ForkJoinTask . rethrow ( ex ) ; } | Final callback from terminating worker as well as upon failure to construct or start a worker . Removes record of worker from array and adjusts counts . If pool is shutting down tries to complete termination . |
26,761 | final void signalWork ( ) { for ( ; ; ) { long c ; int sp , i ; WorkQueue v ; WorkQueue [ ] ws ; if ( ( c = ctl ) >= 0L ) break ; else if ( ( sp = ( int ) c ) == 0 ) { if ( ( c & ADD_WORKER ) != 0L ) tryAddWorker ( c ) ; break ; } else if ( ( ws = workQueues ) == null ) break ; else if ( ws . length <= ( i = sp & SMASK ) ) break ; else if ( ( v = ws [ i ] ) == null ) break ; else { int ns = sp & ~ UNSIGNALLED ; int vs = v . scanState ; long nc = ( v . stackPred & SP_MASK ) | ( UC_MASK & ( c + AC_UNIT ) ) ; if ( sp == vs && U . compareAndSwapLong ( this , CTL , c , nc ) ) { v . scanState = ns ; LockSupport . unpark ( v . parker ) ; break ; } } } } | Tries to create or activate a worker if too few are active . |
26,762 | private void inactivate ( WorkQueue w , int ss ) { int ns = ( ss + SS_SEQ ) | UNSIGNALLED ; long lc = ns & SP_MASK , nc , c ; if ( w != null ) { w . scanState = ns ; do { nc = lc | ( UC_MASK & ( ( c = ctl ) - AC_UNIT ) ) ; w . stackPred = ( int ) c ; } while ( ! U . compareAndSwapLong ( this , CTL , c , nc ) ) ; } } | If worker w exists and is active enqueues and sets status to inactive . |
26,763 | private boolean tryDropSpare ( WorkQueue w ) { if ( w != null && w . isEmpty ( ) ) { long c ; int sp , wl ; WorkQueue [ ] ws ; WorkQueue v ; while ( ( short ) ( ( c = ctl ) >> TC_SHIFT ) > 0 && ( ( sp = ( int ) c ) != 0 || ( int ) ( c >> AC_SHIFT ) > 0 ) && ( ws = workQueues ) != null && ( wl = ws . length ) > 0 ) { boolean dropped , canDrop ; if ( sp == 0 ) { long nc = ( ( AC_MASK & ( c - AC_UNIT ) ) | ( TC_MASK & ( c - TC_UNIT ) ) | ( SP_MASK & c ) ) ; dropped = U . compareAndSwapLong ( this , CTL , c , nc ) ; } else if ( ( v = ws [ ( wl - 1 ) & sp ] ) == null || v . scanState != sp ) dropped = false ; else { long nc = v . stackPred & SP_MASK ; if ( w == v || w . scanState >= 0 ) { canDrop = true ; nc |= ( ( AC_MASK & c ) | ( TC_MASK & ( c - TC_UNIT ) ) ) ; } else { canDrop = false ; nc |= ( ( AC_MASK & ( c + AC_UNIT ) ) | ( TC_MASK & c ) ) ; } if ( U . compareAndSwapLong ( this , CTL , c , nc ) ) { v . scanState = sp & ~ UNSIGNALLED ; LockSupport . unpark ( v . parker ) ; dropped = canDrop ; } else dropped = false ; } if ( dropped ) { int cfg = w . config , idx = cfg & SMASK ; if ( idx >= 0 && idx < ws . length && ws [ idx ] == w ) ws [ idx ] = null ; w . config = cfg | UNREGISTERED ; w . qlock = - 1 ; return true ; } } } return false ; } | If the given worker is a spare with no queued tasks and there are enough existing workers drops it from ctl counts and sets its state to terminated . |
26,764 | final ForkJoinTask < ? > nextTaskFor ( WorkQueue w ) { for ( ForkJoinTask < ? > t ; ; ) { WorkQueue q ; if ( ( t = w . nextLocalTask ( ) ) != null ) return t ; if ( ( q = findNonEmptyStealQueue ( ) ) == null ) return null ; if ( ( t = q . pollAt ( q . base ) ) != null ) return t ; } } | Gets and removes a local or stolen task for the given worker . |
26,765 | private void tryCreateExternalQueue ( int index ) { AuxState aux ; if ( ( aux = auxState ) != null && index >= 0 ) { WorkQueue q = new WorkQueue ( this , null ) ; q . config = index ; q . scanState = ~ UNSIGNALLED ; q . qlock = 1 ; boolean installed = false ; aux . lock ( ) ; try { WorkQueue [ ] ws ; if ( ( ws = workQueues ) != null && index < ws . length && ws [ index ] == null ) { ws [ index ] = q ; installed = true ; } } finally { aux . unlock ( ) ; } if ( installed ) { try { q . growArray ( ) ; } finally { q . qlock = 0 ; } } } } | Constructs and tries to install a new external queue failing if the workQueues array already has a queue at the given index . |
26,766 | final void externalPush ( ForkJoinTask < ? > task ) { int r ; if ( ( r = ThreadLocalRandom . getProbe ( ) ) == 0 ) { ThreadLocalRandom . localInit ( ) ; r = ThreadLocalRandom . getProbe ( ) ; } for ( ; ; ) { WorkQueue q ; int wl , k , stat ; int rs = runState ; WorkQueue [ ] ws = workQueues ; if ( rs <= 0 || ws == null || ( wl = ws . length ) <= 0 ) tryInitialize ( true ) ; else if ( ( q = ws [ k = ( wl - 1 ) & r & SQMASK ] ) == null ) tryCreateExternalQueue ( k ) ; else if ( ( stat = q . sharedPush ( task ) ) < 0 ) break ; else if ( stat == 0 ) { signalWork ( ) ; break ; } else r = ThreadLocalRandom . advanceProbe ( r ) ; } } | Adds the given task to a submission queue at submitter s current queue . Also performs secondary initialization upon the first submission of the first task to the pool and detects first submission by an external thread and creates a new shared queue if the one at index if empty or contended . |
26,767 | private < T > ForkJoinTask < T > externalSubmit ( ForkJoinTask < T > task ) { Thread t ; ForkJoinWorkerThread w ; WorkQueue q ; if ( task == null ) throw new NullPointerException ( ) ; if ( ( ( t = Thread . currentThread ( ) ) instanceof ForkJoinWorkerThread ) && ( w = ( ForkJoinWorkerThread ) t ) . pool == this && ( q = w . workQueue ) != null ) q . push ( task ) ; else externalPush ( task ) ; return task ; } | Pushes a possibly - external submission . |
26,768 | static WorkQueue commonSubmitterQueue ( ) { ForkJoinPool p = common ; int r = ThreadLocalRandom . getProbe ( ) ; WorkQueue [ ] ws ; int wl ; return ( p != null && ( ws = p . workQueues ) != null && ( wl = ws . length ) > 0 ) ? ws [ ( wl - 1 ) & r & SQMASK ] : null ; } | Returns common pool queue for an external thread . |
26,769 | final boolean tryExternalUnpush ( ForkJoinTask < ? > task ) { int r = ThreadLocalRandom . getProbe ( ) ; WorkQueue [ ] ws ; WorkQueue w ; int wl ; return ( ( ws = workQueues ) != null && ( wl = ws . length ) > 0 && ( w = ws [ ( wl - 1 ) & r & SQMASK ] ) != null && w . trySharedUnpush ( task ) ) ; } | Performs tryUnpush for an external submitter . |
26,770 | final int externalHelpComplete ( CountedCompleter < ? > task , int maxTasks ) { WorkQueue [ ] ws ; int wl ; int r = ThreadLocalRandom . getProbe ( ) ; return ( ( ws = workQueues ) != null && ( wl = ws . length ) > 0 ) ? helpComplete ( ws [ ( wl - 1 ) & r & SQMASK ] , task , maxTasks ) : 0 ; } | Performs helpComplete for an external submitter . |
26,771 | @ SuppressWarnings ( "unchecked" ) private EventSetDescriptor [ ] introspectEvents ( ) throws IntrospectionException { MethodDescriptor [ ] theMethods = introspectMethods ( ) ; if ( theMethods == null ) return null ; HashMap < String , HashMap > eventTable = new HashMap < String , HashMap > ( theMethods . length ) ; for ( int i = 0 ; i < theMethods . length ; i ++ ) { introspectListenerMethods ( PREFIX_ADD , theMethods [ i ] . getMethod ( ) , eventTable ) ; introspectListenerMethods ( PREFIX_REMOVE , theMethods [ i ] . getMethod ( ) , eventTable ) ; introspectGetListenerMethods ( theMethods [ i ] . getMethod ( ) , eventTable ) ; } ArrayList < EventSetDescriptor > eventList = new ArrayList < EventSetDescriptor > ( ) ; for ( Map . Entry < String , HashMap > entry : eventTable . entrySet ( ) ) { HashMap table = entry . getValue ( ) ; Method add = ( Method ) table . get ( PREFIX_ADD ) ; Method remove = ( Method ) table . get ( PREFIX_REMOVE ) ; if ( ( add == null ) || ( remove == null ) ) { continue ; } Method get = ( Method ) table . get ( PREFIX_GET ) ; Class < ? > listenerType = ( Class ) table . get ( "listenerType" ) ; Method [ ] listenerMethods = ( Method [ ] ) table . get ( "listenerMethods" ) ; EventSetDescriptor eventSetDescriptor = new EventSetDescriptor ( decapitalize ( entry . getKey ( ) ) , listenerType , listenerMethods , add , remove , get ) ; eventSetDescriptor . setUnicast ( table . get ( "isUnicast" ) != null ) ; eventList . add ( eventSetDescriptor ) ; } EventSetDescriptor [ ] theEvents = new EventSetDescriptor [ eventList . size ( ) ] ; eventList . toArray ( theEvents ) ; return theEvents ; } | Introspects the supplied Bean class and returns a list of the Events of the class |
26,772 | public boolean remove ( Object e ) { if ( e == null ) return false ; Class < ? > eClass = e . getClass ( ) ; if ( eClass != elementType && eClass . getSuperclass ( ) != elementType ) return false ; int eOrdinal = ( ( Enum < ? > ) e ) . ordinal ( ) ; int eWordNum = eOrdinal >>> 6 ; long oldElements = elements [ eWordNum ] ; elements [ eWordNum ] &= ~ ( 1L << eOrdinal ) ; boolean result = ( elements [ eWordNum ] != oldElements ) ; if ( result ) size -- ; return result ; } | Removes the specified element from this set if it is present . |
26,773 | private boolean recalculateSize ( ) { int oldSize = size ; size = 0 ; for ( long elt : elements ) size += Long . bitCount ( elt ) ; return size != oldSize ; } | Recalculates the size of the set . Returns true if it s changed . |
26,774 | public synchronized void setData ( byte [ ] buf , int offset , int length ) { if ( length < 0 || offset < 0 || ( length + offset ) < 0 || ( ( length + offset ) > buf . length ) ) { throw new IllegalArgumentException ( "illegal length or offset" ) ; } this . buf = buf ; this . length = length ; this . bufLength = length ; this . offset = offset ; } | Set the data buffer for this packet . This sets the data length and offset of the packet . |
26,775 | public synchronized void setLength ( int length ) { if ( ( length + offset ) > buf . length || length < 0 || ( length + offset ) < 0 ) { throw new IllegalArgumentException ( "illegal length" ) ; } this . length = length ; this . bufLength = this . length ; } | Set the length for this packet . The length of the packet is the number of bytes from the packet s data buffer that will be sent or the number of bytes of the packet s data buffer that will be used for receiving data . The length must be lesser or equal to the offset plus the length of the packet s buffer . |
26,776 | boolean casValue ( Object cmp , Object val ) { return U . compareAndSwapObject ( this , VALUE , cmp , val ) ; } | compareAndSet value field . |
26,777 | boolean casNext ( Node < K , V > cmp , Node < K , V > val ) { return U . compareAndSwapObject ( this , NEXT , cmp , val ) ; } | compareAndSet next field . |
26,778 | boolean appendMarker ( Node < K , V > f ) { return casNext ( f , new Node < K , V > ( f ) ) ; } | Tries to append a deletion marker to this node . |
26,779 | V getValidValue ( ) { Object v = value ; if ( v == sentinel ( ) || v == BASE_HEADER ) return null ; @ SuppressWarnings ( "unchecked" ) V vv = ( V ) v ; return vv ; } | Returns value if this node contains a valid key - value pair else null . |
26,780 | AbstractMap . SimpleImmutableEntry < K , V > createSnapshot ( ) { Object v = value ; if ( v == null || v == sentinel ( ) || v == BASE_HEADER ) return null ; @ SuppressWarnings ( "unchecked" ) V vv = ( V ) v ; return new AbstractMap . SimpleImmutableEntry < K , V > ( key , vv ) ; } | Creates and returns a new SimpleImmutableEntry holding current mapping if this node holds a valid value else null . |
26,781 | final boolean casRight ( Index < K , V > cmp , Index < K , V > val ) { return U . compareAndSwapObject ( this , RIGHT , cmp , val ) ; } | compareAndSet right field . |
26,782 | final boolean link ( Index < K , V > succ , Index < K , V > newSucc ) { Node < K , V > n = node ; newSucc . right = succ ; return n . value != null && casRight ( succ , newSucc ) ; } | Tries to CAS newSucc as successor . To minimize races with unlink that may lose this index node if the node being indexed is known to be deleted it doesn t try to link in . |
26,783 | private void checkInvariants ( ) { assert ( wordsInUse == 0 || words [ wordsInUse - 1 ] != 0 ) ; assert ( wordsInUse >= 0 && wordsInUse <= words . length ) ; assert ( wordsInUse == words . length || words [ wordsInUse ] == 0 ) ; } | Every public method must preserve these invariants . |
26,784 | public static BitSet valueOf ( long [ ] longs ) { int n ; for ( n = longs . length ; n > 0 && longs [ n - 1 ] == 0 ; n -- ) ; return new BitSet ( Arrays . copyOf ( longs , n ) ) ; } | Returns a new bit set containing all the bits in the given long array . |
26,785 | public static BitSet valueOf ( LongBuffer lb ) { lb = lb . slice ( ) ; int n ; for ( n = lb . remaining ( ) ; n > 0 && lb . get ( n - 1 ) == 0 ; n -- ) ; long [ ] words = new long [ n ] ; lb . get ( words ) ; return new BitSet ( words ) ; } | Returns a new bit set containing all the bits in the given long buffer between its position and limit . |
26,786 | public String getSimpleString ( ) { if ( null != m_simpleString ) { return m_simpleString ; } else if ( null != m_parts ) { final FastStringBuffer buf = getBuffer ( ) ; String out = null ; int n = m_parts . size ( ) ; try { for ( int i = 0 ; i < n ; i ++ ) { AVTPart part = ( AVTPart ) m_parts . elementAt ( i ) ; buf . append ( part . getSimpleString ( ) ) ; } out = buf . toString ( ) ; } finally { if ( USE_OBJECT_POOL ) { StringBufferPool . free ( buf ) ; } else { buf . setLength ( 0 ) ; } ; } return out ; } else { return "" ; } } | Get the AVT as the original string . |
26,787 | public String evaluate ( XPathContext xctxt , int context , org . apache . xml . utils . PrefixResolver nsNode ) throws javax . xml . transform . TransformerException { if ( null != m_simpleString ) { return m_simpleString ; } else if ( null != m_parts ) { final FastStringBuffer buf = getBuffer ( ) ; String out = null ; int n = m_parts . size ( ) ; try { for ( int i = 0 ; i < n ; i ++ ) { AVTPart part = ( AVTPart ) m_parts . elementAt ( i ) ; part . evaluate ( xctxt , buf , context , nsNode ) ; } out = buf . toString ( ) ; } finally { if ( USE_OBJECT_POOL ) { StringBufferPool . free ( buf ) ; } else { buf . setLength ( 0 ) ; } } return out ; } else { return "" ; } } | Evaluate the AVT and return a String . |
26,788 | public void encode ( DerOutputStream out ) throws IOException { if ( gni != null ) { gni . encode ( out ) ; return ; } else { DerOutputStream tmp = new DerOutputStream ( ) ; tmp . putOID ( oid ) ; tmp . write ( DerValue . createTag ( DerValue . TAG_CONTEXT , true , TAG_VALUE ) , nameValue ) ; out . write ( DerValue . tag_Sequence , tmp ) ; } } | Encode the Other name into the DerOutputStream . |
26,789 | public void encode ( DerOutputStream out ) throws IOException { DerOutputStream tagged = new DerOutputStream ( ) ; DerOutputStream tmp = new DerOutputStream ( ) ; if ( assigner != null ) { DerOutputStream tmp2 = new DerOutputStream ( ) ; tmp2 . putPrintableString ( assigner ) ; tagged . write ( DerValue . createTag ( DerValue . TAG_CONTEXT , false , TAG_ASSIGNER ) , tmp2 ) ; } if ( party == null ) throw new IOException ( "Cannot have null partyName" ) ; tmp . putPrintableString ( party ) ; tagged . write ( DerValue . createTag ( DerValue . TAG_CONTEXT , false , TAG_PARTYNAME ) , tmp ) ; out . write ( DerValue . tag_Sequence , tagged ) ; } | Encode the EDI party name into the DerOutputStream . |
26,790 | public static ParenthesizedExpression parenthesizeAndReplace ( Expression expression ) { ParenthesizedExpression newExpr = new ParenthesizedExpression ( ) ; expression . replaceWith ( newExpr ) ; newExpr . setExpression ( expression ) ; return newExpr ; } | Wraps the given expression with a ParenthesizedExpression and replaces it in the tree . |
26,791 | private String inferSourceName ( TypeElement type ) { if ( ! ElementUtil . isPublic ( type ) ) { String srcFile = ElementUtil . getSourceFile ( type ) ; if ( srcFile != null && srcFile . endsWith ( ".java" ) ) { int lastSlash = Math . max ( srcFile . lastIndexOf ( '/' ) , srcFile . lastIndexOf ( '\\' ) ) ; String baseName = lastSlash > - 1 ? srcFile . substring ( lastSlash + 1 ) : srcFile ; return baseName . substring ( 0 , baseName . length ( ) - 5 ) ; } } return ElementUtil . getName ( type ) ; } | Returns what should be the name of the main type associated with this type . Normally an outer type s name matches from its source file name but Java allows additional non - public outer types to be declared in the same source file . |
26,792 | protected void countProximityPosition ( int i ) { if ( ! isReverseAxes ( ) ) super . countProximityPosition ( i ) ; else if ( i < m_proximityPositions . length ) m_proximityPositions [ i ] -- ; } | Count backwards one proximity position . |
26,793 | BigInteger getBigInteger ( int len , boolean makePositive ) throws IOException { if ( len > available ( ) ) throw new IOException ( "short read of integer" ) ; if ( len == 0 ) { throw new IOException ( "Invalid encoding: zero length Int value" ) ; } byte [ ] bytes = new byte [ len ] ; System . arraycopy ( buf , pos , bytes , 0 , len ) ; skip ( len ) ; if ( len >= 2 && ( bytes [ 0 ] == 0 ) && ( bytes [ 1 ] >= 0 ) ) { throw new IOException ( "Invalid encoding: redundant leading 0s" ) ; } if ( makePositive ) { return new BigInteger ( 1 , bytes ) ; } else { return new BigInteger ( bytes ) ; } } | Returns the integer which takes up the specified number of bytes in this buffer as a BigInteger . |
26,794 | public int getInteger ( int len ) throws IOException { BigInteger result = getBigInteger ( len , false ) ; if ( result . compareTo ( BigInteger . valueOf ( Integer . MIN_VALUE ) ) < 0 ) { throw new IOException ( "Integer below minimum valid value" ) ; } if ( result . compareTo ( BigInteger . valueOf ( Integer . MAX_VALUE ) ) > 0 ) { throw new IOException ( "Integer exceeds maximum valid value" ) ; } return result . intValue ( ) ; } | Returns the integer which takes up the specified number of bytes in this buffer . |
26,795 | public byte [ ] getBitString ( int len ) throws IOException { if ( len > available ( ) ) throw new IOException ( "short read of bit string" ) ; if ( len == 0 ) { throw new IOException ( "Invalid encoding: zero length bit string" ) ; } int numOfPadBits = buf [ pos ] ; if ( ( numOfPadBits < 0 ) || ( numOfPadBits > 7 ) ) { throw new IOException ( "Invalid number of padding bits" ) ; } byte [ ] retval = new byte [ len - 1 ] ; System . arraycopy ( buf , pos + 1 , retval , 0 , len - 1 ) ; if ( numOfPadBits != 0 ) { retval [ len - 2 ] &= ( 0xff << numOfPadBits ) ; } skip ( len ) ; return retval ; } | Returns the bit string which takes up the specified number of bytes in this buffer . |
26,796 | BitArray getUnalignedBitString ( ) throws IOException { if ( pos >= count ) return null ; int len = available ( ) ; int unusedBits = buf [ pos ] & 0xff ; if ( unusedBits > 7 ) { throw new IOException ( "Invalid value for unused bits: " + unusedBits ) ; } byte [ ] bits = new byte [ len - 1 ] ; int length = ( bits . length == 0 ) ? 0 : bits . length * 8 - unusedBits ; System . arraycopy ( buf , pos + 1 , bits , 0 , len - 1 ) ; BitArray bitArray = new BitArray ( length , bits ) ; pos = count ; return bitArray ; } | Returns the bit string which takes up the rest of this buffer . The bit string need not be byte - aligned . |
26,797 | public Date getUTCTime ( int len ) throws IOException { if ( len > available ( ) ) throw new IOException ( "short read of DER UTC Time" ) ; if ( len < 11 || len > 17 ) throw new IOException ( "DER UTC Time length error" ) ; return getTime ( len , false ) ; } | Returns the UTC Time value that takes up the specified number of bytes in this buffer . |
26,798 | public Date getGeneralizedTime ( int len ) throws IOException { if ( len > available ( ) ) throw new IOException ( "short read of DER Generalized Time" ) ; if ( len < 13 || len > 23 ) throw new IOException ( "DER Generalized Time length error" ) ; return getTime ( len , true ) ; } | Returns the Generalized Time value that takes up the specified number of bytes in this buffer . |
26,799 | public boolean visit ( TypeDeclaration node ) { TypeMirror serializableType = typeUtil . resolveJavaType ( "java.io.Serializable" ) . asType ( ) ; TypeMirror nodeType = node . getTypeElement ( ) . asType ( ) ; boolean isSerializable = typeUtil . isAssignable ( nodeType , serializableType ) ; boolean stripReflection = ! translationUtil . needsReflection ( node . getTypeElement ( ) ) ; return stripReflection && isSerializable ; } | Only modify Serializable types when stripping reflection metadata . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.