idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
26,500
public int getOwnerDocument ( int nodeHandle ) { if ( DTM . DOCUMENT_NODE == getNodeType ( nodeHandle ) ) return DTM . NULL ; return getDocumentRoot ( nodeHandle ) ; }
Given a node handle find the owning document node . This has the exact same semantics as the DOM Document method of the same name in that if the nodeHandle is a document node it will return NULL .
26,501
public int getNamespaceType ( final int nodeHandle ) { int identity = makeNodeIdentity ( nodeHandle ) ; int expandedNameID = _exptype ( identity ) ; return m_expandedNameTable . getNamespaceID ( expandedNameID ) ; }
Returns the namespace type of a specific node
26,502
public void appendChild ( int newChild , boolean clone , boolean cloneDepth ) { error ( XMLMessages . createXMLMessage ( XMLErrorResources . ER_METHOD_NOT_SUPPORTED , null ) ) ; }
Append a child to the end of the document . Please note that the node is always cloned if it is owned by another document .
26,503
public void migrateTo ( DTMManager mgr ) { m_mgr = mgr ; if ( mgr instanceof DTMManagerDefault ) m_mgrDefault = ( DTMManagerDefault ) mgr ; }
Migrate a DTM built with an old DTMManager to a new DTMManager . After the migration the new DTMManager will treat the DTM as one that is built by itself . This is used to support DTM sharing between multiple transformations .
26,504
public long skip ( long n ) throws IOException { synchronized ( lock ) { ensureOpen ( ) ; long avail = count - pos ; if ( n > avail ) { n = avail ; } if ( n < 0 ) { return 0 ; } pos += n ; return n ; } }
Skips characters . Returns the number of characters that were skipped .
26,505
private TextImpl firstTextNodeInCurrentRun ( ) { TextImpl firstTextInCurrentRun = this ; for ( Node p = getPreviousSibling ( ) ; p != null ; p = p . getPreviousSibling ( ) ) { short nodeType = p . getNodeType ( ) ; if ( nodeType == Node . TEXT_NODE || nodeType == Node . CDATA_SECTION_NODE ) { firstTextInCurrentRun = ( TextImpl ) p ; } else { break ; } } return firstTextInCurrentRun ; }
Returns the first text or CDATA node in the current sequence of text and CDATA nodes .
26,506
private TextImpl nextTextNode ( ) { Node nextSibling = getNextSibling ( ) ; if ( nextSibling == null ) { return null ; } short nodeType = nextSibling . getNodeType ( ) ; return nodeType == Node . TEXT_NODE || nodeType == Node . CDATA_SECTION_NODE ? ( TextImpl ) nextSibling : null ; }
Returns the next sibling node if it exists and it is text or CDATA . Otherwise returns null .
26,507
public final TextImpl minimize ( ) { if ( getLength ( ) == 0 ) { parent . removeChild ( this ) ; return null ; } Node previous = getPreviousSibling ( ) ; if ( previous == null || previous . getNodeType ( ) != Node . TEXT_NODE ) { return this ; } TextImpl previousText = ( TextImpl ) previous ; previousText . buffer . append ( buffer ) ; parent . removeChild ( this ) ; return previousText ; }
Tries to remove this node using itself and the previous node as context . If this node s text is empty this node is removed and null is returned . If the previous node exists and is a text node this node s text will be appended to that node s text and this node will be removed .
26,508
public String getMessage ( ) { StringBuffer sb = new StringBuffer ( ) ; sb . append ( desc ) ; if ( index >= 0 ) { sb . append ( " near index " ) ; sb . append ( index ) ; } sb . append ( nl ) ; sb . append ( pattern ) ; if ( index >= 0 ) { sb . append ( nl ) ; for ( int i = 0 ; i < index ; i ++ ) sb . append ( ' ' ) ; sb . append ( '^' ) ; } return sb . toString ( ) ; }
Returns a multi - line string containing the description of the syntax error and its index the erroneous regular - expression pattern and a visual indication of the error index within the pattern .
26,509
@ SuppressWarnings ( "unchecked" ) public static < T > T [ ] appendElement ( Class < T > kind , T [ ] array , T element ) { final T [ ] result ; final int end ; if ( array != null ) { end = array . length ; result = ( T [ ] ) Array . newInstance ( kind , end + 1 ) ; System . arraycopy ( array , 0 , result , 0 , end ) ; } else { end = 0 ; result = ( T [ ] ) Array . newInstance ( kind , 1 ) ; } result [ end ] = element ; return result ; }
Appends an element to a copy of the array and returns the copy .
26,510
@ SuppressWarnings ( "unchecked" ) public static < T > T [ ] removeElement ( Class < T > kind , T [ ] array , T element ) { if ( array != null ) { final int length = array . length ; for ( int i = 0 ; i < length ; i ++ ) { if ( array [ i ] == element ) { if ( length == 1 ) { return null ; } T [ ] result = ( T [ ] ) Array . newInstance ( kind , length - 1 ) ; System . arraycopy ( array , 0 , result , 0 , i ) ; System . arraycopy ( array , i + 1 , result , i , length - i - 1 ) ; return result ; } } } return array ; }
Removes an element from a copy of the array and returns the copy . If the element is not present then the original array is returned unmodified .
26,511
public void close ( ) throws IOException { if ( in != null ) { try { if ( usesDefaultDeflater ) { def . end ( ) ; } in . close ( ) ; } finally { in = null ; } } }
Closes this input stream and its underlying input stream discarding any pending uncompressed data .
26,512
public int read ( byte [ ] b , int off , int len ) throws IOException { ensureOpen ( ) ; if ( b == null ) { throw new NullPointerException ( "Null buffer for read" ) ; } else if ( off < 0 || len < 0 || len > b . length - off ) { throw new IndexOutOfBoundsException ( ) ; } else if ( len == 0 ) { return 0 ; } int cnt = 0 ; while ( len > 0 && ! def . finished ( ) ) { int n ; if ( def . needsInput ( ) ) { n = in . read ( buf , 0 , buf . length ) ; if ( n < 0 ) { def . finish ( ) ; } else if ( n > 0 ) { def . setInput ( buf , 0 , n ) ; } } n = def . deflate ( b , off , len ) ; cnt += n ; off += n ; len -= n ; } if ( def . finished ( ) ) { reachEOF = true ; if ( cnt == 0 ) { cnt = - 1 ; } } return cnt ; }
Reads compressed data into a byte array . This method will block until some input can be read and compressed .
26,513
public static NetworkInterface getByName ( String name ) throws SocketException { if ( name == null ) throw new NullPointerException ( ) ; return getByName0 ( name ) ; }
Searches for the network interface with the specified name .
26,514
public static Enumeration < NetworkInterface > getNetworkInterfaces ( ) throws SocketException { final NetworkInterface [ ] netifs = getAll ( ) ; if ( netifs == null ) return null ; return new Enumeration < NetworkInterface > ( ) { private int i = 0 ; public NetworkInterface nextElement ( ) { if ( netifs != null && i < netifs . length ) { NetworkInterface netif = netifs [ i ++ ] ; return netif ; } else { throw new NoSuchElementException ( ) ; } } public boolean hasMoreElements ( ) { return ( netifs != null && i < netifs . length ) ; } } ; }
Returns all the interfaces on this machine . Returns null if no network interfaces could be found on this machine .
26,515
private long getYearOffsetInMillis ( ) { long t = ( internalGet ( DAY_OF_YEAR ) - 1 ) * 24 ; t += internalGet ( HOUR_OF_DAY ) ; t *= 60 ; t += internalGet ( MINUTE ) ; t *= 60 ; t += internalGet ( SECOND ) ; t *= 1000 ; return t + internalGet ( MILLISECOND ) - ( internalGet ( ZONE_OFFSET ) + internalGet ( DST_OFFSET ) ) ; }
Returns the millisecond offset from the beginning of this year . This Calendar object must have been normalized .
26,516
private int getWeekNumber ( long fixedDay1 , long fixedDate ) { long fixedDay1st = Gregorian . getDayOfWeekDateOnOrBefore ( fixedDay1 + 6 , getFirstDayOfWeek ( ) ) ; int ndays = ( int ) ( fixedDay1st - fixedDay1 ) ; assert ndays <= 7 ; if ( ndays >= getMinimalDaysInFirstWeek ( ) ) { fixedDay1st -= 7 ; } int normalizedDayOfPeriod = ( int ) ( fixedDate - fixedDay1st ) ; if ( normalizedDayOfPeriod >= 0 ) { return normalizedDayOfPeriod / 7 + 1 ; } return CalendarUtils . floorDivide ( normalizedDayOfPeriod , 7 ) + 1 ; }
Returns the number of weeks in a period between fixedDay1 and fixedDate . The getFirstDayOfWeek - getMinimalDaysInFirstWeek rule is applied to calculate the number of weeks .
26,517
private BaseCalendar . Date getCalendarDate ( long fd ) { BaseCalendar cal = ( fd >= gregorianCutoverDate ) ? gcal : getJulianCalendarSystem ( ) ; BaseCalendar . Date d = ( BaseCalendar . Date ) cal . newCalendarDate ( TimeZone . NO_TIMEZONE ) ; cal . getCalendarDateFromFixedDate ( d , fd ) ; return d ; }
Returns a CalendarDate produced from the specified fixed date .
26,518
private static int getRolledValue ( int value , int amount , int min , int max ) { assert value >= min && value <= max ; int range = max - min + 1 ; amount %= range ; int n = value + amount ; if ( n > max ) { n -= range ; } else if ( n < min ) { n += range ; } assert n >= min && n <= max ; return n ; }
Returns the new value after roll ing the specified value and amount .
26,519
private void readObject ( ObjectInputStream stream ) throws IOException , ClassNotFoundException { stream . defaultReadObject ( ) ; if ( gdate == null ) { gdate = ( BaseCalendar . Date ) gcal . newCalendarDate ( getZone ( ) ) ; cachedFixedDate = Long . MIN_VALUE ; } setGregorianChange ( gregorianCutover ) ; }
Updates internal state .
26,520
public char elementAt ( char index ) { int ix = ( indices [ index >> BLOCKSHIFT ] & 0xFFFF ) + ( index & BLOCKMASK ) ; return ix >= values . length ? defaultValue : values [ ix ] ; }
Get the mapped value of a Unicode character .
26,521
public void setElementAt ( char index , char value ) { if ( isCompact ) expand ( ) ; values [ index ] = value ; touchBlock ( index >> BLOCKSHIFT , value ) ; }
Set a new value for a Unicode character . Set automatically expands the array if it is compacted .
26,522
public void setElementAt ( char start , char end , char value ) { int i ; if ( isCompact ) { expand ( ) ; } for ( i = start ; i <= end ; ++ i ) { values [ i ] = value ; touchBlock ( i >> BLOCKSHIFT , value ) ; } }
Set new values for a range of Unicode character .
26,523
final static boolean arrayRegionMatches ( char [ ] source , int sourceStart , char [ ] target , int targetStart , int len ) { int sourceEnd = sourceStart + len ; int delta = targetStart - sourceStart ; for ( int i = sourceStart ; i < sourceEnd ; i ++ ) { if ( source [ i ] != target [ i + delta ] ) return false ; } return true ; }
Convenience utility to compare two arrays of doubles .
26,524
public void write ( ObjectOutput output ) throws IOException { if ( ! output . equals ( oos ) ) { throw new IllegalArgumentException ( "Attempting to write to a different stream than the one that created this PutField" ) ; } for ( EmulatedFields . ObjectSlot slot : emulatedFields . slots ( ) ) { Object fieldValue = slot . getFieldValue ( ) ; Class < ? > type = slot . getField ( ) . getType ( ) ; if ( type == int . class ) { output . writeInt ( fieldValue != null ? ( ( Integer ) fieldValue ) . intValue ( ) : 0 ) ; } else if ( type == byte . class ) { output . writeByte ( fieldValue != null ? ( ( Byte ) fieldValue ) . byteValue ( ) : 0 ) ; } else if ( type == char . class ) { output . writeChar ( fieldValue != null ? ( ( Character ) fieldValue ) . charValue ( ) : 0 ) ; } else if ( type == short . class ) { output . writeShort ( fieldValue != null ? ( ( Short ) fieldValue ) . shortValue ( ) : 0 ) ; } else if ( type == boolean . class ) { output . writeBoolean ( fieldValue != null ? ( ( Boolean ) fieldValue ) . booleanValue ( ) : false ) ; } else if ( type == long . class ) { output . writeLong ( fieldValue != null ? ( ( Long ) fieldValue ) . longValue ( ) : 0 ) ; } else if ( type == float . class ) { output . writeFloat ( fieldValue != null ? ( ( Float ) fieldValue ) . floatValue ( ) : 0 ) ; } else if ( type == double . class ) { output . writeDouble ( fieldValue != null ? ( ( Double ) fieldValue ) . doubleValue ( ) : 0 ) ; } else { output . writeObject ( fieldValue ) ; } } }
Write the field values to the specified ObjectOutput .
26,525
private void setHeadAndPropagate ( Node node , long propagate ) { Node h = head ; setHead ( node ) ; if ( propagate > 0 || h == null || h . waitStatus < 0 || ( h = head ) == null || h . waitStatus < 0 ) { Node s = node . next ; if ( s == null || s . isShared ( ) ) doReleaseShared ( ) ; } }
Sets head of queue and checks if successor may be waiting in shared mode if so propagating if either propagate > 0 or PROPAGATE status was set .
26,526
private void doAcquireInterruptibly ( long arg ) throws InterruptedException { final Node node = addWaiter ( Node . EXCLUSIVE ) ; try { for ( ; ; ) { final Node p = node . predecessor ( ) ; if ( p == head && tryAcquire ( arg ) ) { setHead ( node ) ; p . next = null ; return ; } if ( shouldParkAfterFailedAcquire ( p , node ) && parkAndCheckInterrupt ( ) ) throw new InterruptedException ( ) ; } } catch ( Throwable t ) { cancelAcquire ( node ) ; throw t ; } }
Acquires in exclusive interruptible mode .
26,527
private boolean doAcquireNanos ( long arg , long nanosTimeout ) throws InterruptedException { if ( nanosTimeout <= 0L ) return false ; final long deadline = System . nanoTime ( ) + nanosTimeout ; final Node node = addWaiter ( Node . EXCLUSIVE ) ; try { for ( ; ; ) { final Node p = node . predecessor ( ) ; if ( p == head && tryAcquire ( arg ) ) { setHead ( node ) ; p . next = null ; return true ; } nanosTimeout = deadline - System . nanoTime ( ) ; if ( nanosTimeout <= 0L ) { cancelAcquire ( node ) ; return false ; } if ( shouldParkAfterFailedAcquire ( p , node ) && nanosTimeout > SPIN_FOR_TIMEOUT_THRESHOLD ) LockSupport . parkNanos ( this , nanosTimeout ) ; if ( Thread . interrupted ( ) ) throw new InterruptedException ( ) ; } } catch ( Throwable t ) { cancelAcquire ( node ) ; throw t ; } }
Acquires in exclusive timed mode .
26,528
private void doAcquireShared ( long arg ) { final Node node = addWaiter ( Node . SHARED ) ; try { boolean interrupted = false ; for ( ; ; ) { final Node p = node . predecessor ( ) ; if ( p == head ) { long r = tryAcquireShared ( arg ) ; if ( r >= 0 ) { setHeadAndPropagate ( node , r ) ; p . next = null ; if ( interrupted ) selfInterrupt ( ) ; return ; } } if ( shouldParkAfterFailedAcquire ( p , node ) && parkAndCheckInterrupt ( ) ) interrupted = true ; } } catch ( Throwable t ) { cancelAcquire ( node ) ; throw t ; } }
Acquires in shared uninterruptible mode .
26,529
final long fullyRelease ( Node node ) { try { long savedState = getState ( ) ; if ( release ( savedState ) ) return savedState ; throw new IllegalMonitorStateException ( ) ; } catch ( Throwable t ) { node . waitStatus = Node . CANCELLED ; throw t ; } }
Invokes release with current state value ; returns saved state . Cancels node and throws exception on failure .
26,530
private Object writeReplace ( ) throws ObjectStreamException { InetAddress inet = new InetAddress ( ) ; inet . holder ( ) . hostName = holder ( ) . getHostName ( ) ; inet . holder ( ) . address = holder ( ) . getAddress ( ) ; inet . holder ( ) . family = 2 ; return inet ; }
Replaces the object to be serialized with an InetAddress object .
26,531
public static String decompress ( byte [ ] buffer ) { char [ ] buf = decompress ( buffer , 0 , buffer . length ) ; return new String ( buf ) ; }
Decompress a byte array into a String .
26,532
public void reset ( ) { fOffsets [ 0 ] = 0x0080 ; fOffsets [ 1 ] = 0x00C0 ; fOffsets [ 2 ] = 0x0400 ; fOffsets [ 3 ] = 0x0600 ; fOffsets [ 4 ] = 0x0900 ; fOffsets [ 5 ] = 0x3040 ; fOffsets [ 6 ] = 0x30A0 ; fOffsets [ 7 ] = 0xFF00 ; fCurrentWindow = 0 ; fMode = SINGLEBYTEMODE ; fBufferLength = 0 ; }
Reset the decompressor to its initial state .
26,533
public synchronized E elementAt ( int index ) { if ( index >= elementCount ) { throw new ArrayIndexOutOfBoundsException ( index + " >= " + elementCount ) ; } return elementData ( index ) ; }
Returns the component at the specified index .
26,534
public synchronized void removeAllElements ( ) { modCount ++ ; for ( int i = 0 ; i < elementCount ; i ++ ) elementData [ i ] = null ; elementCount = 0 ; }
Removes all components from this vector and sets its size to zero .
26,535
@ SuppressWarnings ( "unchecked" ) public synchronized < T > T [ ] toArray ( T [ ] a ) { if ( a . length < elementCount ) return ( T [ ] ) Arrays . copyOf ( elementData , elementCount , a . getClass ( ) ) ; System . arraycopy ( elementData , 0 , a , 0 , elementCount ) ; if ( a . length > elementCount ) a [ elementCount ] = null ; return a ; }
Returns an array containing all of the elements in this Vector in the correct order ; the runtime type of the returned array is that of the specified array . If the Vector fits in the specified array it is returned therein . Otherwise a new array is allocated with the runtime type of the specified array and the size of this Vector .
26,536
public synchronized boolean add ( E e ) { modCount ++ ; ensureCapacityHelper ( elementCount + 1 ) ; elementData [ elementCount ++ ] = e ; return true ; }
Appends the specified element to the end of this Vector .
26,537
public String getIssuerName ( String defaultName ) { return ( cert == null ? defaultName : cert . getIssuerX500Principal ( ) . toString ( ) ) ; }
return string form of issuer name from certificate associated with this build step or a default name if no certificate associated with this build step or if issuer name could not be obtained from the certificate .
26,538
public String getSubjectName ( String defaultName ) { return ( cert == null ? defaultName : cert . getSubjectX500Principal ( ) . toString ( ) ) ; }
return string form of subject name from certificate associated with this build step or a default name if no certificate associated with this build step or if subject name could not be obtained from the certificate .
26,539
public String resultToString ( int res ) { String resultString = "" ; switch ( res ) { case POSSIBLE : resultString = "Certificate to be tried.\n" ; break ; case BACK : resultString = "Certificate backed out since path does not " + "satisfy build requirements.\n" ; break ; case FOLLOW : resultString = "Certificate satisfies conditions.\n" ; break ; case FAIL : resultString = "Certificate backed out since path does not " + "satisfy conditions.\n" ; break ; case SUCCEED : resultString = "Certificate satisfies conditions.\n" ; break ; default : resultString = "Internal error: Invalid step result value.\n" ; } return resultString ; }
return a string representing the meaning of the result code associated with this build step .
26,540
public String verboseToString ( ) { String out = resultToString ( getResult ( ) ) ; switch ( result ) { case BACK : case FAIL : out = out + vertex . throwableToString ( ) ; break ; case FOLLOW : case SUCCEED : out = out + vertex . moreToString ( ) ; break ; case POSSIBLE : break ; default : break ; } out = out + "Certificate contains:\n" + vertex . certToString ( ) ; return out ; }
return a string representation of this build step showing all detail of the vertex state appropriate to the result of this build step and the certificate contents .
26,541
private int [ ] getMagnitudeArray ( ) { if ( offset > 0 || value . length != intLen ) return Arrays . copyOfRange ( value , offset , offset + intLen ) ; return value ; }
Internal helper method to return the magnitude array . The caller is not supposed to modify the returned array .
26,542
private long toLong ( ) { assert ( intLen <= 2 ) : "this MutableBigInteger exceeds the range of long" ; if ( intLen == 0 ) return 0 ; long d = value [ offset ] & LONG_MASK ; return ( intLen == 2 ) ? d << 32 | ( value [ offset + 1 ] & LONG_MASK ) : d ; }
Convert this MutableBigInteger to a long value . The caller has to make sure this MutableBigInteger can be fit into long .
26,543
BigInteger toBigInteger ( int sign ) { if ( intLen == 0 || sign == 0 ) return BigInteger . ZERO ; return new BigInteger ( getMagnitudeArray ( ) , sign ) ; }
Convert this MutableBigInteger to a BigInteger object .
26,544
BigDecimal toBigDecimal ( int sign , int scale ) { if ( intLen == 0 || sign == 0 ) return BigDecimal . zeroValueOf ( scale ) ; int [ ] mag = getMagnitudeArray ( ) ; int len = mag . length ; int d = mag [ 0 ] ; if ( len > 2 || ( d < 0 && len == 2 ) ) return new BigDecimal ( new BigInteger ( mag , sign ) , INFLATED , scale , 0 ) ; long v = ( len == 2 ) ? ( ( mag [ 1 ] & LONG_MASK ) | ( d & LONG_MASK ) << 32 ) : d & LONG_MASK ; return BigDecimal . valueOf ( sign == - 1 ? - v : v , scale ) ; }
Convert this MutableBigInteger to BigDecimal object with the specified sign and scale .
26,545
long toCompactValue ( int sign ) { if ( intLen == 0 || sign == 0 ) return 0L ; int [ ] mag = getMagnitudeArray ( ) ; int len = mag . length ; int d = mag [ 0 ] ; if ( len > 2 || ( d < 0 && len == 2 ) ) return INFLATED ; long v = ( len == 2 ) ? ( ( mag [ 1 ] & LONG_MASK ) | ( d & LONG_MASK ) << 32 ) : d & LONG_MASK ; return sign == - 1 ? - v : v ; }
This is for internal use in converting from a MutableBigInteger object into a long value given a specified sign . returns INFLATED if value is not fit into long
26,546
void clear ( ) { offset = intLen = 0 ; for ( int index = 0 , n = value . length ; index < n ; index ++ ) value [ index ] = 0 ; }
Clear out a MutableBigInteger for reuse .
26,547
private final int getLowestSetBit ( ) { if ( intLen == 0 ) return - 1 ; int j , b ; for ( j = intLen - 1 ; ( j > 0 ) && ( value [ j + offset ] == 0 ) ; j -- ) ; b = value [ j + offset ] ; if ( b == 0 ) return - 1 ; return ( ( intLen - 1 - j ) << 5 ) + Integer . numberOfTrailingZeros ( b ) ; }
Return the index of the lowest set bit in this MutableBigInteger . If the magnitude of this MutableBigInteger is zero - 1 is returned .
26,548
final void normalize ( ) { if ( intLen == 0 ) { offset = 0 ; return ; } int index = offset ; if ( value [ index ] != 0 ) return ; int indexBound = index + intLen ; do { index ++ ; } while ( index < indexBound && value [ index ] == 0 ) ; int numZeros = index - offset ; intLen -= numZeros ; offset = ( intLen == 0 ? 0 : offset + numZeros ) ; }
Ensure that the MutableBigInteger is in normal form specifically making sure that there are no leading zeros and that if the magnitude is zero then intLen is zero .
26,549
private final void ensureCapacity ( int len ) { if ( value . length < len ) { value = new int [ len ] ; offset = 0 ; intLen = len ; } }
If this MutableBigInteger cannot hold len words increase the size of the value array to len words .
26,550
int [ ] toIntArray ( ) { int [ ] result = new int [ intLen ] ; for ( int i = 0 ; i < intLen ; i ++ ) result [ i ] = value [ offset + i ] ; return result ; }
Convert this MutableBigInteger into an int array with no leading zeros of a length that is equal to this MutableBigInteger s intLen .
26,551
void copyValue ( MutableBigInteger src ) { int len = src . intLen ; if ( value . length < len ) value = new int [ len ] ; System . arraycopy ( src . value , src . offset , value , 0 , len ) ; intLen = len ; offset = 0 ; }
Sets this MutableBigInteger s value array to a copy of the specified array . The intLen is set to the length of the new array .
26,552
void copyValue ( int [ ] val ) { int len = val . length ; if ( value . length < len ) value = new int [ len ] ; System . arraycopy ( val , 0 , value , 0 , len ) ; intLen = len ; offset = 0 ; }
Sets this MutableBigInteger s value array to a copy of the specified array . The intLen is set to the length of the specified array .
26,553
boolean isNormal ( ) { if ( intLen + offset > value . length ) return false ; if ( intLen == 0 ) return true ; return ( value [ offset ] != 0 ) ; }
Returns true iff this MutableBigInteger is in normal form . A MutableBigInteger is in normal form if it has no leading zeros after the offset and intLen + offset < = value . length .
26,554
void rightShift ( int n ) { if ( intLen == 0 ) return ; int nInts = n >>> 5 ; int nBits = n & 0x1F ; this . intLen -= nInts ; if ( nBits == 0 ) return ; int bitsInHighWord = BigInteger . bitLengthForInt ( value [ offset ] ) ; if ( nBits >= bitsInHighWord ) { this . primitiveLeftShift ( 32 - nBits ) ; this . intLen -- ; } else { primitiveRightShift ( nBits ) ; } }
Right shift this MutableBigInteger n bits . The MutableBigInteger is left in normal form .
26,555
void leftShift ( int n ) { if ( intLen == 0 ) return ; int nInts = n >>> 5 ; int nBits = n & 0x1F ; int bitsInHighWord = BigInteger . bitLengthForInt ( value [ offset ] ) ; if ( n <= ( 32 - bitsInHighWord ) ) { primitiveLeftShift ( nBits ) ; return ; } int newLen = intLen + nInts + 1 ; if ( nBits <= ( 32 - bitsInHighWord ) ) newLen -- ; if ( value . length < newLen ) { int [ ] result = new int [ newLen ] ; for ( int i = 0 ; i < intLen ; i ++ ) result [ i ] = value [ offset + i ] ; setValue ( result , newLen ) ; } else if ( value . length - offset >= newLen ) { for ( int i = 0 ; i < newLen - intLen ; i ++ ) value [ offset + intLen + i ] = 0 ; } else { for ( int i = 0 ; i < intLen ; i ++ ) value [ i ] = value [ offset + i ] ; for ( int i = intLen ; i < newLen ; i ++ ) value [ i ] = 0 ; offset = 0 ; } intLen = newLen ; if ( nBits == 0 ) return ; if ( nBits <= ( 32 - bitsInHighWord ) ) primitiveLeftShift ( nBits ) ; else primitiveRightShift ( 32 - nBits ) ; }
Left shift this MutableBigInteger n bits .
26,556
private int divadd ( int [ ] a , int [ ] result , int offset ) { long carry = 0 ; for ( int j = a . length - 1 ; j >= 0 ; j -- ) { long sum = ( a [ j ] & LONG_MASK ) + ( result [ j + offset ] & LONG_MASK ) + carry ; result [ j + offset ] = ( int ) sum ; carry = sum >>> 32 ; } return ( int ) carry ; }
A primitive used for division . This method adds in one multiple of the divisor a back to the dividend result at a specified offset . It is used when qhat was estimated too large and must be adjusted .
26,557
private final void primitiveRightShift ( int n ) { int [ ] val = value ; int n2 = 32 - n ; for ( int i = offset + intLen - 1 , c = val [ i ] ; i > offset ; i -- ) { int b = c ; c = val [ i - 1 ] ; val [ i ] = ( c << n2 ) | ( b >>> n ) ; } val [ offset ] >>>= n ; }
Right shift this MutableBigInteger n bits where n is less than 32 . Assumes that intLen > 0 n > 0 for speed
26,558
private final void primitiveLeftShift ( int n ) { int [ ] val = value ; int n2 = 32 - n ; for ( int i = offset , c = val [ i ] , m = i + intLen - 1 ; i < m ; i ++ ) { int b = c ; c = val [ i + 1 ] ; val [ i ] = ( b << n ) | ( c >>> n2 ) ; } val [ offset + intLen - 1 ] <<= n ; }
Left shift this MutableBigInteger n bits where n is less than 32 . Assumes that intLen > 0 n > 0 for speed
26,559
void add ( MutableBigInteger addend ) { int x = intLen ; int y = addend . intLen ; int resultLen = ( intLen > addend . intLen ? intLen : addend . intLen ) ; int [ ] result = ( value . length < resultLen ? new int [ resultLen ] : value ) ; int rstart = result . length - 1 ; long sum ; long carry = 0 ; while ( x > 0 && y > 0 ) { x -- ; y -- ; sum = ( value [ x + offset ] & LONG_MASK ) + ( addend . value [ y + addend . offset ] & LONG_MASK ) + carry ; result [ rstart -- ] = ( int ) sum ; carry = sum >>> 32 ; } while ( x > 0 ) { x -- ; if ( carry == 0 && result == value && rstart == ( x + offset ) ) return ; sum = ( value [ x + offset ] & LONG_MASK ) + carry ; result [ rstart -- ] = ( int ) sum ; carry = sum >>> 32 ; } while ( y > 0 ) { y -- ; sum = ( addend . value [ y + addend . offset ] & LONG_MASK ) + carry ; result [ rstart -- ] = ( int ) sum ; carry = sum >>> 32 ; } if ( carry > 0 ) { resultLen ++ ; if ( result . length < resultLen ) { int temp [ ] = new int [ resultLen ] ; System . arraycopy ( result , 0 , temp , 1 , result . length ) ; temp [ 0 ] = 1 ; result = temp ; } else { result [ rstart -- ] = 1 ; } } value = result ; intLen = resultLen ; offset = result . length - resultLen ; }
Adds the contents of two MutableBigInteger objects . The result is placed within this MutableBigInteger . The contents of the addend are not changed .
26,560
int subtract ( MutableBigInteger b ) { MutableBigInteger a = this ; int [ ] result = value ; int sign = a . compare ( b ) ; if ( sign == 0 ) { reset ( ) ; return 0 ; } if ( sign < 0 ) { MutableBigInteger tmp = a ; a = b ; b = tmp ; } int resultLen = a . intLen ; if ( result . length < resultLen ) result = new int [ resultLen ] ; long diff = 0 ; int x = a . intLen ; int y = b . intLen ; int rstart = result . length - 1 ; while ( y > 0 ) { x -- ; y -- ; diff = ( a . value [ x + a . offset ] & LONG_MASK ) - ( b . value [ y + b . offset ] & LONG_MASK ) - ( ( int ) - ( diff >> 32 ) ) ; result [ rstart -- ] = ( int ) diff ; } while ( x > 0 ) { x -- ; diff = ( a . value [ x + a . offset ] & LONG_MASK ) - ( ( int ) - ( diff >> 32 ) ) ; result [ rstart -- ] = ( int ) diff ; } value = result ; intLen = resultLen ; offset = value . length - resultLen ; normalize ( ) ; return sign ; }
Subtracts the smaller of this and b from the larger and places the result into this MutableBigInteger .
26,561
private int difference ( MutableBigInteger b ) { MutableBigInteger a = this ; int sign = a . compare ( b ) ; if ( sign == 0 ) return 0 ; if ( sign < 0 ) { MutableBigInteger tmp = a ; a = b ; b = tmp ; } long diff = 0 ; int x = a . intLen ; int y = b . intLen ; while ( y > 0 ) { x -- ; y -- ; diff = ( a . value [ a . offset + x ] & LONG_MASK ) - ( b . value [ b . offset + y ] & LONG_MASK ) - ( ( int ) - ( diff >> 32 ) ) ; a . value [ a . offset + x ] = ( int ) diff ; } while ( x > 0 ) { x -- ; diff = ( a . value [ a . offset + x ] & LONG_MASK ) - ( ( int ) - ( diff >> 32 ) ) ; a . value [ a . offset + x ] = ( int ) diff ; } a . normalize ( ) ; return sign ; }
Subtracts the smaller of a and b from the larger and places the result into the larger . Returns 1 if the answer is in a - 1 if in b 0 if no operation was performed .
26,562
void multiply ( MutableBigInteger y , MutableBigInteger z ) { int xLen = intLen ; int yLen = y . intLen ; int newLen = xLen + yLen ; if ( z . value . length < newLen ) z . value = new int [ newLen ] ; z . offset = 0 ; z . intLen = newLen ; long carry = 0 ; for ( int j = yLen - 1 , k = yLen + xLen - 1 ; j >= 0 ; j -- , k -- ) { long product = ( y . value [ j + y . offset ] & LONG_MASK ) * ( value [ xLen - 1 + offset ] & LONG_MASK ) + carry ; z . value [ k ] = ( int ) product ; carry = product >>> 32 ; } z . value [ xLen - 1 ] = ( int ) carry ; for ( int i = xLen - 2 ; i >= 0 ; i -- ) { carry = 0 ; for ( int j = yLen - 1 , k = yLen + i ; j >= 0 ; j -- , k -- ) { long product = ( y . value [ j + y . offset ] & LONG_MASK ) * ( value [ i + offset ] & LONG_MASK ) + ( z . value [ k ] & LONG_MASK ) + carry ; z . value [ k ] = ( int ) product ; carry = product >>> 32 ; } z . value [ i ] = ( int ) carry ; } z . normalize ( ) ; }
Multiply the contents of two MutableBigInteger objects . The result is placed into MutableBigInteger z . The contents of y are not changed .
26,563
void mul ( int y , MutableBigInteger z ) { if ( y == 1 ) { z . copyValue ( this ) ; return ; } if ( y == 0 ) { z . clear ( ) ; return ; } long ylong = y & LONG_MASK ; int [ ] zval = ( z . value . length < intLen + 1 ? new int [ intLen + 1 ] : z . value ) ; long carry = 0 ; for ( int i = intLen - 1 ; i >= 0 ; i -- ) { long product = ylong * ( value [ i + offset ] & LONG_MASK ) + carry ; zval [ i + 1 ] = ( int ) product ; carry = product >>> 32 ; } if ( carry == 0 ) { z . offset = 1 ; z . intLen = intLen ; } else { z . offset = 0 ; z . intLen = intLen + 1 ; zval [ 0 ] = ( int ) carry ; } z . value = zval ; }
Multiply the contents of this MutableBigInteger by the word y . The result is placed into z .
26,564
int divideOneWord ( int divisor , MutableBigInteger quotient ) { long divisorLong = divisor & LONG_MASK ; if ( intLen == 1 ) { long dividendValue = value [ offset ] & LONG_MASK ; int q = ( int ) ( dividendValue / divisorLong ) ; int r = ( int ) ( dividendValue - q * divisorLong ) ; quotient . value [ 0 ] = q ; quotient . intLen = ( q == 0 ) ? 0 : 1 ; quotient . offset = 0 ; return r ; } if ( quotient . value . length < intLen ) quotient . value = new int [ intLen ] ; quotient . offset = 0 ; quotient . intLen = intLen ; int shift = Integer . numberOfLeadingZeros ( divisor ) ; int rem = value [ offset ] ; long remLong = rem & LONG_MASK ; if ( remLong < divisorLong ) { quotient . value [ 0 ] = 0 ; } else { quotient . value [ 0 ] = ( int ) ( remLong / divisorLong ) ; rem = ( int ) ( remLong - ( quotient . value [ 0 ] * divisorLong ) ) ; remLong = rem & LONG_MASK ; } int xlen = intLen ; while ( -- xlen > 0 ) { long dividendEstimate = ( remLong << 32 ) | ( value [ offset + intLen - xlen ] & LONG_MASK ) ; int q ; if ( dividendEstimate >= 0 ) { q = ( int ) ( dividendEstimate / divisorLong ) ; rem = ( int ) ( dividendEstimate - q * divisorLong ) ; } else { long tmp = divWord ( dividendEstimate , divisor ) ; q = ( int ) ( tmp & LONG_MASK ) ; rem = ( int ) ( tmp >>> 32 ) ; } quotient . value [ intLen - xlen ] = q ; remLong = rem & LONG_MASK ; } quotient . normalize ( ) ; if ( shift > 0 ) return rem % divisor ; else return rem ; }
This method is used for division of an n word dividend by a one word divisor . The quotient is placed into quotient . The one word divisor is specified by divisor .
26,565
long divide ( long v , MutableBigInteger quotient ) { if ( v == 0 ) throw new ArithmeticException ( "BigInteger divide by zero" ) ; if ( intLen == 0 ) { quotient . intLen = quotient . offset = 0 ; return 0 ; } if ( v < 0 ) v = - v ; int d = ( int ) ( v >>> 32 ) ; quotient . clear ( ) ; if ( d == 0 ) return divideOneWord ( ( int ) v , quotient ) & LONG_MASK ; else { return divideLongMagnitude ( v , quotient ) . toLong ( ) ; } }
Internally used to calculate the quotient of this div v and places the quotient in the provided MutableBigInteger object and the remainder is returned .
26,566
private int divaddLong ( int dh , int dl , int [ ] result , int offset ) { long carry = 0 ; long sum = ( dl & LONG_MASK ) + ( result [ 1 + offset ] & LONG_MASK ) ; result [ 1 + offset ] = ( int ) sum ; sum = ( dh & LONG_MASK ) + ( result [ offset ] & LONG_MASK ) + carry ; result [ offset ] = ( int ) sum ; carry = sum >>> 32 ; return ( int ) carry ; }
A primitive used for division by long . Specialized version of the method divadd . dh is a high part of the divisor dl is a low part
26,567
private int mulsubLong ( int [ ] q , int dh , int dl , int x , int offset ) { long xLong = x & LONG_MASK ; offset += 2 ; long product = ( dl & LONG_MASK ) * xLong ; long difference = q [ offset ] - product ; q [ offset -- ] = ( int ) difference ; long carry = ( product >>> 32 ) + ( ( ( difference & LONG_MASK ) > ( ( ( ~ ( int ) product ) & LONG_MASK ) ) ) ? 1 : 0 ) ; product = ( dh & LONG_MASK ) * xLong + carry ; difference = q [ offset ] - product ; q [ offset -- ] = ( int ) difference ; carry = ( product >>> 32 ) + ( ( ( difference & LONG_MASK ) > ( ( ( ~ ( int ) product ) & LONG_MASK ) ) ) ? 1 : 0 ) ; return ( int ) carry ; }
This method is used for division by long . Specialized version of the method sulsub . dh is a high part of the divisor dl is a low part
26,568
MutableBigInteger hybridGCD ( MutableBigInteger b ) { MutableBigInteger a = this ; MutableBigInteger q = new MutableBigInteger ( ) ; while ( b . intLen != 0 ) { if ( Math . abs ( a . intLen - b . intLen ) < 2 ) return a . binaryGCD ( b ) ; MutableBigInteger r = a . divide ( b , q ) ; a = b ; b = r ; } return a ; }
Calculate GCD of this and b . This and b are changed by the computation .
26,569
private MutableBigInteger binaryGCD ( MutableBigInteger v ) { MutableBigInteger u = this ; MutableBigInteger r = new MutableBigInteger ( ) ; int s1 = u . getLowestSetBit ( ) ; int s2 = v . getLowestSetBit ( ) ; int k = ( s1 < s2 ) ? s1 : s2 ; if ( k != 0 ) { u . rightShift ( k ) ; v . rightShift ( k ) ; } boolean uOdd = ( k == s1 ) ; MutableBigInteger t = uOdd ? v : u ; int tsign = uOdd ? - 1 : 1 ; int lb ; while ( ( lb = t . getLowestSetBit ( ) ) >= 0 ) { t . rightShift ( lb ) ; if ( tsign > 0 ) u = t ; else v = t ; if ( u . intLen < 2 && v . intLen < 2 ) { int x = u . value [ u . offset ] ; int y = v . value [ v . offset ] ; x = binaryGcd ( x , y ) ; r . value [ 0 ] = x ; r . intLen = 1 ; r . offset = 0 ; if ( k > 0 ) r . leftShift ( k ) ; return r ; } if ( ( tsign = u . difference ( v ) ) == 0 ) break ; t = ( tsign >= 0 ) ? u : v ; } if ( k > 0 ) u . leftShift ( k ) ; return u ; }
Calculate GCD of this and v . Assumes that this and v are not zero .
26,570
static int binaryGcd ( int a , int b ) { if ( b == 0 ) return a ; if ( a == 0 ) return b ; int aZeros = Integer . numberOfTrailingZeros ( a ) ; int bZeros = Integer . numberOfTrailingZeros ( b ) ; a >>>= aZeros ; b >>>= bZeros ; int t = ( aZeros < bZeros ? aZeros : bZeros ) ; while ( a != b ) { if ( ( a + 0x80000000 ) > ( b + 0x80000000 ) ) { a -= b ; a >>>= Integer . numberOfTrailingZeros ( a ) ; } else { b -= a ; b >>>= Integer . numberOfTrailingZeros ( b ) ; } } return a << t ; }
Calculate GCD of a and b interpreted as unsigned integers .
26,571
MutableBigInteger mutableModInverse ( MutableBigInteger p ) { if ( p . isOdd ( ) ) return modInverse ( p ) ; if ( isEven ( ) ) throw new ArithmeticException ( "BigInteger not invertible." ) ; int powersOf2 = p . getLowestSetBit ( ) ; MutableBigInteger oddMod = new MutableBigInteger ( p ) ; oddMod . rightShift ( powersOf2 ) ; if ( oddMod . isOne ( ) ) return modInverseMP2 ( powersOf2 ) ; MutableBigInteger oddPart = modInverse ( oddMod ) ; MutableBigInteger evenPart = modInverseMP2 ( powersOf2 ) ; MutableBigInteger y1 = modInverseBP2 ( oddMod , powersOf2 ) ; MutableBigInteger y2 = oddMod . modInverseMP2 ( powersOf2 ) ; MutableBigInteger temp1 = new MutableBigInteger ( ) ; MutableBigInteger temp2 = new MutableBigInteger ( ) ; MutableBigInteger result = new MutableBigInteger ( ) ; oddPart . leftShift ( powersOf2 ) ; oddPart . multiply ( y1 , result ) ; evenPart . multiply ( oddMod , temp1 ) ; temp1 . multiply ( y2 , temp2 ) ; result . add ( temp2 ) ; return result . divide ( p , temp1 ) ; }
Returns the modInverse of this mod p . This and p are not affected by the operation .
26,572
static int inverseMod32 ( int val ) { int t = val ; t *= 2 - val * t ; t *= 2 - val * t ; t *= 2 - val * t ; t *= 2 - val * t ; return t ; }
Returns the multiplicative inverse of val mod 2^32 . Assumes val is odd .
26,573
static MutableBigInteger modInverseBP2 ( MutableBigInteger mod , int k ) { return fixup ( new MutableBigInteger ( 1 ) , new MutableBigInteger ( mod ) , k ) ; }
Calculate the multiplicative inverse of 2^k mod mod where mod is odd .
26,574
private MutableBigInteger modInverse ( MutableBigInteger mod ) { MutableBigInteger p = new MutableBigInteger ( mod ) ; MutableBigInteger f = new MutableBigInteger ( this ) ; MutableBigInteger g = new MutableBigInteger ( p ) ; SignedMutableBigInteger c = new SignedMutableBigInteger ( 1 ) ; SignedMutableBigInteger d = new SignedMutableBigInteger ( ) ; MutableBigInteger temp = null ; SignedMutableBigInteger sTemp = null ; int k = 0 ; if ( f . isEven ( ) ) { int trailingZeros = f . getLowestSetBit ( ) ; f . rightShift ( trailingZeros ) ; d . leftShift ( trailingZeros ) ; k = trailingZeros ; } while ( ! f . isOne ( ) ) { if ( f . isZero ( ) ) throw new ArithmeticException ( "BigInteger not invertible." ) ; if ( f . compare ( g ) < 0 ) { temp = f ; f = g ; g = temp ; sTemp = d ; d = c ; c = sTemp ; } if ( ( ( f . value [ f . offset + f . intLen - 1 ] ^ g . value [ g . offset + g . intLen - 1 ] ) & 3 ) == 0 ) { f . subtract ( g ) ; c . signedSubtract ( d ) ; } else { f . add ( g ) ; c . signedAdd ( d ) ; } int trailingZeros = f . getLowestSetBit ( ) ; f . rightShift ( trailingZeros ) ; d . leftShift ( trailingZeros ) ; k += trailingZeros ; } while ( c . sign < 0 ) c . signedAdd ( p ) ; return fixup ( c , p , k ) ; }
Calculate the multiplicative inverse of this mod mod where mod is odd . This and mod are not changed by the calculation .
26,575
MutableBigInteger euclidModInverse ( int k ) { MutableBigInteger b = new MutableBigInteger ( 1 ) ; b . leftShift ( k ) ; MutableBigInteger mod = new MutableBigInteger ( b ) ; MutableBigInteger a = new MutableBigInteger ( this ) ; MutableBigInteger q = new MutableBigInteger ( ) ; MutableBigInteger r = b . divide ( a , q ) ; MutableBigInteger swapper = b ; b = r ; r = swapper ; MutableBigInteger t1 = new MutableBigInteger ( q ) ; MutableBigInteger t0 = new MutableBigInteger ( 1 ) ; MutableBigInteger temp = new MutableBigInteger ( ) ; while ( ! b . isOne ( ) ) { r = a . divide ( b , q ) ; if ( r . intLen == 0 ) throw new ArithmeticException ( "BigInteger not invertible." ) ; swapper = r ; a = swapper ; if ( q . intLen == 1 ) t1 . mul ( q . value [ q . offset ] , temp ) ; else q . multiply ( t1 , temp ) ; swapper = q ; q = temp ; temp = swapper ; t0 . add ( q ) ; if ( a . isOne ( ) ) return t0 ; r = b . divide ( a , q ) ; if ( r . intLen == 0 ) throw new ArithmeticException ( "BigInteger not invertible." ) ; swapper = b ; b = r ; if ( q . intLen == 1 ) t0 . mul ( q . value [ q . offset ] , temp ) ; else q . multiply ( t0 , temp ) ; swapper = q ; q = temp ; temp = swapper ; t1 . add ( q ) ; } mod . subtract ( t1 ) ; return mod ; }
Uses the extended Euclidean algorithm to compute the modInverse of base mod a modulus that is a power of 2 . The modulus is 2^k .
26,576
< R > R getValue ( TemporalQuery < R > query ) { R result = temporal . query ( query ) ; if ( result == null && optional == 0 ) { throw new DateTimeException ( "Unable to extract value: " + temporal . getClass ( ) ) ; } return result ; }
Gets a value using a query .
26,577
public int compareTo ( Date anotherDate ) { long thisTime = getMillisOf ( this ) ; long anotherTime = getMillisOf ( anotherDate ) ; return ( thisTime < anotherTime ? - 1 : ( thisTime == anotherTime ? 0 : 1 ) ) ; }
Compares two Dates for ordering .
26,578
private final BaseCalendar . Date normalize ( BaseCalendar . Date date ) { int y = date . getNormalizedYear ( ) ; int m = date . getMonth ( ) ; int d = date . getDayOfMonth ( ) ; int hh = date . getHours ( ) ; int mm = date . getMinutes ( ) ; int ss = date . getSeconds ( ) ; int ms = date . getMillis ( ) ; TimeZone tz = date . getZone ( ) ; if ( y == 1582 || y > 280000000 || y < - 280000000 ) { if ( tz == null ) { tz = TimeZone . getTimeZone ( "GMT" ) ; } GregorianCalendar gc = new GregorianCalendar ( tz ) ; gc . clear ( ) ; gc . set ( GregorianCalendar . MILLISECOND , ms ) ; gc . set ( y , m - 1 , d , hh , mm , ss ) ; fastTime = gc . getTimeInMillis ( ) ; BaseCalendar cal = getCalendarSystem ( fastTime ) ; date = ( BaseCalendar . Date ) cal . getCalendarDate ( fastTime , tz ) ; return date ; } BaseCalendar cal = getCalendarSystem ( y ) ; if ( cal != getCalendarSystem ( date ) ) { date = ( BaseCalendar . Date ) cal . newCalendarDate ( tz ) ; date . setNormalizedDate ( y , m , d ) . setTimeOfDay ( hh , mm , ss , ms ) ; } fastTime = cal . getTime ( date ) ; BaseCalendar ncal = getCalendarSystem ( fastTime ) ; if ( ncal != cal ) { date = ( BaseCalendar . Date ) ncal . newCalendarDate ( tz ) ; date . setNormalizedDate ( y , m , d ) . setTimeOfDay ( hh , mm , ss , ms ) ; fastTime = ncal . getTime ( date ) ; } return date ; }
fastTime and the returned data are in sync upon return .
26,579
public static ZoneRules of ( ZoneOffset baseStandardOffset , ZoneOffset baseWallOffset , List < ZoneOffsetTransition > standardOffsetTransitionList , List < ZoneOffsetTransition > transitionList , List < ZoneOffsetTransitionRule > lastRules ) { Objects . requireNonNull ( baseStandardOffset , "baseStandardOffset" ) ; Objects . requireNonNull ( baseWallOffset , "baseWallOffset" ) ; Objects . requireNonNull ( standardOffsetTransitionList , "standardOffsetTransitionList" ) ; Objects . requireNonNull ( transitionList , "transitionList" ) ; Objects . requireNonNull ( lastRules , "lastRules" ) ; return new ZoneRules ( baseStandardOffset , baseWallOffset , standardOffsetTransitionList , transitionList , lastRules ) ; }
Obtains an instance of a ZoneRules .
26,580
private Object findOffsetInfo ( LocalDateTime dt , ZoneOffsetTransition trans ) { LocalDateTime localTransition = trans . getDateTimeBefore ( ) ; if ( trans . isGap ( ) ) { if ( dt . isBefore ( localTransition ) ) { return trans . getOffsetBefore ( ) ; } if ( dt . isBefore ( trans . getDateTimeAfter ( ) ) ) { return trans ; } else { return trans . getOffsetAfter ( ) ; } } else { if ( dt . isBefore ( localTransition ) == false ) { return trans . getOffsetAfter ( ) ; } if ( dt . isBefore ( trans . getDateTimeAfter ( ) ) ) { return trans . getOffsetBefore ( ) ; } else { return trans ; } } }
Finds the offset info for a local date - time and transition .
26,581
private ZoneOffsetTransition [ ] findTransitionArray ( int year ) { Integer yearObj = year ; ZoneOffsetTransition [ ] transArray = lastRulesCache . get ( yearObj ) ; if ( transArray != null ) { return transArray ; } ZoneOffsetTransitionRule [ ] ruleArray = lastRules ; transArray = new ZoneOffsetTransition [ ruleArray . length ] ; for ( int i = 0 ; i < ruleArray . length ; i ++ ) { transArray [ i ] = ruleArray [ i ] . createTransition ( year ) ; } if ( year < LAST_CACHED_YEAR ) { lastRulesCache . putIfAbsent ( yearObj , transArray ) ; } return transArray ; }
Finds the appropriate transition array for the given year .
26,582
public int getNode ( Source source ) { String url = source . getSystemId ( ) ; if ( null == url ) return DTM . NULL ; int n = m_sourceTree . size ( ) ; for ( int i = 0 ; i < n ; i ++ ) { SourceTree sTree = ( SourceTree ) m_sourceTree . elementAt ( i ) ; if ( url . equals ( sTree . m_url ) ) return sTree . m_root ; } return DTM . NULL ; }
Given a Source object find the node associated with it .
26,583
public int getSourceTree ( String base , String urlString , SourceLocator locator , XPathContext xctxt ) throws TransformerException { try { Source source = this . resolveURI ( base , urlString , locator ) ; return getSourceTree ( source , locator , xctxt ) ; } catch ( IOException ioe ) { throw new TransformerException ( ioe . getMessage ( ) , locator , ioe ) ; } }
Get the source tree from the a base URL and a URL string .
26,584
public int getSourceTree ( Source source , SourceLocator locator , XPathContext xctxt ) throws TransformerException { int n = getNode ( source ) ; if ( DTM . NULL != n ) return n ; n = parseToNode ( source , locator , xctxt ) ; if ( DTM . NULL != n ) putDocumentInCache ( n , source ) ; return n ; }
Get the source tree from the input source .
26,585
public int parseToNode ( Source source , SourceLocator locator , XPathContext xctxt ) throws TransformerException { try { Object xowner = xctxt . getOwnerObject ( ) ; DTM dtm ; if ( null != xowner && xowner instanceof org . apache . xml . dtm . DTMWSFilter ) { dtm = xctxt . getDTM ( source , false , ( org . apache . xml . dtm . DTMWSFilter ) xowner , false , true ) ; } else { dtm = xctxt . getDTM ( source , false , null , false , true ) ; } return dtm . getDocument ( ) ; } catch ( Exception e ) { throw new TransformerException ( e . getMessage ( ) , locator , e ) ; } }
Try to create a DOM source tree from the input source .
26,586
public final void addCaseClosure ( int c , UnicodeSet set ) { switch ( c ) { case 0x49 : set . add ( 0x69 ) ; return ; case 0x69 : set . add ( 0x49 ) ; return ; case 0x130 : set . add ( iDot ) ; return ; case 0x131 : return ; default : break ; } int props = trie . get ( c ) ; if ( ! propsHasException ( props ) ) { if ( getTypeFromProps ( props ) != NONE ) { int delta = getDelta ( props ) ; if ( delta != 0 ) { set . add ( c + delta ) ; } } } else { int excOffset0 , excOffset = getExceptionsOffset ( props ) ; int closureOffset ; int excWord = exceptions . charAt ( excOffset ++ ) ; int index , closureLength , fullLength , length ; excOffset0 = excOffset ; for ( index = EXC_LOWER ; index <= EXC_TITLE ; ++ index ) { if ( hasSlot ( excWord , index ) ) { excOffset = excOffset0 ; c = getSlotValue ( excWord , index , excOffset ) ; set . add ( c ) ; } } if ( hasSlot ( excWord , EXC_CLOSURE ) ) { excOffset = excOffset0 ; long value = getSlotValueAndOffset ( excWord , EXC_CLOSURE , excOffset ) ; closureLength = ( int ) value & CLOSURE_MAX_LENGTH ; closureOffset = ( int ) ( value >> 32 ) + 1 ; } else { closureLength = 0 ; closureOffset = 0 ; } if ( hasSlot ( excWord , EXC_FULL_MAPPINGS ) ) { excOffset = excOffset0 ; long value = getSlotValueAndOffset ( excWord , EXC_FULL_MAPPINGS , excOffset ) ; fullLength = ( int ) value ; excOffset = ( int ) ( value >> 32 ) + 1 ; fullLength &= 0xffff ; excOffset += fullLength & FULL_LOWER ; fullLength >>= 4 ; length = fullLength & 0xf ; if ( length != 0 ) { set . add ( exceptions . substring ( excOffset , excOffset + length ) ) ; excOffset += length ; } fullLength >>= 4 ; excOffset += fullLength & 0xf ; fullLength >>= 4 ; excOffset += fullLength ; closureOffset = excOffset ; } int limit = closureOffset + closureLength ; for ( index = closureOffset ; index < limit ; index += UTF16 . getCharCount ( c ) ) { c = exceptions . codePointAt ( index ) ; set . add ( c ) ; } } }
Adds all simple case mappings and the full case folding for c to sa and also adds special case closure mappings . c itself is not added . For example the mappings - for s include long s - for sharp s include ss - for k include the Kelvin sign
26,587
public final boolean addStringCaseClosure ( String s , UnicodeSet set ) { int i , length , start , limit , result , unfoldOffset , unfoldRows , unfoldRowWidth , unfoldStringWidth ; if ( unfold == null || s == null ) { return false ; } length = s . length ( ) ; if ( length <= 1 ) { return false ; } unfoldRows = unfold [ UNFOLD_ROWS ] ; unfoldRowWidth = unfold [ UNFOLD_ROW_WIDTH ] ; unfoldStringWidth = unfold [ UNFOLD_STRING_WIDTH ] ; if ( length > unfoldStringWidth ) { return false ; } start = 0 ; limit = unfoldRows ; while ( start < limit ) { i = ( start + limit ) / 2 ; unfoldOffset = ( ( i + 1 ) * unfoldRowWidth ) ; result = strcmpMax ( s , unfoldOffset , unfoldStringWidth ) ; if ( result == 0 ) { int c ; for ( i = unfoldStringWidth ; i < unfoldRowWidth && unfold [ unfoldOffset + i ] != 0 ; i += UTF16 . getCharCount ( c ) ) { c = UTF16 . charAt ( unfold , unfoldOffset , unfold . length , i ) ; set . add ( c ) ; addCaseClosure ( c , set ) ; } return true ; } else if ( result < 0 ) { limit = i ; } else { start = i + 1 ; } } return false ; }
Maps the string to single code points and adds the associated case closure mappings . The string is mapped to code points if it is their full case folding string . In other words this performs a reverse full case folding and then adds the case closure items of the resulting code points . If the string is found and its closure applied then the string itself is added as well as part of its code points closure .
26,588
private static final int getCaseLocale ( String language ) { if ( language . length ( ) == 2 ) { if ( language . equals ( "en" ) || language . charAt ( 0 ) > 't' ) { return LOC_ROOT ; } else if ( language . equals ( "tr" ) || language . equals ( "az" ) ) { return LOC_TURKISH ; } else if ( language . equals ( "el" ) ) { return LOC_GREEK ; } else if ( language . equals ( "lt" ) ) { return LOC_LITHUANIAN ; } else if ( language . equals ( "nl" ) ) { return LOC_DUTCH ; } } else if ( language . length ( ) == 3 ) { if ( language . equals ( "tur" ) || language . equals ( "aze" ) ) { return LOC_TURKISH ; } else if ( language . equals ( "ell" ) ) { return LOC_GREEK ; } else if ( language . equals ( "lit" ) ) { return LOC_LITHUANIAN ; } else if ( language . equals ( "nld" ) ) { return LOC_DUTCH ; } } return LOC_ROOT ; }
Accepts both 2 - and 3 - letter language subtags .
26,589
public final int toFullLower ( int c , ContextIterator iter , Appendable out , int caseLocale ) { int result , props ; result = c ; props = trie . get ( c ) ; if ( ! propsHasException ( props ) ) { if ( getTypeFromProps ( props ) >= UPPER ) { result = c + getDelta ( props ) ; } } else { int excOffset = getExceptionsOffset ( props ) , excOffset2 ; int excWord = exceptions . charAt ( excOffset ++ ) ; int full ; excOffset2 = excOffset ; if ( ( excWord & EXC_CONDITIONAL_SPECIAL ) != 0 ) { if ( caseLocale == LOC_LITHUANIAN && ( ( ( c == 0x49 || c == 0x4a || c == 0x12e ) && isFollowedByMoreAbove ( iter ) ) || ( c == 0xcc || c == 0xcd || c == 0x128 ) ) ) { try { switch ( c ) { case 0x49 : out . append ( iDot ) ; return 2 ; case 0x4a : out . append ( jDot ) ; return 2 ; case 0x12e : out . append ( iOgonekDot ) ; return 2 ; case 0xcc : out . append ( iDotGrave ) ; return 3 ; case 0xcd : out . append ( iDotAcute ) ; return 3 ; case 0x128 : out . append ( iDotTilde ) ; return 3 ; default : return 0 ; } } catch ( IOException e ) { throw new ICUUncheckedIOException ( e ) ; } } else if ( caseLocale == LOC_TURKISH && c == 0x130 ) { return 0x69 ; } else if ( caseLocale == LOC_TURKISH && c == 0x307 && isPrecededBy_I ( iter ) ) { return 0 ; } else if ( caseLocale == LOC_TURKISH && c == 0x49 && ! isFollowedByDotAbove ( iter ) ) { return 0x131 ; } else if ( c == 0x130 ) { try { out . append ( iDot ) ; return 2 ; } catch ( IOException e ) { throw new ICUUncheckedIOException ( e ) ; } } else if ( c == 0x3a3 && ! isFollowedByCasedLetter ( iter , 1 ) && isFollowedByCasedLetter ( iter , - 1 ) ) { return 0x3c2 ; } else { } } else if ( hasSlot ( excWord , EXC_FULL_MAPPINGS ) ) { long value = getSlotValueAndOffset ( excWord , EXC_FULL_MAPPINGS , excOffset ) ; full = ( int ) value & FULL_LOWER ; if ( full != 0 ) { excOffset = ( int ) ( value >> 32 ) + 1 ; try { out . append ( exceptions , excOffset , excOffset + full ) ; return full ; } catch ( IOException e ) { throw new ICUUncheckedIOException ( e ) ; } } } if ( hasSlot ( excWord , EXC_LOWER ) ) { result = getSlotValue ( excWord , EXC_LOWER , excOffset2 ) ; } } return ( result == c ) ? ~ result : result ; }
Get the full lowercase mapping for c .
26,590
public void put ( String ID , Class < ? extends Transliterator > transliteratorSubclass , boolean visible ) { registerEntry ( ID , transliteratorSubclass , visible ) ; }
Register a class . This adds an entry to the dynamic store or replaces an existing entry . Any entry in the underlying static locale resource store is masked .
26,591
public void put ( String ID , Transliterator . Factory factory , boolean visible ) { registerEntry ( ID , factory , visible ) ; }
Register an ID and a factory function pointer . This adds an entry to the dynamic store or replaces an existing entry . Any entry in the underlying static locale resource store is masked .
26,592
public void put ( String ID , String resourceName , int dir , boolean visible ) { registerEntry ( ID , new ResourceEntry ( resourceName , dir ) , visible ) ; }
Register an ID and a resource name . This adds an entry to the dynamic store or replaces an existing entry . Any entry in the underlying static locale resource store is masked .
26,593
public void put ( String ID , String alias , boolean visible ) { registerEntry ( ID , new AliasEntry ( alias ) , visible ) ; }
Register an ID and an alias ID . This adds an entry to the dynamic store or replaces an existing entry . Any entry in the underlying static locale resource store is masked .
26,594
public void put ( String ID , Transliterator trans , boolean visible ) { registerEntry ( ID , trans , visible ) ; }
Register an ID and a Transliterator object . This adds an entry to the dynamic store or replaces an existing entry . Any entry in the underlying static locale resource store is masked .
26,595
public void remove ( String ID ) { String [ ] stv = TransliteratorIDParser . IDtoSTV ( ID ) ; String id = TransliteratorIDParser . STVtoID ( stv [ 0 ] , stv [ 1 ] , stv [ 2 ] ) ; registry . remove ( new CaseInsensitiveString ( id ) ) ; removeSTV ( stv [ 0 ] , stv [ 1 ] , stv [ 2 ] ) ; availableIDs . remove ( new CaseInsensitiveString ( id ) ) ; }
Unregister an ID . This removes an entry from the dynamic store if there is one . The static locale resource store is unaffected .
26,596
public Enumeration < String > getAvailableTargets ( String source ) { CaseInsensitiveString cisrc = new CaseInsensitiveString ( source ) ; Map < CaseInsensitiveString , List < CaseInsensitiveString > > targets = specDAG . get ( cisrc ) ; if ( targets == null ) { return new IDEnumeration ( null ) ; } return new IDEnumeration ( Collections . enumeration ( targets . keySet ( ) ) ) ; }
Returns an enumeration over visible target names for the given source .
26,597
public Enumeration < String > getAvailableVariants ( String source , String target ) { CaseInsensitiveString cisrc = new CaseInsensitiveString ( source ) ; CaseInsensitiveString citrg = new CaseInsensitiveString ( target ) ; Map < CaseInsensitiveString , List < CaseInsensitiveString > > targets = specDAG . get ( cisrc ) ; if ( targets == null ) { return new IDEnumeration ( null ) ; } List < CaseInsensitiveString > variants = targets . get ( citrg ) ; if ( variants == null ) { return new IDEnumeration ( null ) ; } return new IDEnumeration ( Collections . enumeration ( variants ) ) ; }
Returns an enumeration over visible variant names for the given source and target .
26,598
protected NodeVector getVector ( ) { NodeVector nv = ( m_cache != null ) ? m_cache . getVector ( ) : null ; return nv ; }
If this iterator needs to cache nodes that are fetched they are stored in the Vector in the generic object .
26,599
private boolean cacheComplete ( ) { final boolean complete ; if ( m_cache != null ) { complete = m_cache . isComplete ( ) ; } else { complete = false ; } return complete ; }
If this NodeSequence has a cache and that cache is fully populated then this method returns true otherwise if there is no cache or it is not complete it returns false .