idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
26,000
protected int getLimit ( int field , int limitType ) { switch ( field ) { case DAY_OF_WEEK : case AM_PM : case HOUR : case HOUR_OF_DAY : case MINUTE : case SECOND : case MILLISECOND : case ZONE_OFFSET : case DST_OFFSET : case DOW_LOCAL : case JULIAN_DAY : case MILLISECONDS_IN_DAY : case IS_LEAP_MONTH : return LIMITS [ field ] [ limitType ] ; case WEEK_OF_MONTH : { int limit ; if ( limitType == MINIMUM ) { limit = getMinimalDaysInFirstWeek ( ) == 1 ? 1 : 0 ; } else if ( limitType == GREATEST_MINIMUM ) { limit = 1 ; } else { int minDaysInFirst = getMinimalDaysInFirstWeek ( ) ; int daysInMonth = handleGetLimit ( DAY_OF_MONTH , limitType ) ; if ( limitType == LEAST_MAXIMUM ) { limit = ( daysInMonth + ( 7 - minDaysInFirst ) ) / 7 ; } else { limit = ( daysInMonth + 6 + ( 7 - minDaysInFirst ) ) / 7 ; } } return limit ; } } return handleGetLimit ( field , limitType ) ; }
Returns a limit for a field .
26,001
private void updateTime ( ) { computeTime ( ) ; if ( isLenient ( ) || ! areAllFieldsSet ) areFieldsSet = false ; isTimeSet = true ; areFieldsVirtuallySet = false ; }
Recompute the time and update the status fields isTimeSet and areFieldsSet . Callers should check isTimeSet and only call this method if isTimeSet is false .
26,002
private final void computeGregorianAndDOWFields ( int julianDay ) { computeGregorianFields ( julianDay ) ; int dow = fields [ DAY_OF_WEEK ] = julianDayToDayOfWeek ( julianDay ) ; int dowLocal = dow - getFirstDayOfWeek ( ) + 1 ; if ( dowLocal < 1 ) { dowLocal += 7 ; } fields [ DOW_LOCAL ] = dowLocal ; }
Compute the Gregorian calendar year month and day of month from the given Julian day . These values are not stored in fields but in member variables gregorianXxx . Also compute the DAY_OF_WEEK and DOW_LOCAL fields .
26,003
private final void computeWeekFields ( ) { int eyear = fields [ EXTENDED_YEAR ] ; int dayOfWeek = fields [ DAY_OF_WEEK ] ; int dayOfYear = fields [ DAY_OF_YEAR ] ; int yearOfWeekOfYear = eyear ; int relDow = ( dayOfWeek + 7 - getFirstDayOfWeek ( ) ) % 7 ; int relDowJan1 = ( dayOfWeek - dayOfYear + 7001 - getFirstDayOfWeek ( ) ) % 7 ; int woy = ( dayOfYear - 1 + relDowJan1 ) / 7 ; if ( ( 7 - relDowJan1 ) >= getMinimalDaysInFirstWeek ( ) ) { ++ woy ; } if ( woy == 0 ) { int prevDoy = dayOfYear + handleGetYearLength ( eyear - 1 ) ; woy = weekNumber ( prevDoy , dayOfWeek ) ; yearOfWeekOfYear -- ; } else { int lastDoy = handleGetYearLength ( eyear ) ; if ( dayOfYear >= ( lastDoy - 5 ) ) { int lastRelDow = ( relDow + lastDoy - dayOfYear ) % 7 ; if ( lastRelDow < 0 ) { lastRelDow += 7 ; } if ( ( ( 6 - lastRelDow ) >= getMinimalDaysInFirstWeek ( ) ) && ( ( dayOfYear + 7 - relDow ) > lastDoy ) ) { woy = 1 ; yearOfWeekOfYear ++ ; } } } fields [ WEEK_OF_YEAR ] = woy ; fields [ YEAR_WOY ] = yearOfWeekOfYear ; int dayOfMonth = fields [ DAY_OF_MONTH ] ; fields [ WEEK_OF_MONTH ] = weekNumber ( dayOfMonth , dayOfWeek ) ; fields [ DAY_OF_WEEK_IN_MONTH ] = ( dayOfMonth - 1 ) / 7 + 1 ; }
Compute the fields WEEK_OF_YEAR YEAR_WOY WEEK_OF_MONTH DAY_OF_WEEK_IN_MONTH and DOW_LOCAL from EXTENDED_YEAR YEAR DAY_OF_WEEK and DAY_OF_YEAR . The latter fields are computed by the subclass based on the calendar system .
26,004
protected int resolveFields ( int [ ] [ ] [ ] precedenceTable ) { int bestField = - 1 ; int tempBestField ; for ( int g = 0 ; g < precedenceTable . length && bestField < 0 ; ++ g ) { int [ ] [ ] group = precedenceTable [ g ] ; int bestStamp = UNSET ; linesInGroup : for ( int l = 0 ; l < group . length ; ++ l ) { int [ ] line = group [ l ] ; int lineStamp = UNSET ; for ( int i = ( line [ 0 ] >= RESOLVE_REMAP ) ? 1 : 0 ; i < line . length ; ++ i ) { int s = stamp [ line [ i ] ] ; if ( s == UNSET ) { continue linesInGroup ; } else { lineStamp = Math . max ( lineStamp , s ) ; } } if ( lineStamp > bestStamp ) { tempBestField = line [ 0 ] ; if ( tempBestField >= RESOLVE_REMAP ) { tempBestField &= ( RESOLVE_REMAP - 1 ) ; if ( tempBestField != DATE || ( stamp [ WEEK_OF_MONTH ] < stamp [ tempBestField ] ) ) { bestField = tempBestField ; } } else { bestField = tempBestField ; } if ( bestField == tempBestField ) { bestStamp = lineStamp ; } } } } return ( bestField >= RESOLVE_REMAP ) ? ( bestField & ( RESOLVE_REMAP - 1 ) ) : bestField ; }
Given a precedence table return the newest field combination in the table or - 1 if none is found .
26,005
protected int newestStamp ( int first , int last , int bestStampSoFar ) { int bestStamp = bestStampSoFar ; for ( int i = first ; i <= last ; ++ i ) { if ( stamp [ i ] > bestStamp ) { bestStamp = stamp [ i ] ; } } return bestStamp ; }
Returns the newest stamp of a given range of fields .
26,006
private Long getImmediatePreviousZoneTransition ( long base ) { Long transitionTime = null ; if ( zone instanceof BasicTimeZone ) { TimeZoneTransition transition = ( ( BasicTimeZone ) zone ) . getPreviousTransition ( base , true ) ; if ( transition != null ) { transitionTime = transition . getTime ( ) ; } } else { transitionTime = getPreviousZoneTransitionTime ( zone , base , 2 * 60 * 60 * 1000 ) ; if ( transitionTime == null ) { transitionTime = getPreviousZoneTransitionTime ( zone , base , 30 * 60 * 60 * 1000 ) ; } } return transitionTime ; }
Find the previous zone transtion near the given time .
26,007
protected int computeZoneOffset ( long millis , int millisInDay ) { int [ ] offsets = new int [ 2 ] ; long wall = millis + millisInDay ; if ( zone instanceof BasicTimeZone ) { int duplicatedTimeOpt = ( repeatedWallTime == WALLTIME_FIRST ) ? BasicTimeZone . LOCAL_FORMER : BasicTimeZone . LOCAL_LATTER ; int nonExistingTimeOpt = ( skippedWallTime == WALLTIME_FIRST ) ? BasicTimeZone . LOCAL_LATTER : BasicTimeZone . LOCAL_FORMER ; ( ( BasicTimeZone ) zone ) . getOffsetFromLocal ( wall , nonExistingTimeOpt , duplicatedTimeOpt , offsets ) ; } else { zone . getOffset ( wall , true , offsets ) ; boolean sawRecentNegativeShift = false ; if ( repeatedWallTime == WALLTIME_FIRST ) { long tgmt = wall - ( offsets [ 0 ] + offsets [ 1 ] ) ; int offsetBefore6 = zone . getOffset ( tgmt - 6 * 60 * 60 * 1000 ) ; int offsetDelta = ( offsets [ 0 ] + offsets [ 1 ] ) - offsetBefore6 ; assert offsetDelta > - 6 * 60 * 60 * 1000 : offsetDelta ; if ( offsetDelta < 0 ) { sawRecentNegativeShift = true ; zone . getOffset ( wall + offsetDelta , true , offsets ) ; } } if ( ! sawRecentNegativeShift && skippedWallTime == WALLTIME_FIRST ) { long tgmt = wall - ( offsets [ 0 ] + offsets [ 1 ] ) ; zone . getOffset ( tgmt , false , offsets ) ; } } return offsets [ 0 ] + offsets [ 1 ] ; }
This method can assume EXTENDED_YEAR has been set .
26,008
protected int computeJulianDay ( ) { if ( stamp [ JULIAN_DAY ] >= MINIMUM_USER_STAMP ) { int bestStamp = newestStamp ( ERA , DAY_OF_WEEK_IN_MONTH , UNSET ) ; bestStamp = newestStamp ( YEAR_WOY , EXTENDED_YEAR , bestStamp ) ; if ( bestStamp <= stamp [ JULIAN_DAY ] ) { return internalGet ( JULIAN_DAY ) ; } } int bestField = resolveFields ( getFieldResolutionTable ( ) ) ; if ( bestField < 0 ) { bestField = DAY_OF_MONTH ; } return handleComputeJulianDay ( bestField ) ; }
Compute the Julian day number as specified by this calendar s fields .
26,009
protected int handleGetMonthLength ( int extendedYear , int month ) { return handleComputeMonthStart ( extendedYear , month + 1 , true ) - handleComputeMonthStart ( extendedYear , month , true ) ; }
Returns the number of days in the given month of the given extended year of this calendar system . Subclasses should override this method if they can provide a more correct or more efficient implementation than the default implementation in Calendar .
26,010
public int getIdForNamespace ( String uri ) { int index = m_values . indexOf ( uri ) ; if ( index < 0 ) { m_values . addElement ( uri ) ; return m_valueIndex ++ ; } else return index ; }
Get a prefix either from the uri mapping or just make one up!
26,011
public String getStringValue ( ) { int child = _firstch2 ( ROOTNODE ) ; if ( child == DTM . NULL ) return EMPTY_STR ; if ( ( _exptype2 ( child ) == DTM . TEXT_NODE ) && ( _nextsib2 ( child ) == DTM . NULL ) ) { int dataIndex = m_dataOrQName . elementAt ( child ) ; if ( dataIndex >= 0 ) return m_chars . getString ( dataIndex >>> TEXT_LENGTH_BITS , dataIndex & TEXT_LENGTH_MAX ) ; else return m_chars . getString ( m_data . elementAt ( - dataIndex ) , m_data . elementAt ( - dataIndex + 1 ) ) ; } else return getStringValueX ( getDocument ( ) ) ; }
Returns the string value of the entire tree
26,012
protected final void copyTextNode ( final int nodeID , SerializationHandler handler ) throws SAXException { if ( nodeID != DTM . NULL ) { int dataIndex = m_dataOrQName . elementAt ( nodeID ) ; if ( dataIndex >= 0 ) { m_chars . sendSAXcharacters ( handler , dataIndex >>> TEXT_LENGTH_BITS , dataIndex & TEXT_LENGTH_MAX ) ; } else { m_chars . sendSAXcharacters ( handler , m_data . elementAt ( - dataIndex ) , m_data . elementAt ( - dataIndex + 1 ) ) ; } } }
Copy the String value of a Text node to a SerializationHandler
26,013
protected final String copyElement ( int nodeID , int exptype , SerializationHandler handler ) throws SAXException { final ExtendedType extType = m_extendedTypes [ exptype ] ; String uri = extType . getNamespace ( ) ; String name = extType . getLocalName ( ) ; if ( uri . length ( ) == 0 ) { handler . startElement ( name ) ; return name ; } else { int qnameIndex = m_dataOrQName . elementAt ( nodeID ) ; if ( qnameIndex == 0 ) { handler . startElement ( name ) ; handler . namespaceAfterStartElement ( EMPTY_STR , uri ) ; return name ; } if ( qnameIndex < 0 ) { qnameIndex = - qnameIndex ; qnameIndex = m_data . elementAt ( qnameIndex ) ; } String qName = m_valuesOrPrefixes . indexToString ( qnameIndex ) ; handler . startElement ( qName ) ; int prefixIndex = qName . indexOf ( ':' ) ; String prefix ; if ( prefixIndex > 0 ) { prefix = qName . substring ( 0 , prefixIndex ) ; } else { prefix = null ; } handler . namespaceAfterStartElement ( prefix , uri ) ; return qName ; } }
Copy an Element node to a SerializationHandler .
26,014
protected final void copyNS ( final int nodeID , SerializationHandler handler , boolean inScope ) throws SAXException { if ( m_namespaceDeclSetElements != null && m_namespaceDeclSetElements . size ( ) == 1 && m_namespaceDeclSets != null && ( ( SuballocatedIntVector ) m_namespaceDeclSets . elementAt ( 0 ) ) . size ( ) == 1 ) return ; SuballocatedIntVector nsContext = null ; int nextNSNode ; if ( inScope ) { nsContext = findNamespaceContext ( nodeID ) ; if ( nsContext == null || nsContext . size ( ) < 1 ) return ; else nextNSNode = makeNodeIdentity ( nsContext . elementAt ( 0 ) ) ; } else nextNSNode = getNextNamespaceNode2 ( nodeID ) ; int nsIndex = 1 ; while ( nextNSNode != DTM . NULL ) { int eType = _exptype2 ( nextNSNode ) ; String nodeName = m_extendedTypes [ eType ] . getLocalName ( ) ; int dataIndex = m_dataOrQName . elementAt ( nextNSNode ) ; if ( dataIndex < 0 ) { dataIndex = - dataIndex ; dataIndex = m_data . elementAt ( dataIndex + 1 ) ; } String nodeValue = ( String ) m_values . elementAt ( dataIndex ) ; handler . namespaceAfterStartElement ( nodeName , nodeValue ) ; if ( inScope ) { if ( nsIndex < nsContext . size ( ) ) { nextNSNode = makeNodeIdentity ( nsContext . elementAt ( nsIndex ) ) ; nsIndex ++ ; } else return ; } else nextNSNode = getNextNamespaceNode2 ( nextNSNode ) ; } }
Copy namespace nodes .
26,015
protected final int getNextNamespaceNode2 ( int baseID ) { int type ; while ( ( type = _type2 ( ++ baseID ) ) == DTM . ATTRIBUTE_NODE ) ; if ( type == DTM . NAMESPACE_NODE ) return baseID ; else return NULL ; }
Return the next namespace node following the given base node .
26,016
protected final void copyAttributes ( final int nodeID , SerializationHandler handler ) throws SAXException { for ( int current = getFirstAttributeIdentity ( nodeID ) ; current != DTM . NULL ; current = getNextAttributeIdentity ( current ) ) { int eType = _exptype2 ( current ) ; copyAttribute ( current , eType , handler ) ; } }
Copy attribute nodes from an element .
26,017
protected final void copyAttribute ( int nodeID , int exptype , SerializationHandler handler ) throws SAXException { final ExtendedType extType = m_extendedTypes [ exptype ] ; final String uri = extType . getNamespace ( ) ; final String localName = extType . getLocalName ( ) ; String prefix = null ; String qname = null ; int dataIndex = _dataOrQName ( nodeID ) ; int valueIndex = dataIndex ; if ( dataIndex <= 0 ) { int prefixIndex = m_data . elementAt ( - dataIndex ) ; valueIndex = m_data . elementAt ( - dataIndex + 1 ) ; qname = m_valuesOrPrefixes . indexToString ( prefixIndex ) ; int colonIndex = qname . indexOf ( ':' ) ; if ( colonIndex > 0 ) { prefix = qname . substring ( 0 , colonIndex ) ; } } if ( uri . length ( ) != 0 ) { handler . namespaceAfterStartElement ( prefix , uri ) ; } String nodeName = ( prefix != null ) ? qname : localName ; String nodeValue = ( String ) m_values . elementAt ( valueIndex ) ; handler . addAttribute ( nodeName , nodeValue ) ; }
Copy an Attribute node to a SerializationHandler
26,018
public static XNodeSet executeFilterExpr ( int context , XPathContext xctxt , PrefixResolver prefixResolver , boolean isTopLevel , int stackFrame , Expression expr ) throws org . apache . xml . utils . WrappedRuntimeException { PrefixResolver savedResolver = xctxt . getNamespaceContext ( ) ; XNodeSet result = null ; try { xctxt . pushCurrentNode ( context ) ; xctxt . setNamespaceContext ( prefixResolver ) ; if ( isTopLevel ) { VariableStack vars = xctxt . getVarStack ( ) ; int savedStart = vars . getStackFrame ( ) ; vars . setStackFrame ( stackFrame ) ; result = ( org . apache . xpath . objects . XNodeSet ) expr . execute ( xctxt ) ; result . setShouldCacheNodes ( true ) ; vars . setStackFrame ( savedStart ) ; } else result = ( org . apache . xpath . objects . XNodeSet ) expr . execute ( xctxt ) ; } catch ( javax . xml . transform . TransformerException se ) { throw new org . apache . xml . utils . WrappedRuntimeException ( se ) ; } finally { xctxt . popCurrentNode ( ) ; xctxt . setNamespaceContext ( savedResolver ) ; } return result ; }
Execute the expression . Meant for reuse by other FilterExpr iterators that are not derived from this object .
26,019
public void characters ( char [ ] ch , int start , int length ) throws org . xml . sax . SAXException { m_char . append ( ch , start , length ) ; }
Replaces the deprecated DocumentHandler interface .
26,020
private void processAccumulatedText ( ) { int len = m_char . length ( ) ; if ( len != m_char_current_start ) { appendTextChild ( m_char_current_start , len - m_char_current_start ) ; m_char_current_start = len ; } }
Flush string accumulation into a text node
26,021
public int getFirstAttribute ( int nodeHandle ) { nodeHandle &= NODEHANDLE_MASK ; if ( ELEMENT_NODE != ( nodes . readEntry ( nodeHandle , 0 ) & 0xFFFF ) ) return NULL ; nodeHandle ++ ; return ( ATTRIBUTE_NODE == ( nodes . readEntry ( nodeHandle , 0 ) & 0xFFFF ) ) ? nodeHandle | m_docHandle : NULL ; }
Given a node handle get the index of the node s first attribute .
26,022
public int getNextSibling ( int nodeHandle ) { nodeHandle &= NODEHANDLE_MASK ; if ( nodeHandle == 0 ) return NULL ; short type = ( short ) ( nodes . readEntry ( nodeHandle , 0 ) & 0xFFFF ) ; if ( ( type == ELEMENT_NODE ) || ( type == ATTRIBUTE_NODE ) || ( type == ENTITY_REFERENCE_NODE ) ) { int nextSib = nodes . readEntry ( nodeHandle , 2 ) ; if ( nextSib == NULL ) return NULL ; if ( nextSib != 0 ) return ( m_docHandle | nextSib ) ; } int thisParent = nodes . readEntry ( nodeHandle , 1 ) ; if ( nodes . readEntry ( ++ nodeHandle , 1 ) == thisParent ) return ( m_docHandle | nodeHandle ) ; return NULL ; }
Given a node handle advance to its next sibling .
26,023
public int getNextAttribute ( int nodeHandle ) { nodeHandle &= NODEHANDLE_MASK ; nodes . readSlot ( nodeHandle , gotslot ) ; short type = ( short ) ( gotslot [ 0 ] & 0xFFFF ) ; if ( type == ELEMENT_NODE ) { return getFirstAttribute ( nodeHandle ) ; } else if ( type == ATTRIBUTE_NODE ) { if ( gotslot [ 2 ] != NULL ) return ( m_docHandle | gotslot [ 2 ] ) ; } return NULL ; }
Given a node handle advance to the next attribute . If an element we advance to its first attribute ; if an attr we advance to the next attr on the same node .
26,024
public int getNextDescendant ( int subtreeRootHandle , int nodeHandle ) { subtreeRootHandle &= NODEHANDLE_MASK ; nodeHandle &= NODEHANDLE_MASK ; if ( nodeHandle == 0 ) return NULL ; while ( ! m_isError ) { if ( done && ( nodeHandle > nodes . slotsUsed ( ) ) ) break ; if ( nodeHandle > subtreeRootHandle ) { nodes . readSlot ( nodeHandle + 1 , gotslot ) ; if ( gotslot [ 2 ] != 0 ) { short type = ( short ) ( gotslot [ 0 ] & 0xFFFF ) ; if ( type == ATTRIBUTE_NODE ) { nodeHandle += 2 ; } else { int nextParentPos = gotslot [ 1 ] ; if ( nextParentPos >= subtreeRootHandle ) return ( m_docHandle | ( nodeHandle + 1 ) ) ; else break ; } } else if ( ! done ) { } else break ; } else { nodeHandle ++ ; } } return NULL ; }
Given a node handle advance to its next descendant . If not yet resolved waits for more nodes to be added to the document and tries again .
26,025
public int getNextPreceding ( int axisContextHandle , int nodeHandle ) { nodeHandle &= NODEHANDLE_MASK ; while ( nodeHandle > 1 ) { nodeHandle -- ; if ( ATTRIBUTE_NODE == ( nodes . readEntry ( nodeHandle , 0 ) & 0xFFFF ) ) continue ; return ( m_docHandle | nodes . specialFind ( axisContextHandle , nodeHandle ) ) ; } return NULL ; }
Given a node handle advance to the next node on the preceding axis .
26,026
public String getLocalNameFromExpandedNameID ( int ExpandedNameID ) { String expandedName = m_localNames . indexToString ( ExpandedNameID ) ; int colonpos = expandedName . indexOf ( ":" ) ; String localName = expandedName . substring ( colonpos + 1 ) ; return localName ; }
Given an expanded - name ID return the local name part .
26,027
public void appendChild ( int newChild , boolean clone , boolean cloneDepth ) { boolean sameDoc = ( ( newChild & DOCHANDLE_MASK ) == m_docHandle ) ; if ( clone || ! sameDoc ) { } else { } }
Append a child to the end of the child list of the current node . Please note that the node is always cloned if it is owned by another document .
26,028
void appendEndElement ( ) { if ( previousSiblingWasParent ) nodes . writeEntry ( previousSibling , 2 , NULL ) ; previousSibling = currentParent ; nodes . readSlot ( currentParent , gotslot ) ; currentParent = gotslot [ 1 ] & 0xFFFF ; previousSiblingWasParent = true ; }
Terminate the element currently acting as an insertion point . Subsequent insertions will occur as the last child of this element s parent .
26,029
private void readDoctype ( boolean saveDtdText ) throws IOException , XmlPullParserException { read ( START_DOCTYPE ) ; int startPosition = - 1 ; if ( saveDtdText ) { bufferCapture = new StringBuilder ( ) ; startPosition = position ; } try { skip ( ) ; rootElementName = readName ( ) ; readExternalId ( true , true ) ; skip ( ) ; if ( peekCharacter ( ) == '[' ) { readInternalSubset ( ) ; } skip ( ) ; } finally { if ( saveDtdText ) { bufferCapture . append ( buffer , 0 , position ) ; bufferCapture . delete ( 0 , startPosition ) ; text = bufferCapture . toString ( ) ; bufferCapture = null ; } } read ( '>' ) ; skip ( ) ; }
Read the document s DTD . Although this parser is non - validating the DTD must be parsed to capture entity values and default attribute values .
26,030
public int nextTag ( ) throws XmlPullParserException , IOException { next ( ) ; if ( type == TEXT && isWhitespace ) { next ( ) ; } if ( type != END_TAG && type != START_TAG ) { throw new XmlPullParserException ( "unexpected type" , this , null ) ; } return type ; }
utility methods to make XML parsing easier ...
26,031
private void popContentSource ( ) { buffer = nextContentSource . buffer ; position = nextContentSource . position ; limit = nextContentSource . limit ; nextContentSource = nextContentSource . next ; }
Replaces the current exhausted buffer with the next buffer in the chain .
26,032
private String getStringForDay ( int day ) { if ( fDates == null ) { loadDates ( ) ; } for ( URelativeString dayItem : fDates ) { if ( dayItem . offset == day ) { return dayItem . string ; } } return null ; }
Get the string at a specific offset .
26,033
private synchronized void loadDates ( ) { ICUResourceBundle rb = ( ICUResourceBundle ) UResourceBundle . getBundleInstance ( ICUData . ICU_BASE_NAME , fLocale ) ; fDates = new ArrayList < URelativeString > ( ) ; RelDateFmtDataSink sink = new RelDateFmtDataSink ( ) ; rb . getAllItemsWithFallback ( "fields/day/relative" , sink ) ; }
Load the Date string array
26,034
private void initCapitalizationContextInfo ( ULocale locale ) { ICUResourceBundle rb = ( ICUResourceBundle ) UResourceBundle . getBundleInstance ( ICUData . ICU_BASE_NAME , locale ) ; try { ICUResourceBundle rdb = rb . getWithFallback ( "contextTransforms/relative" ) ; int [ ] intVector = rdb . getIntVector ( ) ; if ( intVector . length >= 2 ) { capitalizationOfRelativeUnitsForListOrMenu = ( intVector [ 0 ] != 0 ) ; capitalizationOfRelativeUnitsForStandAlone = ( intVector [ 1 ] != 0 ) ; } } catch ( MissingResourceException e ) { } }
Set capitalizationOfRelativeUnitsForListOrMenu capitalizationOfRelativeUnitsForStandAlone
26,035
private Calendar initializeCalendar ( TimeZone zone , ULocale locale ) { if ( calendar == null ) { if ( zone == null ) { calendar = Calendar . getInstance ( locale ) ; } else { calendar = Calendar . getInstance ( zone , locale ) ; } } return calendar ; }
initializes fCalendar from parameters . Returns fCalendar as a convenience .
26,036
public TimeZoneFormat setTimeZoneNames ( TimeZoneNames tznames ) { if ( isFrozen ( ) ) { throw new UnsupportedOperationException ( "Attempt to modify frozen object" ) ; } _tznames = tznames ; _gnames = new TimeZoneGenericNames ( _locale , _tznames ) ; return this ; }
Sets the time zone display name data to this instance .
26,037
public TimeZoneFormat setGMTOffsetPattern ( GMTOffsetPatternType type , String pattern ) { if ( isFrozen ( ) ) { throw new UnsupportedOperationException ( "Attempt to modify frozen object" ) ; } if ( pattern == null ) { throw new NullPointerException ( "Null GMT offset pattern" ) ; } Object [ ] parsedItems = parseOffsetPattern ( pattern , type . required ( ) ) ; _gmtOffsetPatterns [ type . ordinal ( ) ] = pattern ; _gmtOffsetPatternItems [ type . ordinal ( ) ] = parsedItems ; checkAbuttingHoursAndMinutes ( ) ; return this ; }
Sets the offset pattern for the given offset type .
26,038
public String getGMTOffsetDigits ( ) { StringBuilder buf = new StringBuilder ( _gmtOffsetDigits . length ) ; for ( String digit : _gmtOffsetDigits ) { buf . append ( digit ) ; } return buf . toString ( ) ; }
Returns the decimal digit characters used for localized GMT format in a single string containing from 0 to 9 in the ascending order .
26,039
public TimeZoneFormat setGMTOffsetDigits ( String digits ) { if ( isFrozen ( ) ) { throw new UnsupportedOperationException ( "Attempt to modify frozen object" ) ; } if ( digits == null ) { throw new NullPointerException ( "Null GMT offset digits" ) ; } String [ ] digitArray = toCodePoints ( digits ) ; if ( digitArray . length != 10 ) { throw new IllegalArgumentException ( "Length of digits must be 10" ) ; } _gmtOffsetDigits = digitArray ; return this ; }
Sets the decimal digit characters used for localized GMT format .
26,040
public final String formatOffsetISO8601Basic ( int offset , boolean useUtcIndicator , boolean isShort , boolean ignoreSeconds ) { return formatOffsetISO8601 ( offset , true , useUtcIndicator , isShort , ignoreSeconds ) ; }
Returns the ISO 8601 basic time zone string for the given offset . For example - 08 - 0830 and Z
26,041
public final String format ( Style style , TimeZone tz , long date ) { return format ( style , tz , date , null ) ; }
Returns the display name of the time zone at the given date for the style .
26,042
private String formatOffsetLocalizedGMT ( int offset , boolean isShort ) { if ( offset == 0 ) { return _gmtZeroFormat ; } StringBuilder buf = new StringBuilder ( ) ; boolean positive = true ; if ( offset < 0 ) { offset = - offset ; positive = false ; } int offsetH = offset / MILLIS_PER_HOUR ; offset = offset % MILLIS_PER_HOUR ; int offsetM = offset / MILLIS_PER_MINUTE ; offset = offset % MILLIS_PER_MINUTE ; int offsetS = offset / MILLIS_PER_SECOND ; if ( offsetH > MAX_OFFSET_HOUR || offsetM > MAX_OFFSET_MINUTE || offsetS > MAX_OFFSET_SECOND ) { throw new IllegalArgumentException ( "Offset out of range :" + offset ) ; } Object [ ] offsetPatternItems ; if ( positive ) { if ( offsetS != 0 ) { offsetPatternItems = _gmtOffsetPatternItems [ GMTOffsetPatternType . POSITIVE_HMS . ordinal ( ) ] ; } else if ( offsetM != 0 || ! isShort ) { offsetPatternItems = _gmtOffsetPatternItems [ GMTOffsetPatternType . POSITIVE_HM . ordinal ( ) ] ; } else { offsetPatternItems = _gmtOffsetPatternItems [ GMTOffsetPatternType . POSITIVE_H . ordinal ( ) ] ; } } else { if ( offsetS != 0 ) { offsetPatternItems = _gmtOffsetPatternItems [ GMTOffsetPatternType . NEGATIVE_HMS . ordinal ( ) ] ; } else if ( offsetM != 0 || ! isShort ) { offsetPatternItems = _gmtOffsetPatternItems [ GMTOffsetPatternType . NEGATIVE_HM . ordinal ( ) ] ; } else { offsetPatternItems = _gmtOffsetPatternItems [ GMTOffsetPatternType . NEGATIVE_H . ordinal ( ) ] ; } } buf . append ( _gmtPatternPrefix ) ; for ( Object item : offsetPatternItems ) { if ( item instanceof String ) { buf . append ( ( String ) item ) ; } else if ( item instanceof GMTOffsetField ) { GMTOffsetField field = ( GMTOffsetField ) item ; switch ( field . getType ( ) ) { case 'H' : appendOffsetDigits ( buf , offsetH , ( isShort ? 1 : 2 ) ) ; break ; case 'm' : appendOffsetDigits ( buf , offsetM , 2 ) ; break ; case 's' : appendOffsetDigits ( buf , offsetS , 2 ) ; break ; } } } buf . append ( _gmtPatternSuffix ) ; return buf . toString ( ) ; }
Private method used for localized GMT formatting .
26,043
private String formatSpecific ( TimeZone tz , NameType stdType , NameType dstType , long date , Output < TimeType > timeType ) { assert ( stdType == NameType . LONG_STANDARD || stdType == NameType . SHORT_STANDARD ) ; assert ( dstType == NameType . LONG_DAYLIGHT || dstType == NameType . SHORT_DAYLIGHT ) ; boolean isDaylight = tz . inDaylightTime ( new Date ( date ) ) ; String name = isDaylight ? getTimeZoneNames ( ) . getDisplayName ( ZoneMeta . getCanonicalCLDRID ( tz ) , dstType , date ) : getTimeZoneNames ( ) . getDisplayName ( ZoneMeta . getCanonicalCLDRID ( tz ) , stdType , date ) ; if ( name != null && timeType != null ) { timeType . value = isDaylight ? TimeType . DAYLIGHT : TimeType . STANDARD ; } return name ; }
Private method returning the time zone s specific format string .
26,044
private String formatExemplarLocation ( TimeZone tz ) { String location = getTimeZoneNames ( ) . getExemplarLocationName ( ZoneMeta . getCanonicalCLDRID ( tz ) ) ; if ( location == null ) { location = getTimeZoneNames ( ) . getExemplarLocationName ( UNKNOWN_ZONE_ID ) ; if ( location == null ) { location = UNKNOWN_LOCATION ; } } return location ; }
Private method returning the time zone s exemplar location string . This method will never return null .
26,045
private String getTimeZoneID ( String tzID , String mzID ) { String id = tzID ; if ( id == null ) { assert ( mzID != null ) ; id = _tznames . getReferenceZoneID ( mzID , getTargetRegion ( ) ) ; if ( id == null ) { throw new IllegalArgumentException ( "Invalid mzID: " + mzID ) ; } } return id ; }
Private method returns a time zone ID . If tzID is not null the value of tzID is returned . If tzID is null then this method look up a time zone ID for the current region . This is a small helper method used by the parse implementation method
26,046
private synchronized String getTargetRegion ( ) { if ( _region == null ) { _region = _locale . getCountry ( ) ; if ( _region . length ( ) == 0 ) { ULocale tmp = ULocale . addLikelySubtags ( _locale ) ; _region = tmp . getCountry ( ) ; if ( _region . length ( ) == 0 ) { _region = "001" ; } } } return _region ; }
Private method returning the target region . The target regions is determined by the locale of this instance . When a generic name is coming from a meta zone this region is used for checking if the time zone is a reference zone of the meta zone .
26,047
private TimeType getTimeType ( NameType nameType ) { switch ( nameType ) { case LONG_STANDARD : case SHORT_STANDARD : return TimeType . STANDARD ; case LONG_DAYLIGHT : case SHORT_DAYLIGHT : return TimeType . DAYLIGHT ; default : return TimeType . UNKNOWN ; } }
Returns the time type for the given name type
26,048
private static String unquote ( String s ) { if ( s . indexOf ( '\'' ) < 0 ) { return s ; } boolean isPrevQuote = false ; boolean inQuote = false ; StringBuilder buf = new StringBuilder ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( c == '\'' ) { if ( isPrevQuote ) { buf . append ( c ) ; isPrevQuote = false ; } else { isPrevQuote = true ; } inQuote = ! inQuote ; } else { isPrevQuote = false ; buf . append ( c ) ; } } return buf . toString ( ) ; }
Unquotes the message format style pattern .
26,049
private TimeZone getTimeZoneForOffset ( int offset ) { if ( offset == 0 ) { return TimeZone . getTimeZone ( TZID_GMT ) ; } return ZoneMeta . getCustomTimeZone ( offset ) ; }
Creates an instance of TimeZone for the given offset
26,050
private int parseOffsetLocalizedGMTPattern ( String text , int start , boolean isShort , int [ ] parsedLen ) { int idx = start ; int offset = 0 ; boolean parsed = false ; do { int len = _gmtPatternPrefix . length ( ) ; if ( len > 0 && ! text . regionMatches ( true , idx , _gmtPatternPrefix , 0 , len ) ) { break ; } idx += len ; int [ ] offsetLen = new int [ 1 ] ; offset = parseOffsetFields ( text , idx , false , offsetLen ) ; if ( offsetLen [ 0 ] == 0 ) { break ; } idx += offsetLen [ 0 ] ; len = _gmtPatternSuffix . length ( ) ; if ( len > 0 && ! text . regionMatches ( true , idx , _gmtPatternSuffix , 0 , len ) ) { break ; } idx += len ; parsed = true ; } while ( false ) ; parsedLen [ 0 ] = parsed ? idx - start : 0 ; return offset ; }
Parse localized GMT format generated by the pattern used by this formatter except GMT Zero format .
26,051
private int parseOffsetFields ( String text , int start , boolean isShort , int [ ] parsedLen ) { int outLen = 0 ; int offset = 0 ; int sign = 1 ; if ( parsedLen != null && parsedLen . length >= 1 ) { parsedLen [ 0 ] = 0 ; } int offsetH , offsetM , offsetS ; offsetH = offsetM = offsetS = 0 ; int [ ] fields = { 0 , 0 , 0 } ; for ( GMTOffsetPatternType gmtPatType : PARSE_GMT_OFFSET_TYPES ) { Object [ ] items = _gmtOffsetPatternItems [ gmtPatType . ordinal ( ) ] ; assert items != null ; outLen = parseOffsetFieldsWithPattern ( text , start , items , false , fields ) ; if ( outLen > 0 ) { sign = gmtPatType . isPositive ( ) ? 1 : - 1 ; offsetH = fields [ 0 ] ; offsetM = fields [ 1 ] ; offsetS = fields [ 2 ] ; break ; } } if ( outLen > 0 && _abuttingOffsetHoursAndMinutes ) { int tmpLen = 0 ; int tmpSign = 1 ; for ( GMTOffsetPatternType gmtPatType : PARSE_GMT_OFFSET_TYPES ) { Object [ ] items = _gmtOffsetPatternItems [ gmtPatType . ordinal ( ) ] ; assert items != null ; tmpLen = parseOffsetFieldsWithPattern ( text , start , items , true , fields ) ; if ( tmpLen > 0 ) { tmpSign = gmtPatType . isPositive ( ) ? 1 : - 1 ; break ; } } if ( tmpLen > outLen ) { outLen = tmpLen ; sign = tmpSign ; offsetH = fields [ 0 ] ; offsetM = fields [ 1 ] ; offsetS = fields [ 2 ] ; } } if ( parsedLen != null && parsedLen . length >= 1 ) { parsedLen [ 0 ] = outLen ; } if ( outLen > 0 ) { offset = ( ( ( ( offsetH * 60 ) + offsetM ) * 60 ) + offsetS ) * 1000 * sign ; } return offset ; }
Parses localized GMT offset fields into offset .
26,052
private int parseOffsetFieldsWithPattern ( String text , int start , Object [ ] patternItems , boolean forceSingleHourDigit , int fields [ ] ) { assert ( fields != null && fields . length >= 3 ) ; fields [ 0 ] = fields [ 1 ] = fields [ 2 ] = 0 ; boolean failed = false ; int offsetH , offsetM , offsetS ; offsetH = offsetM = offsetS = 0 ; int idx = start ; int [ ] tmpParsedLen = { 0 } ; for ( int i = 0 ; i < patternItems . length ; i ++ ) { if ( patternItems [ i ] instanceof String ) { String patStr = ( String ) patternItems [ i ] ; int len = patStr . length ( ) ; if ( ! text . regionMatches ( true , idx , patStr , 0 , len ) ) { failed = true ; break ; } idx += len ; } else { assert ( patternItems [ i ] instanceof GMTOffsetField ) ; GMTOffsetField field = ( GMTOffsetField ) patternItems [ i ] ; char fieldType = field . getType ( ) ; if ( fieldType == 'H' ) { int maxDigits = forceSingleHourDigit ? 1 : 2 ; offsetH = parseOffsetFieldWithLocalizedDigits ( text , idx , 1 , maxDigits , 0 , MAX_OFFSET_HOUR , tmpParsedLen ) ; } else if ( fieldType == 'm' ) { offsetM = parseOffsetFieldWithLocalizedDigits ( text , idx , 2 , 2 , 0 , MAX_OFFSET_MINUTE , tmpParsedLen ) ; } else if ( fieldType == 's' ) { offsetS = parseOffsetFieldWithLocalizedDigits ( text , idx , 2 , 2 , 0 , MAX_OFFSET_SECOND , tmpParsedLen ) ; } if ( tmpParsedLen [ 0 ] == 0 ) { failed = true ; break ; } idx += tmpParsedLen [ 0 ] ; } } if ( failed ) { return 0 ; } fields [ 0 ] = offsetH ; fields [ 1 ] = offsetM ; fields [ 2 ] = offsetS ; return idx - start ; }
Parses localized GMT offset fields with the given pattern
26,053
private int parseDefaultOffsetFields ( String text , int start , char separator , int [ ] parsedLen ) { int max = text . length ( ) ; int idx = start ; int [ ] len = { 0 } ; int hour = 0 , min = 0 , sec = 0 ; do { hour = parseOffsetFieldWithLocalizedDigits ( text , idx , 1 , 2 , 0 , MAX_OFFSET_HOUR , len ) ; if ( len [ 0 ] == 0 ) { break ; } idx += len [ 0 ] ; if ( idx + 1 < max && text . charAt ( idx ) == separator ) { min = parseOffsetFieldWithLocalizedDigits ( text , idx + 1 , 2 , 2 , 0 , MAX_OFFSET_MINUTE , len ) ; if ( len [ 0 ] == 0 ) { break ; } idx += ( 1 + len [ 0 ] ) ; if ( idx + 1 < max && text . charAt ( idx ) == separator ) { sec = parseOffsetFieldWithLocalizedDigits ( text , idx + 1 , 2 , 2 , 0 , MAX_OFFSET_SECOND , len ) ; if ( len [ 0 ] == 0 ) { break ; } idx += ( 1 + len [ 0 ] ) ; } } } while ( false ) ; if ( idx == start ) { parsedLen [ 0 ] = 0 ; return 0 ; } parsedLen [ 0 ] = idx - start ; return hour * MILLIS_PER_HOUR + min * MILLIS_PER_MINUTE + sec * MILLIS_PER_SECOND ; }
Parses the input GMT offset fields with the default offset pattern .
26,054
private int parseSingleLocalizedDigit ( String text , int start , int [ ] len ) { int digit = - 1 ; len [ 0 ] = 0 ; if ( start < text . length ( ) ) { int cp = Character . codePointAt ( text , start ) ; for ( int i = 0 ; i < _gmtOffsetDigits . length ; i ++ ) { if ( cp == _gmtOffsetDigits [ i ] . codePointAt ( 0 ) ) { digit = i ; break ; } } if ( digit < 0 ) { digit = UCharacter . digit ( cp ) ; } if ( digit >= 0 ) { len [ 0 ] = Character . charCount ( cp ) ; } } return digit ; }
Reads a single decimal digit either localized digits used by this object or any Unicode numeric character .
26,055
private static String parseZoneID ( String text , ParsePosition pos ) { String resolvedID = null ; if ( ZONE_ID_TRIE == null ) { synchronized ( TimeZoneFormat . class ) { if ( ZONE_ID_TRIE == null ) { TextTrieMap < String > trie = new TextTrieMap < String > ( true ) ; String [ ] ids = TimeZone . getAvailableIDs ( ) ; for ( String id : ids ) { trie . put ( id , id ) ; } ZONE_ID_TRIE = trie ; } } } int [ ] matchLen = new int [ ] { 0 } ; Iterator < String > itr = ZONE_ID_TRIE . get ( text , pos . getIndex ( ) , matchLen ) ; if ( itr != null ) { resolvedID = itr . next ( ) ; pos . setIndex ( pos . getIndex ( ) + matchLen [ 0 ] ) ; } else { pos . setErrorIndex ( pos . getIndex ( ) ) ; } return resolvedID ; }
Parse a zone ID .
26,056
private static String parseShortZoneID ( String text , ParsePosition pos ) { String resolvedID = null ; if ( SHORT_ZONE_ID_TRIE == null ) { synchronized ( TimeZoneFormat . class ) { if ( SHORT_ZONE_ID_TRIE == null ) { TextTrieMap < String > trie = new TextTrieMap < String > ( true ) ; Set < String > canonicalIDs = TimeZone . getAvailableIDs ( SystemTimeZoneType . CANONICAL , null , null ) ; for ( String id : canonicalIDs ) { String shortID = ZoneMeta . getShortID ( id ) ; if ( shortID != null ) { trie . put ( shortID , id ) ; } } trie . put ( UNKNOWN_SHORT_ZONE_ID , UNKNOWN_ZONE_ID ) ; SHORT_ZONE_ID_TRIE = trie ; } } } int [ ] matchLen = new int [ ] { 0 } ; Iterator < String > itr = SHORT_ZONE_ID_TRIE . get ( text , pos . getIndex ( ) , matchLen ) ; if ( itr != null ) { resolvedID = itr . next ( ) ; pos . setIndex ( pos . getIndex ( ) + matchLen [ 0 ] ) ; } else { pos . setErrorIndex ( pos . getIndex ( ) ) ; } return resolvedID ; }
Parse a short zone ID .
26,057
private String parseExemplarLocation ( String text , ParsePosition pos ) { int startIdx = pos . getIndex ( ) ; int parsedPos = - 1 ; String tzID = null ; EnumSet < NameType > nameTypes = EnumSet . of ( NameType . EXEMPLAR_LOCATION ) ; Collection < MatchInfo > exemplarMatches = _tznames . find ( text , startIdx , nameTypes ) ; if ( exemplarMatches != null ) { MatchInfo exemplarMatch = null ; for ( MatchInfo match : exemplarMatches ) { if ( startIdx + match . matchLength ( ) > parsedPos ) { exemplarMatch = match ; parsedPos = startIdx + match . matchLength ( ) ; } } if ( exemplarMatch != null ) { tzID = getTimeZoneID ( exemplarMatch . tzID ( ) , exemplarMatch . mzID ( ) ) ; pos . setIndex ( parsedPos ) ; } } if ( tzID == null ) { pos . setErrorIndex ( startIdx ) ; } return tzID ; }
Parse an exemplar location string .
26,058
private List < String > initLabels ( ) { Normalizer2 nfkdNormalizer = Normalizer2 . getNFKDInstance ( ) ; List < String > indexCharacters = new ArrayList < String > ( ) ; String firstScriptBoundary = firstCharsInScripts . get ( 0 ) ; String overflowBoundary = firstCharsInScripts . get ( firstCharsInScripts . size ( ) - 1 ) ; for ( String item : initialLabels ) { boolean checkDistinct ; if ( ! UTF16 . hasMoreCodePointsThan ( item , 1 ) ) { checkDistinct = false ; } else if ( item . charAt ( item . length ( ) - 1 ) == '*' && item . charAt ( item . length ( ) - 2 ) != '*' ) { item = item . substring ( 0 , item . length ( ) - 1 ) ; checkDistinct = false ; } else { checkDistinct = true ; } if ( collatorPrimaryOnly . compare ( item , firstScriptBoundary ) < 0 ) { } else if ( collatorPrimaryOnly . compare ( item , overflowBoundary ) >= 0 ) { } else if ( checkDistinct && collatorPrimaryOnly . compare ( item , separated ( item ) ) == 0 ) { } else { int insertionPoint = Collections . binarySearch ( indexCharacters , item , collatorPrimaryOnly ) ; if ( insertionPoint < 0 ) { indexCharacters . add ( ~ insertionPoint , item ) ; } else { String itemAlreadyIn = indexCharacters . get ( insertionPoint ) ; if ( isOneLabelBetterThanOther ( nfkdNormalizer , item , itemAlreadyIn ) ) { indexCharacters . set ( insertionPoint , item ) ; } } } } final int size = indexCharacters . size ( ) - 1 ; if ( size > maxLabelCount ) { int count = 0 ; int old = - 1 ; for ( Iterator < String > it = indexCharacters . iterator ( ) ; it . hasNext ( ) ; ) { ++ count ; it . next ( ) ; final int bump = count * maxLabelCount / size ; if ( bump == old ) { it . remove ( ) ; } else { old = bump ; } } } return indexCharacters ; }
Determine the best labels to use . This is based on the exemplars but we also process to make sure that they are unique and sort differently and that the overall list is small enough .
26,059
private void addIndexExemplars ( ULocale locale ) { UnicodeSet exemplars = LocaleData . getExemplarSet ( locale , 0 , LocaleData . ES_INDEX ) ; if ( exemplars != null ) { initialLabels . addAll ( exemplars ) ; return ; } exemplars = LocaleData . getExemplarSet ( locale , 0 , LocaleData . ES_STANDARD ) ; exemplars = exemplars . cloneAsThawed ( ) ; if ( exemplars . containsSome ( 'a' , 'z' ) || exemplars . size ( ) == 0 ) { exemplars . addAll ( 'a' , 'z' ) ; } if ( exemplars . containsSome ( 0xAC00 , 0xD7A3 ) ) { exemplars . remove ( 0xAC00 , 0xD7A3 ) . add ( 0xAC00 ) . add ( 0xB098 ) . add ( 0xB2E4 ) . add ( 0xB77C ) . add ( 0xB9C8 ) . add ( 0xBC14 ) . add ( 0xC0AC ) . add ( 0xC544 ) . add ( 0xC790 ) . add ( 0xCC28 ) . add ( 0xCE74 ) . add ( 0xD0C0 ) . add ( 0xD30C ) . add ( 0xD558 ) ; } if ( exemplars . containsSome ( 0x1200 , 0x137F ) ) { UnicodeSet ethiopic = new UnicodeSet ( "[[:Block=Ethiopic:]&[:Script=Ethiopic:]]" ) ; UnicodeSetIterator it = new UnicodeSetIterator ( ethiopic ) ; while ( it . next ( ) && it . codepoint != UnicodeSetIterator . IS_STRING ) { if ( ( it . codepoint & 0x7 ) != 0 ) { exemplars . remove ( it . codepoint ) ; } } } for ( String item : exemplars ) { initialLabels . add ( UCharacter . toUpperCase ( locale , item ) ) ; } }
This method is called to get the index exemplars . Normally these come from the locale directly but if they aren t available we have to synthesize them .
26,060
private boolean addChineseIndexCharacters ( ) { UnicodeSet contractions = new UnicodeSet ( ) ; try { collatorPrimaryOnly . internalAddContractions ( BASE . charAt ( 0 ) , contractions ) ; } catch ( Exception e ) { return false ; } if ( contractions . isEmpty ( ) ) { return false ; } initialLabels . addAll ( contractions ) ; for ( String s : contractions ) { assert ( s . startsWith ( BASE ) ) ; char c = s . charAt ( s . length ( ) - 1 ) ; if ( 0x41 <= c && c <= 0x5A ) { initialLabels . add ( 0x41 , 0x5A ) ; break ; } } return true ; }
Add Chinese index characters from the tailoring .
26,061
public ImmutableIndex < V > buildImmutableIndex ( ) { BucketList < V > immutableBucketList ; if ( inputList != null && ! inputList . isEmpty ( ) ) { immutableBucketList = createBucketList ( ) ; } else { if ( buckets == null ) { buckets = createBucketList ( ) ; } immutableBucketList = buckets ; } return new ImmutableIndex < V > ( immutableBucketList , collatorPrimaryOnly ) ; }
Builds an immutable thread - safe version of this instance without data records .
26,062
public List < String > getBucketLabels ( ) { initBuckets ( ) ; ArrayList < String > result = new ArrayList < String > ( ) ; for ( Bucket < V > bucket : buckets ) { result . add ( bucket . getLabel ( ) ) ; } return result ; }
Get the labels .
26,063
public AlphabeticIndex < V > clearRecords ( ) { if ( inputList != null && ! inputList . isEmpty ( ) ) { inputList . clear ( ) ; buckets = null ; } return this ; }
Clear the index .
26,064
private void initBuckets ( ) { if ( buckets != null ) { return ; } buckets = createBucketList ( ) ; if ( inputList == null || inputList . isEmpty ( ) ) { return ; } Collections . sort ( inputList , recordComparator ) ; Iterator < Bucket < V > > bucketIterator = buckets . fullIterator ( ) ; Bucket < V > currentBucket = bucketIterator . next ( ) ; Bucket < V > nextBucket ; String upperBoundary ; if ( bucketIterator . hasNext ( ) ) { nextBucket = bucketIterator . next ( ) ; upperBoundary = nextBucket . lowerBoundary ; } else { nextBucket = null ; upperBoundary = null ; } for ( Record < V > r : inputList ) { while ( upperBoundary != null && collatorPrimaryOnly . compare ( r . name , upperBoundary ) >= 0 ) { currentBucket = nextBucket ; if ( bucketIterator . hasNext ( ) ) { nextBucket = bucketIterator . next ( ) ; upperBoundary = nextBucket . lowerBoundary ; } else { upperBoundary = null ; } } Bucket < V > bucket = currentBucket ; if ( bucket . displayBucket != null ) { bucket = bucket . displayBucket ; } if ( bucket . records == null ) { bucket . records = new ArrayList < Record < V > > ( ) ; } bucket . records . add ( r ) ; } }
Creates an index and buckets and sorts the list of records into the index .
26,065
private static boolean isOneLabelBetterThanOther ( Normalizer2 nfkdNormalizer , String one , String other ) { String n1 = nfkdNormalizer . normalize ( one ) ; String n2 = nfkdNormalizer . normalize ( other ) ; int result = n1 . codePointCount ( 0 , n1 . length ( ) ) - n2 . codePointCount ( 0 , n2 . length ( ) ) ; if ( result != 0 ) { return result < 0 ; } result = binaryCmp . compare ( n1 , n2 ) ; if ( result != 0 ) { return result < 0 ; } return binaryCmp . compare ( one , other ) < 0 ; }
Returns true if one index character string is better than the other . Shorter NFKD is better and otherwise NFKD - binary - less - than is better and otherwise binary - less - than is better .
26,066
public List < String > getFirstCharactersInScripts ( ) { List < String > dest = new ArrayList < String > ( 200 ) ; UnicodeSet set = new UnicodeSet ( ) ; collatorPrimaryOnly . internalAddContractions ( 0xFDD1 , set ) ; if ( set . isEmpty ( ) ) { throw new UnsupportedOperationException ( "AlphabeticIndex requires script-first-primary contractions" ) ; } for ( String boundary : set ) { int gcMask = 1 << UCharacter . getType ( boundary . codePointAt ( 1 ) ) ; if ( ( gcMask & ( GC_L_MASK | GC_CN_MASK ) ) == 0 ) { continue ; } dest . add ( boundary ) ; } return dest ; }
Return a list of the first character in each script . Only exposed for testing .
26,067
synchronized void establishConnection ( ) throws IOException { if ( isConnected ) { throw new IOException ( "Pipe already connected" ) ; } if ( buffer == null ) { buffer = new byte [ PipedInputStream . PIPE_SIZE ] ; } isConnected = true ; }
Establishes the connection to the PipedOutputStream .
26,068
static Object encodeRelay ( Object r ) { Throwable x ; return ( ( ( r instanceof AltResult ) && ( x = ( ( AltResult ) r ) . ex ) != null && ! ( x instanceof CompletionException ) ) ? new AltResult ( new CompletionException ( x ) ) : r ) ; }
Returns the encoding of a copied outcome ; if exceptional rewraps as a CompletionException else returns argument .
26,069
final void postComplete ( ) { CompletableFuture < ? > f = this ; Completion h ; while ( ( h = f . stack ) != null || ( f != this && ( h = ( f = this ) . stack ) != null ) ) { CompletableFuture < ? > d ; Completion t ; if ( f . casStack ( h , t = h . next ) ) { if ( t != null ) { if ( f != this ) { pushStack ( h ) ; continue ; } h . next = null ; } f = ( d = h . tryFire ( NESTED ) ) == null ? this : d ; } } }
Pops and tries to trigger all reachable dependents . Call only when known to be done .
26,070
final void cleanStack ( ) { for ( Completion p = null , q = stack ; q != null ; ) { Completion s = q . next ; if ( q . isLive ( ) ) { p = q ; q = s ; } else if ( p == null ) { casStack ( q , s ) ; q = stack ; } else { p . next = s ; if ( p . isLive ( ) ) q = s ; else { p = null ; q = stack ; } } } }
Traverses stack and unlinks dead Completions .
26,071
final CompletableFuture < T > postFire ( CompletableFuture < ? > a , int mode ) { if ( a != null && a . stack != null ) { if ( mode < 0 || a . result == null ) a . cleanStack ( ) ; else a . postComplete ( ) ; } if ( result != null && stack != null ) { if ( mode < 0 ) return this ; else postComplete ( ) ; } return null ; }
Post - processing by dependent after successful UniCompletion tryFire . Tries to clean stack of source a and then either runs postComplete or returns this to caller depending on mode .
26,072
final void bipush ( CompletableFuture < ? > b , BiCompletion < ? , ? , ? > c ) { if ( c != null ) { Object r ; while ( ( r = result ) == null && ! tryPushStack ( c ) ) lazySetNext ( c , null ) ; if ( b != null && b != this && b . result == null ) { Completion q = ( r != null ) ? c : new CoCompletion ( c ) ; while ( b . result == null && ! b . tryPushStack ( q ) ) lazySetNext ( q , null ) ; } } }
Pushes completion to this and b unless both done .
26,073
final void orpush ( CompletableFuture < ? > b , BiCompletion < ? , ? , ? > c ) { if ( c != null ) { while ( ( b == null || b . result == null ) && result == null ) { if ( tryPushStack ( c ) ) { if ( b != null && b != this && b . result == null ) { Completion q = new CoCompletion ( c ) ; while ( result == null && b . result == null && ! b . tryPushStack ( q ) ) lazySetNext ( q , null ) ; } break ; } lazySetNext ( c , null ) ; } } }
Pushes completion to this and b unless either done .
26,074
private Object timedGet ( long nanos ) throws TimeoutException { if ( Thread . interrupted ( ) ) return null ; if ( nanos > 0L ) { long d = System . nanoTime ( ) + nanos ; long deadline = ( d == 0L ) ? 1L : d ; Signaller q = null ; boolean queued = false ; Object r ; while ( ( r = result ) == null ) { if ( q == null ) q = new Signaller ( true , nanos , deadline ) ; else if ( ! queued ) queued = tryPushStack ( q ) ; else if ( q . nanos <= 0L ) break ; else { try { ForkJoinPool . managedBlock ( q ) ; } catch ( InterruptedException ie ) { q . interrupted = true ; } if ( q . interrupted ) break ; } } if ( q != null ) q . thread = null ; if ( r != null ) postComplete ( ) ; else cleanStack ( ) ; if ( r != null || ( q != null && q . interrupted ) ) return r ; } throw new TimeoutException ( ) ; }
Returns raw result after waiting or null if interrupted or throws TimeoutException on timeout .
26,075
public T get ( ) throws InterruptedException , ExecutionException { Object r ; return reportGet ( ( r = result ) == null ? waitingGet ( true ) : r ) ; }
Waits if necessary for this future to complete and then returns its result .
26,076
protected void reportError ( String msg , Exception ex , int code ) { try { errorManager . error ( msg , ex , code ) ; } catch ( Exception ex2 ) { System . err . println ( "Handler.reportError caught:" ) ; ex2 . printStackTrace ( ) ; } }
Protected convenience method to report an error to this Handler s ErrorManager . Note that this method retrieves and uses the ErrorManager without doing a security check . It can therefore be used in environments where the caller may be non - privileged .
26,077
public void compute ( ) { Spliterator < P_IN > rs = spliterator , ls ; long sizeEstimate = rs . estimateSize ( ) ; long sizeThreshold = getTargetSize ( sizeEstimate ) ; boolean forkRight = false ; @ SuppressWarnings ( "unchecked" ) K task = ( K ) this ; AtomicReference < R > sr = sharedResult ; R result ; while ( ( result = sr . get ( ) ) == null ) { if ( task . taskCanceled ( ) ) { result = task . getEmptyResult ( ) ; break ; } if ( sizeEstimate <= sizeThreshold || ( ls = rs . trySplit ( ) ) == null ) { result = task . doLeaf ( ) ; break ; } K leftChild , rightChild , taskToFork ; task . leftChild = leftChild = task . makeChild ( ls ) ; task . rightChild = rightChild = task . makeChild ( rs ) ; task . setPendingCount ( 1 ) ; if ( forkRight ) { forkRight = false ; rs = ls ; task = leftChild ; taskToFork = rightChild ; } else { forkRight = true ; task = rightChild ; taskToFork = leftChild ; } taskToFork . fork ( ) ; sizeEstimate = rs . estimateSize ( ) ; } task . setLocalResult ( result ) ; task . tryComplete ( ) ; }
Overrides AbstractTask version to include checks for early exits while splitting or computing .
26,078
public R getLocalResult ( ) { if ( isRoot ( ) ) { R answer = sharedResult . get ( ) ; return ( answer == null ) ? getEmptyResult ( ) : answer ; } else return super . getLocalResult ( ) ; }
Retrieves the local result for this task . If this task is the root retrieves the shared result instead .
26,079
protected boolean taskCanceled ( ) { boolean cancel = canceled ; if ( ! cancel ) { for ( K parent = getParent ( ) ; ! cancel && parent != null ; parent = parent . getParent ( ) ) cancel = parent . canceled ; } return cancel ; }
Queries whether this task is canceled . A task is considered canceled if it or any of its parents have been canceled .
26,080
protected void cancelLaterNodes ( ) { for ( @ SuppressWarnings ( "unchecked" ) K parent = getParent ( ) , node = ( K ) this ; parent != null ; node = parent , parent = parent . getParent ( ) ) { if ( parent . leftChild == node ) { K rightSibling = parent . rightChild ; if ( ! rightSibling . canceled ) rightSibling . cancel ( ) ; } } }
Cancels all tasks which succeed this one in the encounter order . This includes canceling all the current task s right sibling as well as the later right siblings of all its parents .
26,081
private Map < ExecutableElement , VariableElement > createMemberFields ( AnnotationTypeDeclaration node , List < AnnotationTypeMemberDeclaration > members ) { TypeElement type = node . getTypeElement ( ) ; Map < ExecutableElement , VariableElement > fieldElements = new HashMap < > ( ) ; for ( AnnotationTypeMemberDeclaration member : members ) { ExecutableElement memberElement = member . getExecutableElement ( ) ; String propName = NameTable . getAnnotationPropertyName ( memberElement ) ; VariableElement field = GeneratedVariableElement . newField ( propName , memberElement . getReturnType ( ) , type ) ; node . addBodyDeclaration ( new FieldDeclaration ( field , null ) ) ; fieldElements . put ( memberElement , field ) ; } return fieldElements ; }
Create an instance field for each member .
26,082
private void addMemberProperties ( AnnotationTypeDeclaration node , List < AnnotationTypeMemberDeclaration > members , Map < ExecutableElement , VariableElement > fieldElements ) { if ( members . isEmpty ( ) ) { return ; } StringBuilder propertyDecls = new StringBuilder ( ) ; StringBuilder propertyImpls = new StringBuilder ( ) ; for ( AnnotationTypeMemberDeclaration member : members ) { ExecutableElement memberElement = member . getExecutableElement ( ) ; String propName = NameTable . getAnnotationPropertyName ( memberElement ) ; String memberTypeStr = nameTable . getObjCType ( memberElement . getReturnType ( ) ) ; String fieldName = nameTable . getVariableShortName ( fieldElements . get ( memberElement ) ) ; propertyDecls . append ( UnicodeUtils . format ( "@property (readonly) %s%s%s;\n" , memberTypeStr , memberTypeStr . endsWith ( "*" ) ? "" : " " , propName ) ) ; if ( NameTable . needsObjcMethodFamilyNoneAttribute ( propName ) ) { propertyDecls . append ( UnicodeUtils . format ( "- (%s)%s OBJC_METHOD_FAMILY_NONE;\n" , memberTypeStr , propName ) ) ; } propertyImpls . append ( UnicodeUtils . format ( "@synthesize %s = %s;\n" , propName , fieldName ) ) ; } node . addBodyDeclaration ( NativeDeclaration . newInnerDeclaration ( propertyDecls . toString ( ) , propertyImpls . toString ( ) ) ) ; }
Generate the property declarations and synthesize statements .
26,083
private void addDefaultAccessors ( AnnotationTypeDeclaration node , List < AnnotationTypeMemberDeclaration > members ) { TypeElement type = node . getTypeElement ( ) ; for ( AnnotationTypeMemberDeclaration member : members ) { ExecutableElement memberElement = member . getExecutableElement ( ) ; AnnotationValue defaultValue = memberElement . getDefaultValue ( ) ; if ( defaultValue == null || defaultValue . getValue ( ) == null ) { continue ; } TypeMirror memberType = memberElement . getReturnType ( ) ; String propName = NameTable . getAnnotationPropertyName ( memberElement ) ; ExecutableElement defaultGetterElement = GeneratedExecutableElement . newMethodWithSelector ( propName + "Default" , memberType , type ) . addModifiers ( Modifier . STATIC ) ; MethodDeclaration defaultGetter = new MethodDeclaration ( defaultGetterElement ) ; defaultGetter . setHasDeclaration ( false ) ; Block defaultGetterBody = new Block ( ) ; defaultGetter . setBody ( defaultGetterBody ) ; defaultGetterBody . addStatement ( new ReturnStatement ( translationUtil . createAnnotationValue ( memberType , defaultValue ) ) ) ; node . addBodyDeclaration ( defaultGetter ) ; } }
Create accessors for properties that have default values .
26,084
public void setComment ( String comment ) { if ( comment == null ) { this . comment = null ; return ; } if ( comment . getBytes ( StandardCharsets . UTF_8 ) . length > 0xffff ) { throw new IllegalArgumentException ( comment + " too long: " + comment . getBytes ( StandardCharsets . UTF_8 ) . length ) ; } this . comment = comment ; }
Sets the optional comment string for the entry .
26,085
public String getFunction ( int i ) throws ArrayIndexOutOfBoundsException { if ( null == m_functions ) throw new ArrayIndexOutOfBoundsException ( ) ; return ( String ) m_functions . elementAt ( i ) ; }
Get a function at a given index in this extension element
26,086
public String getElement ( int i ) throws ArrayIndexOutOfBoundsException { if ( null == m_elements ) throw new ArrayIndexOutOfBoundsException ( ) ; return ( String ) m_elements . elementAt ( i ) ; }
Get the element at the given index
26,087
public static CompactDecimalFormat getInstance ( Locale locale , CompactStyle style ) { return new CompactDecimalFormat ( ULocale . forLocale ( locale ) , style ) ; }
Create a CompactDecimalFormat appropriate for a locale . The result may be affected by the number system in the locale such as ar - u - nu - latn .
26,088
private Data getData ( ULocale locale , CompactStyle style ) { CompactDecimalDataCache . DataBundle bundle = cache . get ( locale ) ; switch ( style ) { case SHORT : return bundle . shortData ; case LONG : return bundle . longData ; default : return bundle . shortData ; } }
Gets the data for a particular locale and style . If style is unrecognized we just return data for CompactStyle . SHORT .
26,089
private Data getCurrencyData ( ULocale locale ) { CompactDecimalDataCache . DataBundle bundle = cache . get ( locale ) ; return bundle . shortCurrencyData ; }
Gets the currency data for a particular locale . Currently only short currency format is supported since that is the only form in CLDR .
26,090
public double getNumberFromNode ( int n ) { XMLString xstr = m_dtmMgr . getDTM ( n ) . getStringValue ( n ) ; return xstr . toDouble ( ) ; }
Get numeric value of the string conversion from a single node .
26,091
public double numWithSideEffects ( ) { int node = nextNode ( ) ; return ( node != DTM . NULL ) ? getNumberFromNode ( node ) : Double . NaN ; }
Cast result object to a number but allow side effects such as the incrementing of an iterator .
26,092
public XMLString getStringFromNode ( int n ) { if ( DTM . NULL != n ) { return m_dtmMgr . getDTM ( n ) . getStringValue ( n ) ; } else { return org . apache . xpath . objects . XString . EMPTYSTRING ; } }
Get the string conversion from a single node .
26,093
public XObject getFresh ( ) { try { if ( hasCache ( ) ) return ( XObject ) cloneWithReset ( ) ; else return this ; } catch ( CloneNotSupportedException cnse ) { throw new RuntimeException ( cnse . getMessage ( ) ) ; } }
Get a fresh copy of the object . For use with variables .
26,094
public NodeSetDTM mutableNodeset ( ) { NodeSetDTM mnl ; if ( m_obj instanceof NodeSetDTM ) { mnl = ( NodeSetDTM ) m_obj ; } else { mnl = new NodeSetDTM ( iter ( ) ) ; setObject ( mnl ) ; setCurrentPos ( 0 ) ; } return mnl ; }
Cast result object to a mutableNodeset .
26,095
public static java . util . TimeZone wrap ( android . icu . util . TimeZone tz ) { return new TimeZoneAdapter ( tz ) ; }
Given a java . util . TimeZone wrap it in the appropriate adapter subclass of android . icu . util . TimeZone and return the adapter .
26,096
public DTMAxisTraverser getAxisTraverser ( final int axis ) { DTMAxisTraverser traverser ; if ( null == m_traversers ) { m_traversers = new DTMAxisTraverser [ Axis . getNamesLength ( ) ] ; traverser = null ; } else { traverser = m_traversers [ axis ] ; if ( traverser != null ) return traverser ; } switch ( axis ) { case Axis . ANCESTOR : traverser = new AncestorTraverser ( ) ; break ; case Axis . ANCESTORORSELF : traverser = new AncestorOrSelfTraverser ( ) ; break ; case Axis . ATTRIBUTE : traverser = new AttributeTraverser ( ) ; break ; case Axis . CHILD : traverser = new ChildTraverser ( ) ; break ; case Axis . DESCENDANT : traverser = new DescendantTraverser ( ) ; break ; case Axis . DESCENDANTORSELF : traverser = new DescendantOrSelfTraverser ( ) ; break ; case Axis . FOLLOWING : traverser = new FollowingTraverser ( ) ; break ; case Axis . FOLLOWINGSIBLING : traverser = new FollowingSiblingTraverser ( ) ; break ; case Axis . NAMESPACE : traverser = new NamespaceTraverser ( ) ; break ; case Axis . NAMESPACEDECLS : traverser = new NamespaceDeclsTraverser ( ) ; break ; case Axis . PARENT : traverser = new ParentTraverser ( ) ; break ; case Axis . PRECEDING : traverser = new PrecedingTraverser ( ) ; break ; case Axis . PRECEDINGSIBLING : traverser = new PrecedingSiblingTraverser ( ) ; break ; case Axis . SELF : traverser = new SelfTraverser ( ) ; break ; case Axis . ALL : traverser = new AllFromRootTraverser ( ) ; break ; case Axis . ALLFROMNODE : traverser = new AllFromNodeTraverser ( ) ; break ; case Axis . PRECEDINGANDANCESTOR : traverser = new PrecedingAndAncestorTraverser ( ) ; break ; case Axis . DESCENDANTSFROMROOT : traverser = new DescendantFromRootTraverser ( ) ; break ; case Axis . DESCENDANTSORSELFFROMROOT : traverser = new DescendantOrSelfFromRootTraverser ( ) ; break ; case Axis . ROOT : traverser = new RootTraverser ( ) ; break ; case Axis . FILTEREDLIST : return null ; default : throw new DTMException ( XMLMessages . createXMLMessage ( XMLErrorResources . ER_UNKNOWN_AXIS_TYPE , new Object [ ] { Integer . toString ( axis ) } ) ) ; } if ( null == traverser ) throw new DTMException ( XMLMessages . createXMLMessage ( XMLErrorResources . ER_AXIS_TRAVERSER_NOT_SUPPORTED , new Object [ ] { Axis . getNames ( axis ) } ) ) ; m_traversers [ axis ] = traverser ; return traverser ; }
This returns a stateless traverser that can navigate over an XPath axis though perhaps not in document order .
26,097
public boolean translateReadyOps ( int ops , int initialOps , SelectionKeyImpl sk ) { int intOps = sk . nioInterestOps ( ) ; int oldOps = sk . nioReadyOps ( ) ; int newOps = initialOps ; if ( ( ops & PollArrayWrapper . POLLNVAL ) != 0 ) { return false ; } if ( ( ops & ( PollArrayWrapper . POLLERR | PollArrayWrapper . POLLHUP ) ) != 0 ) { newOps = intOps ; sk . nioReadyOps ( newOps ) ; readyToConnect = true ; return ( newOps & ~ oldOps ) != 0 ; } if ( ( ( ops & PollArrayWrapper . POLLIN ) != 0 ) && ( ( intOps & SelectionKey . OP_READ ) != 0 ) && ( state == ST_CONNECTED ) ) newOps |= SelectionKey . OP_READ ; if ( ( ( ops & PollArrayWrapper . POLLCONN ) != 0 ) && ( ( intOps & SelectionKey . OP_CONNECT ) != 0 ) && ( ( state == ST_UNCONNECTED ) || ( state == ST_PENDING ) ) ) { newOps |= SelectionKey . OP_CONNECT ; readyToConnect = true ; } if ( ( ( ops & PollArrayWrapper . POLLOUT ) != 0 ) && ( ( intOps & SelectionKey . OP_WRITE ) != 0 ) && ( state == ST_CONNECTED ) ) newOps |= SelectionKey . OP_WRITE ; sk . nioReadyOps ( newOps ) ; return ( newOps & ~ oldOps ) != 0 ; }
Translates native poll revent ops into a ready operation ops
26,098
public void comment ( String data ) throws org . xml . sax . SAXException { final int length = data . length ( ) ; if ( length > m_charsBuff . length ) { m_charsBuff = new char [ length * 2 + 1 ] ; } data . getChars ( 0 , length , m_charsBuff , 0 ) ; comment ( m_charsBuff , 0 , length ) ; }
Called when a Comment is to be constructed . Note that Xalan will normally invoke the other version of this method . %REVIEW% In fact is this one ever needed or was it a mistake?
26,099
private void openFiles ( ) throws IOException { LogManager manager = LogManager . getLogManager ( ) ; manager . checkPermission ( ) ; if ( count < 1 ) { throw new IllegalArgumentException ( "file count = " + count ) ; } if ( limit < 0 ) { limit = 0 ; } InitializationErrorManager em = new InitializationErrorManager ( ) ; setErrorManager ( em ) ; int unique = - 1 ; for ( ; ; ) { unique ++ ; if ( unique > MAX_LOCKS ) { throw new IOException ( "Couldn't get lock for " + pattern ) ; } lockFileName = generate ( pattern , 0 , unique ) . toString ( ) + ".lck" ; synchronized ( locks ) { if ( locks . get ( lockFileName ) != null ) { continue ; } FileChannel fc ; try { lockStream = new FileOutputStream ( lockFileName ) ; fc = lockStream . getChannel ( ) ; } catch ( IOException ix ) { continue ; } boolean available ; try { available = fc . tryLock ( ) != null ; } catch ( IOException ix ) { available = true ; } if ( available ) { locks . put ( lockFileName , lockFileName ) ; break ; } fc . close ( ) ; } } files = new File [ count ] ; for ( int i = 0 ; i < count ; i ++ ) { files [ i ] = generate ( pattern , i , unique ) ; } if ( append ) { open ( files [ 0 ] , true ) ; } else { rotate ( ) ; } Exception ex = em . lastException ; if ( ex != null ) { if ( ex instanceof IOException ) { throw ( IOException ) ex ; } else if ( ex instanceof SecurityException ) { throw ( SecurityException ) ex ; } else { throw new IOException ( "Exception: " + ex ) ; } } setErrorManager ( new ErrorManager ( ) ) ; }
configured instance variables .