idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
26,900 | public String getString ( int maxLength ) throws java . io . IOException { String result = null ; if ( fInputStream != null ) { StringBuilder sb = new StringBuilder ( ) ; char [ ] buffer = new char [ 1024 ] ; Reader reader = getReader ( ) ; int max = maxLength < 0 ? Integer . MAX_VALUE : maxLength ; int bytesRead = 0 ; while ( ( bytesRead = reader . read ( buffer , 0 , Math . min ( max , 1024 ) ) ) >= 0 ) { sb . append ( buffer , 0 , bytesRead ) ; max -= bytesRead ; } reader . close ( ) ; return sb . toString ( ) ; } else { String name = getName ( ) ; int startSuffix = name . indexOf ( "_rtl" ) < 0 ? name . indexOf ( "_ltr" ) : name . indexOf ( "_rtl" ) ; if ( startSuffix > 0 ) { name = name . substring ( 0 , startSuffix ) ; } result = new String ( fRawInput , name ) ; } return result ; } | Create a Java String from Unicode character data corresponding to the original byte data supplied to the Charset detect operation . The length of the returned string is limited to the specified size ; the string will be trunctated to this length if necessary . A limit value of zero or less is ignored and treated as no limit . |
26,901 | public InputFile getNextFile ( ) { for ( Iterator < String > iter = queuedNames . iterator ( ) ; iter . hasNext ( ) ; ) { String name = iter . next ( ) ; iter . remove ( ) ; processedNames . add ( name ) ; InputFile file = getFileForName ( name ) ; if ( file != null ) { return file ; } } return null ; } | Returns the next Java source file to be processed . Returns null if the queue is empty . |
26,902 | static void Print ( AddressBook addressBook ) { for ( Person person : addressBook . getPeopleList ( ) ) { System . out . println ( "Person ID: " + person . getId ( ) ) ; System . out . println ( " Name: " + person . getName ( ) ) ; if ( ! person . getEmail ( ) . isEmpty ( ) ) { System . out . println ( " E-mail address: " + person . getEmail ( ) ) ; } for ( Person . PhoneNumber phoneNumber : person . getPhonesList ( ) ) { switch ( phoneNumber . getType ( ) ) { case MOBILE : System . out . print ( " Mobile phone #: " ) ; break ; case HOME : System . out . print ( " Home phone #: " ) ; break ; case WORK : System . out . print ( " Work phone #: " ) ; break ; } System . out . println ( phoneNumber . getNumber ( ) ) ; } } } | Iterates though all people in the AddressBook and prints info about them . |
26,903 | public static void main ( String [ ] args ) throws Exception { if ( args . length != 1 ) { System . err . println ( "Usage: ListPeople ADDRESS_BOOK_FILE" ) ; System . exit ( - 1 ) ; } AddressBook addressBook = AddressBook . parseFrom ( new FileInputStream ( args [ 0 ] ) ) ; Print ( addressBook ) ; } | the information inside . |
26,904 | public int push ( int i ) { if ( ( m_firstFree + 1 ) >= m_mapSize ) { m_mapSize += m_blocksize ; int newMap [ ] = new int [ m_mapSize ] ; System . arraycopy ( m_map , 0 , newMap , 0 , m_firstFree + 1 ) ; m_map = newMap ; } m_map [ m_firstFree ] = i ; m_firstFree ++ ; return i ; } | Pushes an item onto the top of this stack . |
26,905 | public void encode ( DerOutputStream out ) throws IOException { DerValue derValue = new DerValue ( nameValue ) ; out . putDerValue ( derValue ) ; } | Encode the X400 name into the DerOutputStream . |
26,906 | public final void addElement ( Object value ) { if ( ( m_firstFree + 1 ) >= m_mapSize ) { m_mapSize += m_blocksize ; Object newMap [ ] = new Object [ m_mapSize ] ; System . arraycopy ( m_map , 0 , newMap , 0 , m_firstFree + 1 ) ; m_map = newMap ; } m_map [ m_firstFree ] = value ; m_firstFree ++ ; } | Append an object onto the vector . |
26,907 | public final boolean contains ( Object s ) { for ( int i = 0 ; i < m_firstFree ; i ++ ) { if ( m_map [ i ] == s ) return true ; } return false ; } | Tell if the table contains the given Object . |
26,908 | public static void dumpUnit ( CompilationUnit unit ) { String relativeOutputPath = unit . getMainTypeName ( ) . replace ( '.' , '/' ) + ".ast" ; File outputFile = new File ( unit . getEnv ( ) . options ( ) . fileUtil ( ) . getOutputDirectory ( ) , relativeOutputPath ) ; outputFile . getParentFile ( ) . mkdirs ( ) ; try ( FileOutputStream fout = new FileOutputStream ( outputFile ) ; OutputStreamWriter out = new OutputStreamWriter ( fout , "UTF-8" ) ) { out . write ( dump ( unit ) ) ; } catch ( IOException e ) { ErrorUtil . fatalError ( e , outputFile . getPath ( ) ) ; } } | Dumps a compilation unit to a file . The output file s path is the same as where translated files get written but with an ast suffix . |
26,909 | public static String dump ( TreeNode node ) { DebugASTDump dumper = new DebugASTDump ( ) ; node . accept ( dumper ) ; dumper . sb . newline ( ) ; return dumper . toString ( ) ; } | Dumps an AST node as a string . |
26,910 | private int compareMagnitude ( BigDecimal val ) { long ys = val . intCompact ; long xs = this . intCompact ; if ( xs == 0 ) return ( ys == 0 ) ? 0 : - 1 ; if ( ys == 0 ) return 1 ; long sdiff = ( long ) this . scale - val . scale ; if ( sdiff != 0 ) { long xae = ( long ) this . precision ( ) - this . scale ; long yae = ( long ) val . precision ( ) - val . scale ; if ( xae < yae ) return - 1 ; if ( xae > yae ) return 1 ; BigInteger rb = null ; if ( sdiff < 0 ) { if ( sdiff > Integer . MIN_VALUE && ( xs == INFLATED || ( xs = longMultiplyPowerTen ( xs , ( int ) - sdiff ) ) == INFLATED ) && ys == INFLATED ) { rb = bigMultiplyPowerTen ( ( int ) - sdiff ) ; return rb . compareMagnitude ( val . intVal ) ; } } else { if ( sdiff <= Integer . MAX_VALUE && ( ys == INFLATED || ( ys = longMultiplyPowerTen ( ys , ( int ) sdiff ) ) == INFLATED ) && xs == INFLATED ) { rb = val . bigMultiplyPowerTen ( ( int ) sdiff ) ; return this . intVal . compareMagnitude ( rb ) ; } } } if ( xs != INFLATED ) return ( ys != INFLATED ) ? longCompareMagnitude ( xs , ys ) : - 1 ; else if ( ys != INFLATED ) return 1 ; else return this . intVal . compareMagnitude ( val . intVal ) ; } | Version of compareTo that ignores sign . |
26,911 | private static int bigDigitLength ( BigInteger b ) { if ( b . signum == 0 ) return 1 ; int r = ( int ) ( ( ( ( long ) b . bitLength ( ) + 1 ) * 646456993 ) >>> 31 ) ; return b . compareMagnitude ( bigTenToThe ( r ) ) < 0 ? r : r + 1 ; } | Returns the length of the absolute value of a BigInteger in decimal digits . |
26,912 | private int checkScale ( long val ) { int asInt = ( int ) val ; if ( asInt != val ) { asInt = val > Integer . MAX_VALUE ? Integer . MAX_VALUE : Integer . MIN_VALUE ; BigInteger b ; if ( intCompact != 0 && ( ( b = intVal ) == null || b . signum ( ) != 0 ) ) throw new ArithmeticException ( asInt > 0 ? "Underflow" : "Overflow" ) ; } return asInt ; } | Check a scale for Underflow or Overflow . If this BigDecimal is nonzero throw an exception if the scale is outof range . If this is zero saturate the scale to the extreme value of the right sign if the scale is out of range . |
26,913 | private static boolean commonNeedIncrement ( int roundingMode , int qsign , int cmpFracHalf , boolean oddQuot ) { switch ( roundingMode ) { case ROUND_UNNECESSARY : throw new ArithmeticException ( "Rounding necessary" ) ; case ROUND_UP : return true ; case ROUND_DOWN : return false ; case ROUND_CEILING : return qsign > 0 ; case ROUND_FLOOR : return qsign < 0 ; default : assert roundingMode >= ROUND_HALF_UP && roundingMode <= ROUND_HALF_EVEN : "Unexpected rounding mode" + RoundingMode . valueOf ( roundingMode ) ; if ( cmpFracHalf < 0 ) return false ; else if ( cmpFracHalf > 0 ) return true ; else { assert cmpFracHalf == 0 ; switch ( roundingMode ) { case ROUND_HALF_DOWN : return false ; case ROUND_HALF_UP : return true ; case ROUND_HALF_EVEN : return oddQuot ; default : throw new AssertionError ( "Unexpected rounding mode" + roundingMode ) ; } } } } | Shared logic of need increment computation . |
26,914 | private final int yearType ( int year ) { int yearLength = handleGetYearLength ( year ) ; if ( yearLength > 380 ) { yearLength -= 30 ; } int type = 0 ; switch ( yearLength ) { case 353 : type = 0 ; break ; case 354 : type = 1 ; break ; case 355 : type = 2 ; break ; default : throw new IllegalArgumentException ( "Illegal year length " + yearLength + " in year " + year ) ; } return type ; } | Returns the the type of a given year . 0 Deficient year with 353 or 383 days 1 Normal year with 354 or 384 days 2 Complete year with 355 or 385 days |
26,915 | protected int handleGetMonthLength ( int extendedYear , int month ) { while ( month < 0 ) { month += monthsInYear ( -- extendedYear ) ; } while ( month > 12 ) { month -= monthsInYear ( extendedYear ++ ) ; } switch ( month ) { case HESHVAN : case KISLEV : return MONTH_LENGTH [ month ] [ yearType ( extendedYear ) ] ; default : return MONTH_LENGTH [ month ] [ 0 ] ; } } | Returns the length of the given month in the given year |
26,916 | public Hashtable getEnvironmentHash ( ) { Hashtable hash = new Hashtable ( ) ; checkJAXPVersion ( hash ) ; checkProcessorVersion ( hash ) ; checkParserVersion ( hash ) ; checkAntVersion ( hash ) ; checkDOMVersion ( hash ) ; checkSAXVersion ( hash ) ; checkSystemProperties ( hash ) ; return hash ; } | Fill a hash with basic environment settings that affect Xalan . |
26,917 | protected boolean writeEnvironmentReport ( Hashtable h ) { if ( null == h ) { logMsg ( "# ERROR: writeEnvironmentReport called with null Hashtable" ) ; return false ; } boolean errors = false ; logMsg ( "#---- BEGIN writeEnvironmentReport($Revision: 468646 $): Useful stuff found: ----" ) ; for ( Enumeration keys = h . keys ( ) ; keys . hasMoreElements ( ) ; ) { Object key = keys . nextElement ( ) ; String keyStr = ( String ) key ; try { if ( keyStr . startsWith ( FOUNDCLASSES ) ) { Vector v = ( Vector ) h . get ( keyStr ) ; errors |= logFoundJars ( v , keyStr ) ; } else { if ( keyStr . startsWith ( ERROR ) ) { errors = true ; } logMsg ( keyStr + "=" + h . get ( keyStr ) ) ; } } catch ( Exception e ) { logMsg ( "Reading-" + key + "= threw: " + e . toString ( ) ) ; } } logMsg ( "#----- END writeEnvironmentReport: Useful properties found: -----" ) ; return errors ; } | Dump a basic Xalan environment report to outWriter . |
26,918 | protected void checkSystemProperties ( Hashtable h ) { if ( null == h ) h = new Hashtable ( ) ; try { String javaVersion = System . getProperty ( "java.version" ) ; h . put ( "java.version" , javaVersion ) ; } catch ( SecurityException se ) { h . put ( "java.version" , "WARNING: SecurityException thrown accessing system version properties" ) ; } try { String cp = System . getProperty ( "java.class.path" ) ; h . put ( "java.class.path" , cp ) ; Vector classpathJars = checkPathForJars ( cp , jarNames ) ; if ( null != classpathJars ) h . put ( FOUNDCLASSES + "java.class.path" , classpathJars ) ; String othercp = System . getProperty ( "sun.boot.class.path" ) ; if ( null != othercp ) { h . put ( "sun.boot.class.path" , othercp ) ; classpathJars = checkPathForJars ( othercp , jarNames ) ; if ( null != classpathJars ) h . put ( FOUNDCLASSES + "sun.boot.class.path" , classpathJars ) ; } othercp = System . getProperty ( "java.ext.dirs" ) ; if ( null != othercp ) { h . put ( "java.ext.dirs" , othercp ) ; classpathJars = checkPathForJars ( othercp , jarNames ) ; if ( null != classpathJars ) h . put ( FOUNDCLASSES + "java.ext.dirs" , classpathJars ) ; } } catch ( SecurityException se2 ) { h . put ( "java.class.path" , "WARNING: SecurityException thrown accessing system classpath properties" ) ; } } | Fillin hash with info about SystemProperties . |
26,919 | protected Vector checkPathForJars ( String cp , String [ ] jars ) { if ( ( null == cp ) || ( null == jars ) || ( 0 == cp . length ( ) ) || ( 0 == jars . length ) ) return null ; Vector v = new Vector ( ) ; StringTokenizer st = new StringTokenizer ( cp , File . pathSeparator ) ; while ( st . hasMoreTokens ( ) ) { String filename = st . nextToken ( ) ; for ( int i = 0 ; i < jars . length ; i ++ ) { if ( filename . indexOf ( jars [ i ] ) > - 1 ) { File f = new File ( filename ) ; if ( f . exists ( ) ) { try { Hashtable h = new Hashtable ( 2 ) ; h . put ( jars [ i ] + "-path" , f . getAbsolutePath ( ) ) ; if ( ! ( "xalan.jar" . equalsIgnoreCase ( jars [ i ] ) ) ) { h . put ( jars [ i ] + "-apparent.version" , getApparentVersion ( jars [ i ] , f . length ( ) ) ) ; } v . addElement ( h ) ; } catch ( Exception e ) { } } else { Hashtable h = new Hashtable ( 2 ) ; h . put ( jars [ i ] + "-path" , WARNING + " Classpath entry: " + filename + " does not exist" ) ; h . put ( jars [ i ] + "-apparent.version" , CLASS_NOTPRESENT ) ; v . addElement ( h ) ; } } } } return v ; } | Cheap - o listing of specified . jars found in the classpath . |
26,920 | protected String getApparentVersion ( String jarName , long jarSize ) { String foundSize = ( String ) jarVersions . get ( new Long ( jarSize ) ) ; if ( ( null != foundSize ) && ( foundSize . startsWith ( jarName ) ) ) { return foundSize ; } else { if ( "xerces.jar" . equalsIgnoreCase ( jarName ) || "xercesImpl.jar" . equalsIgnoreCase ( jarName ) ) { return jarName + " " + WARNING + CLASS_PRESENT ; } else { return jarName + " " + CLASS_PRESENT ; } } } | Cheap - o method to determine the product version of a . jar . |
26,921 | protected void checkJAXPVersion ( Hashtable h ) { if ( null == h ) h = new Hashtable ( ) ; final Class noArgs [ ] = new Class [ 0 ] ; Class clazz = null ; try { final String JAXP1_CLASS = "javax.xml.parsers.DocumentBuilder" ; final String JAXP11_METHOD = "getDOMImplementation" ; clazz = ObjectFactory . findProviderClass ( JAXP1_CLASS , ObjectFactory . findClassLoader ( ) , true ) ; Method method = clazz . getMethod ( JAXP11_METHOD , noArgs ) ; h . put ( VERSION + "JAXP" , "1.1 or higher" ) ; } catch ( Exception e ) { if ( null != clazz ) { h . put ( ERROR + VERSION + "JAXP" , "1.0.1" ) ; h . put ( ERROR , ERROR_FOUND ) ; } else { h . put ( ERROR + VERSION + "JAXP" , CLASS_NOTPRESENT ) ; h . put ( ERROR , ERROR_FOUND ) ; } } } | Report version information about JAXP interfaces . |
26,922 | protected void checkProcessorVersion ( Hashtable h ) { if ( null == h ) h = new Hashtable ( ) ; try { final String XALAN1_VERSION_CLASS = "org.apache.xalan.xslt.XSLProcessorVersion" ; Class clazz = ObjectFactory . findProviderClass ( XALAN1_VERSION_CLASS , ObjectFactory . findClassLoader ( ) , true ) ; StringBuffer buf = new StringBuffer ( ) ; Field f = clazz . getField ( "PRODUCT" ) ; buf . append ( f . get ( null ) ) ; buf . append ( ';' ) ; f = clazz . getField ( "LANGUAGE" ) ; buf . append ( f . get ( null ) ) ; buf . append ( ';' ) ; f = clazz . getField ( "S_VERSION" ) ; buf . append ( f . get ( null ) ) ; buf . append ( ';' ) ; h . put ( VERSION + "xalan1" , buf . toString ( ) ) ; } catch ( Exception e1 ) { h . put ( VERSION + "xalan1" , CLASS_NOTPRESENT ) ; } try { final String XALAN2_VERSION_CLASS = "org.apache.xalan.processor.XSLProcessorVersion" ; Class clazz = ObjectFactory . findProviderClass ( XALAN2_VERSION_CLASS , ObjectFactory . findClassLoader ( ) , true ) ; StringBuffer buf = new StringBuffer ( ) ; Field f = clazz . getField ( "S_VERSION" ) ; buf . append ( f . get ( null ) ) ; h . put ( VERSION + "xalan2x" , buf . toString ( ) ) ; } catch ( Exception e2 ) { h . put ( VERSION + "xalan2x" , CLASS_NOTPRESENT ) ; } try { final String XALAN2_2_VERSION_CLASS = "org.apache.xalan.Version" ; final String XALAN2_2_VERSION_METHOD = "getVersion" ; final Class noArgs [ ] = new Class [ 0 ] ; Class clazz = ObjectFactory . findProviderClass ( XALAN2_2_VERSION_CLASS , ObjectFactory . findClassLoader ( ) , true ) ; Method method = clazz . getMethod ( XALAN2_2_VERSION_METHOD , noArgs ) ; Object returnValue = method . invoke ( null , new Object [ 0 ] ) ; h . put ( VERSION + "xalan2_2" , ( String ) returnValue ) ; } catch ( Exception e2 ) { h . put ( VERSION + "xalan2_2" , CLASS_NOTPRESENT ) ; } } | Report product version information from Xalan - J . |
26,923 | protected void checkParserVersion ( Hashtable h ) { if ( null == h ) h = new Hashtable ( ) ; try { final String XERCES1_VERSION_CLASS = "org.apache.xerces.framework.Version" ; Class clazz = ObjectFactory . findProviderClass ( XERCES1_VERSION_CLASS , ObjectFactory . findClassLoader ( ) , true ) ; Field f = clazz . getField ( "fVersion" ) ; String parserVersion = ( String ) f . get ( null ) ; h . put ( VERSION + "xerces1" , parserVersion ) ; } catch ( Exception e ) { h . put ( VERSION + "xerces1" , CLASS_NOTPRESENT ) ; } try { final String XERCES2_VERSION_CLASS = "org.apache.xerces.impl.Version" ; Class clazz = ObjectFactory . findProviderClass ( XERCES2_VERSION_CLASS , ObjectFactory . findClassLoader ( ) , true ) ; Field f = clazz . getField ( "fVersion" ) ; String parserVersion = ( String ) f . get ( null ) ; h . put ( VERSION + "xerces2" , parserVersion ) ; } catch ( Exception e ) { h . put ( VERSION + "xerces2" , CLASS_NOTPRESENT ) ; } try { final String CRIMSON_CLASS = "org.apache.crimson.parser.Parser2" ; Class clazz = ObjectFactory . findProviderClass ( CRIMSON_CLASS , ObjectFactory . findClassLoader ( ) , true ) ; h . put ( VERSION + "crimson" , CLASS_PRESENT ) ; } catch ( Exception e ) { h . put ( VERSION + "crimson" , CLASS_NOTPRESENT ) ; } } | Report product version information from common parsers . |
26,924 | protected void checkAntVersion ( Hashtable h ) { if ( null == h ) h = new Hashtable ( ) ; try { final String ANT_VERSION_CLASS = "org.apache.tools.ant.Main" ; final String ANT_VERSION_METHOD = "getAntVersion" ; final Class noArgs [ ] = new Class [ 0 ] ; Class clazz = ObjectFactory . findProviderClass ( ANT_VERSION_CLASS , ObjectFactory . findClassLoader ( ) , true ) ; Method method = clazz . getMethod ( ANT_VERSION_METHOD , noArgs ) ; Object returnValue = method . invoke ( null , new Object [ 0 ] ) ; h . put ( VERSION + "ant" , ( String ) returnValue ) ; } catch ( Exception e ) { h . put ( VERSION + "ant" , CLASS_NOTPRESENT ) ; } } | Report product version information from Ant . |
26,925 | protected void checkDOMVersion ( Hashtable h ) { if ( null == h ) h = new Hashtable ( ) ; final String DOM_LEVEL2_CLASS = "org.w3c.dom.Document" ; final String DOM_LEVEL2_METHOD = "createElementNS" ; final String DOM_LEVEL2WD_CLASS = "org.w3c.dom.Node" ; final String DOM_LEVEL2WD_METHOD = "supported" ; final String DOM_LEVEL2FD_CLASS = "org.w3c.dom.Node" ; final String DOM_LEVEL2FD_METHOD = "isSupported" ; final Class twoStringArgs [ ] = { java . lang . String . class , java . lang . String . class } ; try { Class clazz = ObjectFactory . findProviderClass ( DOM_LEVEL2_CLASS , ObjectFactory . findClassLoader ( ) , true ) ; Method method = clazz . getMethod ( DOM_LEVEL2_METHOD , twoStringArgs ) ; h . put ( VERSION + "DOM" , "2.0" ) ; try { clazz = ObjectFactory . findProviderClass ( DOM_LEVEL2WD_CLASS , ObjectFactory . findClassLoader ( ) , true ) ; method = clazz . getMethod ( DOM_LEVEL2WD_METHOD , twoStringArgs ) ; h . put ( ERROR + VERSION + "DOM.draftlevel" , "2.0wd" ) ; h . put ( ERROR , ERROR_FOUND ) ; } catch ( Exception e2 ) { try { clazz = ObjectFactory . findProviderClass ( DOM_LEVEL2FD_CLASS , ObjectFactory . findClassLoader ( ) , true ) ; method = clazz . getMethod ( DOM_LEVEL2FD_METHOD , twoStringArgs ) ; h . put ( VERSION + "DOM.draftlevel" , "2.0fd" ) ; } catch ( Exception e3 ) { h . put ( ERROR + VERSION + "DOM.draftlevel" , "2.0unknown" ) ; h . put ( ERROR , ERROR_FOUND ) ; } } } catch ( Exception e ) { h . put ( ERROR + VERSION + "DOM" , "ERROR attempting to load DOM level 2 class: " + e . toString ( ) ) ; h . put ( ERROR , ERROR_FOUND ) ; } } | Report version info from DOM interfaces . |
26,926 | protected void checkSAXVersion ( Hashtable h ) { if ( null == h ) h = new Hashtable ( ) ; final String SAX_VERSION1_CLASS = "org.xml.sax.Parser" ; final String SAX_VERSION1_METHOD = "parse" ; final String SAX_VERSION2_CLASS = "org.xml.sax.XMLReader" ; final String SAX_VERSION2_METHOD = "parse" ; final String SAX_VERSION2BETA_CLASSNF = "org.xml.sax.helpers.AttributesImpl" ; final String SAX_VERSION2BETA_METHODNF = "setAttributes" ; final Class oneStringArg [ ] = { java . lang . String . class } ; final Class attributesArg [ ] = { org . xml . sax . Attributes . class } ; try { Class clazz = ObjectFactory . findProviderClass ( SAX_VERSION2BETA_CLASSNF , ObjectFactory . findClassLoader ( ) , true ) ; Method method = clazz . getMethod ( SAX_VERSION2BETA_METHODNF , attributesArg ) ; h . put ( VERSION + "SAX" , "2.0" ) ; } catch ( Exception e ) { h . put ( ERROR + VERSION + "SAX" , "ERROR attempting to load SAX version 2 class: " + e . toString ( ) ) ; h . put ( ERROR , ERROR_FOUND ) ; try { Class clazz = ObjectFactory . findProviderClass ( SAX_VERSION2_CLASS , ObjectFactory . findClassLoader ( ) , true ) ; Method method = clazz . getMethod ( SAX_VERSION2_METHOD , oneStringArg ) ; h . put ( VERSION + "SAX-backlevel" , "2.0beta2-or-earlier" ) ; } catch ( Exception e2 ) { h . put ( ERROR + VERSION + "SAX" , "ERROR attempting to load SAX version 2 class: " + e . toString ( ) ) ; h . put ( ERROR , ERROR_FOUND ) ; try { Class clazz = ObjectFactory . findProviderClass ( SAX_VERSION1_CLASS , ObjectFactory . findClassLoader ( ) , true ) ; Method method = clazz . getMethod ( SAX_VERSION1_METHOD , oneStringArg ) ; h . put ( VERSION + "SAX-backlevel" , "1.0" ) ; } catch ( Exception e3 ) { h . put ( ERROR + VERSION + "SAX-backlevel" , "ERROR attempting to load SAX version 1 class: " + e3 . toString ( ) ) ; } } } } | Report version info from SAX interfaces . |
26,927 | private boolean authenticate ( byte method , InputStream in , BufferedOutputStream out ) throws IOException { return authenticate ( method , in , out , 0L ) ; } | Provides the authentication machanism required by the proxy . |
26,928 | public static VersionInfo getDataVersion ( ) { UResourceBundle icudatares = null ; try { icudatares = UResourceBundle . getBundleInstance ( ICUData . ICU_BASE_NAME , ICUDataVersion . U_ICU_VERSION_BUNDLE , ICUResourceBundle . ICU_DATA_CLASS_LOADER ) ; icudatares = icudatares . get ( ICUDataVersion . U_ICU_DATA_KEY ) ; } catch ( MissingResourceException ex ) { return null ; } return VersionInfo . getInstance ( icudatares . getString ( ) ) ; } | This function retrieves the data version from icuver and returns a VersionInfo object with that version information . |
26,929 | public static String getDisplayName ( String [ ] [ ] zoneStrings , String id , boolean daylight , int style ) { String [ ] needle = new String [ ] { id } ; int index = Arrays . binarySearch ( zoneStrings , needle , ZONE_STRINGS_COMPARATOR ) ; if ( index >= 0 ) { String [ ] row = zoneStrings [ index ] ; if ( daylight ) { return ( style == TimeZone . LONG ) ? row [ LONG_NAME_DST ] : row [ SHORT_NAME_DST ] ; } else { return ( style == TimeZone . LONG ) ? row [ LONG_NAME ] : row [ SHORT_NAME ] ; } } return null ; } | Returns the appropriate string from zoneStrings . Used with getZoneStrings . |
26,930 | public static String [ ] [ ] getZoneStrings ( Locale locale ) { if ( locale == null ) { locale = Locale . getDefault ( ) ; } return cachedZoneStrings . get ( locale ) ; } | Returns an array of time zone strings as used by DateFormatSymbols . getZoneStrings . |
26,931 | public void updateProgress ( long latestProgress , long expectedProgress ) { lastProgress = progress ; progress = latestProgress ; expected = expectedProgress ; if ( connected ( ) == false ) state = State . CONNECTED ; else state = State . UPDATE ; if ( lastProgress / threshold != progress / threshold ) { progressMonitor . updateProgress ( this ) ; } if ( expected != - 1 ) { if ( progress >= expected && progress != 0 ) close ( ) ; } } | Update progress . |
26,932 | public void startNonText ( StylesheetHandler handler ) throws org . xml . sax . SAXException { if ( this == handler . getCurrentProcessor ( ) ) { handler . popProcessor ( ) ; } int nChars = m_accumulator . length ( ) ; if ( ( nChars > 0 ) && ( ( null != m_xslTextElement ) || ! XMLCharacterRecognizer . isWhiteSpace ( m_accumulator ) ) || handler . isSpacePreserve ( ) ) { ElemTextLiteral elem = new ElemTextLiteral ( ) ; elem . setDOMBackPointer ( m_firstBackPointer ) ; elem . setLocaterInfo ( handler . getLocator ( ) ) ; try { elem . setPrefixes ( handler . getNamespaceSupport ( ) ) ; } catch ( TransformerException te ) { throw new org . xml . sax . SAXException ( te ) ; } boolean doe = ( null != m_xslTextElement ) ? m_xslTextElement . getDisableOutputEscaping ( ) : false ; elem . setDisableOutputEscaping ( doe ) ; elem . setPreserveSpace ( true ) ; char [ ] chars = new char [ nChars ] ; m_accumulator . getChars ( 0 , nChars , chars , 0 ) ; elem . setChars ( chars ) ; ElemTemplateElement parent = handler . getElemTemplateElement ( ) ; parent . appendChild ( elem ) ; } m_accumulator . setLength ( 0 ) ; m_firstBackPointer = null ; } | Receive notification of the start of the non - text event . This is sent to the current processor when any non - text event occurs . |
26,933 | public double match ( ULocale desired , ULocale desiredMax , ULocale supported , ULocale supportedMax ) { return matcherData . match ( desired , desiredMax , supported , supportedMax ) ; } | Returns a fraction between 0 and 1 where 1 means that the languages are a perfect match and 0 means that they are completely different . Note that the precise values may change over time ; no code should be made dependent on the values remaining constant . |
26,934 | public ULocale getBestMatch ( LocalePriorityList languageList ) { double bestWeight = 0 ; ULocale bestTableMatch = null ; double penalty = 0 ; OutputDouble matchWeight = new OutputDouble ( ) ; for ( final ULocale language : languageList ) { final ULocale matchLocale = getBestMatchInternal ( language , matchWeight ) ; final double weight = matchWeight . value * languageList . getWeight ( language ) - penalty ; if ( weight > bestWeight ) { bestWeight = weight ; bestTableMatch = matchLocale ; } penalty += 0.07000001 ; } if ( bestWeight < threshold ) { bestTableMatch = defaultLanguage ; } return bestTableMatch ; } | Get the best match for a LanguagePriorityList |
26,935 | private ULocale getBestMatchInternal ( ULocale languageCode , OutputDouble outputWeight ) { languageCode = canonicalize ( languageCode ) ; final ULocale maximized = addLikelySubtags ( languageCode ) ; if ( DEBUG ) { System . out . println ( "\ngetBestMatchInternal: " + languageCode + ";\t" + maximized ) ; } double bestWeight = 0 ; ULocale bestTableMatch = null ; String baseLanguage = maximized . getLanguage ( ) ; Set < R3 < ULocale , ULocale , Double > > searchTable = desiredLanguageToPossibleLocalesToMaxLocaleToData . get ( baseLanguage ) ; if ( searchTable != null ) { if ( DEBUG ) System . out . println ( "\tSearching: " + searchTable ) ; for ( final R3 < ULocale , ULocale , Double > tableKeyValue : searchTable ) { ULocale tableKey = tableKeyValue . get0 ( ) ; ULocale maxLocale = tableKeyValue . get1 ( ) ; Double matchedWeight = tableKeyValue . get2 ( ) ; final double match = match ( languageCode , maximized , tableKey , maxLocale ) ; if ( DEBUG ) { System . out . println ( "\t" + tableKeyValue + ";\t" + match + "\n" ) ; } final double weight = match * matchedWeight ; if ( weight > bestWeight ) { bestWeight = weight ; bestTableMatch = tableKey ; if ( weight > 0.999d ) { break ; } } } } if ( bestWeight < threshold ) { bestTableMatch = defaultLanguage ; } if ( outputWeight != null ) { outputWeight . value = bestWeight ; } return bestTableMatch ; } | Get the best match for an individual language code . |
26,936 | private void processMapping ( ) { for ( Entry < String , Set < String > > desiredToMatchingLanguages : matcherData . matchingLanguages ( ) . keyValuesSet ( ) ) { String desired = desiredToMatchingLanguages . getKey ( ) ; Set < String > supported = desiredToMatchingLanguages . getValue ( ) ; for ( R3 < ULocale , ULocale , Double > localeToMaxAndWeight : localeToMaxLocaleAndWeight ) { final ULocale key = localeToMaxAndWeight . get0 ( ) ; String lang = key . getLanguage ( ) ; if ( supported . contains ( lang ) ) { addFiltered ( desired , localeToMaxAndWeight ) ; } } } for ( R3 < ULocale , ULocale , Double > localeToMaxAndWeight : localeToMaxLocaleAndWeight ) { final ULocale key = localeToMaxAndWeight . get0 ( ) ; String lang = key . getLanguage ( ) ; addFiltered ( lang , localeToMaxAndWeight ) ; } } | We preprocess the data to get just the possible matches for each desired base language . |
26,937 | private ULocale addLikelySubtags ( ULocale languageCode ) { if ( languageCode . equals ( UNKNOWN_LOCALE ) ) { return UNKNOWN_LOCALE ; } final ULocale result = ULocale . addLikelySubtags ( languageCode ) ; if ( result == null || result . equals ( languageCode ) ) { final String language = languageCode . getLanguage ( ) ; final String script = languageCode . getScript ( ) ; final String region = languageCode . getCountry ( ) ; return new ULocale ( ( language . length ( ) == 0 ? "und" : language ) + "_" + ( script . length ( ) == 0 ? "Zzzz" : script ) + "_" + ( region . length ( ) == 0 ? "ZZ" : region ) ) ; } return result ; } | We need to add another method to addLikelySubtags that doesn t return null but instead substitutes Zzzz and ZZ if unknown . There are also a few cases where addLikelySubtags needs to have expanded data to handle all deprecated codes . |
26,938 | private static long calcSize ( long size , long skip , long limit ) { return size >= 0 ? Math . max ( - 1 , Math . min ( size - skip , limit ) ) : - 1 ; } | Calculates the sliced size given the current size number of elements skip and the number of elements to limit . |
26,939 | private static long calcSliceFence ( long skip , long limit ) { long sliceFence = limit >= 0 ? skip + limit : Long . MAX_VALUE ; return ( sliceFence >= 0 ) ? sliceFence : Long . MAX_VALUE ; } | Calculates the slice fence which is one past the index of the slice range |
26,940 | @ SuppressWarnings ( "unchecked" ) private static < P_IN > Spliterator < P_IN > sliceSpliterator ( StreamShape shape , Spliterator < P_IN > s , long skip , long limit ) { assert s . hasCharacteristics ( Spliterator . SUBSIZED ) ; long sliceFence = calcSliceFence ( skip , limit ) ; switch ( shape ) { case REFERENCE : return new StreamSpliterators . SliceSpliterator . OfRef < > ( s , skip , sliceFence ) ; case INT_VALUE : return ( Spliterator < P_IN > ) new StreamSpliterators . SliceSpliterator . OfInt ( ( Spliterator . OfInt ) s , skip , sliceFence ) ; case LONG_VALUE : return ( Spliterator < P_IN > ) new StreamSpliterators . SliceSpliterator . OfLong ( ( Spliterator . OfLong ) s , skip , sliceFence ) ; case DOUBLE_VALUE : return ( Spliterator < P_IN > ) new StreamSpliterators . SliceSpliterator . OfDouble ( ( Spliterator . OfDouble ) s , skip , sliceFence ) ; default : throw new IllegalStateException ( "Unknown shape " + shape ) ; } } | Creates a slice spliterator given a stream shape governing the spliterator type . Requires that the underlying Spliterator be SUBSIZED . |
26,941 | public String nextString ( ) throws NoSuchElementException , UResourceTypeMismatchException { if ( index < size ) { return bundle . getString ( index ++ ) ; } throw new NoSuchElementException ( ) ; } | Returns the next String of this iterator if this iterator object has at least one more element to provide |
26,942 | public MessagePattern parse ( String pattern ) { preParse ( pattern ) ; parseMessage ( 0 , 0 , 0 , ArgType . NONE ) ; postParse ( ) ; return this ; } | Parses a MessageFormat pattern string . |
26,943 | public MessagePattern parsePluralStyle ( String pattern ) { preParse ( pattern ) ; parsePluralOrSelectStyle ( ArgType . PLURAL , 0 , 0 ) ; postParse ( ) ; return this ; } | Parses a PluralFormat pattern string . |
26,944 | public MessagePattern parseSelectStyle ( String pattern ) { preParse ( pattern ) ; parsePluralOrSelectStyle ( ArgType . SELECT , 0 , 0 ) ; postParse ( ) ; return this ; } | Parses a SelectFormat pattern string . |
26,945 | public static int validateArgumentName ( String name ) { if ( ! PatternProps . isIdentifier ( name ) ) { return ARG_NAME_NOT_VALID ; } return parseArgNumber ( name , 0 , name . length ( ) ) ; } | Validates and parses an argument name or argument number string . An argument name must be a pattern identifier that is it must contain no Unicode Pattern_Syntax or Pattern_White_Space characters . If it only contains ASCII digits then it must be a small integer with no leading zero . |
26,946 | public boolean partSubstringMatches ( Part part , String s ) { return part . length == s . length ( ) && msg . regionMatches ( part . index , s , 0 , part . length ) ; } | Compares the part s substring with the input string s . |
26,947 | public double getNumericValue ( Part part ) { Part . Type type = part . type ; if ( type == Part . Type . ARG_INT ) { return part . value ; } else if ( type == Part . Type . ARG_DOUBLE ) { return numericValues . get ( part . value ) ; } else { return NO_NUMERIC_VALUE ; } } | Returns the numeric value associated with an ARG_INT or ARG_DOUBLE . |
26,948 | public int getLimitPartIndex ( int start ) { int limit = parts . get ( start ) . limitPartIndex ; if ( limit < start ) { return start ; } return limit ; } | Returns the index of the ARG|MSG_LIMIT part corresponding to the ARG|MSG_START at start . |
26,949 | @ SuppressWarnings ( "unchecked" ) public MessagePattern cloneAsThawed ( ) { MessagePattern newMsg ; try { newMsg = ( MessagePattern ) super . clone ( ) ; } catch ( CloneNotSupportedException e ) { throw new ICUCloneNotSupportedException ( e ) ; } newMsg . parts = ( ArrayList < Part > ) parts . clone ( ) ; if ( numericValues != null ) { newMsg . numericValues = ( ArrayList < Double > ) numericValues . clone ( ) ; } newMsg . frozen = false ; return newMsg ; } | Creates and returns an unfrozen copy of this object . |
26,950 | private static int parseArgNumber ( CharSequence s , int start , int limit ) { if ( start >= limit ) { return ARG_NAME_NOT_VALID ; } int number ; boolean badNumber ; char c = s . charAt ( start ++ ) ; if ( c == '0' ) { if ( start == limit ) { return 0 ; } else { number = 0 ; badNumber = true ; } } else if ( '1' <= c && c <= '9' ) { number = c - '0' ; badNumber = false ; } else { return ARG_NAME_NOT_NUMBER ; } while ( start < limit ) { c = s . charAt ( start ++ ) ; if ( '0' <= c && c <= '9' ) { if ( number >= Integer . MAX_VALUE / 10 ) { badNumber = true ; } number = number * 10 + ( c - '0' ) ; } else { return ARG_NAME_NOT_NUMBER ; } } if ( badNumber ) { return ARG_NAME_NOT_VALID ; } else { return number ; } } | Validates and parses an argument name or argument number string . This internal method assumes that the input substring is a pattern identifier . |
26,951 | private void parseDouble ( int start , int limit , boolean allowInfinity ) { assert start < limit ; for ( ; ; ) { int value = 0 ; int isNegative = 0 ; int index = start ; char c = msg . charAt ( index ++ ) ; if ( c == '-' ) { isNegative = 1 ; if ( index == limit ) { break ; } c = msg . charAt ( index ++ ) ; } else if ( c == '+' ) { if ( index == limit ) { break ; } c = msg . charAt ( index ++ ) ; } if ( c == 0x221e ) { if ( allowInfinity && index == limit ) { addArgDoublePart ( isNegative != 0 ? Double . NEGATIVE_INFINITY : Double . POSITIVE_INFINITY , start , limit - start ) ; return ; } else { break ; } } while ( '0' <= c && c <= '9' ) { value = value * 10 + ( c - '0' ) ; if ( value > ( Part . MAX_VALUE + isNegative ) ) { break ; } if ( index == limit ) { addPart ( Part . Type . ARG_INT , start , limit - start , isNegative != 0 ? - value : value ) ; return ; } c = msg . charAt ( index ++ ) ; } double numericValue = Double . parseDouble ( msg . substring ( start , limit ) ) ; addArgDoublePart ( numericValue , start , limit - start ) ; return ; } throw new NumberFormatException ( "Bad syntax for numeric value: " + msg . substring ( start , limit ) ) ; } | Parses a number from the specified message substring . |
26,952 | private int skipDouble ( int index ) { while ( index < msg . length ( ) ) { char c = msg . charAt ( index ) ; if ( ( c < '0' && "+-." . indexOf ( c ) < 0 ) || ( c > '9' && c != 'e' && c != 'E' && c != 0x221e ) ) { break ; } ++ index ; } return index ; } | Skips a sequence of characters that could occur in a double value . Does not fully parse or validate the value . |
26,953 | public static Normalizer2WithImpl getN2WithImpl ( int index ) { switch ( index ) { case 0 : return getNFCInstance ( ) . decomp ; case 1 : return getNFKCInstance ( ) . decomp ; case 2 : return getNFCInstance ( ) . comp ; case 3 : return getNFKCInstance ( ) . comp ; default : return null ; } } | For use in properties APIs . |
26,954 | Parsed copy ( ) { Parsed cloned = new Parsed ( ) ; cloned . fieldValues . putAll ( this . fieldValues ) ; cloned . zone = this . zone ; cloned . chrono = this . chrono ; cloned . leapSecond = this . leapSecond ; return cloned ; } | Creates a copy . |
26,955 | TemporalAccessor resolve ( ResolverStyle resolverStyle , Set < TemporalField > resolverFields ) { if ( resolverFields != null ) { fieldValues . keySet ( ) . retainAll ( resolverFields ) ; } this . resolverStyle = resolverStyle ; resolveFields ( ) ; resolveTimeLenient ( ) ; crossCheck ( ) ; resolvePeriod ( ) ; resolveFractional ( ) ; resolveInstant ( ) ; return this ; } | Resolves the fields in this context . |
26,956 | public int getValue ( int ch ) { if ( m_isCompacted_ || ch > UCharacter . MAX_VALUE || ch < 0 ) { return 0 ; } int block = m_index_ [ ch >> SHIFT_ ] ; return m_data_ [ Math . abs ( block ) + ( ch & MASK_ ) ] ; } | Gets a 32 bit data from the table data |
26,957 | public int getValue ( int ch , boolean [ ] inBlockZero ) { if ( m_isCompacted_ || ch > UCharacter . MAX_VALUE || ch < 0 ) { if ( inBlockZero != null ) { inBlockZero [ 0 ] = true ; } return 0 ; } int block = m_index_ [ ch >> SHIFT_ ] ; if ( inBlockZero != null ) { inBlockZero [ 0 ] = ( block == 0 ) ; } return m_data_ [ Math . abs ( block ) + ( ch & MASK_ ) ] ; } | Get a 32 bit data from the table data |
26,958 | public boolean setValue ( int ch , int value ) { if ( m_isCompacted_ || ch > UCharacter . MAX_VALUE || ch < 0 ) { return false ; } int block = getDataBlock ( ch ) ; if ( block < 0 ) { return false ; } m_data_ [ block + ( ch & MASK_ ) ] = value ; return true ; } | Sets a 32 bit data in the table data |
26,959 | public IntTrie serialize ( TrieBuilder . DataManipulate datamanipulate , Trie . DataManipulate triedatamanipulate ) { if ( datamanipulate == null ) { throw new IllegalArgumentException ( "Parameters can not be null" ) ; } if ( ! m_isCompacted_ ) { compact ( false ) ; fold ( datamanipulate ) ; compact ( true ) ; m_isCompacted_ = true ; } if ( m_dataLength_ >= MAX_DATA_LENGTH_ ) { throw new ArrayIndexOutOfBoundsException ( "Data length too small" ) ; } char index [ ] = new char [ m_indexLength_ ] ; int data [ ] = new int [ m_dataLength_ ] ; for ( int i = 0 ; i < m_indexLength_ ; i ++ ) { index [ i ] = ( char ) ( m_index_ [ i ] >>> INDEX_SHIFT_ ) ; } System . arraycopy ( m_data_ , 0 , data , 0 , m_dataLength_ ) ; int options = SHIFT_ | ( INDEX_SHIFT_ << OPTIONS_INDEX_SHIFT_ ) ; options |= OPTIONS_DATA_IS_32_BIT_ ; if ( m_isLatin1Linear_ ) { options |= OPTIONS_LATIN1_IS_LINEAR_ ; } return new IntTrie ( index , data , m_initialValue_ , options , triedatamanipulate ) ; } | Serializes the build table with 32 bit data |
26,960 | public int serialize ( OutputStream os , boolean reduceTo16Bits , TrieBuilder . DataManipulate datamanipulate ) throws IOException { if ( datamanipulate == null ) { throw new IllegalArgumentException ( "Parameters can not be null" ) ; } if ( ! m_isCompacted_ ) { compact ( false ) ; fold ( datamanipulate ) ; compact ( true ) ; m_isCompacted_ = true ; } int length ; if ( reduceTo16Bits ) { length = m_dataLength_ + m_indexLength_ ; } else { length = m_dataLength_ ; } if ( length >= MAX_DATA_LENGTH_ ) { throw new ArrayIndexOutOfBoundsException ( "Data length too small" ) ; } length = Trie . HEADER_LENGTH_ + 2 * m_indexLength_ ; if ( reduceTo16Bits ) { length += 2 * m_dataLength_ ; } else { length += 4 * m_dataLength_ ; } if ( os == null ) { return length ; } DataOutputStream dos = new DataOutputStream ( os ) ; dos . writeInt ( Trie . HEADER_SIGNATURE_ ) ; int options = Trie . INDEX_STAGE_1_SHIFT_ | ( Trie . INDEX_STAGE_2_SHIFT_ << Trie . HEADER_OPTIONS_INDEX_SHIFT_ ) ; if ( ! reduceTo16Bits ) { options |= Trie . HEADER_OPTIONS_DATA_IS_32_BIT_ ; } if ( m_isLatin1Linear_ ) { options |= Trie . HEADER_OPTIONS_LATIN1_IS_LINEAR_MASK_ ; } dos . writeInt ( options ) ; dos . writeInt ( m_indexLength_ ) ; dos . writeInt ( m_dataLength_ ) ; if ( reduceTo16Bits ) { for ( int i = 0 ; i < m_indexLength_ ; i ++ ) { int v = ( m_index_ [ i ] + m_indexLength_ ) >>> Trie . INDEX_STAGE_2_SHIFT_ ; dos . writeChar ( v ) ; } for ( int i = 0 ; i < m_dataLength_ ; i ++ ) { int v = m_data_ [ i ] & 0x0000ffff ; dos . writeChar ( v ) ; } } else { for ( int i = 0 ; i < m_indexLength_ ; i ++ ) { int v = ( m_index_ [ i ] ) >>> Trie . INDEX_STAGE_2_SHIFT_ ; dos . writeChar ( v ) ; } for ( int i = 0 ; i < m_dataLength_ ; i ++ ) { dos . writeInt ( m_data_ [ i ] ) ; } } return length ; } | Serializes the build table to an output stream . |
26,961 | private static final int findSameDataBlock ( int data [ ] , int dataLength , int otherBlock , int step ) { dataLength -= DATA_BLOCK_LENGTH ; for ( int block = 0 ; block <= dataLength ; block += step ) { if ( equal_int ( data , block , otherBlock , DATA_BLOCK_LENGTH ) ) { return block ; } } return - 1 ; } | Find the same data block |
26,962 | private final void fold ( DataManipulate manipulate ) { int leadIndexes [ ] = new int [ SURROGATE_BLOCK_COUNT_ ] ; int index [ ] = m_index_ ; System . arraycopy ( index , 0xd800 >> SHIFT_ , leadIndexes , 0 , SURROGATE_BLOCK_COUNT_ ) ; int block = 0 ; if ( m_leadUnitValue_ == m_initialValue_ ) { } else { block = allocDataBlock ( ) ; if ( block < 0 ) { throw new IllegalStateException ( "Internal error: Out of memory space" ) ; } fillBlock ( block , 0 , DATA_BLOCK_LENGTH , m_leadUnitValue_ , true ) ; block = - block ; } for ( int c = ( 0xd800 >> SHIFT_ ) ; c < ( 0xdc00 >> SHIFT_ ) ; ++ c ) { m_index_ [ c ] = block ; } int indexLength = BMP_INDEX_LENGTH_ ; for ( int c = 0x10000 ; c < 0x110000 ; ) { if ( index [ c >> SHIFT_ ] != 0 ) { c &= ~ 0x3ff ; block = findSameIndexBlock ( index , indexLength , c >> SHIFT_ ) ; int value = manipulate . getFoldedValue ( c , block + SURROGATE_BLOCK_COUNT_ ) ; if ( value != getValue ( UTF16 . getLeadSurrogate ( c ) ) ) { if ( ! setValue ( UTF16 . getLeadSurrogate ( c ) , value ) ) { throw new ArrayIndexOutOfBoundsException ( "Data table overflow" ) ; } if ( block == indexLength ) { System . arraycopy ( index , c >> SHIFT_ , index , indexLength , SURROGATE_BLOCK_COUNT_ ) ; indexLength += SURROGATE_BLOCK_COUNT_ ; } } c += 0x400 ; } else { c += DATA_BLOCK_LENGTH ; } } if ( indexLength >= MAX_INDEX_LENGTH_ ) { throw new ArrayIndexOutOfBoundsException ( "Index table overflow" ) ; } System . arraycopy ( index , BMP_INDEX_LENGTH_ , index , BMP_INDEX_LENGTH_ + SURROGATE_BLOCK_COUNT_ , indexLength - BMP_INDEX_LENGTH_ ) ; System . arraycopy ( leadIndexes , 0 , index , BMP_INDEX_LENGTH_ , SURROGATE_BLOCK_COUNT_ ) ; indexLength += SURROGATE_BLOCK_COUNT_ ; m_indexLength_ = indexLength ; } | Fold the normalization data for supplementary code points into a compact area on top of the BMP - part of the trie index with the lead surrogates indexing this compact area . |
26,963 | private void readObject ( ObjectInputStream s ) throws IOException , ClassNotFoundException { scope_ifname = null ; scope_ifname_set = false ; if ( getClass ( ) . getClassLoader ( ) != Class . class . getClassLoader ( ) ) { throw new SecurityException ( "invalid address type" ) ; } s . defaultReadObject ( ) ; if ( ifname != null && ! "" . equals ( ifname ) ) { try { scope_ifname = NetworkInterface . getByName ( ifname ) ; if ( scope_ifname == null ) { scope_id_set = false ; scope_ifname_set = false ; scope_id = 0 ; } else { try { scope_id = deriveNumericScope ( scope_ifname ) ; } catch ( UnknownHostException e ) { } } } catch ( SocketException e ) { } } ipaddress = ipaddress . clone ( ) ; if ( ipaddress . length != INADDRSZ ) { throw new InvalidObjectException ( "invalid address length: " + ipaddress . length ) ; } if ( holder ( ) . getFamily ( ) != AF_INET6 ) { throw new InvalidObjectException ( "invalid address family type" ) ; } } | restore the state of this object from stream including the scope information only if the scoped interface name is valid on this system |
26,964 | public boolean isAnyLocalAddress ( ) { byte test = 0x00 ; for ( int i = 0 ; i < INADDRSZ ; i ++ ) { test |= ipaddress [ i ] ; } return ( test == 0x00 ) ; } | Utility routine to check if the InetAddress in a wildcard address . |
26,965 | public boolean isLoopbackAddress ( ) { byte test = 0x00 ; for ( int i = 0 ; i < 15 ; i ++ ) { test |= ipaddress [ i ] ; } return ( test == 0x00 ) && ( ipaddress [ 15 ] == 0x01 ) ; } | Utility routine to check if the InetAddress is a loopback address . |
26,966 | public boolean isIPv4CompatibleAddress ( ) { if ( ( ipaddress [ 0 ] == 0x00 ) && ( ipaddress [ 1 ] == 0x00 ) && ( ipaddress [ 2 ] == 0x00 ) && ( ipaddress [ 3 ] == 0x00 ) && ( ipaddress [ 4 ] == 0x00 ) && ( ipaddress [ 5 ] == 0x00 ) && ( ipaddress [ 6 ] == 0x00 ) && ( ipaddress [ 7 ] == 0x00 ) && ( ipaddress [ 8 ] == 0x00 ) && ( ipaddress [ 9 ] == 0x00 ) && ( ipaddress [ 10 ] == 0x00 ) && ( ipaddress [ 11 ] == 0x00 ) ) { return true ; } return false ; } | Utility routine to check if the InetAddress is an IPv4 compatible IPv6 address . |
26,967 | private synchronized void writeObject ( java . io . ObjectOutputStream s ) throws IOException { if ( scope_ifname_set ) { ifname = scope_ifname . getName ( ) ; } s . defaultWriteObject ( ) ; } | default behavior is overridden in order to write the scope_ifname field as a String rather than a NetworkInterface which is not serializable |
26,968 | public void pushContext ( ) { Context2 parentContext = currentContext ; currentContext = parentContext . getChild ( ) ; if ( currentContext == null ) { currentContext = new Context2 ( parentContext ) ; } else { currentContext . setParent ( parentContext ) ; } } | Start a new Namespace context . |
26,969 | public String [ ] processName ( String qName , String [ ] parts , boolean isAttribute ) { String [ ] name = currentContext . processName ( qName , isAttribute ) ; if ( name == null ) return null ; System . arraycopy ( name , 0 , parts , 0 , 3 ) ; return parts ; } | Process a raw XML 1 . 0 name . |
26,970 | void declarePrefix ( String prefix , String uri ) { if ( ! tablesDirty ) { copyTables ( ) ; } if ( declarations == null ) { declarations = new Vector ( ) ; } prefix = prefix . intern ( ) ; uri = uri . intern ( ) ; if ( "" . equals ( prefix ) ) { if ( "" . equals ( uri ) ) { defaultNS = null ; } else { defaultNS = uri ; } } else { prefixTable . put ( prefix , uri ) ; uriTable . put ( uri , prefix ) ; } declarations . addElement ( prefix ) ; } | Declare a Namespace prefix for this context . |
26,971 | String [ ] processName ( String qName , boolean isAttribute ) { String name [ ] ; Hashtable table ; if ( isAttribute ) { if ( elementNameTable == null ) elementNameTable = new Hashtable ( ) ; table = elementNameTable ; } else { if ( attributeNameTable == null ) attributeNameTable = new Hashtable ( ) ; table = attributeNameTable ; } name = ( String [ ] ) table . get ( qName ) ; if ( name != null ) { return name ; } name = new String [ 3 ] ; int index = qName . indexOf ( ':' ) ; if ( index == - 1 ) { if ( isAttribute || defaultNS == null ) { name [ 0 ] = "" ; } else { name [ 0 ] = defaultNS ; } name [ 1 ] = qName . intern ( ) ; name [ 2 ] = name [ 1 ] ; } else { String prefix = qName . substring ( 0 , index ) ; String local = qName . substring ( index + 1 ) ; String uri ; if ( "" . equals ( prefix ) ) { uri = defaultNS ; } else { uri = ( String ) prefixTable . get ( prefix ) ; } if ( uri == null ) { return null ; } name [ 0 ] = uri ; name [ 1 ] = local . intern ( ) ; name [ 2 ] = qName . intern ( ) ; } table . put ( name [ 2 ] , name ) ; tablesDirty = true ; return name ; } | Process a raw XML 1 . 0 name in this context . |
26,972 | String getURI ( String prefix ) { if ( "" . equals ( prefix ) ) { return defaultNS ; } else if ( prefixTable == null ) { return null ; } else { return ( String ) prefixTable . get ( prefix ) ; } } | Look up the URI associated with a prefix in this context . |
26,973 | String getPrefix ( String uri ) { if ( uriTable == null ) { return null ; } else { return ( String ) uriTable . get ( uri ) ; } } | Look up one of the prefixes associated with a URI in this context . |
26,974 | private void copyTables ( ) { prefixTable = ( Hashtable ) prefixTable . clone ( ) ; uriTable = ( Hashtable ) uriTable . clone ( ) ; if ( elementNameTable != null ) elementNameTable = new Hashtable ( ) ; if ( attributeNameTable != null ) attributeNameTable = new Hashtable ( ) ; tablesDirty = true ; } | Copy on write for the internal tables in this context . |
26,975 | public String getMessage ( ) { String errnoName = OsConstants . errnoName ( errno ) ; if ( errnoName == null ) { errnoName = "errno " + errno ; } String description = Libcore . os . strerror ( errno ) ; return functionName + " failed: " + errnoName + " (" + description + ")" ; } | Converts the stashed function name and errno value to a human - readable string . We do this here rather than in the constructor so that callers only pay for this if they need it . |
26,976 | private static Collection < X509CRL > getCRLs ( X509CRLSelector selector , X509CertImpl certImpl , DistributionPoint point , boolean [ ] reasonsMask , boolean signFlag , PublicKey prevKey , X509Certificate prevCert , String provider , List < CertStore > certStores , Set < TrustAnchor > trustAnchors , Date validity ) throws CertStoreException { GeneralNames fullName = point . getFullName ( ) ; if ( fullName == null ) { RDN relativeName = point . getRelativeName ( ) ; if ( relativeName == null ) { return Collections . emptySet ( ) ; } try { GeneralNames crlIssuers = point . getCRLIssuer ( ) ; if ( crlIssuers == null ) { fullName = getFullNames ( ( X500Name ) certImpl . getIssuerDN ( ) , relativeName ) ; } else { if ( crlIssuers . size ( ) != 1 ) { return Collections . emptySet ( ) ; } else { fullName = getFullNames ( ( X500Name ) crlIssuers . get ( 0 ) . getName ( ) , relativeName ) ; } } } catch ( IOException ioe ) { return Collections . emptySet ( ) ; } } Collection < X509CRL > possibleCRLs = new ArrayList < > ( ) ; CertStoreException savedCSE = null ; for ( Iterator < GeneralName > t = fullName . iterator ( ) ; t . hasNext ( ) ; ) { try { GeneralName name = t . next ( ) ; if ( name . getType ( ) == GeneralNameInterface . NAME_DIRECTORY ) { X500Name x500Name = ( X500Name ) name . getName ( ) ; possibleCRLs . addAll ( getCRLs ( x500Name , certImpl . getIssuerX500Principal ( ) , certStores ) ) ; } else if ( name . getType ( ) == GeneralNameInterface . NAME_URI ) { URIName uriName = ( URIName ) name . getName ( ) ; X509CRL crl = getCRL ( uriName ) ; if ( crl != null ) { possibleCRLs . add ( crl ) ; } } } catch ( CertStoreException cse ) { savedCSE = cse ; } } if ( possibleCRLs . isEmpty ( ) && savedCSE != null ) { throw savedCSE ; } Collection < X509CRL > crls = new ArrayList < > ( 2 ) ; for ( X509CRL crl : possibleCRLs ) { try { selector . setIssuerNames ( null ) ; if ( selector . match ( crl ) && verifyCRL ( certImpl , point , crl , reasonsMask , signFlag , prevKey , prevCert , provider , trustAnchors , certStores , validity ) ) { crls . add ( crl ) ; } } catch ( IOException | CRLException e ) { if ( debug != null ) { debug . println ( "Exception verifying CRL: " + e . getMessage ( ) ) ; e . printStackTrace ( ) ; } } } return crls ; } | Download CRLs from the given distribution point verify and return them . See the top of the class for current limitations . |
26,977 | private static X509CRL getCRL ( URIName name ) throws CertStoreException { URI uri = name . getURI ( ) ; if ( debug != null ) { debug . println ( "Trying to fetch CRL from DP " + uri ) ; } CertStore ucs = null ; try { ucs = URICertStore . getInstance ( new URICertStore . URICertStoreParameters ( uri ) ) ; } catch ( InvalidAlgorithmParameterException | NoSuchAlgorithmException e ) { if ( debug != null ) { debug . println ( "Can't create URICertStore: " + e . getMessage ( ) ) ; } return null ; } Collection < ? extends CRL > crls = ucs . getCRLs ( null ) ; if ( crls . isEmpty ( ) ) { return null ; } else { return ( X509CRL ) crls . iterator ( ) . next ( ) ; } } | Download CRL from given URI . |
26,978 | private static Collection < X509CRL > getCRLs ( X500Name name , X500Principal certIssuer , List < CertStore > certStores ) throws CertStoreException { if ( debug != null ) { debug . println ( "Trying to fetch CRL from DP " + name ) ; } X509CRLSelector xcs = new X509CRLSelector ( ) ; xcs . addIssuer ( name . asX500Principal ( ) ) ; xcs . addIssuer ( certIssuer ) ; Collection < X509CRL > crls = new ArrayList < > ( ) ; CertStoreException savedCSE = null ; for ( CertStore store : certStores ) { try { for ( CRL crl : store . getCRLs ( xcs ) ) { crls . add ( ( X509CRL ) crl ) ; } } catch ( CertStoreException cse ) { if ( debug != null ) { debug . println ( "Exception while retrieving " + "CRLs: " + cse ) ; cse . printStackTrace ( ) ; } savedCSE = new PKIX . CertStoreTypeException ( store . getType ( ) , cse ) ; } } if ( crls . isEmpty ( ) && savedCSE != null ) { throw savedCSE ; } else { return crls ; } } | Fetch CRLs from certStores . |
26,979 | private static GeneralNames getFullNames ( X500Name issuer , RDN rdn ) throws IOException { List < RDN > rdns = new ArrayList < > ( issuer . rdns ( ) ) ; rdns . add ( rdn ) ; X500Name fullName = new X500Name ( rdns . toArray ( new RDN [ 0 ] ) ) ; GeneralNames fullNames = new GeneralNames ( ) ; fullNames . add ( new GeneralName ( fullName ) ) ; return fullNames ; } | Append relative name to the issuer name and return a new GeneralNames object . |
26,980 | private static boolean issues ( X509CertImpl cert , X509CRLImpl crl , String provider ) throws IOException { boolean matched = false ; AdaptableX509CertSelector issuerSelector = new AdaptableX509CertSelector ( ) ; boolean [ ] usages = cert . getKeyUsage ( ) ; if ( usages != null ) { usages [ 6 ] = true ; issuerSelector . setKeyUsage ( usages ) ; } X500Principal crlIssuer = crl . getIssuerX500Principal ( ) ; issuerSelector . setSubject ( crlIssuer ) ; AuthorityKeyIdentifierExtension crlAKID = crl . getAuthKeyIdExtension ( ) ; if ( crlAKID != null ) { issuerSelector . parseAuthorityKeyIdentifierExtension ( crlAKID ) ; } matched = issuerSelector . match ( cert ) ; if ( matched && ( crlAKID == null || cert . getAuthorityKeyIdentifierExtension ( ) == null ) ) { try { crl . verify ( cert . getPublicKey ( ) , provider ) ; matched = true ; } catch ( GeneralSecurityException e ) { matched = false ; } } return matched ; } | Verifies whether a CRL is issued by a certain certificate |
26,981 | public void addUnchanged ( int unchangedLength ) { if ( unchangedLength < 0 ) { throw new IllegalArgumentException ( "addUnchanged(" + unchangedLength + "): length must not be negative" ) ; } int last = lastUnit ( ) ; if ( last < MAX_UNCHANGED ) { int remaining = MAX_UNCHANGED - last ; if ( remaining >= unchangedLength ) { setLastUnit ( last + unchangedLength ) ; return ; } setLastUnit ( MAX_UNCHANGED ) ; unchangedLength -= remaining ; } while ( unchangedLength >= MAX_UNCHANGED_LENGTH ) { append ( MAX_UNCHANGED ) ; unchangedLength -= MAX_UNCHANGED_LENGTH ; } if ( unchangedLength > 0 ) { append ( unchangedLength - 1 ) ; } } | Adds a record for an unchanged segment of text . Normally called from inside ICU string transformation functions not user code . |
26,982 | public static int skipWhiteSpace ( CharSequence s , int i ) { while ( i < s . length ( ) && isWhiteSpace ( s . charAt ( i ) ) ) { ++ i ; } return i ; } | Skips over Pattern_White_Space starting at index i of the CharSequence . |
26,983 | public static boolean isIdentifier ( CharSequence s ) { int limit = s . length ( ) ; if ( limit == 0 ) { return false ; } int start = 0 ; do { if ( isSyntaxOrWhiteSpace ( s . charAt ( start ++ ) ) ) { return false ; } } while ( start < limit ) ; return true ; } | Tests whether the CharSequence contains a pattern identifier that is whether it contains only non - Pattern_White_Space non - Pattern_Syntax characters . |
26,984 | public static int skipIdentifier ( CharSequence s , int i ) { while ( i < s . length ( ) && ! isSyntaxOrWhiteSpace ( s . charAt ( i ) ) ) { ++ i ; } return i ; } | Skips over a pattern identifier starting at index i of the CharSequence . |
26,985 | public DurationFormatterFactory setPeriodFormatter ( PeriodFormatter formatter ) { if ( formatter != this . formatter ) { this . formatter = formatter ; reset ( ) ; } return this ; } | Set the period formatter used by the factory . New formatters created with this factory will use the given period formatter . |
26,986 | public DurationFormatterFactory setPeriodBuilder ( PeriodBuilder builder ) { if ( builder != this . builder ) { this . builder = builder ; reset ( ) ; } return this ; } | Set the builder used by the factory . New formatters created with this factory will use the given locale . |
26,987 | public DurationFormatterFactory setFallback ( DateFormatter fallback ) { boolean doReset = fallback == null ? this . fallback != null : ! fallback . equals ( this . fallback ) ; if ( doReset ) { this . fallback = fallback ; reset ( ) ; } return this ; } | Set a fallback formatter for durations over a given limit . |
26,988 | public DurationFormatterFactory setFallbackLimit ( long fallbackLimit ) { if ( fallbackLimit < 0 ) { fallbackLimit = 0 ; } if ( fallbackLimit != this . fallbackLimit ) { this . fallbackLimit = fallbackLimit ; reset ( ) ; } return this ; } | Set a fallback limit for durations over a given limit . |
26,989 | public DurationFormatter getFormatter ( ) { if ( f == null ) { if ( fallback != null ) { fallback = fallback . withLocale ( localeName ) . withTimeZone ( timeZone ) ; } formatter = getPeriodFormatter ( ) ; builder = getPeriodBuilder ( ) ; f = createFormatter ( ) ; } return f ; } | Return a formatter based on this factory s current settings . |
26,990 | public PeriodFormatter getPeriodFormatter ( ) { if ( formatter == null ) { formatter = ps . newPeriodFormatterFactory ( ) . setLocale ( localeName ) . getFormatter ( ) ; } return formatter ; } | Return the current period formatter . |
26,991 | public PeriodBuilder getPeriodBuilder ( ) { if ( builder == null ) { builder = ps . newPeriodBuilderFactory ( ) . setLocale ( localeName ) . setTimeZone ( timeZone ) . getSingleUnitBuilder ( ) ; } return builder ; } | Return the current builder . |
26,992 | public boolean [ ] getKeyUsageMappedBits ( ) { KeyUsageExtension keyUsage = new KeyUsageExtension ( ) ; Boolean val = Boolean . TRUE ; try { if ( isSet ( getPosition ( SSL_CLIENT ) ) || isSet ( getPosition ( S_MIME ) ) || isSet ( getPosition ( OBJECT_SIGNING ) ) ) keyUsage . set ( KeyUsageExtension . DIGITAL_SIGNATURE , val ) ; if ( isSet ( getPosition ( SSL_SERVER ) ) ) keyUsage . set ( KeyUsageExtension . KEY_ENCIPHERMENT , val ) ; if ( isSet ( getPosition ( SSL_CA ) ) || isSet ( getPosition ( S_MIME_CA ) ) || isSet ( getPosition ( OBJECT_SIGNING_CA ) ) ) keyUsage . set ( KeyUsageExtension . KEY_CERTSIGN , val ) ; } catch ( IOException e ) { } return keyUsage . getBits ( ) ; } | Get a boolean array representing the bits of this extension as it maps to the KeyUsage extension . |
26,993 | public int next ( int options ) { int c = DONE ; isEscaped = false ; for ( ; ; ) { c = _current ( ) ; _advance ( UTF16 . getCharCount ( c ) ) ; if ( c == SymbolTable . SYMBOL_REF && buf == null && ( options & PARSE_VARIABLES ) != 0 && sym != null ) { String name = sym . parseReference ( text , pos , text . length ( ) ) ; if ( name == null ) { break ; } bufPos = 0 ; buf = sym . lookup ( name ) ; if ( buf == null ) { throw new IllegalArgumentException ( "Undefined variable: " + name ) ; } if ( buf . length == 0 ) { buf = null ; } continue ; } if ( ( options & SKIP_WHITESPACE ) != 0 && PatternProps . isWhiteSpace ( c ) ) { continue ; } if ( c == '\\' && ( options & PARSE_ESCAPES ) != 0 ) { int offset [ ] = new int [ ] { 0 } ; c = Utility . unescapeAt ( lookahead ( ) , offset ) ; jumpahead ( offset [ 0 ] ) ; isEscaped = true ; if ( c < 0 ) { throw new IllegalArgumentException ( "Invalid escape" ) ; } } break ; } return c ; } | Returns the next character using the given options or DONE if there are no more characters and advance the position to the next character . |
26,994 | private int _current ( ) { if ( buf != null ) { return UTF16 . charAt ( buf , 0 , buf . length , bufPos ) ; } else { int i = pos . getIndex ( ) ; return ( i < text . length ( ) ) ? UTF16 . charAt ( text , i ) : DONE ; } } | Returns the current 32 - bit code point without parsing escapes parsing variables or skipping whitespace . |
26,995 | private void _advance ( int count ) { if ( buf != null ) { bufPos += count ; if ( bufPos == buf . length ) { buf = null ; } } else { pos . setIndex ( pos . getIndex ( ) + count ) ; if ( pos . getIndex ( ) > text . length ( ) ) { pos . setIndex ( text . length ( ) ) ; } } } | Advances the position by the given amount . |
26,996 | public static String getISO3Country ( String country ) { int offset = findIndex ( _countries , country ) ; if ( offset >= 0 ) { return _countries3 [ offset ] ; } else { offset = findIndex ( _obsoleteCountries , country ) ; if ( offset >= 0 ) { return _obsoleteCountries3 [ offset ] ; } } return "" ; } | Returns a three - letter abbreviation for the provided country . If the provided country is empty returns the empty string . Otherwise returns an uppercase ISO 3166 3 - letter country code . |
26,997 | private static int findIndex ( String [ ] array , String target ) { for ( int i = 0 ; i < array . length ; i ++ ) { if ( target . equals ( array [ i ] ) ) { return i ; } } return - 1 ; } | linear search of the string array . the arrays are unfortunately ordered by the two - letter target code not the three - letter search code which seems backwards . |
26,998 | public void setFeature ( String name , boolean value ) throws SAXNotRecognizedException , SAXNotSupportedException { if ( parent != null ) { parent . setFeature ( name , value ) ; } else { throw new SAXNotRecognizedException ( "Feature: " + name ) ; } } | Set the value of a feature . |
26,999 | public void init ( Compiler compiler , int opPos , int stepType ) throws javax . xml . transform . TransformerException { super . init ( compiler , opPos , stepType ) ; switch ( stepType ) { case OpCodes . OP_FUNCTION : case OpCodes . OP_EXTFUNCTION : m_mustHardReset = true ; case OpCodes . OP_GROUP : case OpCodes . OP_VARIABLE : m_expr = compiler . compile ( opPos ) ; m_expr . exprSetParent ( this ) ; if ( m_expr instanceof org . apache . xpath . operations . Variable ) { m_canDetachNodeset = false ; } break ; default : m_expr = compiler . compile ( opPos + 2 ) ; m_expr . exprSetParent ( this ) ; } } | Init a FilterExprWalker . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.