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...
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 : p...
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 ) ; new...
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 == s...
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 != n...
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 ( StandardChar...
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 ...
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 ret...
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 ...
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 ==...
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 ZipExc...
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" ) ; } ZipEn...
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 ) ;...
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 LO...
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 > isPr...
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 = ( ICU...
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 ...
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 < ...
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 = f...
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 ....
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 && ! "" . eq...
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 ;...
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 ....
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 . eq...
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 ) ...
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_ENA...
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 ) { checkUnb...
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 ( XML11Cha...
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 . isXML11In...
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 ...
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 ) { Strin...
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 != nul...
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 ( inv...
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 . charVa...
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 != ...
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 . g...
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 - re...
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 attrV...
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 ; S...
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 = ( (...
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 ] ...
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 . s...
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 ) ...
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...
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 ) { bo...
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 = workQu...
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...
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...
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 ) ; fo...
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...
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...
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 . ...
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 ...
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 . t...
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 ( D...
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 baseN...
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 , b...
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_VAL...
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 ) ) ...
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 . leng...
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 = !...
Only modify Serializable types when stripping reflection metadata .