idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
25,600
public final void pushPair ( int v1 , int v2 ) { if ( null == m_map ) { m_map = new int [ m_blocksize ] ; m_mapSize = m_blocksize ; } else { if ( ( m_firstFree + 2 ) >= m_mapSize ) { m_mapSize += m_blocksize ; int newMap [ ] = new int [ m_mapSize ] ; System . arraycopy ( m_map , 0 , newMap , 0 , m_firstFree ) ; m_map = newMap ; } } m_map [ m_firstFree ] = v1 ; m_map [ m_firstFree + 1 ] = v2 ; m_firstFree += 2 ; }
Push a pair of nodes into the stack . Special purpose method for TransformerImpl pushElemTemplateElement . Performance critical .
25,601
public final void popPair ( ) { m_firstFree -= 2 ; m_map [ m_firstFree ] = DTM . NULL ; m_map [ m_firstFree + 1 ] = DTM . NULL ; }
Pop a pair of nodes from the tail of the stack . Special purpose method for TransformerImpl pushElemTemplateElement . Performance critical .
25,602
public void insertInOrder ( int value ) { for ( int i = 0 ; i < m_firstFree ; i ++ ) { if ( value < m_map [ i ] ) { insertElementAt ( value , i ) ; return ; } } addElement ( value ) ; }
Insert a node in order in the list .
25,603
public void sort ( int a [ ] , int lo0 , int hi0 ) throws Exception { int lo = lo0 ; int hi = hi0 ; if ( lo >= hi ) { return ; } else if ( lo == hi - 1 ) { if ( a [ lo ] > a [ hi ] ) { int T = a [ lo ] ; a [ lo ] = a [ hi ] ; a [ hi ] = T ; } return ; } int pivot = a [ ( lo + hi ) / 2 ] ; a [ ( lo + hi ) / 2 ] = a [ hi ] ; a [ hi ] = pivot ; while ( lo < hi ) { while ( a [ lo ] <= pivot && lo < hi ) { lo ++ ; } while ( pivot <= a [ hi ] && lo < hi ) { hi -- ; } if ( lo < hi ) { int T = a [ lo ] ; a [ lo ] = a [ hi ] ; a [ hi ] = T ; } } a [ hi0 ] = a [ hi ] ; a [ hi ] = pivot ; sort ( a , lo0 , lo - 1 ) ; sort ( a , hi + 1 , hi0 ) ; }
Sort an array using a quicksort algorithm .
25,604
public static RelativeDateTimeFormatter getInstance ( ULocale locale ) { return getInstance ( locale , null , Style . LONG , DisplayContext . CAPITALIZATION_NONE ) ; }
Returns a RelativeDateTimeFormatter for a particular locale .
25,605
public static RelativeDateTimeFormatter getInstance ( ULocale locale , NumberFormat nf ) { return getInstance ( locale , nf , Style . LONG , DisplayContext . CAPITALIZATION_NONE ) ; }
Returns a RelativeDateTimeFormatter for a particular locale that uses a particular NumberFormat object .
25,606
public static RelativeDateTimeFormatter getInstance ( ULocale locale , NumberFormat nf , Style style , DisplayContext capitalizationContext ) { RelativeDateTimeFormatterData data = cache . get ( locale ) ; if ( nf == null ) { nf = NumberFormat . getInstance ( locale ) ; } else { nf = ( NumberFormat ) nf . clone ( ) ; } return new RelativeDateTimeFormatter ( data . qualitativeUnitMap , data . relUnitPatternMap , SimpleFormatterImpl . compileToStringMinMaxArguments ( data . dateTimePattern , new StringBuilder ( ) , 2 , 2 ) , PluralRules . forLocale ( locale ) , nf , style , capitalizationContext , capitalizationContext == DisplayContext . CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE ? BreakIterator . getSentenceInstance ( locale ) : null , locale ) ; }
Returns a RelativeDateTimeFormatter for a particular locale that uses a particular NumberFormat object style and capitalization context
25,607
public String format ( double quantity , Direction direction , RelativeUnit unit ) { if ( direction != Direction . LAST && direction != Direction . NEXT ) { throw new IllegalArgumentException ( "direction must be NEXT or LAST" ) ; } String result ; int pastFutureIndex = ( direction == Direction . NEXT ? 1 : 0 ) ; synchronized ( numberFormat ) { StringBuffer formatStr = new StringBuffer ( ) ; DontCareFieldPosition fieldPosition = DontCareFieldPosition . INSTANCE ; StandardPlural pluralForm = QuantityFormatter . selectPlural ( quantity , numberFormat , pluralRules , formatStr , fieldPosition ) ; String formatter = getRelativeUnitPluralPattern ( style , unit , pastFutureIndex , pluralForm ) ; result = SimpleFormatterImpl . formatCompiledPattern ( formatter , formatStr ) ; } return adjustForContext ( result ) ; }
Formats a relative date with a quantity such as in 5 days or 3 months ago
25,608
public String format ( Direction direction , AbsoluteUnit unit ) { if ( unit == AbsoluteUnit . NOW && direction != Direction . PLAIN ) { throw new IllegalArgumentException ( "NOW can only accept direction PLAIN." ) ; } String result ; if ( ( direction == Direction . PLAIN ) && ( AbsoluteUnit . SUNDAY . ordinal ( ) <= unit . ordinal ( ) && unit . ordinal ( ) <= AbsoluteUnit . SATURDAY . ordinal ( ) ) ) { int dateSymbolsDayOrdinal = ( unit . ordinal ( ) - AbsoluteUnit . SUNDAY . ordinal ( ) ) + Calendar . SUNDAY ; String [ ] dayNames = dateFormatSymbols . getWeekdays ( DateFormatSymbols . STANDALONE , styleToDateFormatSymbolsWidth [ style . ordinal ( ) ] ) ; result = dayNames [ dateSymbolsDayOrdinal ] ; } else { result = getAbsoluteUnitString ( style , unit , direction ) ; } return result != null ? adjustForContext ( result ) : null ; }
Formats a relative date without a quantity .
25,609
private String getAbsoluteUnitString ( Style style , AbsoluteUnit unit , Direction direction ) { EnumMap < AbsoluteUnit , EnumMap < Direction , String > > unitMap ; EnumMap < Direction , String > dirMap ; do { unitMap = qualitativeUnitMap . get ( style ) ; if ( unitMap != null ) { dirMap = unitMap . get ( unit ) ; if ( dirMap != null ) { String result = dirMap . get ( direction ) ; if ( result != null ) { return result ; } } } } while ( ( style = fallbackCache [ style . ordinal ( ) ] ) != null ) ; return null ; }
Gets the string value from qualitativeUnitMap with fallback based on style .
25,610
public String combineDateAndTime ( String relativeDateString , String timeString ) { return SimpleFormatterImpl . formatCompiledPattern ( combinedDateAndTime , timeString , relativeDateString ) ; }
Combines a relative date string and a time string in this object s locale . This is done with the same date - time separator used for the default calendar in this locale .
25,611
private void handleThrows ( ) { Scope curScope = scope ; while ( curScope != null ) { if ( curScope . kind == Scope . Kind . TRY ) { scope . mergeInto ( curScope . next ) ; } curScope = curScope . next ; } }
scope of each try block .
25,612
private boolean isBoxingMethod ( ExecutableElement method ) { TypeElement declaringClass = ElementUtil . getDeclaringClass ( method ) ; if ( typeUtil . isBoxedType ( declaringClass . asType ( ) ) ) { String name = ElementUtil . getName ( method ) ; TypeMirror returnType = method . getReturnType ( ) ; List < ? extends VariableElement > params = method . getParameters ( ) ; if ( name . equals ( "valueOf" ) && params . size ( ) == 1 && params . get ( 0 ) . asType ( ) . getKind ( ) . isPrimitive ( ) ) { return true ; } if ( params . isEmpty ( ) && returnType . getKind ( ) . isPrimitive ( ) && name . equals ( TypeUtil . getName ( returnType ) + "Value" ) ) { return true ; } } return false ; }
Checks if the given method is a primitive boxing or unboxing method .
25,613
public void endVisit ( FunctionInvocation node ) { if ( Objects . equals ( node . getFunctionElement ( ) , NIL_CHK_ELEM ) ) { VariableElement var = TreeUtil . getVariableElement ( node . getArgument ( 0 ) ) ; if ( var != null ) { addSafeVar ( var ) ; } } }
added nil_chk s .
25,614
public void setRequestProperty ( String key , String value ) { if ( connected ) throw new IllegalStateException ( "Already connected" ) ; if ( key == null ) throw new NullPointerException ( "key is null" ) ; if ( requests == null ) requests = new MessageHeader ( ) ; requests . set ( key , value ) ; }
Sets the general request property . If a property with the key already exists overwrite its value with the new value .
25,615
public void addRequestProperty ( String key , String value ) { if ( connected ) throw new IllegalStateException ( "Already connected" ) ; if ( key == null ) throw new NullPointerException ( "key is null" ) ; if ( requests == null ) requests = new MessageHeader ( ) ; requests . add ( key , value ) ; }
Adds a general request property specified by a key - value pair . This method will not overwrite existing values associated with the same key .
25,616
public String getRequestProperty ( String key ) { if ( connected ) throw new IllegalStateException ( "Already connected" ) ; if ( requests == null ) return null ; return requests . findValue ( key ) ; }
Returns the value of the named general request property for this connection .
25,617
public Map < String , List < String > > getRequestProperties ( ) { if ( connected ) throw new IllegalStateException ( "Already connected" ) ; if ( requests == null ) return Collections . EMPTY_MAP ; return requests . getHeaders ( null ) ; }
Returns an unmodifiable Map of general request properties for this connection . The Map keys are Strings that represent the request - header field names . Each Map value is a unmodifiable List of Strings that represents the corresponding field values .
25,618
synchronized ContentHandler getContentHandler ( ) throws IOException { String contentType = stripOffParameters ( getContentType ( ) ) ; ContentHandler handler = null ; if ( contentType == null ) { if ( ( contentType = guessContentTypeFromName ( url . getFile ( ) ) ) == null ) { contentType = guessContentTypeFromStream ( getInputStream ( ) ) ; } } if ( contentType == null ) { return UnknownContentHandler . INSTANCE ; } try { handler = ( ContentHandler ) handlers . get ( contentType ) ; if ( handler != null ) return handler ; } catch ( Exception e ) { } if ( factory != null ) handler = factory . createContentHandler ( contentType ) ; if ( handler == null ) { try { handler = lookupContentHandlerClassFor ( contentType ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; handler = UnknownContentHandler . INSTANCE ; } handlers . put ( contentType , handler ) ; } return handler ; }
Gets the Content Handler appropriate for this connection .
25,619
private String getContentHandlerPkgPrefixes ( ) { String packagePrefixList = System . getProperty ( contentPathProp , "" ) ; if ( packagePrefixList != "" ) { packagePrefixList += "|" ; } return packagePrefixList + contentClassPrefix ; }
Returns a vertical bar separated list of package prefixes for potential content handlers . Tries to get the java . content . handler . pkgs property to use as a set of package prefixes to search . Whether or not that property has been defined the sun . net . www . content is always the last one on the returned package list .
25,620
static private int readBytes ( int c [ ] , int len , InputStream is ) throws IOException { byte buf [ ] = new byte [ len ] ; if ( is . read ( buf , 0 , len ) < len ) { return - 1 ; } for ( int i = 0 ; i < len ; i ++ ) { c [ i ] = buf [ i ] & 0xff ; } return 0 ; }
Tries to read the specified number of bytes from the stream Returns - 1 If EOF is reached before len bytes are read returns 0 otherwise
25,621
static private long skipForward ( InputStream is , long toSkip ) throws IOException { long eachSkip = 0 ; long skipped = 0 ; while ( skipped != toSkip ) { eachSkip = is . skip ( toSkip - skipped ) ; if ( eachSkip <= 0 ) { if ( is . read ( ) == - 1 ) { return skipped ; } else { skipped ++ ; } } skipped += eachSkip ; } return skipped ; }
Skips through the specified number of bytes from the stream until either EOF is reached or the specified number of bytes have been skipped
25,622
public static final ElemDesc getElemDesc ( String name ) { Object obj = m_elementFlags . get ( name ) ; if ( null != obj ) return ( ElemDesc ) obj ; return m_dummy ; }
Get a description of the given element .
25,623
private void outputDocTypeDecl ( String name ) throws SAXException { if ( true == m_needToOutputDocTypeDecl ) { String doctypeSystem = getDoctypeSystem ( ) ; String doctypePublic = getDoctypePublic ( ) ; if ( ( null != doctypeSystem ) || ( null != doctypePublic ) ) { final java . io . Writer writer = m_writer ; try { writer . write ( "<!DOCTYPE " ) ; writer . write ( name ) ; if ( null != doctypePublic ) { writer . write ( " PUBLIC \"" ) ; writer . write ( doctypePublic ) ; writer . write ( '"' ) ; } if ( null != doctypeSystem ) { if ( null == doctypePublic ) writer . write ( " SYSTEM \"" ) ; else writer . write ( " \"" ) ; writer . write ( doctypeSystem ) ; writer . write ( '"' ) ; } writer . write ( '>' ) ; outputLineSep ( ) ; } catch ( IOException e ) { throw new SAXException ( e ) ; } } } m_needToOutputDocTypeDecl = false ; }
This method should only get called once . If a DOCTYPE declaration needs to get written out it will be written out . If it doesn t need to be written out then the call to this method has no effect .
25,624
private static String makeHHString ( int i ) { String s = Integer . toHexString ( i ) . toUpperCase ( ) ; if ( s . length ( ) == 1 ) { s = "0" + s ; } return s ; }
Make an integer into an HH hex value . Does no checking on the size of the input since this is only meant to be used locally by writeAttrURI .
25,625
protected void closeStartTag ( ) throws SAXException { try { if ( m_tracer != null ) super . fireStartElem ( m_elemContext . m_elementName ) ; int nAttrs = m_attributes . getLength ( ) ; if ( nAttrs > 0 ) { processAttributes ( m_writer , nAttrs ) ; m_attributes . clear ( ) ; } m_writer . write ( '>' ) ; if ( m_CdataElems != null ) m_elemContext . m_isCdataSection = isCdataSection ( ) ; if ( m_doIndent ) { m_isprevtext = false ; m_preserves . push ( m_ispreserve ) ; } } catch ( IOException e ) { throw new SAXException ( e ) ; } }
For the enclosing elements starting tag write out out any attributes followed by > . At this point we also mark if this element is a cdata - section - element .
25,626
public void attributeDecl ( String eName , String aName , String type , String valueDefault , String value ) throws SAXException { }
This method does nothing .
25,627
public byte [ ] getEncodedInfo ( ) throws CertificateEncodingException { try { if ( rawCertInfo == null ) { DerOutputStream tmp = new DerOutputStream ( ) ; emit ( tmp ) ; rawCertInfo = tmp . toByteArray ( ) ; } return rawCertInfo . clone ( ) ; } catch ( IOException e ) { throw new CertificateEncodingException ( e . toString ( ) ) ; } catch ( CertificateException e ) { throw new CertificateEncodingException ( e . toString ( ) ) ; } }
Returns the encoded certificate info .
25,628
public void set ( String name , Object val ) throws CertificateException , IOException { X509AttributeName attrName = new X509AttributeName ( name ) ; int attr = attributeMap ( attrName . getPrefix ( ) ) ; if ( attr == 0 ) { throw new CertificateException ( "Attribute name not recognized: " + name ) ; } rawCertInfo = null ; String suffix = attrName . getSuffix ( ) ; switch ( attr ) { case ATTR_VERSION : if ( suffix == null ) { setVersion ( val ) ; } else { version . set ( suffix , val ) ; } break ; case ATTR_SERIAL : if ( suffix == null ) { setSerialNumber ( val ) ; } else { serialNum . set ( suffix , val ) ; } break ; case ATTR_ALGORITHM : if ( suffix == null ) { setAlgorithmId ( val ) ; } else { algId . set ( suffix , val ) ; } break ; case ATTR_ISSUER : setIssuer ( val ) ; break ; case ATTR_VALIDITY : if ( suffix == null ) { setValidity ( val ) ; } else { interval . set ( suffix , val ) ; } break ; case ATTR_SUBJECT : setSubject ( val ) ; break ; case ATTR_KEY : if ( suffix == null ) { setKey ( val ) ; } else { pubKey . set ( suffix , val ) ; } break ; case ATTR_ISSUER_ID : setIssuerUniqueId ( val ) ; break ; case ATTR_SUBJECT_ID : setSubjectUniqueId ( val ) ; break ; case ATTR_EXTENSIONS : if ( suffix == null ) { setExtensions ( val ) ; } else { if ( extensions == null ) extensions = new CertificateExtensions ( ) ; extensions . set ( suffix , val ) ; } break ; } }
Set the certificate attribute .
25,629
public void delete ( String name ) throws CertificateException , IOException { X509AttributeName attrName = new X509AttributeName ( name ) ; int attr = attributeMap ( attrName . getPrefix ( ) ) ; if ( attr == 0 ) { throw new CertificateException ( "Attribute name not recognized: " + name ) ; } rawCertInfo = null ; String suffix = attrName . getSuffix ( ) ; switch ( attr ) { case ATTR_VERSION : if ( suffix == null ) { version = null ; } else { version . delete ( suffix ) ; } break ; case ( ATTR_SERIAL ) : if ( suffix == null ) { serialNum = null ; } else { serialNum . delete ( suffix ) ; } break ; case ( ATTR_ALGORITHM ) : if ( suffix == null ) { algId = null ; } else { algId . delete ( suffix ) ; } break ; case ( ATTR_ISSUER ) : issuer = null ; break ; case ( ATTR_VALIDITY ) : if ( suffix == null ) { interval = null ; } else { interval . delete ( suffix ) ; } break ; case ( ATTR_SUBJECT ) : subject = null ; break ; case ( ATTR_KEY ) : if ( suffix == null ) { pubKey = null ; } else { pubKey . delete ( suffix ) ; } break ; case ( ATTR_ISSUER_ID ) : issuerUniqueId = null ; break ; case ( ATTR_SUBJECT_ID ) : subjectUniqueId = null ; break ; case ( ATTR_EXTENSIONS ) : if ( suffix == null ) { extensions = null ; } else { if ( extensions != null ) extensions . delete ( suffix ) ; } break ; } }
Delete the certificate attribute .
25,630
public Object get ( String name ) throws CertificateException , IOException { X509AttributeName attrName = new X509AttributeName ( name ) ; int attr = attributeMap ( attrName . getPrefix ( ) ) ; if ( attr == 0 ) { throw new CertificateParsingException ( "Attribute name not recognized: " + name ) ; } String suffix = attrName . getSuffix ( ) ; switch ( attr ) { case ( ATTR_EXTENSIONS ) : if ( suffix == null ) { return ( extensions ) ; } else { if ( extensions == null ) { return null ; } else { return ( extensions . get ( suffix ) ) ; } } case ( ATTR_SUBJECT ) : if ( suffix == null ) { return ( subject ) ; } else { return ( getX500Name ( suffix , false ) ) ; } case ( ATTR_ISSUER ) : if ( suffix == null ) { return ( issuer ) ; } else { return ( getX500Name ( suffix , true ) ) ; } case ( ATTR_KEY ) : if ( suffix == null ) { return ( pubKey ) ; } else { return ( pubKey . get ( suffix ) ) ; } case ( ATTR_ALGORITHM ) : if ( suffix == null ) { return ( algId ) ; } else { return ( algId . get ( suffix ) ) ; } case ( ATTR_VALIDITY ) : if ( suffix == null ) { return ( interval ) ; } else { return ( interval . get ( suffix ) ) ; } case ( ATTR_VERSION ) : if ( suffix == null ) { return ( version ) ; } else { return ( version . get ( suffix ) ) ; } case ( ATTR_SERIAL ) : if ( suffix == null ) { return ( serialNum ) ; } else { return ( serialNum . get ( suffix ) ) ; } case ( ATTR_ISSUER_ID ) : return ( issuerUniqueId ) ; case ( ATTR_SUBJECT_ID ) : return ( subjectUniqueId ) ; } return null ; }
Get the certificate attribute .
25,631
private int attributeMap ( String name ) { Integer num = map . get ( name ) ; if ( num == null ) { return 0 ; } return num . intValue ( ) ; }
Returns the integer attribute number for the passed attribute name .
25,632
private void setVersion ( Object val ) throws CertificateException { if ( ! ( val instanceof CertificateVersion ) ) { throw new CertificateException ( "Version class type invalid." ) ; } version = ( CertificateVersion ) val ; }
Set the version number of the certificate .
25,633
private void setSerialNumber ( Object val ) throws CertificateException { if ( ! ( val instanceof CertificateSerialNumber ) ) { throw new CertificateException ( "SerialNumber class type invalid." ) ; } serialNum = ( CertificateSerialNumber ) val ; }
Set the serial number of the certificate .
25,634
private void setAlgorithmId ( Object val ) throws CertificateException { if ( ! ( val instanceof CertificateAlgorithmId ) ) { throw new CertificateException ( "AlgorithmId class type invalid." ) ; } algId = ( CertificateAlgorithmId ) val ; }
Set the algorithm id of the certificate .
25,635
private void setIssuer ( Object val ) throws CertificateException { if ( ! ( val instanceof X500Name ) ) { throw new CertificateException ( "Issuer class type invalid." ) ; } issuer = ( X500Name ) val ; }
Set the issuer name of the certificate .
25,636
private void setValidity ( Object val ) throws CertificateException { if ( ! ( val instanceof CertificateValidity ) ) { throw new CertificateException ( "CertificateValidity class type invalid." ) ; } interval = ( CertificateValidity ) val ; }
Set the validity interval of the certificate .
25,637
private void setSubject ( Object val ) throws CertificateException { if ( ! ( val instanceof X500Name ) ) { throw new CertificateException ( "Subject class type invalid." ) ; } subject = ( X500Name ) val ; }
Set the subject name of the certificate .
25,638
private void setKey ( Object val ) throws CertificateException { if ( ! ( val instanceof CertificateX509Key ) ) { throw new CertificateException ( "Key class type invalid." ) ; } pubKey = ( CertificateX509Key ) val ; }
Set the public key in the certificate .
25,639
private void setIssuerUniqueId ( Object val ) throws CertificateException { if ( version . compare ( CertificateVersion . V2 ) < 0 ) { throw new CertificateException ( "Invalid version" ) ; } if ( ! ( val instanceof UniqueIdentity ) ) { throw new CertificateException ( "IssuerUniqueId class type invalid." ) ; } issuerUniqueId = ( UniqueIdentity ) val ; }
Set the Issuer Unique Identity in the certificate .
25,640
private void setSubjectUniqueId ( Object val ) throws CertificateException { if ( version . compare ( CertificateVersion . V2 ) < 0 ) { throw new CertificateException ( "Invalid version" ) ; } if ( ! ( val instanceof UniqueIdentity ) ) { throw new CertificateException ( "SubjectUniqueId class type invalid." ) ; } subjectUniqueId = ( UniqueIdentity ) val ; }
Set the Subject Unique Identity in the certificate .
25,641
private void setExtensions ( Object val ) throws CertificateException { if ( version . compare ( CertificateVersion . V3 ) < 0 ) { throw new CertificateException ( "Invalid version" ) ; } if ( ! ( val instanceof CertificateExtensions ) ) { throw new CertificateException ( "Extensions class type invalid." ) ; } extensions = ( CertificateExtensions ) val ; }
Set the extensions in the certificate .
25,642
public final Object parseObject ( String source , ParsePosition parsePosition ) { return parse ( source , parsePosition ) ; }
Parses text from a string to produce a number .
25,643
public final String format ( long number ) { StringBuffer buf = new StringBuffer ( 19 ) ; FieldPosition pos = new FieldPosition ( 0 ) ; format ( number , buf , pos ) ; return buf . toString ( ) ; }
Specialization of format .
25,644
public final String format ( java . math . BigDecimal number ) { return format ( number , new StringBuffer ( ) , new FieldPosition ( 0 ) ) . toString ( ) ; }
Convenience method to format a BigDecimal .
25,645
public void setMaximumIntegerDigits ( int newValue ) { maximumIntegerDigits = Math . max ( 0 , newValue ) ; if ( minimumIntegerDigits > maximumIntegerDigits ) minimumIntegerDigits = maximumIntegerDigits ; }
Sets the maximum number of digits allowed in the integer portion of a number . This must be &gt ; = minimumIntegerDigits . If the new value for maximumIntegerDigits is less than the current value of minimumIntegerDigits then minimumIntegerDigits will also be set to the new value .
25,646
public void setMinimumIntegerDigits ( int newValue ) { minimumIntegerDigits = Math . max ( 0 , newValue ) ; if ( minimumIntegerDigits > maximumIntegerDigits ) maximumIntegerDigits = minimumIntegerDigits ; }
Sets the minimum number of digits allowed in the integer portion of a number . This must be &lt ; = maximumIntegerDigits . If the new value for minimumIntegerDigits is more than the current value of maximumIntegerDigits then maximumIntegerDigits will also be set to the new value .
25,647
public void setMinimumFractionDigits ( int newValue ) { minimumFractionDigits = Math . max ( 0 , newValue ) ; if ( maximumFractionDigits < minimumFractionDigits ) maximumFractionDigits = minimumFractionDigits ; }
Sets the minimum number of digits allowed in the fraction portion of a number . This must be &lt ; = maximumFractionDigits . If the new value for minimumFractionDigits exceeds the current value of maximumFractionDigits then maximumFractionDigits will also be set to the new value .
25,648
public static NumberFormat getInstance ( ULocale desiredLocale , int choice ) { if ( choice < NUMBERSTYLE || choice > STANDARDCURRENCYSTYLE ) { throw new IllegalArgumentException ( "choice should be from NUMBERSTYLE to STANDARDCURRENCYSTYLE" ) ; } return getShim ( ) . createInstance ( desiredLocale , choice ) ; }
Returns a specific style number format for a specific locale .
25,649
static NumberFormat createInstance ( ULocale desiredLocale , int choice ) { String pattern = getPattern ( desiredLocale , choice ) ; DecimalFormatSymbols symbols = new DecimalFormatSymbols ( desiredLocale ) ; if ( choice == CURRENCYSTYLE || choice == ISOCURRENCYSTYLE || choice == ACCOUNTINGCURRENCYSTYLE || choice == CASHCURRENCYSTYLE || choice == STANDARDCURRENCYSTYLE ) { String temp = symbols . getCurrencyPattern ( ) ; if ( temp != null ) { pattern = temp ; } } if ( choice == ISOCURRENCYSTYLE ) { pattern = pattern . replace ( "\u00A4" , doubleCurrencyStr ) ; } NumberingSystem ns = NumberingSystem . getInstance ( desiredLocale ) ; if ( ns == null ) { return null ; } NumberFormat format ; if ( ns != null && ns . isAlgorithmic ( ) ) { String nsDesc ; String nsRuleSetGroup ; String nsRuleSetName ; ULocale nsLoc ; int desiredRulesType = RuleBasedNumberFormat . NUMBERING_SYSTEM ; nsDesc = ns . getDescription ( ) ; int firstSlash = nsDesc . indexOf ( "/" ) ; int lastSlash = nsDesc . lastIndexOf ( "/" ) ; if ( lastSlash > firstSlash ) { String nsLocID = nsDesc . substring ( 0 , firstSlash ) ; nsRuleSetGroup = nsDesc . substring ( firstSlash + 1 , lastSlash ) ; nsRuleSetName = nsDesc . substring ( lastSlash + 1 ) ; nsLoc = new ULocale ( nsLocID ) ; if ( nsRuleSetGroup . equals ( "SpelloutRules" ) ) { desiredRulesType = RuleBasedNumberFormat . SPELLOUT ; } } else { nsLoc = desiredLocale ; nsRuleSetName = nsDesc ; } RuleBasedNumberFormat r = new RuleBasedNumberFormat ( nsLoc , desiredRulesType ) ; r . setDefaultRuleSet ( nsRuleSetName ) ; format = r ; } else { DecimalFormat f = new DecimalFormat ( pattern , symbols , choice ) ; if ( choice == INTEGERSTYLE ) { f . setMaximumFractionDigits ( 0 ) ; f . setDecimalSeparatorAlwaysShown ( false ) ; f . setParseIntegerOnly ( true ) ; } if ( choice == CASHCURRENCYSTYLE ) { f . setCurrencyUsage ( CurrencyUsage . CASH ) ; } format = f ; } ULocale valid = symbols . getLocale ( ULocale . VALID_LOCALE ) ; ULocale actual = symbols . getLocale ( ULocale . ACTUAL_LOCALE ) ; format . setLocale ( valid , actual ) ; return format ; }
Hook for service
25,650
public static boolean isXML11ValidLiteral ( int c ) { return ( ( c < 0x10000 && ( ( XML11CHARS [ c ] & MASK_XML11_VALID ) != 0 && ( XML11CHARS [ c ] & MASK_XML11_CONTROL ) == 0 ) ) || ( 0x10000 <= c && c <= 0x10FFFF ) ) ; }
Returns true if the specified character is valid and permitted outside of a character reference . That is this method will return false for the same set as isXML11Valid except it also reports false for control characters .
25,651
private static int scriptNameToCode ( String name ) { try { int [ ] codes = UScript . getCode ( name ) ; return codes != null ? codes [ 0 ] : UScript . INVALID_CODE ; } catch ( MissingResourceException e ) { return UScript . INVALID_CODE ; } }
Return the script code for a given name or UScript . INVALID_CODE if not found .
25,652
protected String resolvePrefix ( SerializationHandler rhandler , String prefix , String nodeNamespace ) throws TransformerException { return prefix ; }
Resolve the namespace into a prefix . Meant to be overidded by elemAttribute if this class is derived .
25,653
private boolean mapPatternElemPos ( int nesting , boolean isStart , boolean isAttrName ) { if ( 0 == nesting ) { if ( m_patternMapSize >= m_patternMap . length ) { int patternMap [ ] = m_patternMap ; int len = m_patternMap . length ; m_patternMap = new int [ m_patternMapSize + 100 ] ; System . arraycopy ( patternMap , 0 , m_patternMap , 0 , len ) ; } if ( ! isStart ) { m_patternMap [ m_patternMapSize - 1 ] -= TARGETEXTRA ; } m_patternMap [ m_patternMapSize ] = ( m_compiler . getTokenQueueSize ( ) - ( isAttrName ? 1 : 0 ) ) + TARGETEXTRA ; m_patternMapSize ++ ; isStart = false ; } return isStart ; }
Record the current position on the token queue as long as this is a top - level element . Must be called before the next token is added to the m_tokenQueue .
25,654
private int getTokenQueuePosFromMap ( int i ) { int pos = m_patternMap [ i ] ; return ( pos >= TARGETEXTRA ) ? ( pos - TARGETEXTRA ) : pos ; }
Given a map pos return the corresponding token queue pos .
25,655
private final void resetTokenMark ( int mark ) { int qsz = m_compiler . getTokenQueueSize ( ) ; m_processor . m_queueMark = ( mark > 0 ) ? ( ( mark <= qsz ) ? mark - 1 : mark ) : 0 ; if ( m_processor . m_queueMark < qsz ) { m_processor . m_token = ( String ) m_compiler . getTokenQueue ( ) . elementAt ( m_processor . m_queueMark ++ ) ; m_processor . m_tokenChar = m_processor . m_token . charAt ( 0 ) ; } else { m_processor . m_token = null ; m_processor . m_tokenChar = 0 ; } }
Reset token queue mark and m_token to a given position .
25,656
final int getKeywordToken ( String key ) { int tok ; try { Integer itok = ( Integer ) Keywords . getKeyWord ( key ) ; tok = ( null != itok ) ? itok . intValue ( ) : 0 ; } catch ( NullPointerException npe ) { tok = 0 ; } catch ( ClassCastException cce ) { tok = 0 ; } return tok ; }
Given a string return the corresponding keyword token .
25,657
private void recordTokenString ( Vector targetStrings ) { int tokPos = getTokenQueuePosFromMap ( m_patternMapSize - 1 ) ; resetTokenMark ( tokPos + 1 ) ; if ( m_processor . lookahead ( '(' , 1 ) ) { int tok = getKeywordToken ( m_processor . m_token ) ; switch ( tok ) { case OpCodes . NODETYPE_COMMENT : targetStrings . addElement ( PsuedoNames . PSEUDONAME_COMMENT ) ; break ; case OpCodes . NODETYPE_TEXT : targetStrings . addElement ( PsuedoNames . PSEUDONAME_TEXT ) ; break ; case OpCodes . NODETYPE_NODE : targetStrings . addElement ( PsuedoNames . PSEUDONAME_ANY ) ; break ; case OpCodes . NODETYPE_ROOT : targetStrings . addElement ( PsuedoNames . PSEUDONAME_ROOT ) ; break ; case OpCodes . NODETYPE_ANYELEMENT : targetStrings . addElement ( PsuedoNames . PSEUDONAME_ANY ) ; break ; case OpCodes . NODETYPE_PI : targetStrings . addElement ( PsuedoNames . PSEUDONAME_ANY ) ; break ; default : targetStrings . addElement ( PsuedoNames . PSEUDONAME_ANY ) ; } } else { if ( m_processor . tokenIs ( '@' ) ) { tokPos ++ ; resetTokenMark ( tokPos + 1 ) ; } if ( m_processor . lookahead ( ':' , 1 ) ) { tokPos += 2 ; } targetStrings . addElement ( m_compiler . getTokenQueue ( ) . elementAt ( tokPos ) ) ; } }
Record the current token in the passed vector .
25,658
private int mapNSTokens ( String pat , int startSubstring , int posOfNSSep , int posOfScan ) throws javax . xml . transform . TransformerException { String prefix = "" ; if ( ( startSubstring >= 0 ) && ( posOfNSSep >= 0 ) ) { prefix = pat . substring ( startSubstring , posOfNSSep ) ; } String uName ; if ( ( null != m_namespaceContext ) && ! prefix . equals ( "*" ) && ! prefix . equals ( "xmlns" ) ) { try { if ( prefix . length ( ) > 0 ) uName = ( ( PrefixResolver ) m_namespaceContext ) . getNamespaceForPrefix ( prefix ) ; else { if ( false ) { addToTokenQueue ( ":" ) ; String s = pat . substring ( posOfNSSep + 1 , posOfScan ) ; if ( s . length ( ) > 0 ) addToTokenQueue ( s ) ; return - 1 ; } else { uName = ( ( PrefixResolver ) m_namespaceContext ) . getNamespaceForPrefix ( prefix ) ; } } } catch ( ClassCastException cce ) { uName = m_namespaceContext . getNamespaceForPrefix ( prefix ) ; } } else { uName = prefix ; } if ( ( null != uName ) && ( uName . length ( ) > 0 ) ) { addToTokenQueue ( uName ) ; addToTokenQueue ( ":" ) ; String s = pat . substring ( posOfNSSep + 1 , posOfScan ) ; if ( s . length ( ) > 0 ) addToTokenQueue ( s ) ; } else { m_processor . errorForDOM3 ( XPATHErrorResources . ER_PREFIX_MUST_RESOLVE , new String [ ] { prefix } ) ; } return - 1 ; }
When a seperator token is found see if there s a element name or the like to map .
25,659
public ULocale getLocale ( int index ) { List < ULocale > lcls = locales ; if ( lcls == null ) { lcls = guessLocales ( ) ; } if ( index >= 0 && index < lcls . size ( ) ) { return lcls . get ( index ) ; } return null ; }
Convenience function for getting the locales in priority order
25,660
public GlobalizationPreferences setLocales ( String acceptLanguageString ) { if ( isFrozen ( ) ) { throw new UnsupportedOperationException ( "Attempt to modify immutable object" ) ; } ULocale [ ] acceptLocales = null ; try { acceptLocales = ULocale . parseAcceptLanguage ( acceptLanguageString , true ) ; } catch ( ParseException pe ) { throw new IllegalArgumentException ( "Invalid Accept-Language string" ) ; } return setLocales ( acceptLocales ) ; }
Convenience routine for setting the locale priority list from an Accept - Language string .
25,661
public GlobalizationPreferences setCalendar ( Calendar calendar ) { if ( isFrozen ( ) ) { throw new UnsupportedOperationException ( "Attempt to modify immutable object" ) ; } this . calendar = ( Calendar ) calendar . clone ( ) ; return this ; }
Sets the calendar . If this has not been set uses default for territory .
25,662
public Calendar getCalendar ( ) { if ( calendar == null ) { return guessCalendar ( ) ; } Calendar temp = ( Calendar ) calendar . clone ( ) ; temp . setTimeZone ( getTimeZone ( ) ) ; temp . setTimeInMillis ( System . currentTimeMillis ( ) ) ; return temp ; }
Get a copy of the calendar according to the settings .
25,663
public GlobalizationPreferences setTimeZone ( TimeZone timezone ) { if ( isFrozen ( ) ) { throw new UnsupportedOperationException ( "Attempt to modify immutable object" ) ; } this . timezone = ( TimeZone ) timezone . clone ( ) ; return this ; }
Sets the timezone ID . If this has not been set uses default for territory .
25,664
public Collator getCollator ( ) { if ( collator == null ) { return guessCollator ( ) ; } try { return ( Collator ) collator . clone ( ) ; } catch ( CloneNotSupportedException e ) { throw new ICUCloneNotSupportedException ( "Error in cloning collator" , e ) ; } }
Get a copy of the collator according to the settings .
25,665
public GlobalizationPreferences setCollator ( Collator collator ) { if ( isFrozen ( ) ) { throw new UnsupportedOperationException ( "Attempt to modify immutable object" ) ; } try { this . collator = ( Collator ) collator . clone ( ) ; } catch ( CloneNotSupportedException e ) { throw new ICUCloneNotSupportedException ( "Error in cloning collator" , e ) ; } return this ; }
Explicitly set the collator for this object .
25,666
public BreakIterator getBreakIterator ( int type ) { if ( type < BI_CHARACTER || type >= BI_LIMIT ) { throw new IllegalArgumentException ( "Illegal break iterator type" ) ; } if ( breakIterators == null || breakIterators [ type ] == null ) { return guessBreakIterator ( type ) ; } return ( BreakIterator ) breakIterators [ type ] . clone ( ) ; }
Get a copy of the break iterator for the specified type according to the settings .
25,667
public GlobalizationPreferences setBreakIterator ( int type , BreakIterator iterator ) { if ( type < BI_CHARACTER || type >= BI_LIMIT ) { throw new IllegalArgumentException ( "Illegal break iterator type" ) ; } if ( isFrozen ( ) ) { throw new UnsupportedOperationException ( "Attempt to modify immutable object" ) ; } if ( breakIterators == null ) breakIterators = new BreakIterator [ BI_LIMIT ] ; breakIterators [ type ] = ( BreakIterator ) iterator . clone ( ) ; return this ; }
Explicitly set the break iterator for this object .
25,668
public GlobalizationPreferences setDateFormat ( int dateStyle , int timeStyle , DateFormat format ) { if ( isFrozen ( ) ) { throw new UnsupportedOperationException ( "Attempt to modify immutable object" ) ; } if ( dateFormats == null ) { dateFormats = new DateFormat [ DF_LIMIT ] [ DF_LIMIT ] ; } dateFormats [ dateStyle ] [ timeStyle ] = ( DateFormat ) format . clone ( ) ; return this ; }
Set an explicit date format . Overrides the locale priority list for a particular combination of dateStyle and timeStyle . DF_NONE should be used if for the style where only the date or time format individually is being set .
25,669
public GlobalizationPreferences setNumberFormat ( int style , NumberFormat format ) { if ( isFrozen ( ) ) { throw new UnsupportedOperationException ( "Attempt to modify immutable object" ) ; } if ( numberFormats == null ) { numberFormats = new NumberFormat [ NF_LIMIT ] ; } numberFormats [ style ] = ( NumberFormat ) format . clone ( ) ; return this ; }
Sets a number format explicitly . Overrides the general locale settings .
25,670
public GlobalizationPreferences reset ( ) { if ( isFrozen ( ) ) { throw new UnsupportedOperationException ( "Attempt to modify immutable object" ) ; } locales = null ; territory = null ; calendar = null ; collator = null ; breakIterators = null ; timezone = null ; currency = null ; dateFormats = null ; numberFormats = null ; implicitLocales = null ; return this ; }
Restore the object to the initial state .
25,671
protected String guessTerritory ( ) { String result ; for ( ULocale locale : getLocales ( ) ) { result = locale . getCountry ( ) ; if ( result . length ( ) != 0 ) { return result ; } } ULocale firstLocale = getLocale ( 0 ) ; String language = firstLocale . getLanguage ( ) ; String script = firstLocale . getScript ( ) ; result = null ; if ( script . length ( ) != 0 ) { result = language_territory_hack_map . get ( language + "_" + script ) ; } if ( result == null ) { result = language_territory_hack_map . get ( language ) ; } if ( result == null ) { result = "US" ; } return result ; }
This function can be overridden by subclasses to use different heuristics .
25,672
public void error ( TransformerException exception ) throws TransformerException { if ( m_throwExceptionOnError ) throw exception ; else { PrintWriter pw = getErrorWriter ( ) ; printLocation ( pw , exception ) ; pw . println ( exception . getMessage ( ) ) ; } }
Receive notification of a recoverable error .
25,673
private void readInput ( ) { if ( buf . limit ( ) == buf . capacity ( ) ) makeSpace ( ) ; int p = buf . position ( ) ; buf . position ( buf . limit ( ) ) ; buf . limit ( buf . capacity ( ) ) ; int n = 0 ; try { n = source . read ( buf ) ; } catch ( IOException ioe ) { lastException = ioe ; n = - 1 ; } if ( n == - 1 ) { sourceClosed = true ; needInput = false ; } if ( n > 0 ) needInput = false ; buf . limit ( buf . position ( ) ) ; buf . position ( p ) ; matcher . reset ( buf ) ; }
Tries to read more input . May block .
25,674
private boolean makeSpace ( ) { clearCaches ( ) ; int offset = savedScannerPosition == - 1 ? position : savedScannerPosition ; buf . position ( offset ) ; if ( offset > 0 ) { buf . compact ( ) ; translateSavedIndexes ( offset ) ; position -= offset ; buf . flip ( ) ; return true ; } int newSize = buf . capacity ( ) * 2 ; CharBuffer newBuf = CharBuffer . allocate ( newSize ) ; newBuf . put ( buf ) ; newBuf . flip ( ) ; translateSavedIndexes ( offset ) ; position -= offset ; buf = newBuf ; matcher . reset ( buf ) ; return true ; }
or else there will be space in the buffer
25,675
private boolean hasTokenInBuffer ( ) { matchValid = false ; matcher . usePattern ( delimPattern ) ; matcher . region ( position , buf . limit ( ) ) ; if ( matcher . lookingAt ( ) ) position = matcher . end ( ) ; if ( position == buf . limit ( ) ) return false ; return true ; }
means that there will be another token with or without more input .
25,676
private String findPatternInBuffer ( Pattern pattern , int horizon ) { matchValid = false ; matcher . usePattern ( pattern ) ; int bufferLimit = buf . limit ( ) ; int horizonLimit = - 1 ; int searchLimit = bufferLimit ; if ( horizon > 0 ) { horizonLimit = position + horizon ; if ( horizonLimit < bufferLimit ) searchLimit = horizonLimit ; } matcher . region ( position , searchLimit ) ; if ( matcher . find ( ) ) { if ( matcher . hitEnd ( ) && ( ! sourceClosed ) ) { if ( searchLimit != horizonLimit ) { needInput = true ; return null ; } if ( ( searchLimit == horizonLimit ) && matcher . requireEnd ( ) ) { needInput = true ; return null ; } } position = matcher . end ( ) ; return matcher . group ( ) ; } if ( sourceClosed ) return null ; if ( ( horizon == 0 ) || ( searchLimit != horizonLimit ) ) needInput = true ; return null ; }
Returns a match for the specified input pattern .
25,677
private String matchPatternInBuffer ( Pattern pattern ) { matchValid = false ; matcher . usePattern ( pattern ) ; matcher . region ( position , buf . limit ( ) ) ; if ( matcher . lookingAt ( ) ) { if ( matcher . hitEnd ( ) && ( ! sourceClosed ) ) { needInput = true ; return null ; } position = matcher . end ( ) ; return matcher . group ( ) ; } if ( sourceClosed ) return null ; needInput = true ; return null ; }
the current position
25,678
public void close ( ) { if ( closed ) return ; if ( source instanceof Closeable ) { try { ( ( Closeable ) source ) . close ( ) ; } catch ( IOException ioe ) { lastException = ioe ; } } sourceClosed = true ; source = null ; closed = true ; }
Closes this scanner .
25,679
public Scanner useLocale ( Locale locale ) { if ( locale . equals ( this . locale ) ) return this ; this . locale = locale ; DecimalFormat df = ( DecimalFormat ) NumberFormat . getNumberInstance ( locale ) ; DecimalFormatSymbols dfs = DecimalFormatSymbols . getInstance ( locale ) ; groupSeparator = "\\" + dfs . getGroupingSeparator ( ) ; decimalSeparator = "\\" + dfs . getDecimalSeparator ( ) ; nanString = "\\Q" + dfs . getNaN ( ) + "\\E" ; infinityString = "\\Q" + dfs . getInfinity ( ) + "\\E" ; positivePrefix = df . getPositivePrefix ( ) ; if ( positivePrefix . length ( ) > 0 ) positivePrefix = "\\Q" + positivePrefix + "\\E" ; negativePrefix = df . getNegativePrefix ( ) ; if ( negativePrefix . length ( ) > 0 ) negativePrefix = "\\Q" + negativePrefix + "\\E" ; positiveSuffix = df . getPositiveSuffix ( ) ; if ( positiveSuffix . length ( ) > 0 ) positiveSuffix = "\\Q" + positiveSuffix + "\\E" ; negativeSuffix = df . getNegativeSuffix ( ) ; if ( negativeSuffix . length ( ) > 0 ) negativeSuffix = "\\Q" + negativeSuffix + "\\E" ; integerPattern = null ; floatPattern = null ; return this ; }
Sets this scanner s locale to the specified locale .
25,680
public Scanner useRadix ( int radix ) { if ( ( radix < Character . MIN_RADIX ) || ( radix > Character . MAX_RADIX ) ) throw new IllegalArgumentException ( "radix:" + radix ) ; if ( this . defaultRadix == radix ) return this ; this . defaultRadix = radix ; integerPattern = null ; return this ; }
Sets this scanner s default radix to the specified radix .
25,681
private void setRadix ( int radix ) { if ( radix > Character . MAX_RADIX ) { throw new IllegalArgumentException ( "radix == " + radix ) ; } if ( this . radix != radix ) { integerPattern = null ; this . radix = radix ; } }
the default is left untouched .
25,682
public boolean hasNext ( ) { ensureOpen ( ) ; saveState ( ) ; while ( ! sourceClosed ) { if ( hasTokenInBuffer ( ) ) return revertState ( true ) ; readInput ( ) ; } boolean result = hasTokenInBuffer ( ) ; return revertState ( result ) ; }
Returns true if this scanner has another token in its input . This method may block while waiting for input to scan . The scanner does not advance past any input .
25,683
public boolean hasNext ( Pattern pattern ) { ensureOpen ( ) ; if ( pattern == null ) throw new NullPointerException ( ) ; hasNextPattern = null ; saveState ( ) ; while ( true ) { if ( getCompleteTokenInBuffer ( pattern ) != null ) { matchValid = true ; cacheResult ( ) ; return revertState ( true ) ; } if ( needInput ) readInput ( ) ; else return revertState ( false ) ; } }
Returns true if the next complete token matches the specified pattern . A complete token is prefixed and postfixed by input that matches the delimiter pattern . This method may block while waiting for input . The scanner does not advance past any input .
25,684
public boolean hasNextLine ( ) { saveState ( ) ; String result = findWithinHorizon ( linePattern ( ) , 0 ) ; if ( result != null ) { MatchResult mr = this . match ( ) ; String lineSep = mr . group ( 1 ) ; if ( lineSep != null ) { result = result . substring ( 0 , result . length ( ) - lineSep . length ( ) ) ; cacheResult ( result ) ; } else { cacheResult ( ) ; } } revertState ( ) ; return ( result != null ) ; }
Returns true if there is another line in the input of this scanner . This method may block while waiting for input . The scanner does not advance past any input .
25,685
public String nextLine ( ) { if ( hasNextPattern == linePattern ( ) ) return getCachedResult ( ) ; clearCaches ( ) ; String result = findWithinHorizon ( linePattern , 0 ) ; if ( result == null ) throw new NoSuchElementException ( "No line found" ) ; MatchResult mr = this . match ( ) ; String lineSep = mr . group ( 1 ) ; if ( lineSep != null ) result = result . substring ( 0 , result . length ( ) - lineSep . length ( ) ) ; if ( result == null ) throw new NoSuchElementException ( ) ; else return result ; }
Advances this scanner past the current line and returns the input that was skipped .
25,686
public String findWithinHorizon ( String pattern , int horizon ) { return findWithinHorizon ( patternCache . forName ( pattern ) , horizon ) ; }
Attempts to find the next occurrence of a pattern constructed from the specified string ignoring delimiters .
25,687
public String findWithinHorizon ( Pattern pattern , int horizon ) { ensureOpen ( ) ; if ( pattern == null ) throw new NullPointerException ( ) ; if ( horizon < 0 ) throw new IllegalArgumentException ( "horizon < 0" ) ; clearCaches ( ) ; while ( true ) { String token = findPatternInBuffer ( pattern , horizon ) ; if ( token != null ) { matchValid = true ; return token ; } if ( needInput ) readInput ( ) ; else break ; } return null ; }
Attempts to find the next occurrence of the specified pattern .
25,688
public Scanner skip ( Pattern pattern ) { ensureOpen ( ) ; if ( pattern == null ) throw new NullPointerException ( ) ; clearCaches ( ) ; while ( true ) { String token = matchPatternInBuffer ( pattern ) ; if ( token != null ) { matchValid = true ; position = matcher . end ( ) ; return this ; } if ( needInput ) readInput ( ) ; else throw new NoSuchElementException ( ) ; } }
Skips input that matches the specified pattern ignoring delimiters . This method will skip input if an anchored match of the specified pattern succeeds .
25,689
private String processIntegerToken ( String token ) { String result = token . replaceAll ( "" + groupSeparator , "" ) ; boolean isNegative = false ; int preLen = negativePrefix . length ( ) ; if ( ( preLen > 0 ) && result . startsWith ( negativePrefix ) ) { isNegative = true ; result = result . substring ( preLen ) ; } int sufLen = negativeSuffix . length ( ) ; if ( ( sufLen > 0 ) && result . endsWith ( negativeSuffix ) ) { isNegative = true ; result = result . substring ( result . length ( ) - sufLen , result . length ( ) ) ; } if ( isNegative ) result = "-" + result ; return result ; }
The integer token must be stripped of prefixes group separators and suffixes non ascii digits must be converted into ascii digits before parse will accept it .
25,690
private String processFloatToken ( String token ) { String result = token . replaceAll ( groupSeparator , "" ) ; if ( ! decimalSeparator . equals ( "\\." ) ) result = result . replaceAll ( decimalSeparator , "." ) ; boolean isNegative = false ; int preLen = negativePrefix . length ( ) ; if ( ( preLen > 0 ) && result . startsWith ( negativePrefix ) ) { isNegative = true ; result = result . substring ( preLen ) ; } int sufLen = negativeSuffix . length ( ) ; if ( ( sufLen > 0 ) && result . endsWith ( negativeSuffix ) ) { isNegative = true ; result = result . substring ( result . length ( ) - sufLen , result . length ( ) ) ; } if ( result . equals ( nanString ) ) result = "NaN" ; if ( result . equals ( infinityString ) ) result = "Infinity" ; if ( result . equals ( "\u221E" ) ) result = "Infinity" ; if ( isNegative ) result = "-" + result ; Matcher m = NON_ASCII_DIGIT . matcher ( result ) ; if ( m . find ( ) ) { StringBuilder inASCII = new StringBuilder ( ) ; for ( int i = 0 ; i < result . length ( ) ; i ++ ) { char nextChar = result . charAt ( i ) ; if ( Character . isDigit ( nextChar ) ) { int d = Character . digit ( nextChar , 10 ) ; if ( d != - 1 ) inASCII . append ( d ) ; else inASCII . append ( nextChar ) ; } else { inASCII . append ( nextChar ) ; } } result = inASCII . toString ( ) ; } return result ; }
The float token must be stripped of prefixes group separators and suffixes non ascii digits must be converted into ascii digits before parseFloat will accept it .
25,691
public Scanner reset ( ) { delimPattern = WHITESPACE_PATTERN ; useLocale ( Locale . getDefault ( Locale . Category . FORMAT ) ) ; useRadix ( 10 ) ; clearCaches ( ) ; return this ; }
Resets this scanner .
25,692
public void removeAttribute ( int index ) { int origMax = getLength ( ) - 1 ; super . removeAttribute ( index ) ; if ( index != origMax ) { System . arraycopy ( declared , index + 1 , declared , index , origMax - index ) ; System . arraycopy ( specified , index + 1 , specified , index , origMax - index ) ; } }
javadoc entirely from superclass
25,693
public void setDeclared ( int index , boolean value ) { if ( index < 0 || index >= getLength ( ) ) throw new ArrayIndexOutOfBoundsException ( "No attribute at index: " + index ) ; declared [ index ] = value ; }
Assign a value to the declared flag of a specific attribute . This is normally needed only for attributes of type CDATA including attributes whose type is changed to or from CDATA .
25,694
public void setSpecified ( int index , boolean value ) { if ( index < 0 || index >= getLength ( ) ) throw new ArrayIndexOutOfBoundsException ( "No attribute at index: " + index ) ; specified [ index ] = value ; }
Assign a value to the specified flag of a specific attribute . This is the only way this flag can be cleared except clearing by initialization with the copy constructor .
25,695
public Expression getArg ( int n ) { if ( n >= 0 && n < m_argVec . size ( ) ) return ( Expression ) m_argVec . elementAt ( n ) ; else return null ; }
Return the nth argument passed to the extension function .
25,696
public void callArgVisitors ( XPathVisitor visitor ) { for ( int i = 0 ; i < m_argVec . size ( ) ; i ++ ) { Expression exp = ( Expression ) m_argVec . elementAt ( i ) ; exp . callVisitors ( new ArgExtOwner ( exp ) , visitor ) ; } }
Call the visitors for the function arguments .
25,697
public void exprSetParent ( ExpressionNode n ) { super . exprSetParent ( n ) ; int nArgs = m_argVec . size ( ) ; for ( int i = 0 ; i < nArgs ; i ++ ) { Expression arg = ( Expression ) m_argVec . elementAt ( i ) ; arg . exprSetParent ( n ) ; } }
Set the parent node . For an extension function we also need to set the parent node for all argument expressions .
25,698
protected void reportWrongNumberArgs ( ) throws WrongNumberArgsException { String fMsg = XSLMessages . createXPATHMessage ( XPATHErrorResources . ER_INCORRECT_PROGRAMMER_ASSERTION , new Object [ ] { "Programmer's assertion: the method FunctionMultiArgs.reportWrongNumberArgs() should never be called." } ) ; throw new RuntimeException ( fMsg ) ; }
Constructs and throws a WrongNumberArgException with the appropriate message for this function object . This class supports an arbitrary number of arguments so this method must never be called .
25,699
public void execute ( TransformerImpl transformer ) throws TransformerException { try { SerializationHandler rth = transformer . getResultTreeHandler ( ) ; if ( m_disableOutputEscaping ) { rth . processingInstruction ( javax . xml . transform . Result . PI_DISABLE_OUTPUT_ESCAPING , "" ) ; } rth . characters ( m_ch , 0 , m_ch . length ) ; if ( m_disableOutputEscaping ) { rth . processingInstruction ( javax . xml . transform . Result . PI_ENABLE_OUTPUT_ESCAPING , "" ) ; } } catch ( SAXException se ) { throw new TransformerException ( se ) ; } }
Copy the text literal to the result tree .