[llvm-commits] [llvm-gcc-4.2] r43913 [42/80] - in /llvm-gcc-4.2/trunk: boehm-gc/ boehm-gc/Mac_files/ boehm-gc/cord/ boehm-gc/doc/ boehm-gc/include/ boehm-gc/include/private/ boehm-gc/tests/ libffi/ libffi/include/ libffi/src/ libffi/src/alpha/ libffi/src/arm/ libffi/src/cris/ libffi/src/frv/ libffi/src/ia64/ libffi/src/m32r/ libffi/src/m68k/ libffi/src/mips/ libffi/src/pa/ libffi/src/powerpc/ libffi/src/s390/ libffi/src/sh/ libffi/src/sh64/ libffi/src/sparc/ libffi/src/x86/ libffi/testsuite/ libffi/testsuite/config/ li...

Bill Wendling isanbard at gmail.com
Thu Nov 8 14:57:11 PST 2007


Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/DatabaseMetaData.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/DatabaseMetaData.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/DatabaseMetaData.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/DatabaseMetaData.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,2270 @@
+/* DatabaseMetaData.java -- Information about the database itself.
+   Copyright (C) 1999, 2000, 2001, 2002, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.sql;
+
+public interface DatabaseMetaData 
+{
+  /**
+   * It is unknown whether or not the procedure returns a result.
+   */
+  int procedureResultUnknown = 0;
+
+  /**
+   * The procedure does not return a result.
+   */
+  int procedureNoResult = 1;
+
+  /**
+   * The procedure returns a result.
+   */
+  int procedureReturnsResult = 2;
+
+  /**
+   * The column type is unknown.
+   */
+  int procedureColumnUnknown = 0;
+
+  /**
+   * The column type is input.
+   */
+  int procedureColumnIn = 1;
+
+  /**
+   * The column type is input/output.
+   */
+  int procedureColumnInOut = 2;
+
+  /**
+   * The column type is output
+   */
+  int procedureColumnOut = 4;
+
+  /**
+   * The column is used for return values.
+   */
+  int procedureColumnReturn = 5;
+
+  /**
+   * The column is used for storing results
+   */
+  int procedureColumnResult = 3;
+
+  /**
+   * NULL values are not allowed.
+   */
+  int procedureNoNulls = 0;
+
+  /**
+   * NULL values are allowed.
+   */
+  int procedureNullable = 1;
+
+  /**
+   * It is unknown whether or not NULL values are allowed.
+   */
+  int procedureNullableUnknown = 2;
+
+  /**
+   * The column does not allow NULL
+   */
+  int columnNoNulls = 0;
+
+  /**
+   * The column does allow NULL
+   */
+  int columnNullable = 1;
+
+  /**
+   * It is unknown whether or not the column allows NULL
+   */
+  int columnNullableUnknown = 2;
+
+  /**
+   * The best row's scope is only guaranteed to be valid so long as the
+   * row is actually being used.
+   */
+  int bestRowTemporary = 0;
+
+  /**
+   * The best row identifier is valid to the end of the transaction.
+   */
+  int bestRowTransaction = 1;
+
+  /**
+   * The best row identifier is valid to the end of the session.
+   */
+  int bestRowSession = 2;
+
+  /**
+   * The best row may or may not be a pseudo-column.
+   */
+  int bestRowUnknown = 0;
+
+  /**
+   * The best row identifier is not a pseudo-column.
+   */
+  int bestRowNotPseudo = 1;
+
+  /**
+   * The best row identifier is a pseudo-column.
+   */
+  int bestRowPseudo = 2;
+
+  /**
+   * It is unknown whether or not the version column is a pseudo-column.
+   */
+  int versionColumnUnknown = 0;
+
+  /**
+   * The version column is not a pseudo-column
+   */
+  int versionColumnNotPseudo = 1;
+
+  /**
+   * The version column is a pseudo-column
+   */
+  int versionColumnPseudo = 2;
+
+  /**
+   * Foreign key changes are cascaded in updates or deletes.
+   */
+  int importedKeyCascade = 0;
+
+  /**
+   * Column may not be updated or deleted in use as a foreign key.
+   */
+  int importedKeyRestrict = 1;
+
+  /**
+   * When primary key is updated or deleted, the foreign key is set to NULL.
+   */
+  int importedKeySetNull = 2;
+
+  /**
+   * If the primary key is a foreign key, it cannot be udpated or deleted.
+   */
+  int importedKeyNoAction = 3;
+
+  /**
+   * If the primary key is updated or deleted, the foreign key is set to
+   * a default value.
+   */
+  int importedKeySetDefault = 4;
+
+  /**
+   * Wish I knew what this meant.
+   */
+  int importedKeyInitiallyDeferred = 5;
+
+  /**
+   * Wish I knew what this meant.
+   */
+  int importedKeyInitiallyImmediate = 6;
+
+  /**
+   * Wish I knew what this meant.
+   */
+  int importedKeyNotDeferrable = 7;
+
+  /**
+   * A NULL value is not allowed for this data type.
+   */
+  int typeNoNulls = 0;
+
+  /**
+   * A NULL value is allowed for this data type.
+   */
+  int typeNullable = 1;
+
+  /**
+   * It is unknown whether or not NULL values are allowed for this data type.
+   */
+  int typeNullableUnknown = 2;
+
+  /**
+   * Where clauses are not supported for this type.
+   */
+  int typePredNone = 0;
+
+  /**
+   * Only "WHERE..LIKE" style WHERE clauses are allowed on this data type.
+   */
+  int typePredChar = 1;
+
+  /**
+   * All WHERE clauses except "WHERE..LIKE" style are allowed on this data type.
+   */
+  int typePredBasic = 2;
+
+  /**
+   * Any type of WHERE clause is allowed for this data type.
+   */
+  int typeSearchable = 3;
+
+  /**
+   * This column contains table statistics.
+   */
+  short tableIndexStatistic = 0;
+
+  /**
+   * This table index is clustered.
+   */
+  short tableIndexClustered = 1;
+
+  /**
+   * This table index is hashed.
+   */
+  short tableIndexHashed = 2;
+
+  /**
+   * This table index is of another type.
+   */
+  short tableIndexOther = 3;
+
+  /**
+   * A NULL value is not allowed for this attribute.
+   */
+  short attributeNoNulls = 0;
+
+  /**
+   * A NULL value is allowed for this attribute.
+   */
+  short attributeNullable = 1;
+
+  /**
+   * It is unknown whether or not NULL values are allowed for this attribute.
+   */
+  short attributeNullableUnknown = 2;
+
+  int sqlStateXOpen = 1;
+
+  int sqlStateSQL99 = 2;
+
+  /**
+   * This method tests whether or not all the procedures returned by
+   * the <code>getProcedures</code> method can be called by this user.
+   *
+   * @return <code>true</code> if all the procedures can be called,
+   * <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean allProceduresAreCallable() throws SQLException;
+
+  /**
+   * This method tests whether or not all the table returned by the
+   * <code>getTables</code> method can be selected by this user.
+   *
+   * @return <code>true</code> if all the procedures can be called,
+   * <code>false</code> otherwise.
+   *
+   * @exception SQLException If an error occurs.
+   */
+  boolean allTablesAreSelectable() throws SQLException;
+
+  /**
+   * This method returns the URL for this database.
+   *
+   * @return The URL string for this database, or <code>null</code> if it
+   *         is not known.
+   * @exception SQLException If an error occurs.
+   */
+  String getURL() throws SQLException;
+
+  /**
+   * This method returns the database username for this connection.
+   *
+   * @return The database username.
+   * @exception SQLException If an error occurs.
+   */
+  String getUserName() throws SQLException;
+
+  /**
+   * This method tests whether or not the database is in read only mode.
+   *
+   * @return <code>true</code> if the database is in read only mode,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean isReadOnly() throws SQLException;
+
+  /**
+   * This method tests whether or not NULL's sort as high values.
+   *
+   * @return <code>true</code> if NULL's sort as high values, <code>false</code>
+   *         otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean nullsAreSortedHigh() throws SQLException;
+
+  /**
+   * This method tests whether or not NULL's sort as low values.
+   *
+   * @return <code>true</code> if NULL's sort as low values, <code>false</code>
+   * otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean nullsAreSortedLow() throws SQLException;
+
+  /**
+   * This method tests whether or not NULL's sort as high values.
+   *
+   * @return <code>true</code> if NULL's sort as high values, <code>false</code>
+   * otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean nullsAreSortedAtStart() throws SQLException;
+
+  /**
+   * This method test whether or not NULL's are sorted to the end
+   * of the list regardless of ascending or descending sort order.
+   *
+   * @return <code>true</code> if NULL's always sort to the end,
+   * <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean nullsAreSortedAtEnd() throws SQLException;
+
+  /**
+   * This method returns the name of the database product.
+   *
+   * @return The database product.
+   * @exception SQLException If an error occurs.
+   */
+  String getDatabaseProductName() throws SQLException;
+
+  /**
+   * This method returns the version of the database product.
+   *
+   * @return The version of the database product.
+   * @exception SQLException If an error occurs.
+   */
+  String getDatabaseProductVersion() throws SQLException;
+
+  /**
+   * This method returns the name of the JDBC driver.
+   *
+   * @return The name of the JDBC driver.
+   * @exception SQLException If an error occurs.
+   */
+  String getDriverName() throws SQLException;
+
+  /**
+   * This method returns the version of the JDBC driver.
+   *
+   * @return The version of the JDBC driver.
+   * @exception SQLException If an error occurs.
+   */
+  String getDriverVersion() throws SQLException;
+
+  /**
+   * This method returns the major version number of the JDBC driver.
+   *
+   * @return The major version number of the JDBC driver.
+   */
+  int getDriverMajorVersion();
+
+  /**
+   * This method returns the minor version number of the JDBC driver.
+   *
+   * @return The minor version number of the JDBC driver.
+   */
+  int getDriverMinorVersion();
+
+  /**
+   * This method tests whether or not the database uses local files to
+   * store tables.
+   *
+   * @return <code>true</code> if the database uses local files, 
+   * <code>false</code> otherwise.
+   *
+   * @exception SQLException If an error occurs.
+   */
+  boolean usesLocalFiles() throws SQLException;
+
+  /**
+   * This method tests whether or not the database uses a separate file for
+   * each table.
+   *
+   * @return <code>true</code> if the database uses a separate file for each
+   * table <code>false</code> otherwise.
+   *
+   * @exception SQLException If an error occurs.
+   */
+  boolean usesLocalFilePerTable() throws SQLException;
+
+  /**
+   * This method tests whether or not the database supports identifiers
+   * with mixed case.
+   *
+   * @return <code>true</code> if the database supports mixed case identifiers,
+   * <code>false</code> otherwise.
+   *
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsMixedCaseIdentifiers() throws SQLException;
+
+  /**
+   * This method tests whether or not the database treats mixed case
+   * identifiers as all upper case.
+   *
+   * @return <code>true</code> if the database treats all identifiers as
+   *         upper case, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean storesUpperCaseIdentifiers() throws SQLException;
+
+  /**
+   * This method tests whether or not the database treats mixed case
+   * identifiers as all lower case.
+   *
+   * @return <code>true</code> if the database treats all identifiers as
+   *         lower case, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean storesLowerCaseIdentifiers() throws SQLException;
+
+  /**
+   * This method tests whether or not the database stores mixed case 
+   * identifers even if it treats them as case insensitive.
+   *
+   * @return <code>true</code> if the database stores mixed case identifiers,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean storesMixedCaseIdentifiers() throws SQLException;
+
+  /**
+   * This method tests whether or not the database supports quoted identifiers
+   * with mixed case.
+   *
+   * @return <code>true</code> if the database supports mixed case quoted
+   *         identifiers, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsMixedCaseQuotedIdentifiers() throws SQLException;
+
+  /**
+   * This method tests whether or not the database treats mixed case
+   * quoted identifiers as all upper case.
+   *
+   * @return <code>true</code> if the database treats all quoted identifiers 
+   *         as upper case, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean storesUpperCaseQuotedIdentifiers() throws SQLException;
+
+  /**
+   * This method tests whether or not the database treats mixed case
+   * quoted identifiers as all lower case.
+   *
+   * @return <code>true</code> if the database treats all quoted identifiers 
+   *         as lower case, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean storesLowerCaseQuotedIdentifiers() throws SQLException;
+
+  /**
+   * This method tests whether or not the database stores mixed case 
+   * quoted identifers even if it treats them as case insensitive.
+   *
+   * @return <code>true</code> if the database stores mixed case quoted 
+   *         identifiers, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean storesMixedCaseQuotedIdentifiers() throws SQLException;
+
+  /**
+   * This metohd returns the quote string for SQL identifiers.
+   *
+   * @return The quote string for SQL identifers, or a space if quoting
+   *         is not supported.
+   * @exception SQLException If an error occurs.
+   */
+  String getIdentifierQuoteString() throws SQLException;
+
+  /**
+   * This method returns a comma separated list of all the SQL keywords in
+   * the database that are not in SQL92.
+   *
+   * @return The list of SQL keywords not in SQL92.
+   * @exception SQLException If an error occurs.
+   */
+  String getSQLKeywords() throws SQLException;
+
+  /**
+   * This method returns a comma separated list of math functions.
+   *
+   * @return The list of math functions.
+   * @exception SQLException If an error occurs.
+   */
+  String getNumericFunctions() throws SQLException;
+
+  /**
+   * This method returns a comma separated list of string functions.
+   *
+   * @return The list of string functions.
+   * @exception SQLException If an error occurs.
+   */
+  String getStringFunctions() throws SQLException;
+
+  /**
+   * This method returns a comma separated list of of system functions.
+   *
+   * @return A comma separated list of system functions.
+   * @exception SQLException If an error occurs.
+   */
+  String getSystemFunctions() throws SQLException;
+
+  /**
+   * This method returns comma separated list of time/date functions.
+   * 
+   * @return The list of time/date functions.
+   * @exception SQLException If an error occurs.
+   */
+  String getTimeDateFunctions() throws SQLException;
+
+  /**
+   * This method returns the string used to escape wildcards in search strings.
+   *
+   * @return The string used to escape wildcards in search strings.
+   * @exception SQLException If an error occurs.
+   */
+  String getSearchStringEscape() throws SQLException;
+
+  /**
+   * This methods returns non-standard characters that can appear in 
+   * unquoted identifiers.
+   *
+   * @return Non-standard characters that can appear in unquoted identifiers.
+   * @exception SQLException If an error occurs.
+   */
+  String getExtraNameCharacters() throws SQLException;
+
+  /**
+   * This method tests whether or not the database supports
+   * "ALTER TABLE ADD COLUMN"
+   *
+   * @return <code>true</code> if column add supported, <code>false</code>
+   *         otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsAlterTableWithAddColumn() throws SQLException;
+
+  /**
+   * This method tests whether or not the database supports
+   * "ALTER TABLE DROP COLUMN"
+   *
+   * @return <code>true</code> if column drop supported, <code>false</code>
+   *         otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsAlterTableWithDropColumn() throws SQLException;
+
+  /**
+   * This method tests whether or not column aliasing is supported.
+   *
+   * @return <code>true</code> if column aliasing is supported,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsColumnAliasing() throws SQLException;
+
+  /**
+   * This method tests whether the concatenation of a NULL and non-NULL
+   * value results in a NULL.  This will always be true in fully JDBC compliant
+   * drivers.
+   *
+   * @return <code>true</code> if concatenating NULL and a non-NULL value
+   *         returns a NULL, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean nullPlusNonNullIsNull() throws SQLException;
+
+  /**
+   * Tests whether or not CONVERT is supported.
+   *
+   * @return <code>true</code> if CONVERT is supported, <code>false</code>
+   *         otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsConvert() throws SQLException;
+
+  /**
+   * This method tests whether or not CONVERT can be performed between the
+   * specified types.  The types are contants from <code>Types</code>.
+   *
+   * @param fromType The SQL type to convert from.
+   * @param toType The SQL type to convert to.
+   * @return <code>true</code> if the conversion can be performed,
+   *         <code>false</code> otherwise.
+   * @see Types
+   */
+  boolean supportsConvert(int fromType, int toType) throws
+      SQLException;
+
+  /**
+   * This method tests whether or not table correlation names are 
+   * supported.  This will be always be <code>true</code> in a fully JDBC
+   * compliant driver.
+   *
+   * @return <code>true</code> if table correlation names are supported,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsTableCorrelationNames() throws SQLException;
+
+  /**
+   * This method tests whether correlation names must be different from the
+   * name of the table.
+   *
+   * @return <code>true</code> if the correlation name must be different from
+   *         the table name, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsDifferentTableCorrelationNames() throws SQLException;
+
+  /**
+   * This method tests whether or not expressions are allowed in an
+   * ORDER BY lists.
+   *
+   * @return <code>true</code> if expressions are allowed in ORDER BY
+   *         lists, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsExpressionsInOrderBy() throws SQLException;
+
+  /**
+   * This method tests whether or ORDER BY on a non-selected column is
+   * allowed.
+   *
+   * @return <code>true</code> if a non-selected column can be used in an
+   *         ORDER BY, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsOrderByUnrelated() throws SQLException;
+
+  /**
+   * This method tests whether or not GROUP BY is supported.
+   *
+   * @return <code>true</code> if GROUP BY is supported, <code>false</code>
+   *         otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsGroupBy() throws SQLException;
+
+  /**
+   * This method tests whether GROUP BY on a non-selected column is
+   * allowed.
+   *
+   * @return <code>true</code> if a non-selected column can be used in a
+   *         GROUP BY, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsGroupByUnrelated() throws SQLException;
+
+  /**
+   * This method tests whether or not a GROUP BY can add columns not in the
+   * select if it includes all the columns in the select.
+   *
+   * @return <code>true</code> if GROUP BY an add columns provided it includes
+   *         all columns in the select, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsGroupByBeyondSelect() throws SQLException;
+
+  /**
+   * This method tests whether or not the escape character is supported in
+   * LIKE expressions.  A fully JDBC compliant driver will always return
+   * <code>true</code>.
+   *
+   * @return <code>true</code> if escapes are supported in LIKE expressions,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsLikeEscapeClause() throws SQLException;
+
+  /**
+   * This method tests whether multiple result sets for a single statement are
+   * supported.
+   *
+   * @return <code>true</code> if multiple result sets are supported for a 
+   *         single statement, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsMultipleResultSets() throws SQLException;
+
+  /**
+   * This method test whether or not multiple transactions may be open
+   * at once, as long as they are on different connections.
+   *
+   * @return <code>true</code> if multiple transactions on different
+   *         connections are supported, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsMultipleTransactions() throws SQLException;
+
+  /**
+   * This method tests whether or not columns can be defined as NOT NULL.  A
+   * fully JDBC compliant driver always returns <code>true</code>.
+   *
+   * @return <code>true</code> if NOT NULL columns are supported,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsNonNullableColumns() throws SQLException;
+
+  /**
+   * This method tests whether or not the minimum grammer for ODBC is supported.
+   * A fully JDBC compliant driver will always return <code>true</code>.
+   *
+   * @return <code>true</code> if the ODBC minimum grammar is supported,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsMinimumSQLGrammar() throws SQLException;
+
+  /**
+   * This method tests whether or not the core grammer for ODBC is supported.
+   *
+   * @return <code>true</code> if the ODBC core grammar is supported,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsCoreSQLGrammar() throws SQLException;
+
+  /**
+   * This method tests whether or not the extended grammer for ODBC is supported.
+   *
+   * @return <code>true</code> if the ODBC extended grammar is supported,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsExtendedSQLGrammar() throws SQLException;
+
+  /**
+   * This method tests whether or not the ANSI92 entry level SQL
+   * grammar is supported.  A fully JDBC compliant drivers must return
+   * <code>true</code>.
+   *
+   * @return <code>true</code> if the ANSI92 entry level SQL grammar is
+   *         supported, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsANSI92EntryLevelSQL() throws SQLException;
+
+  /**
+   * This method tests whether or not the ANSI92 intermediate SQL
+   * grammar is supported.  
+   *
+   * @return <code>true</code> if the ANSI92 intermediate SQL grammar is
+   *         supported, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsANSI92IntermediateSQL() throws SQLException;
+
+  /**
+   * This method tests whether or not the ANSI92 full SQL
+   * grammar is supported.  
+   *
+   * @return <code>true</code> if the ANSI92 full SQL grammar is
+   *         supported, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsANSI92FullSQL() throws SQLException;
+
+  /**
+   * This method tests whether or not the SQL integrity enhancement
+   * facility is supported.
+   *
+   * @return <code>true</code> if the integrity enhancement facility is
+   *         supported, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsIntegrityEnhancementFacility() throws SQLException;
+
+  /**
+   * This method tests whether or not the database supports outer joins.
+   *
+   * @return <code>true</code> if outer joins are supported, <code>false</code>
+   *         otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsOuterJoins() throws SQLException;
+
+  /**
+   * This method tests whether or not the database supports full outer joins.
+   *
+   * @return <code>true</code> if full outer joins are supported, 
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsFullOuterJoins() throws SQLException;
+
+  /**
+   * This method tests whether or not the database supports limited outer joins.
+   *
+   * @return <code>true</code> if limited outer joins are supported, 
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsLimitedOuterJoins() throws SQLException;
+
+  /**
+   * This method returns the vendor's term for "schema".
+   *
+   * @return The vendor's term for schema.
+   * @exception SQLException if an error occurs.
+   */
+  String getSchemaTerm() throws SQLException;
+
+  /**
+   * This method returns the vendor's term for "procedure".
+   *
+   * @return The vendor's term for procedure.
+   * @exception SQLException if an error occurs.
+   */
+  String getProcedureTerm() throws SQLException;
+
+  /**
+   * This method returns the vendor's term for "catalog".
+   *
+   * @return The vendor's term for catalog.
+   * @exception SQLException if an error occurs.
+   */
+  String getCatalogTerm() throws SQLException;
+
+  /**
+   * This method tests whether a catalog name appears at the beginning of
+   * a fully qualified table name.
+   *
+   * @return <code>true</code> if the catalog name appears at the beginning,
+   *         <code>false</code> if it appears at the end.
+   * @exception SQLException If an error occurs.
+   */
+  boolean isCatalogAtStart() throws SQLException;
+
+  /**
+   * This method returns the separator between the catalog name and the
+   * table name.
+   *
+   * @return The separator between the catalog name and the table name.
+   * @exception SQLException If an error occurs.
+   */
+  String getCatalogSeparator() throws SQLException;
+
+  /**
+   * This method tests whether a catalog name can appear in a data
+   * manipulation statement.
+   *
+   * @return <code>true</code> if a catalog name can appear in a data
+   *         manipulation statement, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsSchemasInDataManipulation() throws SQLException;
+
+  /**
+   * This method tests whether a catalog name can appear in a procedure
+   * call
+   *
+   * @return <code>true</code> if a catalog name can appear in a procedure
+   *         call, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsSchemasInProcedureCalls() throws SQLException;
+
+  /**
+   * This method tests whether a catalog name can appear in a table definition.
+   *
+   * @return <code>true</code> if a catalog name can appear in a table
+   *         definition, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsSchemasInTableDefinitions() throws SQLException;
+
+  /**
+   * This method tests whether a catalog name can appear in an index definition.
+   *
+   * @return <code>true</code> if a catalog name can appear in an index
+   *         definition, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsSchemasInIndexDefinitions() throws SQLException;
+
+  /**
+   * This method tests whether a catalog name can appear in privilege definitions.
+   *
+   * @return <code>true</code> if a catalog name can appear in privilege
+   *         definition, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsSchemasInPrivilegeDefinitions() throws SQLException;
+
+  /**
+   * This method tests whether a catalog name can appear in a data
+   * manipulation statement.
+   *
+   * @return <code>true</code> if a catalog name can appear in a data
+   *         manipulation statement, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsCatalogsInDataManipulation() throws SQLException;
+
+  /**
+   * This method tests whether a catalog name can appear in a procedure
+   * call
+   *
+   * @return <code>true</code> if a catalog name can appear in a procedure
+   *         call, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsCatalogsInProcedureCalls() throws SQLException;
+
+  /**
+   * This method tests whether a catalog name can appear in a table definition.
+   *
+   * @return <code>true</code> if a catalog name can appear in a table
+   *         definition, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsCatalogsInTableDefinitions() throws SQLException;
+
+  /**
+   * This method tests whether a catalog name can appear in an index definition.
+   *
+   * @return <code>true</code> if a catalog name can appear in an index
+   *         definition, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsCatalogsInIndexDefinitions() throws SQLException;
+
+  /**
+   * This method tests whether a catalog name can appear in privilege definitions.
+   *
+   * @return <code>true</code> if a catalog name can appear in privilege
+   *         definition, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException;
+
+  /**
+   * This method tests whether or not that database supports positioned
+   * deletes.
+   *
+   * @return <code>true</code> if positioned deletes are supported,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsPositionedDelete() throws SQLException;
+
+  /**
+   * This method tests whether or not that database supports positioned
+   * updates.
+   *
+   * @return <code>true</code> if positioned updates are supported,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsPositionedUpdate() throws SQLException;
+
+  /**
+   * This method tests whether or not SELECT FOR UPDATE is supported by the
+   * database.
+   *
+   * @return <code>true</code> if SELECT FOR UPDATE is supported 
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsSelectForUpdate() throws SQLException;
+
+  /**
+   * This method tests whether or not stored procedures are supported on
+   * this database.
+   *
+   * @return <code>true</code> if stored procedures are supported,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsStoredProcedures() throws SQLException;
+
+  /**
+   * This method tests whether or not subqueries are allowed in comparisons.
+   * A fully JDBC compliant driver will always return <code>true</code>.
+   *
+   * @return <code>true</code> if subqueries are allowed in comparisons,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsSubqueriesInComparisons() throws SQLException;
+
+  /**
+   * This method tests whether or not subqueries are allowed in exists
+   * expressions.  A fully JDBC compliant driver will always return
+   * <code>true</code>.
+   *
+   * @return <code>true</code> if subqueries are allowed in exists 
+   *         expressions, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsSubqueriesInExists() throws SQLException;
+
+  /**
+   * This method tests whether subqueries are allowed in IN statements.
+   * A fully JDBC compliant driver will always return <code>true</code>.
+   *
+   * @return <code>true</code> if the driver supports subqueries in IN
+   *         statements, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsSubqueriesInIns() throws SQLException;
+
+  /**
+   * This method tests whether or not subqueries are allowed in quantified
+   * expressions.  A fully JDBC compliant driver will always return
+   * <code>true</code>.
+   *
+   * @return <code>true</code> if subqueries are allowed in quantified 
+   *         expressions, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsSubqueriesInQuantifieds() throws SQLException;
+
+  /**
+   * This method test whether or not correlated subqueries are allowed. A
+   * fully JDBC compliant driver will always return <code>true</code>.
+   *
+   * @return <code>true</code> if correlated subqueries are allowed,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsCorrelatedSubqueries() throws SQLException;
+
+  /**
+   * This method tests whether or not the UNION statement is supported.
+   *
+   * @return <code>true</code> if UNION is supported, <code>false</code>
+   *         otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsUnion() throws SQLException;
+
+  /**
+   * This method tests whether or not the UNION ALL statement is supported.
+   *
+   * @return <code>true</code> if UNION ALL is supported, <code>false</code>
+   *         otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsUnionAll() throws SQLException;
+
+  /**
+   * This method tests whether or not the database supports cursors
+   * remaining open across commits.
+   *
+   * @return <code>true</code> if cursors can remain open across commits,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsOpenCursorsAcrossCommit() throws SQLException;
+
+  /**
+   * This method tests whether or not the database supports cursors
+   * remaining open across rollbacks.
+   *
+   * @return <code>true</code> if cursors can remain open across rollbacks,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsOpenCursorsAcrossRollback() throws SQLException;
+
+  /**
+   * This method tests whether or not the database supports statements
+   * remaining open across commits.
+   *
+   * @return <code>true</code> if statements can remain open across commits,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsOpenStatementsAcrossCommit() throws SQLException;
+
+  /**
+   * This method tests whether or not the database supports statements
+   * remaining open across rollbacks.
+   *
+   * @return <code>true</code> if statements can remain open across rollbacks,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsOpenStatementsAcrossRollback() throws SQLException;
+
+  /**
+   * This method returns the number of hex characters allowed in an inline
+   * binary literal.
+   *
+   * @return The number of hex characters allowed in a binary literal, 0 meaning
+   *         either an unknown or unlimited number.
+   * @exception SQLException If an error occurs.
+   */
+  int getMaxBinaryLiteralLength() throws SQLException;
+
+  /**
+   * This method returns the maximum length of a character literal.
+   * 
+   * @return The maximum length of a character literal.
+   * @exception SQLException If an error occurs.
+   */
+  int getMaxCharLiteralLength() throws SQLException;
+
+  /**
+   * This method returns the maximum length of a column name.
+   *
+   * @return The maximum length of a column name.
+   * @exception SQLException If an error occurs.
+   */
+  int getMaxColumnNameLength() throws SQLException;
+
+  /**
+   * This method returns the maximum number of columns in a GROUP BY statement.
+   *
+   * @return The maximum number of columns in a GROUP BY statement.
+   * @exception SQLException If an error occurs.
+   */
+  int getMaxColumnsInGroupBy() throws SQLException;
+
+  /**
+   * This method returns the maximum number of columns in an index.
+   *
+   * @return The maximum number of columns in an index.
+   * @exception SQLException If an error occurs.
+   */
+  int getMaxColumnsInIndex() throws SQLException;
+
+  /**
+   * This method returns the maximum number of columns in an ORDER BY statement.
+   *
+   * @return The maximum number of columns in an ORDER BY statement.
+   * @exception SQLException If an error occurs.
+   */
+  int getMaxColumnsInOrderBy() throws SQLException;
+
+  /**
+   * This method returns the maximum number of columns in a SELECT statement.
+   *
+   * @return The maximum number of columns in a SELECT statement.
+   * @exception SQLException If an error occurs.
+   */
+  int getMaxColumnsInSelect() throws SQLException;
+
+  /**
+   * This method returns the maximum number of columns in a table.
+   *
+   * @return The maximum number of columns in a table.
+   * @exception SQLException If an error occurs.
+   */
+  int getMaxColumnsInTable() throws SQLException;
+
+  /**
+   * This method returns the maximum number of connections this client
+   * can have to the database.
+   *
+   * @return The maximum number of database connections.
+   * @SQLException If an error occurs.
+   */
+  int getMaxConnections() throws SQLException;
+
+  /**
+   * This method returns the maximum length of a cursor name.
+   *
+   * @return The maximum length of a cursor name.
+   * @exception SQLException If an error occurs.
+   */
+  int getMaxCursorNameLength() throws SQLException;
+
+  /**
+   * This method returns the maximum length of an index.
+   *
+   * @return The maximum length of an index.
+   * @exception SQLException If an error occurs.
+   */
+  int getMaxIndexLength() throws SQLException;
+
+  /**
+   * This method returns the maximum length of a schema name.
+   *
+   * @return The maximum length of a schema name.
+   * @exception SQLException If an error occurs.
+   */
+  int getMaxSchemaNameLength() throws SQLException;
+
+  /**
+   * This method returns the maximum length of a procedure name.
+   *
+   * @return The maximum length of a procedure name.
+   * @exception SQLException If an error occurs.
+   */
+  int getMaxProcedureNameLength() throws SQLException;
+
+  /**
+   * This method returns the maximum length of a catalog name.
+   *
+   * @return The maximum length of a catalog name.
+   * @exception SQLException If an error occurs.
+   */
+  int getMaxCatalogNameLength() throws SQLException;
+
+  /**
+   * This method returns the maximum size of a row in bytes.
+   *
+   * @return The maximum size of a row.
+   * @exception SQLException If an error occurs.
+   */
+  int getMaxRowSize() throws SQLException;
+
+  /**
+   * This method tests whether or not the maximum row size includes BLOB's
+   *
+   * @return <code>true</code> if the maximum row size includes BLOB's,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean doesMaxRowSizeIncludeBlobs() throws SQLException;
+
+  /**
+   * This method includes the maximum length of a SQL statement.
+   *
+   * @return The maximum length of a SQL statement.
+   * @exception SQLException If an error occurs.
+   */
+  int getMaxStatementLength() throws SQLException;
+
+  /**
+   * This method returns the maximum number of statements that can be
+   * active at any time.
+   *
+   * @return The maximum number of statements that can be active at any time.
+   * @exception SQLException If an error occurs.
+   */
+  int getMaxStatements() throws SQLException;
+
+  /**
+   * This method returns the maximum length of a table name.
+   *
+   * @return The maximum length of a table name.
+   * @exception SQLException If an error occurs.
+   */
+  int getMaxTableNameLength() throws SQLException;
+
+  /**
+   * This method returns the maximum number of tables that may be referenced
+   * in a SELECT statement.
+   *
+   * @return The maximum number of tables allowed in a SELECT statement.
+   * @exception SQLException If an error occurs.
+   */
+  int getMaxTablesInSelect() throws SQLException;
+
+  /**
+   * This method returns the maximum length of a user name.
+   *
+   * @return The maximum length of a user name.
+   * @exception SQLException If an error occurs.
+   */
+  int getMaxUserNameLength() throws SQLException;
+
+  /**
+   * This method returns the default transaction isolation level of the
+   * database.
+   *
+   * @return The default transaction isolation level of the database.
+   * @exception SQLException If an error occurs.
+   * @see Connection
+   */
+  int getDefaultTransactionIsolation() throws SQLException;
+
+  /**
+   * This method tests whether or not the database supports transactions.
+   *
+   * @return <code>true</code> if the database supports transactions,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsTransactions() throws SQLException;
+
+  /**
+   * This method tests whether or not the database supports the specified
+   * transaction isolation level.
+   *
+   * @param level The transaction isolation level.
+   *
+   * @return <code>true</code> if the specified transaction isolation level
+   *         is supported, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsTransactionIsolationLevel(int level) throws
+      SQLException;
+
+  /**
+   * This method tests whether or not DDL and DML statements allowed within 
+   * the same transaction.
+   *
+   * @return <code>true</code> if DDL and DML statements are allowed in the
+   *         same transaction, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsDataDefinitionAndDataManipulationTransactions()
+      throws SQLException;
+
+  /**
+   * This method tests whether or not only DML statement are allowed
+   * inside a transaction.
+   *
+   * @return <code>true</code> if only DML statements are allowed in
+   *         transactions, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsDataManipulationTransactionsOnly() throws
+      SQLException;
+
+  /**
+   * This method tests whether or not a DDL statement will cause the
+   * current transaction to be automatically committed.
+   *
+   * @return <code>true</code> if DDL causes an immediate transaction commit,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean dataDefinitionCausesTransactionCommit() throws SQLException;
+
+  /**
+   * This method tests whether or not DDL statements are ignored in
+   * transactions.
+   *
+   * @return <code>true</code> if DDL statements are ignored in transactions,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean dataDefinitionIgnoredInTransactions() throws SQLException;
+
+  /**
+   * This method returns a list of all the stored procedures matching the
+   * specified pattern in the given schema and catalog.  This is returned
+   * a <code>ResultSet</code> with the following columns:
+   * <p>
+   * <ol>
+   * <li>PROCEDURE_CAT - The catalog the procedure is in, which may be 
+   * <code>null</code>.</li>
+   * <li>PROCEDURE_SCHEM - The schema the procedures is in, which may be
+   * <code>null</code>.</li>
+   * <li>PROCEDURE_NAME - The name of the procedure.</li>
+   * <li>Unused</li>
+   * <li>Unused</li>
+   * <li>Unused</li>
+   * <li>REMARKS - A description of the procedure</li>
+   * <li>PROCEDURE_TYPE - Indicates the return type of the procedure, which 
+   * is one of the contstants defined in this class 
+   * (<code>procedureResultUnknown</code>, <code>procedureNoResult</code>, or
+   * <code>procedureReturnsResult</code>).</li>
+   * </ol>
+   *
+   * @param catalog The name of the catalog to return stored procedured from,
+   *        or "" to return procedures from all catalogs.
+   * @param schemaPattern A schema pattern for the schemas to return stored
+   *        procedures from, or "" to return procedures from all schemas.
+   * @param procedurePattern The pattern of procedure names to return.
+   * @returns A <code>ResultSet</code> with all the requested procedures.
+   * @exception SQLException If an error occurs.
+   */
+  ResultSet getProcedures(String catalog, String schemaPattern, String
+      procedurePattern) throws SQLException;
+
+  /**
+   * This method returns a list of the parameter and result columns for
+   * the requested stored procedures.  This is returned in the form of a
+   * <code>ResultSet</code> with the following columns:
+   * <p>
+   * <ol>
+   * <li>PROCEDURE_CAT - The catalog the procedure is in, which may be 
+   * <code>null</code>.</li>
+   * <li>PROCEDURE_SCHEM - The schema the procedures is in, which may be
+   * <code>null</code>.</li>
+   * <li>PROCEDURE_NAME - The name of the procedure.</li>
+   * <li>COLUMN_NAME - The name of the column</li>
+   * <li>COLUMN_TYPE - The type of the column, which will be one of the
+   * contants defined in this class (<code>procedureColumnUnknown</code>,
+   * <code>procedureColumnIn</code>, <code>procedureColumnInOut</code>,
+   * <code>procedureColumnOut</code>, <code>procedureColumnReturn</code>,
+   * or <code>procedureColumnResult</code>).</li>
+   * <li>DATA_TYPE - The SQL type of the column. This is one of the constants
+   * defined in <code>Types</code>.</li>
+   * <li>TYPE_NAME - The string name of the data type for this column.</li>
+   * <li>PRECISION - The precision of the column.</li>
+   * <li>LENGTH - The length of the column in bytes</li>
+   * <li>SCALE - The scale of the column.</li>
+   * <li>RADIX - The radix of the column.</li>
+   * <li>NULLABLE - Whether or not the column is NULLABLE.  This is one of
+   * the constants defined in this class (<code>procedureNoNulls</code>,
+   * <code>procedureNullable</code>, or <code>procedureNullableUnknown</code>)</li>
+   * <li>REMARKS - A description of the column.</li>
+   * </ol>
+   *
+   * @param catalog The name of the catalog to return stored procedured from,
+   *        or "" to return procedures from all catalogs.
+   * @param schemaPattern A schema pattern for the schemas to return stored
+   *        procedures from, or "" to return procedures from all schemas.
+   * @param procedurePattern The pattern of procedures names to return.
+   * @param columnPattern The pattern of column names to return.
+   * @returns A <code>ResultSet</code> with all the requested procedures.
+   * @exception SQLException If an error occurs.
+   */
+  ResultSet getProcedureColumns(String catalog, String schemaPattern,
+      String procedurePattern, String columnPattern) throws
+      SQLException;
+
+  /**
+   * This method returns a list of the requested table as a   
+   * <code>ResultSet</code> with the following columns:
+   *
+   * <ol>
+   * <li>TABLE_CAT - The catalog the table is in, which may be <code>null</code>.</li>
+   * <li>TABLE_SCHEM - The schema the table is in, which may be <code>null</code>.</li>
+   * <li>TABLE_NAME - The name of the table.</li>
+   * <li>TABLE_TYPE - A string describing the table type.  This will be one
+   * of the values returned by the <code>getTableTypes()</code> method.</li>
+   * <li>REMARKS - Comments about the table.</li>
+   * </ol>
+   * 
+   * @param catalog The name of the catalog to return tables from,
+   *        or "" to return tables from all catalogs.
+   * @param schemaPattern A schema pattern for the schemas to return tables
+   *        from, or "" to return tables from all schemas.
+   * @param tablePattern The pattern of table names to return.
+   * @param types The list of table types to include; null returns all types.
+   * @returns A <code>ResultSet</code> with all the requested tables.
+   * @exception SQLException If an error occurs.
+   */
+  ResultSet getTables(String catalog, String schemaPattern, String
+      tablePattern, String[] types) throws SQLException;
+
+  /**
+   * This method returns the list of database schemas as a 
+   * <code>ResultSet</code>, with one column - TABLE_SCHEM - that is the
+   * name of the schema.
+   *
+   * @return A <code>ResultSet</code> with all the requested schemas.
+   * @exception SQLException If an error occurs.
+   */
+  ResultSet getSchemas() throws SQLException;
+
+  /**
+   * This method returns the list of database catalogs as a
+   * <code>ResultSet</code> with one column - TABLE_CAT - that is the
+   * name of the catalog.
+   *
+   * @return A <code>ResultSet</code> with all the requested catalogs.
+   * @exception SQLException If an error occurs.
+   */
+  ResultSet getCatalogs() throws SQLException;
+
+  /**
+   * This method returns the list of database table types as a
+   * <code>ResultSet</code> with one column - TABLE_TYPE - that is the
+   * name of the table type.
+   *
+   * @return A <code>ResultSet</code> with all the requested table types.
+   * @exception SQLException If an error occurs.
+   */
+  ResultSet getTableTypes() throws SQLException;
+
+  /**
+   * This method returns a list of the tables columns for
+   * the requested tables.  This is returned in the form of a
+   * <code>ResultSet</code> with the following columns:
+   * <p>
+   * <ol>
+   * <li>TABLE_CAT - The catalog the table is in, which may be 
+   * <code>null</code>.</li>
+   * <li>TABLE_SCHEM - The schema the tables is in, which may be
+   * <code>null</code>.</li>
+   * <li>TABLE_NAME - The name of the table.</li>
+   * <li>COLUMN_NAME - The name of the column</li>
+   * <li>DATA_TYPE - The SQL type of the column. This is one of the constants
+   * defined in <code>Types</code>.</li>
+   * <li>TYPE_NAME - The string name of the data type for this column.</li>
+   * <li>COLUMN_SIZE - The size of the column.</li>
+   * <li>Unused</li>
+   * <li>NUM_PREC_RADIX - The radix of the column.</li>
+   * <li>NULLABLE - Whether or not the column is NULLABLE.  This is one of
+   * the constants defined in this class (<code>tableNoNulls</code>,
+   * <code>tableNullable</code>, or <code>tableNullableUnknown</code>)</li>
+   * <li>REMARKS - A description of the column.</li>
+   * <li>COLUMN_DEF - The default value for the column, may be <code>null</code>.</li>
+   * <li>SQL_DATA_TYPE - Unused</li>
+   * <li>SQL_DATETIME_SUB - Unused</li>
+   * <li>CHAR_OCTET_LENGTH - For character columns, the maximum number of bytes
+   * in the column.</li>
+   * <li>ORDINAL_POSITION - The index of the column in the table.</li>
+   * <li>IS_NULLABLE - "NO" means no, "YES" means maybe, and an empty string
+   * means unknown.</li>
+   * </ol>
+   *
+   * @param catalog The name of the catalog to return table from,
+   * or "" to return tables from all catalogs.
+   * @param schemaPattern A schema pattern for the schemas to return 
+   * tables from, or "" to return tables from all schemas.
+   * @param tablePattern The pattern of table names to return.
+   * @param columnPattern The pattern of column names to return.
+   * @returns A <code>ResultSet</code> with all the requested tables.
+   * @exception SQLException If an error occurs.
+   */
+  ResultSet getColumns(String catalog, String schemaPattern, String
+      tablePattern, String columnPattern) throws SQLException;
+
+  /**
+   * This method returns the access rights that have been granted to the
+   * requested columns.  This information is returned as a <code>ResultSet</code>
+   * with the following columns:
+   *
+   * <ol>
+   * <li>TABLE_CAT - The catalog the table is in, which may be 
+   * <code>null</code>.</li>
+   * <li>TABLE_SCHEM - The schema the tables is in, which may be
+   * <code>null</code>.</li>
+   * <li>TABLE_NAME - The name of the table.</li>
+   * <li>COLUMN_NAME - The name of the column.</li>
+   * <li>GRANTOR - The entity that granted the access.</li>
+   * <li>GRANTEE - The entity granted the access.</li>
+   * <li>PRIVILEGE - The name of the privilege granted.</li>
+   * <li>IS_GRANTABLE - "YES" if the grantee can grant the privilege to
+   * others, "NO" if not, and <code>null</code> if unknown.</li>
+   * </ol>
+   *
+   * @param catalog The catalog to retrieve information from, or the empty string
+   *        to return entities not associated with a catalog, or <code>null</code>
+   *        to return information from all catalogs.
+   * @param schema The schema to retrieve information from, or the empty string
+   *        to return entities not associated with a schema.
+   * @param tableName The table name to return information for.
+   * @param columnPattern A pattern of column names to return information for.
+   * @return A <code>ResultSet</code> with all the requested privileges.
+   * @exception SQLException If an error occurs.
+   */
+  ResultSet getColumnPrivileges(String catalog, String schema, String
+      tableName, String columnPattern) throws SQLException;
+
+  /**
+   * This method returns the access rights that have been granted to the
+   * requested tables.  This information is returned as a <code>ResultSet</code>
+   * with the following columns:
+   *
+   * <ol>
+   * <li>TABLE_CAT - The catalog the table is in, which may be 
+   * <code>null</code>.</li>
+   * <li>TABLE_SCHEM - The schema the tables is in, which may be
+   * <code>null</code>.</li>
+   * <li>TABLE_NAME - The name of the table.</li>
+   * <li>GRANTOR - The entity that granted the access.</li>
+   * <li>GRANTEE - The entity granted the access.</li>
+   * <li>PRIVILEGE - The name of the privilege granted.</li>
+   * <li>IS_GRANTABLE - "YES" if the grantee can grant the privilege to
+   * others, "NO" if not, and <code>null</code> if unknown.</li>
+   * </ol>
+   *
+   * @param catalog The catalog to retrieve information from, or the empty string
+   *        to return entities not associated with a catalog, or <code>null</code>
+   *        to return information from all catalogs.
+   * @param schemaPattern The schema to retrieve information from, or the empty string
+   *        to return entities not associated with a schema.
+   * @param tablePattern The table name pattern of tables to return 
+   *        information for.
+   * @return A <code>ResultSet</code> with all the requested privileges.
+   * @exception SQLException If an error occurs.
+   */
+  ResultSet getTablePrivileges(String catalog, String schemaPattern,
+      String tablePattern) throws SQLException;
+
+  /**
+   * This method returns the best set of columns for uniquely identifying
+   * a row.  It returns this information as a <code>ResultSet</code> with
+   * the following columns:
+   *
+   * <ol>
+   * <li>SCOPE - The scope of the results returned.  This is one of the 
+   * constants defined in this class (<code>bestRowTemporary</code>,
+   * <code>bestRowTransaction</code>, or <code>bestRowSession</code>).</li>
+   * <li>COLUMN_NAME - The name of the column.</li>
+   * <li>DATA_TYPE - The SQL type of the column. This is one of the constants
+   * defined in <code>Types</code>.</li>
+   * <li>TYPE_NAME - The string name of the data type for this column.</li>
+   * <li>COLUMN_SIZE - The precision of the columns</li>
+   * <li>BUFFER_LENGTH - Unused</li>
+   * <li>DECIMAL_DIGITS - The scale of the column.</li>
+   * <li>PSEUDO_COLUMN - Whether or not the best row identifier is a
+   * pseudo_column.  This is one of the constants defined in this class 
+   * (<code>bestRowUnknown</code>, <code>bestRowNotPseudo</code>, or
+   * <code>bestRowPseudo</code>).</li>
+   * </ol>
+   *
+   * @param catalog The catalog to retrieve information from, or the empty string
+   * to return entities not associated with a catalog, or <code>null</code>
+   * to return information from all catalogs.
+   * @param schema The schema to retrieve information from, or the empty string
+   * to return entities not associated with a schema.
+   * @param tableName The table name to return information for.
+   * @param scope One of the best row id scope constants from this class.
+   * @param nullable <code>true</code> to include columns that are nullable,
+   * <code>false</code> otherwise.
+   * @return A <code>ResultSet</code> with the best row identifier.
+   * @exception SQLException If an error occurs.
+   */
+  ResultSet getBestRowIdentifier(String catalog, String schema,
+    String tableName, int scope, boolean nullable) throws SQLException;
+
+  /**
+   * This method returns the set of columns that are automatically updated
+   * when the row is update. It returns this information as a 
+   * <code>ResultSet</code> with the following columns:
+   *
+   * <ol>
+   * <li>SCOPE - Unused</li>
+   * <li>COLUMN_NAME - The name of the column.</li>
+   * <li>DATA_TYPE - The SQL type of the column. This is one of the constants
+   * defined in <code>Types</code>.</li>
+   * <li>TYPE_NAME - The string name of the data type for this column.</li>
+   * <li>COLUMN_SIZE - The precision of the columns</li>
+   * <li>BUFFER_LENGTH - Unused</li>
+   * <li>DECIMAL_DIGITS - The scale of the column.</li>
+   * <li>PSEUDO_COLUMN - Whether or not the best row identifier is a
+   * pseudo_column.  This is one of the constants defined in this class 
+   * (<code>versionRowUnknown</code>, <code>versionRowNotPseudo</code>, or
+   * <code>versionRowPseudo</code>).</li>
+   * </ol>
+   *
+   * @param catalog The catalog to retrieve information from, or the empty string
+   *        to return entities not associated with a catalog, or <code>null</code>
+   *        to return information from all catalogs.
+   * @param schema The schema to retrieve information from, or the empty string
+   *        to return entities not associated with a schema.
+   * @param tableName The table name to return information for
+   * @return A <code>ResultSet</code> with the version columns.
+   * @exception SQLException If an error occurs.
+   */
+  ResultSet getVersionColumns(String catalog, String schema,
+    String tableName) throws SQLException;
+
+  /**
+   * This method returns a list of a table's primary key columns.  These
+   * are returned as a <code>ResultSet</code> with the following columns.
+   *
+   * <ol>
+   * <li>TABLE_CAT - The catalog of the table, which may be <code>null</code>.</li>
+   * <li>TABLE_SCHEM - The schema of the table, which may be <code>null</code>.</li>
+   * <li>TABLE_NAME - The name of the table.</li>
+   * <li>COLUMN_NAME - The name of the column.</li>
+   * <li>KEY_SEQ - The sequence number of the column within the primary key.</li>
+   * <li>PK_NAME - The name of the primary key, which may be <code>null</code>.</li>
+   * </ol>
+   *
+   * @param catalog The catalog to retrieve information from, or the empty string
+   *        to return entities not associated with a catalog, or <code>null</code>
+   *        to return information from all catalogs.
+   * @param schema The schema to retrieve information from, or the empty string
+   *        to return entities not associated with a schema.
+   * @param tableName The table name to return information for.
+   * @return A <code>ResultSet</code> with the primary key columns.
+   * @exception SQLException If an error occurs.
+   */
+  ResultSet getPrimaryKeys(String catalog, String schema, String tableName)
+      throws SQLException;
+
+  /**
+   * This method returns a list of the table's foreign keys.  These are
+   * returned as a <code>ResultSet</code> with the following columns:
+   *
+   * <ol>
+   * <li>PKTABLE_CAT - The catalog of the table the key was imported from.</li>
+   * <li>PKTABLE_SCHEM - The schema of the table the key was imported from.</li>
+   * <li>PKTABLE_NAME - The name of the table the key was imported from.</li>
+   * <li>PKCOLUMN_NAME - The name of the column that was imported.</li>
+   * <li>FKTABLE_CAT - The foreign key catalog name.</li>
+   * <li>FKTABLE_SCHEM - The foreign key schema name.</li>
+   * <li>FKTABLE_NAME - The foreign key table name.</li>
+   * <li>FKCOLUMN_NAME - The foreign key column name.</li>
+   * <li>KEY_SEQ - The sequence number of the column within the foreign key.</li>
+   * <li>UPDATE_RULE - How the foreign key behaves when the primary key is
+   * updated.  This is one of the constants defined in this class 
+   * (<code>importedNoAction</code>, <code>importedKeyCascade</code>,
+   * <code>importedKeySetNull</code>, <code>importedKeySetDefault</code>, or
+   * <code>importedKeyRestrict</code>).</li>
+   * <li>DELETE_RULE - How the foreign key behaves when the primary key is
+   * deleted.  This is one of the constants defined in this class 
+   * (<code>importedNoAction</code>, <code>importedKeyCascade</code>,
+   * <code>importedKeySetNull</code>, or <code>importedKeySetDefault</code>)</li>
+   * <li>FK_NAME - The name of the foreign key.</li>
+   * <li>PK_NAME - The name of the primary key.</li>
+   * <li>DEFERRABILITY - The deferrability value.  This is one of the
+   * constants defined in this table (<code>importedKeyInitiallyDeferred</code>,
+   * <code>importedKeyInitiallyImmediate</code>, or
+   * <code>importedKeyNotDeferrable</code>).</li>
+   * </ol>
+   *
+   * @param catalog The catalog to retrieve information from, or the empty string
+   *        to return entities not associated with a catalog, or <code>null</code>
+   *        to return information from all catalogs.
+   * @param schema The schema to retrieve information from, or the empty string
+   *        to return entities not associated with a schema.
+   * @param tableName The table name to return information for.
+   * @return A <code>ResultSet</code> with the foreign key columns.
+   * @exception SQLException If an error occurs.
+   */
+  ResultSet getImportedKeys(String catalog, String schema,
+    String tableName) throws SQLException;
+
+  /**
+   * This method returns a list of the table's which use this table's
+   * primary key as a foreign key.  The information is
+   * returned as a <code>ResultSet</code> with the following columns:
+   *
+   * <ol>
+   * <li>PKTABLE_CAT - The catalog of the table the key was imported from.</li>
+   * <li>PKTABLE_SCHEM - The schema of the table the key was imported from.</li>
+   * <li>PKTABLE_NAME - The name of the table the key was imported from.</li>
+   * <li>PKCOLUMN_NAME - The name of the column that was imported.</li>
+   * <li>FKTABLE_CAT - The foreign key catalog name.</li>
+   * <li>FKTABLE_SCHEM - The foreign key schema name.</li>
+   * <li>FKTABLE_NAME - The foreign key table name.</li>
+   * <li>FKCOLUMN_NAME - The foreign key column name.</li>
+   * <li>KEY_SEQ - The sequence number of the column within the foreign key.</li>
+   * <li>UPDATE_RULE - How the foreign key behaves when the primary key is
+   * updated.  This is one of the constants defined in this class 
+   * (<code>importedNoAction</code>, <code>importedKeyCascade</code>,
+   * <code>importedKeySetNull</code>, <code>importedKeySetDefault</code>, or
+   * <code>importedKeyRestrict</code>).</li>
+   * <li>DELETE_RULE - How the foreign key behaves when the primary key is
+   * deleted.  This is one of the constants defined in this class 
+   * (<code>importedNoAction</code>, <code>importedKeyCascade</code>,
+   * <code>importedKeySetNull</code>, or <code>importedKeySetDefault</code>)</li>
+   * <li>FK_NAME - The name of the foreign key.</li>
+   * <li>PK_NAME - The name of the primary key.</li>
+   * <li>DEFERRABILITY - The deferrability value.  This is one of the
+   * constants defined in this table (<code>importedKeyInitiallyDeferred</code>,
+   * <code>importedKeyInitiallyImmediate</code>, or
+   * <code>importedKeyNotDeferrable</code>).</li>
+   * </ol>
+   *
+   * @param catalog The catalog to retrieve information from, or the empty string
+   *        to return entities not associated with a catalog, or <code>null</code>
+   *        to return information from all catalogs.
+   * @param schema The schema to retrieve information from, or the empty string
+   *        to return entities not associated with a schema.
+   * @param tableName The table name to return information for.
+   * @return A <code>ResultSet</code> with the requested information
+   * @exception SQLException If an error occurs.
+   */
+  ResultSet getExportedKeys(String catalog, String schema,
+    String tableName) throws SQLException;
+
+  /**
+   * This method returns a description of how one table imports another
+   * table's primary key as a foreign key.  The information is
+   * returned as a <code>ResultSet</code> with the following columns:
+   *
+   * <ol>
+   * <li>PKTABLE_CAT - The catalog of the table the key was imported from.</li>
+   * <li>PKTABLE_SCHEM - The schema of the table the key was imported from.</li>
+   * <li>PKTABLE_NAME - The name of the table the key was imported from.</li>
+   * <li>PKCOLUMN_NAME - The name of the column that was imported.</li>
+   * <li>FKTABLE_CAT - The foreign key catalog name.</li>
+   * <li>FKTABLE_SCHEM - The foreign key schema name.</li>
+   * <li>FKTABLE_NAME - The foreign key table name.</li>
+   * <li>FKCOLUMN_NAME - The foreign key column name.</li>
+   * <li>KEY_SEQ - The sequence number of the column within the foreign key.</li>
+   * <li>UPDATE_RULE - How the foreign key behaves when the primary key is
+   * updated.  This is one of the constants defined in this class 
+   * (<code>importedNoAction</code>, <code>importedKeyCascade</code>,
+   * <code>importedKeySetNull</code>, <code>importedKeySetDefault</code>, or
+   * <code>importedKeyRestrict</code>).</li>
+   * <li>DELETE_RULE - How the foreign key behaves when the primary key is
+   * deleted.  This is one of the constants defined in this class 
+   * (<code>importedNoAction</code>, <code>importedKeyCascade</code>,
+   * <code>importedKeySetNull</code>, or <code>importedKeySetDefault</code>)</li>
+   * <li>FK_NAME - The name of the foreign key.</li>
+   * <li>PK_NAME - The name of the primary key.</li>
+   * <li>DEFERRABILITY - The deferrability value.  This is one of the
+   * constants defined in this table (<code>importedKeyInitiallyDeferred</code>,
+   * <code>importedKeyInitiallyImmediate</code>, or
+   * <code>importedKeyNotDeferrable</code>).</li>
+   * </ol>
+   *
+   * @param primaryCatalog The catalog to retrieve information from, or the
+   *        empty string to return entities not associated with a catalog, or
+   *        <code>null</code> to return information from all catalogs, on the
+   *         exporting side.
+   * @param primarySchema The schema to retrieve information from, or the empty
+   *        string to return entities not associated with a schema, on the
+   *        exporting side.
+   * @param primaryTableName The table name to return information for, on the
+   *        exporting side.
+   * @param foreignCatalog The catalog to retrieve information from, or the
+   *        empty string to return entities not associated with a catalog,
+   *        or <code>null</code> to return information from all catalogs, on
+   *        the importing side.
+   * @param foreignSchema The schema to retrieve information from, or the
+   *        empty string to return entities not associated with a schema on
+   *        the importing side.
+   * @param foreignTableName The table name to return information for on the
+   *        importing side.
+   * @return A <code>ResultSet</code> with the requested information
+   * @exception SQLException If an error occurs.
+   */
+  ResultSet getCrossReference(String primaryCatalog, String
+    primarySchema, String primaryTableName, String foreignCatalog, String
+    foreignSchema, String foreignTableName) throws SQLException;
+
+  /**
+   * This method returns a list of the SQL types supported by this
+   * database.  The information is returned as a <code>ResultSet</code>
+   * with the following columns:
+   *
+   * <ol>
+   * <li>TYPE_NAME - The name of the data type.</li>
+   * <li>DATA_TYPE - A data type constant from <code>Types</code> for this
+   * type.</li>
+   * <li>PRECISION - The maximum precision of this type.</li>
+   * <li>LITERAL_PREFIX - Prefix value used to quote a literal, which may be
+   * <code>null</code>.</li>
+   * <li>LITERAL_SUFFIX - Suffix value used to quote a literal, which may be
+   * <code>null</code>.</li>
+   * <li>CREATE_PARAMS - The parameters used to create the type, which may be
+   * <code>null</code>.</li>
+   * <li>NULLABLE - Whether or not this type supports NULL values.  This will
+   * be one of the constants defined in this interface 
+   * (<code>typeNoNulls</code>, <code>typeNullable</code>, or
+   * <code>typeNullableUnknown</code>).</li>
+   * <li>CASE_SENSITIVE - Whether or not the value is case sensitive.</li>
+   * <li>SEARCHABLE - Whether or not "LIKE" expressions are supported in
+   * WHERE clauses for this type.  This will be one of the constants defined
+   * in this interface (<code>typePredNone</code>, <code>typePredChar</code>,
+   * <code>typePredBasic</code>, or <code>typeSearchable</code>).</li>
+   * <li>UNSIGNED_ATTRIBUTE - Is the value of this type unsigned.</li>
+   * <li>FIXED_PREC_SCALE - Whether or not this type can be used for money.</li>
+   * <li>AUTO_INCREMENT - Whether or not this type supports auto-incrementing.</li>
+   * <li>LOCAL_TYPE_NAME - A localized name for this data type.</li>
+   * <li>MINIMUM_SCALE - The minimum scale supported by this type.</li>
+   * <li>MAXIMUM_SCALE - The maximum scale supported by this type.</li>
+   * <li>SQL_DATA_TYPE - Unused.</li>
+   * <li>SQL_DATETIME_SUB - Unused.</li>
+   * <li>NUM_PREC_RADIX - The radix of this data type.</li>
+   * </ol>
+   * 
+   * @return A <code>ResultSet</code> with the list of available data types.
+   * @exception SQLException If an error occurs.
+   */
+  ResultSet getTypeInfo() throws SQLException;
+
+  /**
+   * This method returns information about a tables indices and statistics.
+   * It is returned as a <code>ResultSet</code> with the following columns:
+   *
+   * <ol>
+   * <li>TABLE_CAT - The catalog of the table, which may be <code>null</code>.</li>
+   * <li>TABLE_SCHEM - The schema of the table, which may be <code>null</code>.</li>
+   * <li>TABLE_NAME - The name of the table.</li>
+   * <li>NON_UNIQUE - Are index values non-unique?</li>
+   * <li>INDEX_QUALIFIER The index catalog, which may be <code>null</code></li>
+   * <li>INDEX_NAME - The name of the index.</li>
+   * <li>TYPE - The type of index, which will be one of the constants defined
+   * in this interface (<code>tableIndexStatistic</code>,
+   * <code>tableIndexClustered</code>, <code>tableIndexHashed</code>, or
+   * <code>tableIndexOther</code>).</li>
+   * <li>ORDINAL_POSITION - The sequence number of this column in the index.
+   * This will be 0 when the index type is <code>tableIndexStatistic</code>.</li>
+   * <li>COLUMN_NAME - The name of this column in the index.</li>
+   * <li>ASC_OR_DESC - "A" for an ascending sort sequence, "D" for a
+   * descending sort sequence or <code>null</code> if a sort sequence is not
+   * supported.</li>
+   * <li>CARDINALITY - The number of unique rows in the index, or the number
+   * of rows in the table if the index type is <code>tableIndexStatistic</code>.</li>
+   * <li>PAGES - The number of pages used for the index, or the number of pages
+   * in the table if the index type is <code>tableIndexStatistic</code>.</li>
+   * <li>FILTER_CONDITION - The filter condition for this index, which may be
+   * <code>null</code>.</li>
+   * </ol>
+   *
+   * @param catalog The catalog to retrieve information from, or the empty string
+   *        to return entities not associated with a catalog, or 
+   *        <code>null</code> to return information from all catalogs.
+   * @param schema The schema to retrieve information from, or the empty string
+   *        to return entities not associated with a schema.
+   * @param tableName The table name to return information for.
+   * @param unique <code>true</code> to return only unique indexes, 
+   *        <code>false</code> otherwise.
+   * @param approximate <code>true</code> if data values can be approximations,
+   *        <code>false</code> otherwise.
+   * @return A <code>ResultSet</code> with the requested index information
+   * @exception SQLException If an error occurs.
+   */
+  ResultSet getIndexInfo(String catalog, String schema, String tableName,
+    boolean unique, boolean approximate) throws SQLException;
+
+  /**
+   * This method tests whether or not the datbase supports the specified
+   * result type.
+   *
+   * @param type The desired result type, which is one of the constants
+   * defined in <code>ResultSet</code>.
+   *
+   * @return <code>true</code> if the result set type is supported,
+   * <code>false</code> otherwise.
+   *
+   * @exception SQLException If an error occurs.
+   *
+   * @see ResultSet
+   */
+  boolean supportsResultSetType(int type) throws SQLException;
+
+  /**
+   * This method tests whether the specified result set type and result set
+   * concurrency type are supported by the database.
+   *
+   * @param type The desired result type, which is one of the constants
+   *        defined in <code>ResultSet</code>.
+   * @param concurrency The desired concurrency type, which is one of the
+   *                    constants defined in <code>ResultSet</code>.
+   * @return <code>true</code> if the result set type is supported,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   * @see ResultSet
+   */
+  boolean supportsResultSetConcurrency(int type, int concurrency)
+      throws SQLException;
+
+  /**
+   * This method tests whether or not the specified result set type sees its
+   * own updates.
+   *
+   * @param type The desired result type, which is one of the constants
+   *        defined in <code>ResultSet</code>.
+   * @return <code>true</code> if the result set type sees its own updates,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   * @see ResultSet
+   */
+  boolean ownUpdatesAreVisible(int type) throws SQLException;
+
+ /**
+   * This method tests whether or not the specified result set type sees its
+   * own deletes.
+   *
+   * @param type The desired result type, which is one of the constants
+   *        defined in <code>ResultSet</code>.
+   * @return <code>true</code> if the result set type sees its own deletes,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   * @see ResultSet
+   */
+  boolean ownDeletesAreVisible(int type) throws SQLException;
+
+  /**
+   * This method tests whether or not the specified result set type sees its
+   * own inserts.
+   *
+   * @param type The desired result type, which is one of the constants
+   *        defined in <code>ResultSet</code>.
+   * @return <code>true</code> if the result set type sees its own inserts,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   * @see ResultSet
+   */
+  boolean ownInsertsAreVisible(int type) throws SQLException;
+
+  /**
+   * This method tests whether or not the specified result set type sees 
+   * updates committed by others.
+   *
+   * @param type The desired result type, which is one of the constants
+   *        defined in <code>ResultSet</code>.
+   * @return <code>true</code> if the result set type sees other updates,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   * @see ResultSet
+   */
+  boolean othersUpdatesAreVisible(int type) throws SQLException;
+
+  /**
+   * This method tests whether or not the specified result set type sees 
+   * deletes committed by others.
+   *
+   * @param type The desired result type, which is one of the constants
+   *        defined in <code>ResultSet</code>.
+   * @return <code>true</code> if the result set type sees other deletes,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   * @see ResultSet
+   */
+  boolean othersDeletesAreVisible(int type) throws SQLException;
+
+  /**
+   * This method tests whether or not the specified result set type sees 
+   * inserts committed by others.
+   *
+   * @param type The desired result type, which is one of the constants
+   *        defined in <code>ResultSet</code>.
+   * @return <code>true</code> if the result set type sees other inserts,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   * @see ResultSet
+   */
+  boolean othersInsertsAreVisible(int type) throws SQLException;
+
+  /**
+   * This method tests whether or not the specified result set type can detect
+   * a visible update by calling the <code>rowUpdated</code> method.
+   *
+   * @param type The desired result type, which is one of the constants
+   *        defined in <code>ResultSet</code>.
+   * @return <code>true</code> if the result set type can detect visible updates
+   *         using <code>rowUpdated</code>, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   * @see ResultSet
+   */
+  boolean updatesAreDetected(int type) throws SQLException;
+
+  /**
+   * This method tests whether or not the specified result set type can detect
+   * a visible delete by calling the <code>rowUpdated</code> method.
+   *
+   * @param type The desired result type, which is one of the constants
+   *        defined in <code>ResultSet</code>.
+   * @return <code>true</code> if the result set type can detect visible deletes
+   *         using <code>rowUpdated</code>, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   * @see ResultSet
+   */
+  boolean deletesAreDetected(int type) throws SQLException;
+  
+  /**
+   * This method tests whether or not the specified result set type can detect
+   * a visible insert by calling the <code>rowUpdated</code> method.
+   *
+   * @param type The desired result type, which is one of the constants
+   *        defined in <code>ResultSet</code>.
+   * @return <code>true</code> if the result set type can detect visible inserts
+   *         using <code>rowUpdated</code>, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   * @see ResultSet
+   */
+  boolean insertsAreDetected(int type) throws SQLException;
+
+  /**
+   * This method tests whether or not the database supports batch updates.
+   *
+   * @return <code>true</code> if batch updates are supported,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean supportsBatchUpdates() throws SQLException;
+
+  /**
+   * This method returns the list of user defined data types in use.  These
+   * are returned as a <code>ResultSet</code> with the following columns:
+   *
+   * <ol>
+   * <li>TYPE_CAT - The catalog name, which may be <code>null</code>.</li>
+   * <li>TYPE_SCEHM - The schema name, which may be <code>null</code>.</li>
+   * <li>TYPE_NAME - The user defined data type name.</li>
+   * <li>CLASS_NAME - The Java class name this type maps to.</li>
+   * <li>DATA_TYPE - A type identifier from <code>Types</code> for this type.
+   * This will be one of <code>JAVA_OBJECT</code>, <code>STRUCT</code>, or
+   * <code>DISTINCT</code>.</li>
+   * <li>REMARKS - Comments about this data type.</li>
+   * </ol>
+   *
+   * @param catalog The catalog to retrieve information from, or the empty string
+   *        to return entities not associated with a catalog, or <code>null</code>
+   *        to return information from all catalogs.
+   * @param schemaPattern The schema to retrieve information from, or the
+   *        empty string to return entities not associated with a schema.
+   * @param typePattern The type name pattern to match.
+   * @param types The type identifier patterns (from <code>Types</code>) to
+   *        match.
+   * @return A <code>ResultSet</code> with the requested type information
+   * @exception SQLException If an error occurs.
+   */
+  ResultSet getUDTs(String catalog, String schemaPattern, String
+      typePattern, int[] types) throws SQLException;
+
+  /**
+   * This method returns the <code>Connection</code> object that was used
+   * to generate the metadata in this object.
+   *
+   * @return The connection for this object.
+   * @exception SQLException If an error occurs.
+   */
+  Connection getConnection() throws SQLException;
+
+  /**
+   * This method tests whether the databse supports savepoints.
+   * 
+   * @return <code>true</code> if the database supports savepoints,
+   *         <code>false</code> if it does not.
+   * @exception SQLException If an error occurs.
+   * @see Savepoint
+   * @since 1.4
+   */
+  boolean supportsSavepoints() throws SQLException;
+
+  /**
+   * This method tests whether the database supports named parameters.
+   * 
+   * @return <code>true</code> if the database supports named parameters,
+   *         <code>false</code> if it does not.
+   * @exception SQLException If an error occurs.
+   * @since 1.4
+   */
+  boolean supportsNamedParameters() throws SQLException;
+
+  /**
+   * This method tests whether the database supports returning multiple
+   * <code>ResultSet</code>S from a <code>CallableStatement</code> at once.
+   * 
+   * @return <code>true</code> if the database supports returnig multiple
+   *         results at once, <code>false</code> if it does not.
+   * @exception SQLException If an error occurs.
+   * @since 1.4
+   */
+  boolean supportsMultipleOpenResults() throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  boolean supportsGetGeneratedKeys() throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  ResultSet getSuperTypes(String catalog, String schemaPattern,
+    String typePattern) throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  ResultSet getSuperTables(String catalog, String schemaPattern,
+    String tablePattern) throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  ResultSet getAttributes(String catalog, String schemaPattern, String
+    typePattern, String attributePattern) throws SQLException;
+
+  /**
+   * This method tests if the database supports the specified holdability type.
+   * Valid values for this parameter are specified in the
+   * <code>ResultSet</code> class.
+   * 
+   * @param holdability The holdability type to test.
+   * @return <code>true</code> if the database supports the holdability type,
+   *         <code>false</code> if it does not.
+   * @exception SQLException If an error occurs.
+   * @see ResultSet
+   * @since 1.4
+   */
+  boolean supportsResultSetHoldability(int holdability)
+    throws SQLException;
+
+  /**
+   * This method returns the default holdability type of <code>ResultSet</code>S
+   * retrieved from this database. The possible values are specified in the
+   * <code>ResultSet</code> class.
+   * 
+   * @return The default holdability type.
+   * @exception SQLException If an error occurs.
+   * @since 1.4
+   */
+  int getResultSetHoldability() throws SQLException;
+
+  /**
+   * This method returns the major version number of the database.
+   * 
+   * @return The major version number of the database.
+   * @exception SQLException If an error occurs.
+   * @since 1.4
+   */
+  int getDatabaseMajorVersion() throws SQLException;
+
+  /**
+   * This method returns the minor version number of the database.
+   * 
+   * @return The minor version number of the database.
+   * @exception SQLException If an error occurs.
+   * @since 1.4
+   */
+  int getDatabaseMinorVersion() throws SQLException;
+
+  /**
+   * This method returns the major version number of the JDBC driver.
+   * 
+   * @return The major version number of the JDBC driver.
+   * @exception  SQLException If an error occurs.
+   * @since 1.4
+   */
+  int getJDBCMajorVersion() throws SQLException;
+
+  /**
+   * This method returns the minor version number of the JDBC driver.
+   * 
+   * @return The minor version number of the database.
+   * @exception SQLException If an error occurs.
+   * @since 1.4
+   */
+  int getJDBCMinorVersion() throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  int getSQLStateType() throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  boolean locatorsUpdateCopy() throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  boolean supportsStatementPooling() throws SQLException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Date.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Date.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Date.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Date.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,184 @@
+/* Date.java -- Wrapper around java.util.Date
+   Copyright (C) 1999, 2000, 2003, 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.sql;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+
+/**
+  * This class is a wrapper around java.util.Date to allow the JDBC
+  * driver to identify the value as a SQL Date.
+  *
+  * @author Aaron M. Renn (arenn at urbanophile.com)
+  */
+public class Date extends java.util.Date 
+{
+  static final long serialVersionUID = 1511598038487230103L;
+
+  /**
+   * Used for parsing and formatting this date.
+   */
+  private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+
+  /**
+   * This method initializes a new instance of this class with the
+   * specified year, month, and day.
+   *
+   * @param year The year of this date minue 1900.
+   * @param month The month of this date (0-11).
+   * @param day The day of this date (1-31).
+   *
+   * @deprecated
+   */
+  public Date(int year, int month, int day)
+  {
+    super(year, month, day);  
+  }
+
+  /**
+   * This method initializes a new instance of this class with the
+   * specified time value representing the number of milliseconds since 
+   * Jan 1, 1970 at 12:00 midnight GMT.
+   *
+   * @param date The time value to intialize this date to.
+   */
+  public Date(long date)
+  {
+    super(date);
+  }
+
+  /**
+   * This method always throws an IllegalArgumentException.
+   *
+   * @throws IllegalArgumentException when it's called.
+   * @deprecated
+   */
+  public int getHours() throws IllegalArgumentException
+  {
+    throw new IllegalArgumentException();
+  }
+
+  /**
+   * This method always throws an IllegalArgumentException.
+   *
+   * @throws IllegalArgumentException when it's called.
+   * @deprecated
+   */
+  public int getMinutes() throws IllegalArgumentException
+  {
+    throw new IllegalArgumentException();
+  }
+
+  /**
+   * This method always throws an IllegalArgumentException.
+   *
+   * @throws IllegalArgumentException when it's called.
+   * @deprecated
+   */
+  public int getSeconds() throws IllegalArgumentException
+  {
+    throw new IllegalArgumentException();
+  }
+
+  /**
+   * This method always throws an IllegalArgumentException.
+   *
+   * @throws IllegalArgumentException when it's called.
+   * @deprecated
+   */
+  public void setHours(int newValue) throws IllegalArgumentException
+  {
+    throw new IllegalArgumentException();
+  }
+
+  /**
+   * This method always throws an IllegalArgumentException.
+   *
+   * @throws IllegalArgumentException when it's called.
+   * @deprecated
+   */
+  public void setMinutes(int newValue) throws IllegalArgumentException
+  {
+    throw new IllegalArgumentException();
+  }
+
+  /**
+   * This method always throws an IllegalArgumentException.
+   *
+   * @throws IllegalArgumentException when it's called.
+   * @deprecated
+   */
+  public void setSeconds(int newValue) throws IllegalArgumentException
+  {
+    throw new IllegalArgumentException();
+  }
+
+  /**
+   * This method returns a new instance of this class by parsing a
+   * date in JDBC format into a Java date.
+   *
+   * @param str The string to parse.
+   * @return The resulting <code>java.sql.Date</code> value.
+   */
+  public static Date valueOf (String str)
+  {
+    try 
+      {
+	java.util.Date d = (java.util.Date) sdf.parseObject(str);
+
+	if (d == null)
+	  throw new IllegalArgumentException(str);
+	else
+	  return new Date(d.getTime());
+      }
+    catch (ParseException e)
+      {
+	throw new IllegalArgumentException(str);
+      }
+  }
+
+  /**
+   * This method returns this date in JDBC format.
+   *
+   * @return This date as a string.
+   */
+  public String toString()
+  {
+    return sdf.format(this);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Driver.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Driver.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Driver.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Driver.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,123 @@
+/* Driver.java -- A JDBC driver
+   Copyright (C) 1999, 2000, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.sql;
+
+import java.util.Properties;
+
+/**
+  * This interface specifies a mechanism for accessing a JDBC database
+  * driver.  When the class implementing this method is loaded, it should
+  * register an instance of itself with the <code>DriverManager</code> in
+  * a static initializer.  
+  * <p>
+  * Because the <code>DriverManager</code> might attempt to use several
+  * drivers to find one that can connect to the requested database, 
+  * this driver should not cause large numbers of classes and code to
+  * be loaded.  If another driver is the one that ends up performing the
+  * request, any loading done by this driver would be wasted.
+  *
+  * @author Aaron M. Renn (arenn at urbanophile.com)
+  */
+public interface Driver 
+{
+  /**
+   * This method connects to the specified database using the connection
+   * properties supplied.  If the driver does not understand the database
+   * URL, it should return <code>null</code> instead of throwing an
+   * exception since the <code>DriverManager</code> will probe a driver
+   * in this manner.
+   * 
+   * @param url The URL string for this connection.
+   * @param properties The list of database connection properties.
+   * @return A <code>Connection</code> object for the newly established
+   *         connection, or <code>null</code> if the URL is not understood.
+   * @exception SQLException If an error occurs.
+   */
+  Connection connect(String url, Properties properties) throws SQLException;
+
+  /**
+   * This method tests whether or not the driver believes it can connect to
+   * the specified database.  The driver should only test whether it 
+   * understands and accepts the URL. It should not necessarily attempt to 
+   * probe the database for a connection.
+   *
+   * @param url The database URL string.
+   * @return <code>true</code> if the drivers can connect to the database, 
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean acceptsURL(String url) throws SQLException;
+
+  /**
+   * This method returns an array of possible properties that could be
+   * used to connect to the specified database.
+   *
+   * @param url The URL string of the database to connect to.
+   * @param properties The list of properties the caller is planning to use
+   *        to connect to the database.
+   * @return A list of possible additional properties for a connection to this
+   *         database.  This list may be empty.
+   * @exception SQLException If an error occurs.
+   */
+  DriverPropertyInfo[] getPropertyInfo(String url, Properties properties)
+    throws SQLException;
+
+  /**
+   * This method returns the major version number of the driver.
+   *
+   * @return The major version number of the driver.
+   */      
+  int getMajorVersion();
+
+  /**
+   * This method returns the minor version number of the driver.
+   *
+   * @return The minor version number of the driver.
+   */
+  int getMinorVersion();
+
+  /**
+   * This method tests whether or not the driver is JDBC compliant.  This
+   * method should only return <code>true</code> if the driver has been
+   * certified as JDBC compliant.
+   *
+   * @return <code>true</code> if the driver has been certified JDBC compliant,
+   *         <code>false</code> otherwise.
+   */
+  boolean jdbcCompliant();
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/DriverManager.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/DriverManager.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/DriverManager.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/DriverManager.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,345 @@
+/* DriverManager.java -- Manage JDBC drivers
+   Copyright (C) 1999, 2000, 2001, 2003, 2004, 2006
+   Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.sql;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+/**
+  * This class manages the JDBC drivers in the system. It maintains a
+  * registry of drivers and locates the appropriate driver to handle a
+  * JDBC database URL.
+  * <p>
+  * On startup, <code>DriverManager</code> loads all the managers specified
+  * by the system property <code>jdbc.drivers</code>.  The value of this
+  * property should be a colon separated list of fully qualified driver
+  * class names.  Additional drivers can be loaded at any time by
+  * simply loading the driver class with <code>class.forName(String)</code>.
+  * The driver should automatically register itself in a static 
+  * initializer.
+  * <p>
+  * The methods in this class are all <code>static</code>. This class
+  * cannot be instantiated.
+  *
+  * @author Aaron M. Renn (arenn at urbanophile.com)
+  */
+public class DriverManager 
+{
+  /**
+   * This is the log stream for JDBC drivers.
+   */
+  private static PrintStream log_stream;
+
+  /**
+   * This is the log writer for JDBC drivers.
+   */
+  private static PrintWriter log_writer;
+
+  /**
+   * This is the login timeout used by JDBC drivers.
+   */
+  private static int login_timeout;
+
+  /**
+   * This is the list of JDBC drivers that are loaded.
+   */
+  private static Vector drivers;
+   // Hmm, seems like we might want to do a Hashtable and lookup by something,
+   // but what would it be?
+
+  // Load all drivers on startup
+  static
+  {
+    drivers = new Vector();
+
+    String driver_string = System.getProperty("jdbc.drivers");
+    if (driver_string != null)
+      {
+	StringTokenizer st = new StringTokenizer(driver_string);
+	while (st.hasMoreTokens())
+          {
+            String driver_classname = st.nextToken();
+
+            try
+              {
+        	Class.forName(driver_classname); // The driver registers itself
+              }
+            catch (Exception e)
+	      {
+		// Ignore not founds
+	      }
+          }
+      }
+
+  }
+
+  /** Can't be instantiated. */
+  private DriverManager()
+  {
+  }
+
+  /**
+   * This method returns the log writer being used by all JDBC drivers.
+   * This method should be used in place of the deprecated
+   * <code>getLogStream</code> method.
+   *
+   * @return The log writer in use by JDBC drivers.
+   */
+  public static PrintWriter getLogWriter()
+  {
+    return log_writer;
+  }
+  
+  /**
+   * This method sets the log writer being used by JDBC drivers.  This is a
+   * system-wide parameter that affects all drivers.  Note that since there
+   * is no way to retrieve a <code>PrintStream</code> from a 
+   * <code>PrintWriter</code>, this method cannot set the log stream in
+   * use by JDBC.  Thus any older drivers may not see this setting.
+   *
+   * @param out The new log writer for JDBC.
+   */
+  public static void setLogWriter(PrintWriter out)
+  {
+    DriverManager.log_writer = out;
+  }
+
+/**
+  * This method attempts to return a connection to the specified
+  * JDBC URL string using the specified connection properties.
+  *
+  * @param url The JDBC URL string to connect to.
+  * @param properties The connection properties.
+  *
+  * @return A <code>Connection</code> to that URL.
+  *
+  * @exception SQLException If an error occurs.
+  */
+  public static Connection getConnection(String url, Properties properties)
+    throws SQLException
+  {
+    Driver d = getDriver(url);
+    if (d == null)
+      throw new SQLException("Driver not found for URL: " + url);
+
+    return d.connect(url, properties);
+  }
+
+
+  /**
+   * This method attempts to return a connection to the specified
+   * JDBC URL string using the specified username and password.
+   *
+   * @param url The JDBC URL string to connect to.
+   * @param user The username to connect with.
+   * @param password The password to connect with.
+   * @return A <code>Connection</code> to that URL.
+   * @exception SQLException If an error occurs.
+   */
+  public static Connection getConnection(String url, String user,
+    String password) throws SQLException
+  {
+    Properties p = new Properties();
+
+    if (user != null)
+      p.setProperty("user", user);
+    if (password != null)
+      p.setProperty("password", password);
+
+    return getConnection(url, p);
+  }
+
+  /**
+   * This method attempts to return a connection to the specified
+   * JDBC URL string.
+   *
+   * @param url The JDBC URL string to connect to.
+   *
+   * @return A <code>Connection</code> to that URL.
+   *
+   * @exception SQLException If an error occurs.
+   */
+  public static Connection getConnection(String url) throws SQLException
+  {
+    return getConnection(url, new Properties());
+  }
+
+  /**
+   * This method returns a driver that can connect to the specified
+   * JDBC URL string.  This will be selected from among drivers loaded
+   * at initialization time and those drivers manually loaded by the
+   * same class loader as the caller.
+   *
+   * @param url The JDBC URL string to find a driver for.
+   *
+   * @return A <code>Driver</code> that can connect to the specified
+   * URL.
+   *
+   * @exception SQLException If an error occurs, or no suitable driver can be found.
+   */
+  public static Driver getDriver(String url) throws SQLException
+  {
+    // FIXME: Limit driver search to the appropriate subset of loaded drivers.
+    Enumeration e = drivers.elements();
+    while(e.hasMoreElements())
+      {
+	Driver d = (Driver)e.nextElement();
+	if (d.acceptsURL(url))
+          return d;
+      }
+
+    throw new SQLException("No driver found for " + url);
+  }
+
+  /**
+   * This method registers a new driver with the manager.  This is normally
+   * called by the driver itself in a static initializer.
+   *
+   * @param driver The new <code>Driver</code> to add.
+   *
+   * @exception SQLException If an error occurs.
+   */
+  public static void registerDriver(Driver driver) throws SQLException
+  {
+    if (! drivers.contains(driver))
+      drivers.addElement(driver);  
+  }
+
+/**
+  * This method de-registers a driver from the manager.
+  *
+  * @param driver The <code>Driver</code> to unregister.
+  *
+  * @exception SQLException If an error occurs.
+  */
+  public static void deregisterDriver(Driver driver) throws SQLException
+  {
+    if (drivers.contains(driver))
+      drivers.removeElement(driver);
+  }
+
+  /**
+   * This method returns a list of all the currently registered JDBC drivers
+   * that were loaded by the current <code>ClassLoader</code>.
+   *
+   * @return An <code>Enumeration</code> of all currently loaded JDBC drivers.
+   */
+  public static Enumeration getDrivers()
+  {
+    Vector v = new Vector();
+    Enumeration e = drivers.elements();
+
+    // Is this right?
+    ClassLoader cl = Thread.currentThread().getContextClassLoader();
+
+    while(e.hasMoreElements())
+      {
+	Object obj = e.nextElement();
+
+	ClassLoader loader = obj.getClass().getClassLoader();
+
+	if (loader == null)
+	  loader = ClassLoader.getSystemClassLoader();
+	if (! loader.equals(cl))
+	  continue;
+
+	v.addElement(obj);
+      } 
+
+    return v.elements();
+  }
+
+  /**
+   * This method set the login timeout used by JDBC drivers.  This is a
+   * system-wide parameter that applies to all drivers.
+   *
+   * @param seconds The new login timeout value.
+   */
+  public static void setLoginTimeout(int seconds)
+  {
+    DriverManager.login_timeout = seconds;  
+  }
+
+  /**
+   * This method returns the login timeout in use by JDBC drivers systemwide.
+   *
+   * @return The login timeout.
+   */
+  public static int getLoginTimeout()
+  {
+    return login_timeout;
+  }
+
+  /**
+   * This method sets the log stream in use by JDBC.
+   *
+   * @param stream The log stream in use by JDBC.
+   * @deprecated Use <code>setLogWriter</code> instead.
+   */
+  public static void setLogStream(PrintStream stream)
+  {
+    DriverManager.log_stream = stream;
+  }
+
+  /**
+   * This method returns the log stream in use by JDBC.
+   *
+   * @return The log stream in use by JDBC.
+   * @deprecated Use <code>getLogWriter()</code> instead.
+   */
+  public static PrintStream getLogStream()
+  {
+    return log_stream;
+  }
+
+  /**
+   * This method prints the specified line to the log stream.
+   *
+   * @param message The string to write to the log stream.
+   */
+  public static void println(String message)
+  {
+    if (log_stream != null) // Watch for user not using logging
+      log_stream.println(message);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/DriverPropertyInfo.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/DriverPropertyInfo.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/DriverPropertyInfo.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/DriverPropertyInfo.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,88 @@
+/* DriverPropertyInfo.java -- Property information about drivers.
+   Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.sql;
+
+/**
+ * This class holds a driver property that can be used for querying or
+ * setting driver configuration parameters.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class DriverPropertyInfo 
+{
+  /**
+   * The name of the property.
+   */
+  public String name;
+
+  /**
+   * A description of the property, possibly <code>null</code>.
+   */
+  public String description;
+
+  /**
+   * A flag indicating whether or not a value for this property is required
+   * in order to connect to the database.
+   */
+  public boolean required;
+
+  /**
+   * This is the value of the property.
+   */
+  public String value;
+
+  /**
+    * If values are restricted to certain choices, this is the list of valid
+    * ones.  Otherwise it is <code>null</code>.
+    */
+  public String[] choices;
+
+  /**
+   * This method initializes a new instance of <code>DriverPropertyInfo</code>
+   * with the specified name and value.  All other fields are defaulted.
+   *
+   * @param name The name of the property.
+   * @param value The value to assign to the property.
+   */
+  public DriverPropertyInfo(String name, String value)
+  {
+    this.name = name;
+    this.value = value;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/ParameterMetaData.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/ParameterMetaData.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/ParameterMetaData.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/ParameterMetaData.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,103 @@
+/* ParameterMetaData.java
+   Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.sql;
+
+/**
+ * @since 1.4
+ */
+public interface ParameterMetaData 
+{
+  int parameterNoNulls = 0;
+
+  int parameterNullable = 1;
+
+  int parameterNullableUnknown = 2;
+
+  int parameterModeUnknown = 0;
+
+  int parameterModeIn = 1;
+
+  int parameterModeInOut = 2;
+
+  int parameterModeOut = 4;
+
+  /**
+   * @since 1.4
+   */
+  int getParameterCount() throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  int isNullable(int param) throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  boolean isSigned(int param) throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  int getPrecision(int param) throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  int getScale(int param) throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  int getParameterType(int param) throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  String getParameterTypeName(int param) throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  String getParameterClassName(int param) throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  int getParameterMode(int param) throws SQLException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/PreparedStatement.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/PreparedStatement.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/PreparedStatement.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/PreparedStatement.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,458 @@
+/* PreparedStatement.java -- Interface for pre-compiled statements.
+   Copyright (C) 1999, 2000, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.sql;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.util.Calendar;
+
+/**
+ * This interface provides a mechanism for executing pre-compiled
+ * statements.  This provides greater efficiency when calling the same
+ * statement multiple times.  Parameters are allowed in a statement,
+ * providings for maximum reusability.
+ * 
+ * <p> Note that in this class parameter indices start at 1, not 0.</p>
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public interface PreparedStatement extends Statement 
+{
+  /**
+   * This method executes a prepared SQL query and returns its ResultSet.
+   *
+   * @return The ResultSet of the SQL statement.
+   * @exception SQLException If an error occurs.
+   */
+  ResultSet executeQuery() throws SQLException;
+
+  /**
+   * This method executes an SQL INSERT, UPDATE or DELETE statement.  SQL
+   * statements that return nothing such as SQL DDL statements can be executed.
+   *
+   * @return The result is either the row count for INSERT, UPDATE or DELETE
+   *         statements; or 0 for SQL statements that return nothing.
+   * @exception SQLException If an error occurs.
+   */
+  int executeUpdate() throws SQLException;
+
+  /**
+   * This method populates the specified parameter with a SQL NULL value
+   * for the specified type.
+   *
+   * @param index The index of the parameter to set.
+   * @param sqlType The SQL type identifier of the parameter from 
+   *                <code>Types</code>
+   *
+   * @exception SQLException If an error occurs.
+   */
+  void setNull(int index, int sqlType) throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>boolean</code> value.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The value of the parameter.
+   * @exception SQLException If an error occurs.
+   */
+  void setBoolean(int index, boolean value) throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>byte</code> value.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The value of the parameter.
+   * @exception SQLException If an error occurs.
+   */
+  void setByte(int index, byte value) throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>short</code> value.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The value of the parameter.
+   * @exception SQLException If an error occurs.
+   */
+  void setShort(int index, short value) throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>int</code> value.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The value of the parameter.
+   * @exception SQLException If an error occurs.
+   */
+  void setInt(int index, int value) throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>long</code> value.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The value of the parameter.
+   * @exception SQLException If an error occurs.
+   */
+  void setLong(int index, long value) throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>float</code> value.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The value of the parameter.
+   * @exception SQLException If an error occurs.
+   */
+  void setFloat(int index, float value) throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>double</code> value.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The value of the parameter.
+   * @exception SQLException If an error occurs.
+   */
+  void setDouble(int index, double value) throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>java.math.BigDecimal</code> value.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The value of the parameter.
+   * @exception SQLException If an error occurs.
+   */
+  void setBigDecimal(int index, BigDecimal value) throws
+      SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>String</code> value.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The value of the parameter.
+   * @exception SQLException If an error occurs.
+   */
+  void setString(int index, String value) throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>byte</code> array value.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The value of the parameter.
+   * @exception SQLException If an error occurs.
+   */
+  void setBytes(int index, byte[] value) throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>java.sql.Date</code> value.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The value of the parameter.
+   * @exception SQLException If an error occurs.
+   */
+  void setDate(int index, Date value) throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>java.sql.Time</code> value.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The value of the parameter.
+   * @exception SQLException If an error occurs.
+   */
+  void setTime(int index, Time value) throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>java.sql.Timestamp</code> value.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The value of the parameter.
+   * @exception SQLException If an error occurs.
+   */
+  void setTimestamp(int index, Timestamp value)
+    throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * ASCII <code>InputStream</code> value.
+   *
+   * @param index The index of the parameter value to set.
+   * @param stream The stream from which the parameter value is read.
+   * @param count The number of bytes in the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void setAsciiStream(int index, InputStream stream, int count)
+    throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * Unicode UTF-8 <code>InputStream</code> value.
+   *
+   * @param index The index of the parameter value to set.
+   * @param stream The stream from which the parameter value is read.
+   * @param count The number of bytes in the stream.
+   * @exception SQLException If an error occurs.
+   * @deprecated
+   */
+  void setUnicodeStream(int index, InputStream stream, int count)
+    throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * binary <code>InputStream</code> value.
+   *
+   * @param index The index of the parameter value to set.
+   * @param stream The stream from which the parameter value is read.
+   * @param count The number of bytes in the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void setBinaryStream(int index, InputStream stream, int count)
+    throws SQLException;
+
+  /**
+   * This method clears all of the input parameter that have been
+   * set on this statement.
+   *
+   * @exception SQLException If an error occurs.
+   */
+  void clearParameters() throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>Object</code> value.  The specified SQL object type will be used.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The value of the parameter.
+   * @param sqlType The SQL type to use for the parameter, from 
+   *                <code>Types</code>
+   * @param scale The scale of the value, for numeric values only.
+   * @exception SQLException If an error occurs.
+   * @see Types
+   */
+  void setObject(int index, Object value, int sqlType, int scale)
+    throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>Object</code> value.  The specified SQL object type will be used.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The value of the parameter.
+   * @param sqlType The SQL type to use for the parameter, from 
+   *                      <code>Types</code>
+   * @exception SQLException If an error occurs.
+   * @see Types
+   */
+  void setObject(int index, Object value, int sqlType)
+    throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>Object</code> value.  The default object type to SQL type mapping
+   * will be used.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The value of the parameter.
+   * @exception SQLException If an error occurs.
+   */
+  void setObject(int index, Object value) throws SQLException;
+
+  /**
+   * This method executes a prepared SQL query.
+   * Some prepared statements return multiple results; the execute method
+   * handles these complex statements as well as the simpler form of
+   * statements handled by executeQuery and executeUpdate.
+   *
+   * @return The result of the SQL statement.
+   * @exception SQLException If an error occurs.
+   */
+  boolean execute() throws SQLException;
+
+  /**
+   * This method adds a set of parameters to the batch for JDBC 2.0.
+   * @exception SQLException If an error occurs.
+   */
+  void addBatch() throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * character <code>Reader</code> value.
+   *
+   * @param index The index of the parameter value to set.
+   * @param reader The reader from which the parameter value is read.
+   * @param count The number of characters in the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void setCharacterStream(int index, Reader reader, int count)
+  throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>Ref</code> value.  The default object type to SQL type mapping
+   * will be used.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The <code>Ref</code> used to set the value of the parameter.
+   * @exception SQLException If an error occurs.
+   */
+  void setRef(int index, Ref value) throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>Blob</code> value.  The default object type to SQL type mapping
+   * will be used.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The <code>Blob</code> used to set the 
+   *             value of the parameter.
+   * @exception SQLException If an error occurs.
+   */
+  void setBlob(int index, Blob value) throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>Clob</code> value.  The default object type to SQL type mapping
+   * will be used.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The <code>Clob</code> used to set the
+   *              value of the parameter.
+   * @exception SQLException If an error occurs.
+   */
+  void setClob(int index, Clob value) throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>Array</code> value.  The default object type to SQL type mapping
+   * will be used.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The value of the parameter.
+   * @exception SQLException If an error occurs.
+   */
+  void setArray(int index, Array value) throws SQLException;
+
+  /**
+   * This method returns meta data for the result set from this statement.
+   *
+   * @return Meta data for the result set from this statement.
+   * @exception SQLException If an error occurs.
+   */
+  ResultSetMetaData getMetaData() throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>java.sql.Date</code> value.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The value of the parameter.
+   * @param cal The <code>Calendar</code> to use for timezone and locale.
+   * @exception SQLException If an error occurs.
+   */
+  void setDate(int index, Date value, Calendar cal)
+    throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>java.sql.Time</code> value.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The value of the parameter.
+   * @param cal The <code>Calendar</code> to use for timezone and locale.
+   * @exception SQLException If an error occurs.
+   */
+  void setTime(int index, Time value, Calendar cal)
+    throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>java.sql.Timestamp</code> value.
+   *
+   * @param index The index of the parameter value to set.
+   * @param value The value of the parameter.
+   * @param cal The <code>Calendar</code> to use for timezone and locale.
+   * @exception SQLException If an error occurs.
+   */
+  void setTimestamp(int index, Timestamp value, Calendar cal)
+    throws SQLException;
+
+  /**
+   * This method populates the specified parameter with a SQL NULL value
+   * for the specified type.
+   *
+   * @param index The index of the parameter to set.
+   * @param sqlType The SQL type identifier of the parameter from
+   *                <code>Types</code>
+   * @param typeName The name of the data type, for user defined types.
+   * @exception SQLException If an error occurs.
+   */
+  void setNull(int index, int sqlType, String typeName)
+    throws SQLException;
+
+  /**
+   * This method sets the specified parameter from the given Java
+   * <code>java.net.URL</code> value.
+   * 
+   * @param index The index of the parameter to set.
+   * @param value The value of the parameter.
+   * @exception SQLException If an error occurs.
+   * @since 1.4
+   */
+  void setURL(int index, URL value) throws SQLException;
+
+  /**
+   * Returns information about the parameters set on this 
+   * <code>PreparedStatement</code> (see {@link ParameterMetaData} for a
+   * detailed description of the provided information).
+   * 
+   * @return Meta data for the parameters of this statement.
+   * @see ParameterMetaData
+   * @since 1.4
+   */
+  ParameterMetaData getParameterMetaData() throws SQLException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Ref.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Ref.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Ref.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Ref.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* Ref.java -- Reference to a SQL structured type.
+   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.sql;
+
+import java.util.Map;
+
+/**
+ * This interface provides a mechanism for obtaining information about
+ * a SQL structured type
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @since 1.2
+ */
+public interface Ref 
+{
+  /**
+   * This method returns the fully qualified name of the SQL structured
+   * type of the referenced item.
+   *
+   * @return The fully qualified name of the SQL structured type.
+   * @exception SQLException If an error occurs.
+   * @since 1.2
+   */
+  String getBaseTypeName() throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  Object getObject(Map map) throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  Object getObject() throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  void setObject(Object value) throws SQLException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/ResultSet.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/ResultSet.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/ResultSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/ResultSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1610 @@
+/* ResultSet.java -- A SQL statement result set.
+   Copyright (C) 1999, 2000, 2002, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.sql;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.util.Calendar;
+import java.util.Map;
+
+/**
+ * This interface provides access to the data set returned by a SQL
+ * statement.  An instance of this interface is returned by the various
+ * execution methods in the <code>Statement</code>.
+ *
+ * <p> This class models a cursor, which can be stepped through one row at a
+ * time.  Methods are provided for accessing columns by column name or by
+ * index.</p>
+ *
+ * <p> Note that a result set is invalidated if the statement that returned
+ * it is closed.</p>
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public interface ResultSet 
+{
+  /**
+   * The rows will be processed in order from first to last.
+   */
+  int FETCH_FORWARD = 1000;
+
+  /**
+   * The rows will be processed in order from last to first.
+   */
+  int FETCH_REVERSE = 1001;
+
+  /**
+   * The rows will be processed in an unknown order
+   */
+  int FETCH_UNKNOWN = 1002;
+
+  /**
+   * This type of result set may only step forward through the rows returned.
+   */
+  int TYPE_FORWARD_ONLY = 1003;
+
+  /**
+   * This type of result set is scrollable and is not sensitive to changes
+   * made by other statements.
+   */
+  int TYPE_SCROLL_INSENSITIVE = 1004;
+
+  /**
+   * This type of result set is scrollable and is also sensitive to changes
+   * made by other statements.
+   */
+  int TYPE_SCROLL_SENSITIVE = 1005;
+
+  /**
+   * The concurrency mode of for the result set may not be modified.
+   */
+  int CONCUR_READ_ONLY = 1007;
+
+  /**
+   * The concurrency mode of for the result set may be modified.
+   */
+  int CONCUR_UPDATABLE = 1008;
+
+  int HOLD_CURSORS_OVER_COMMIT = 1;
+
+  int CLOSE_CURSORS_AT_COMMIT = 2;
+
+  /**
+   * This method advances to the next row in the result set.  Any streams
+   * open on the current row are closed automatically.
+   *
+   * @return <code>true</code> if the next row exists, <code>false</code>
+   *         otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean next() throws SQLException;
+
+  /**
+   * This method closes the result set and frees any associated resources.
+   * 
+   * @exception SQLException If an error occurs.
+   */
+  void close() throws SQLException;
+
+  /**
+   * This method tests whether the value of the last column that was fetched
+   * was actually a SQL NULL value.
+   *
+   * @return <code>true</code> if the last column fetched was a NULL,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean wasNull() throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>String</code>.
+   *
+   * @param columnIndex The index of the column to return.
+   * @return The column value as a <code>String</code>.
+   * @exception SQLException If an error occurs.
+   */
+  String getString(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>boolean</code>.
+   *
+   * @param columnIndex The index of the column to return.
+   * @return The column value as a <code>boolean</code>.
+   * @exception SQLException If an error occurs.
+   */
+  boolean getBoolean(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>byte</code>.
+   *
+   * @param columnIndex The index of the column to return.
+   * @return The column value as a <code>byte</code>.
+   * @exception SQLException If an error occurs.
+   */
+  byte getByte(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>short</code>.
+   *
+   * @param columnIndex The index of the column to return.
+   * @return The column value as a <code>short</code>.
+   * @exception SQLException If an error occurs.
+   */
+  short getShort(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>int</code>.
+   *
+   * @param columnIndex The index of the column to return.
+   * @return The column value as a <code>int</code>.
+   * @exception SQLException If an error occurs.
+   */
+  int getInt(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>long</code>.
+   *
+   * @param columnIndex The index of the column to return.
+   * @return The column value as a <code>long</code>.
+   * @exception SQLException If an error occurs.
+   */
+  long getLong(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>float</code>.
+   *
+   * @param columnIndex The index of the column to return.
+   * @return The column value as a <code>float</code>.
+   * @exception SQLException If an error occurs.
+   */
+  float getFloat(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>double</code>.
+   *
+   * @param columnIndex The index of the column to return.
+   * @return The column value as a <code>double</code>.
+   * @exception SQLException If an error occurs.
+   */
+  double getDouble(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>BigDecimal</code>.
+   *
+   * @param columnIndex The index of the column to return.
+   * @param scale The number of digits to the right of the decimal to return.
+   * @return The column value as a <code>BigDecimal</code>.
+   * @exception SQLException If an error occurs.
+   * @deprecated
+   */
+  BigDecimal getBigDecimal(int columnIndex, int scale)
+    throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * byte array.
+   *
+   * @param columnIndex The index of the column to return.
+   * @return The column value as a byte array
+   * @exception SQLException If an error occurs.
+   */
+  byte[] getBytes(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>java.sql.Date</code>.
+   *
+   * @param columnIndex The index of the column to return.
+   * @return The column value as a <code>java.sql.Date</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Date getDate(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>java.sql.Time</code>.
+   *
+   * @param columnIndex The index of the column to return.
+   * @return The column value as a <code>java.sql.Time</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Time getTime(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>java.sql.Timestamp</code>.
+   *
+   * @param columnIndex The index of the column to return.
+   * @return The column value as a <code>java.sql.Timestamp</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Timestamp getTimestamp(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as an ASCII 
+   * stream.  Note that all the data from this stream must be read before
+   * fetching the value of any other column.  Please also be aware that 
+   * calling <code>next()</code> or <code>close()</code> on this result set
+   * will close this stream as well.
+   *
+   * @param columnIndex The index of the column to return.
+   * @return The column value as an ASCII <code>InputStream</code>.
+   * @exception SQLException If an error occurs.
+   */
+  InputStream getAsciiStream(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Unicode UTF-8
+   * stream.  Note that all the data from this stream must be read before
+   * fetching the value of any other column.  Please also be aware that 
+   * calling <code>next()</code> or <code>close()</code> on this result set
+   * will close this stream as well.
+   *
+   * @param columnIndex The index of the column to return.
+   * @return The column value as a Unicode UTF-8 <code>InputStream</code>.
+   * @exception SQLException If an error occurs.
+   * @deprecated Use getCharacterStream instead.
+   */
+  InputStream getUnicodeStream(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a raw byte
+   * stream.  Note that all the data from this stream must be read before
+   * fetching the value of any other column.  Please also be aware that 
+   * calling <code>next()</code> or <code>close()</code> on this result set
+   * will close this stream as well.
+   *
+   * @param columnIndex The index of the column to return.
+   * @return The column value as a raw byte <code>InputStream</code>.
+   * @exception SQLException If an error occurs.
+   */
+  InputStream getBinaryStream(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>String</code>.
+   *
+   * @param columnName The name of the column to return.
+   * @return The column value as a <code>String</code>.
+   * @exception SQLException If an error occurs.
+   */
+  String getString(String columnName) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>boolean</code>.
+   *
+   * @param columnName The name of the column to return.
+   * @return The column value as a <code>boolean</code>.
+   * @exception SQLException If an error occurs.
+   */
+  boolean getBoolean(String columnName) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>byte</code>.
+   *
+   * @param columnName The name of the column to return.
+   * @return The column value as a <code>byte</code>.
+   * @exception SQLException If an error occurs.
+   */
+  byte getByte(String columnName) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>short</code>.
+   *
+   * @param columnName The name of the column to return.
+   * @return The column value as a <code>short</code>.
+   * @exception SQLException If an error occurs.
+   */
+  short getShort(String columnName) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>int</code>.
+   *
+   * @param columnName The name of the column to return.
+   * @return The column value as a <code>int</code>.
+   * @exception SQLException If an error occurs.
+   */
+  int getInt(String columnName) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>long</code>.
+   *
+   * @param columnName The name of the column to return.
+   * @return The column value as a <code>long</code>.
+   * @exception SQLException If an error occurs.
+   */
+  long getLong(String columnName) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>float</code>.
+   *
+   * @param columnName The name of the column to return.
+   * @return The column value as a <code>float</code>.
+   * @exception SQLException If an error occurs.
+   */
+  float getFloat(String columnName) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>double</code>.
+   *
+   * @param columnName The name of the column to return.
+   * @return The column value as a <code>double</code>.
+   * @exception SQLException If an error occurs.
+   */
+  double getDouble(String columnName) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>BigDecimal</code>.
+   *
+   * @param columnName The name of the column to return.
+   * @return The column value as a <code>BigDecimal</code>.
+   * @exception SQLException If an error occurs.
+   * @deprecated
+   */
+  BigDecimal getBigDecimal(String columnName, int scale)
+    throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * byte array.
+   *
+   * @param columnName The name of the column to return.
+   * @return The column value as a byte array
+   * @exception SQLException If an error occurs.
+   */
+  byte[] getBytes(String columnName) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>java.sql.Date</code>.
+   *
+   * @param columnName The name of the column to return.
+   * @return The column value as a <code>java.sql.Date</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Date getDate(String columnName) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>java.sql.Time</code>.
+   *
+   * @param columnName The name of the column to return.
+   * @return The column value as a <code>java.sql.Time</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Time getTime(String columnName) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>java.sql.Timestamp</code>.
+   *
+   * @param columnName The name of the column to return.
+   * @return The column value as a <code>java.sql.Timestamp</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Timestamp getTimestamp(String columnName) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as an ASCII 
+   * stream.  Note that all the data from this stream must be read before
+   * fetching the value of any other column.  Please also be aware that 
+   * calling <code>next()</code> or <code>close()</code> on this result set
+   * will close this stream as well.
+   *
+   * @param columnName The name of the column to return.
+   * @return The column value as an ASCII <code>InputStream</code>.
+   * @exception SQLException If an error occurs.
+   */
+  InputStream getAsciiStream(String columnName) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Unicode UTF-8
+   * stream.  Note that all the data from this stream must be read before
+   * fetching the value of any other column.  Please also be aware that 
+   * calling <code>next()</code> or <code>close()</code> on this result set
+   * will close this stream as well.
+   *
+   * @param columnName The name of the column to return.
+   * @return The column value as a Unicode UTF-8 <code>InputStream</code>.
+   * @exception SQLException If an error occurs.
+   * @deprecated Use getCharacterStream instead.
+   */
+  InputStream getUnicodeStream(String columnName) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a raw byte
+   * stream.  Note that all the data from this stream must be read before
+   * fetching the value of any other column.  Please also be aware that 
+   * calling <code>next()</code> or <code>close()</code> on this result set
+   * will close this stream as well.
+   *
+   * @param columnName The name of the column to return.
+   * @return The column value as a raw byte <code>InputStream</code>.
+   * @exception SQLException If an error occurs.
+   */
+  InputStream getBinaryStream(String columnName) throws SQLException;
+
+  /**
+   * This method returns the first SQL warning associated with this result
+   * set.  Any additional warnings will be chained to this one.
+   *
+   * @return The first SQLWarning for this result set, or <code>null</code> if
+   *         there are no warnings.
+   * @exception SQLException If an error occurs.
+   */
+  SQLWarning getWarnings() throws SQLException;
+
+  /**
+   * This method clears all warnings associated with this result set.
+   *
+   * @exception SQLException If an error occurs.
+   */
+  void clearWarnings() throws SQLException;
+
+  /**
+   * This method returns the name of the database cursor used by this
+   * result set.
+   *
+   * @return The name of the database cursor used by this result set.
+   * @exception SQLException If an error occurs.
+   */
+  String getCursorName() throws SQLException;
+
+  /**
+   * This method returns data about the columns returned as part of the
+   * result set as a <code>ResultSetMetaData</code> instance.
+   *
+   * @return The <code>ResultSetMetaData</code> instance for this result set.
+   * @exception SQLException If an error occurs.
+   */
+  ResultSetMetaData getMetaData() throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>Object</code>.
+   *
+   * @param columnIndex The index of the column to return.
+   * @return The column value as an <code>Object</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Object getObject(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>Object</code>.
+   *
+   * @param columnName The name of the column to return.
+   * @return The column value as an <code>Object</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Object getObject(String columnName) throws SQLException;
+
+  /**
+   * This method returns the column index of the specified named column.
+   *
+   * @param columnName The name of the column.
+   * @return The index of the column.
+   * @exception SQLException If an error occurs.
+   */
+  int findColumn(String columnName) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a character
+   * stream.  Note that all the data from this stream must be read before
+   * fetching the value of any other column.  Please also be aware that 
+   * calling <code>next()</code> or <code>close()</code> on this result set
+   * will close this stream as well.
+   *
+   * @param columnIndex The index of the column to return.
+   * @return The column value as an character <code>Reader</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Reader getCharacterStream(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a character
+   * stream.  Note that all the data from this stream must be read before
+   * fetching the value of any other column.  Please also be aware that 
+   * calling <code>next()</code> or <code>close()</code> on this result set
+   * will close this stream as well.
+   *
+   * @param columnName The name of the column to return.
+   * @return The column value as an character <code>Reader</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Reader getCharacterStream(String columnName) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>BigDecimal</code>.
+   *
+   * @param columnIndex The index of the column to return.
+   * @return The column value as a <code>BigDecimal</code>.
+   * @exception SQLException If an error occurs.
+   */
+  BigDecimal getBigDecimal(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>BigDecimal</code>.
+   *
+   * @param columnName The name of the column to return.
+   * @return The column value as a <code>BigDecimal</code>.
+   * @exception SQLException If an error occurs.
+   */
+  BigDecimal getBigDecimal(String columnName) throws SQLException;
+
+  /**
+   * This method tests whether or not the cursor is before the first row
+   * in the result set.
+   *
+   * @return <code>true</code> if the cursor is positioned before the first
+   *         row, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean isBeforeFirst() throws SQLException;
+
+  /**
+   * This method tests whether or not the cursor is after the last row
+   * in the result set.
+   *
+   * @return <code>true</code> if the cursor is positioned after the last
+   *         row, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean isAfterLast() throws SQLException;
+
+  /**
+   * This method tests whether or not the cursor is positioned on the first
+   * row in the result set.
+   *
+   * @return <code>true</code> if the cursor is positioned on the first
+   *         row, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean isFirst() throws SQLException;
+
+  /**
+   * This method tests whether or not the cursor is on the last row
+   * in the result set.
+   *
+   * @return <code>true</code> if the cursor is positioned on the last
+   *         row, <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean isLast() throws SQLException;
+
+  /**
+   * This method repositions the cursor to before the first row in the
+   * result set.
+   * 
+   * @exception SQLException If an error occurs.
+   */
+  void beforeFirst() throws SQLException;
+
+  /**
+   * This method repositions the cursor to after the last row in the result
+   * set.
+   * 
+   * @exception SQLException If an error occurs.
+   */
+  void afterLast() throws SQLException;
+
+  /**
+   * This method repositions the cursor on the first row in the
+   * result set.
+   *
+   * @return <code>true</code> if the cursor is on a valid row;
+   *         <code>false</code> if there are no rows in the result set.
+   * @exception SQLException If an error occurs.
+   */
+  boolean first() throws SQLException;
+
+  /**
+   * This method repositions the cursor on the last row in the result
+   * set.
+   * 
+   * @return <code>true</code> if the cursor is on a valid row;
+   *         <code>false</code> if there are no rows in the result set.
+   * @exception SQLException If an error occurs.
+   */
+  boolean last() throws SQLException;
+
+  /**
+   * This method returns the current row number in the cursor.  Numbering
+   * begins at index 1.
+   *
+   * @return The current row number, or 0 if there is not current row.
+   * @exception SQLException If an error occurs.
+   */
+  int getRow() throws SQLException;
+
+  /**
+   * This method positions the result set to the specified absolute row.
+   * Positive numbers are row offsets from the beginning of the result
+   * set (numbering starts from row 1) and negative numbers are row offsets
+   * from the end of the result set (numbering starts from -1).
+   *
+   * @param row The row to position the result set to.
+   *
+   * @return <code>true</code> if the current position was changed,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean absolute(int row) throws SQLException;
+
+  /**
+   * This method moves the result set position relative to the current row.
+   * The offset can be positive or negative.
+   *
+   * @param rows The number of row positions to move.
+   * @return <code>true</code> if the current position was changed,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean relative(int rows) throws SQLException;
+
+  /**
+   * This method moves the current position to the previous row in the
+   * result set.
+   *
+   * @return <code>true</code> if the previous row exists, <code>false</code>
+   *         otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean previous() throws SQLException;
+
+  /**
+   * This method provides a hint to the driver about which direction the
+   * result set will be processed in. 
+   *
+   * @param direction The direction in which rows will be processed. The
+   *                  allowed values are the <code>FETCH_*</code> constants
+   *                  defined in this interface.
+   * @exception SQLException If an error occurs.
+   */
+  void setFetchDirection(int direction) throws SQLException;
+
+  /**
+   * This method returns the current fetch direction for this result set.
+   *
+   * @return The fetch direction for this result set.
+   * @exception SQLException If an error occurs.
+   */
+  int getFetchDirection() throws SQLException;
+
+  /**
+   * This method provides a hint to the driver about how many rows at a
+   * time it should fetch from the database.
+   *
+   * @param rows The number of rows the driver should fetch per call.
+   * @exception SQLException If an error occurs.
+   */
+  void setFetchSize(int rows) throws SQLException;
+
+  /**
+   * This method returns the current number of rows that will be fetched 
+   * from the database at a time.
+   *
+   * @return The current fetch size for this result set.
+   * @exception SQLException If an error occurs.
+   */
+  int getFetchSize() throws SQLException;
+
+  /**
+   * This method returns the result set type of this result set.  This will
+   * be one of the <code>TYPE_*</code> constants defined in this interface.
+   *
+   * @return The result set type.
+   * @exception SQLException If an error occurs.
+   */
+  int getType() throws SQLException;
+
+  /**
+   * This method returns the concurrency type of this result set.  This will
+   * be one of the <code>CONCUR_*</code> constants defined in this interface.
+   *
+   * @return The result set concurrency type.
+   * @exception SQLException If an error occurs.
+   */
+  int getConcurrency() throws SQLException;
+
+  /**
+   * This method tests whether or not the current row in the result set
+   * has been updated.  Updates must be visible in order of this method to
+   * detect the update.
+   *
+   * @return <code>true</code> if the row has been updated, <code>false</code>
+   *         otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean rowUpdated() throws SQLException;
+
+  /**
+   * This method tests whether or not the current row in the result set
+   * has been inserted.  Inserts must be visible in order of this method to
+   * detect the insert.
+   *
+   * @return <code>true</code> if the row has been inserted, <code>false</code>
+   *         otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean rowInserted() throws SQLException;
+
+  /**
+   * This method tests whether or not the current row in the result set
+   * has been deleted.  Deletes must be visible in order of this method to
+   * detect the deletion.
+   *
+   * @return <code>true</code> if the row has been deleted, <code>false</code>
+   *         otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean rowDeleted() throws SQLException;
+
+  /**
+   * This method updates the specified column to have a NULL value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnIndex The index of the column to update.
+   * @exception SQLException If an error occurs.
+   */
+  void updateNull(int columnIndex) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a boolean value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnIndex The index of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateBoolean(int columnIndex, boolean value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a byte value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnIndex The index of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateByte(int columnIndex, byte value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a short value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnIndex The index of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateShort(int columnIndex, short value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have an int value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnIndex The index of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateInt(int columnIndex, int value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a long value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnIndex The index of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateLong(int columnIndex, long value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a float value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnIndex The index of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateFloat(int columnIndex, float value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a double value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnIndex The index of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateDouble(int columnIndex, double value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a BigDecimal value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnIndex The index of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateBigDecimal(int columnIndex, BigDecimal value)
+    throws SQLException;
+
+  /**
+   * This method updates the specified column to have a String value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnIndex The index of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateString(int columnIndex, String value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a byte array value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnIndex The index of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateBytes(int columnIndex, byte[] value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a java.sql.Date value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnIndex The index of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateDate(int columnIndex, Date value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a java.sql.Time value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnIndex The index of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateTime(int columnIndex, Time value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a java.sql.Timestamp value.  
+   * This does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnIndex The index of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateTimestamp(int columnIndex, Timestamp value)
+    throws SQLException;
+
+  /**
+   * This method updates the specified column from an ASCII text stream.
+   * This does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnIndex The index of the column to update.
+   * @param stream The stream from which the column value is updated.
+   * @param count The length of the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void updateAsciiStream(int columnIndex, InputStream stream, int count)
+    throws SQLException;
+
+  /**
+   * This method updates the specified column from a binary stream.
+   * This does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnIndex The index of the column to update.
+   * @param stream The stream from which the column value is updated.
+   * @param count The length of the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void updateBinaryStream(int columnIndex, InputStream stream, int count)
+    throws SQLException;
+
+  /**
+   * This method updates the specified column from a character stream.
+   * This does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnIndex The index of the column to update.
+   * @param reader The reader from which the column value is updated.
+   * @param count The length of the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void updateCharacterStream(int columnIndex, Reader reader, int count)
+    throws SQLException;
+
+  /**
+   * This method updates the specified column to have an Object value.  
+   * This does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnIndex The index of the column to update.
+   * @param value The new value of the column.
+   * @param scale The scale of the object in question, which is used only
+   *              for numeric type objects.
+   * @exception SQLException If an error occurs.
+   */
+  void updateObject(int columnIndex, Object value, int scale)
+    throws SQLException;
+
+  /**
+   * This method updates the specified column to have an Object value.  
+   * This does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnIndex The index of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateObject(int columnIndex, Object value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a NULL value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnName The name of the column to update.
+   * @exception SQLException If an error occurs.
+   */
+  void updateNull(String columnName) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a boolean value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnName The name of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateBoolean(String columnName, boolean value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a byte value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnName The name of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateByte(String columnName, byte value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a short value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnName The name of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateShort(String columnName, short value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have an int value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnName The name of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateInt(String columnName, int value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a long value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnName The name of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateLong(String columnName, long value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a float value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnName The name of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateFloat(String columnName, float value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a double value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnName The name of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateDouble(String columnName, double value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a BigDecimal value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnName The name of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateBigDecimal(String columnName, BigDecimal value)
+    throws SQLException;
+
+  /**
+   * This method updates the specified column to have a String value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnName The name of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateString(String columnName, String value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a byte array value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnName The name of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateBytes(String columnName, byte[] value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a java.sql.Date value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnName The name of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateDate(String columnName, Date value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a java.sql.Time value.  This
+   * does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnName The name of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateTime(String columnName, Time value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a java.sql.Timestamp value.  
+   * This does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnName The name of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateTimestamp(String columnName, Timestamp value)
+    throws SQLException;
+
+  /**
+   * This method updates the specified column from an ASCII text stream.
+   * This does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnName The name of the column to update.
+   * @param stream The stream from which the column value is updated.
+   * @param count The length of the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void updateAsciiStream(String columnName, InputStream stream, int count)
+    throws SQLException;
+
+  /**
+   * This method updates the specified column from a binary stream.
+   * This does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnName The name of the column to update.
+   * @param stream The stream from which the column value is updated.
+   * @param count The length of the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void updateBinaryStream(String columnName, InputStream stream, int count)
+    throws SQLException;
+
+  /**
+   * This method updates the specified column from a character stream.
+   * This does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnName The name of the column to update.
+   * @param reader The reader from which the column value is updated.
+   * @param count The length of the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void updateCharacterStream(String columnName, Reader reader, int count)
+    throws SQLException;
+
+  /**
+   * This method updates the specified column to have an Object value.  
+   * This does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnName The name of the column to update.
+   * @param value The new value of the column.
+   * @param scale The scale of the object in question, which is used only
+   *              for numeric type objects.
+   * @exception SQLException If an error occurs.
+   */
+  void updateObject(String columnName, Object value, int scale)
+    throws SQLException;
+
+  /**
+   * This method updates the specified column to have an Object value.  
+   * This does not update the actual database.  <code>updateRow</code> must be
+   * called in order to do that.
+   *
+   * @param columnName The name of the column to update.
+   * @param value The new value of the column.
+   * @exception SQLException If an error occurs.
+   */
+  void updateObject(String columnName, Object value) throws SQLException;
+
+  /**
+   * This method inserts the current row into the database.  The result set
+   * must be positioned on the insert row in order to call this method
+   * successfully.
+   *
+   * @exception SQLException If an error occurs.
+   */
+  void insertRow() throws SQLException;
+
+  /**
+   * This method updates the current row in the database.
+   *
+   * @exception SQLException If an error occurs.
+   */
+  void updateRow() throws SQLException;
+
+  /**
+   * This method deletes the current row in the database.
+   *
+   * @exception SQLException If an error occurs.
+   */
+  void deleteRow() throws SQLException;
+
+  /**
+   * This method refreshes the contents of the current row from the database.
+   *
+   * @exception SQLException If an error occurs.
+   */
+  void refreshRow() throws SQLException;
+
+  /**
+   * This method cancels any changes that have been made to a row.  If 
+   * the <code>rowUpdate</code> method has been called, then the changes
+   * cannot be undone.
+   *
+   * @exception SQLException If an error occurs.
+   */
+  void cancelRowUpdates() throws SQLException;
+
+  /**
+   * This method positions the result set to the "insert row", which allows
+   * a new row to be inserted into the database from the result set.
+   *
+   * @exception SQLException If an error occurs.
+   */
+  void moveToInsertRow() throws SQLException;
+
+  /**
+   * This method moves the result set position from the insert row back to
+   * the current row that was selected prior to moving to the insert row.
+   *
+   * @exception SQLException If an error occurs.
+   */
+  void moveToCurrentRow() throws SQLException;
+
+  /**
+   * This method returns a the <code>Statement</code> that was used to
+   * produce this result set.
+   *
+   * @return The <code>Statement</code> used to produce this result set.
+   *
+   * @exception SQLException If an error occurs.
+   */
+  Statement getStatement() throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>Object</code> using the specified SQL type to Java type map.
+   *
+   * @param columnIndex The index of the column to return.
+   * @param map The SQL type to Java type map to use.
+   * @return The value of the column as an <code>Object</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Object getObject(int columnIndex, Map map) throws SQLException;
+
+  /**
+   * This method returns a <code>Ref</code> for the specified column which
+   * represents the structured type for the column.
+   *
+   * @param columnIndex The index of the column to return.
+   * @return A <code>Ref</code> object for the column
+   * @exception SQLException If an error occurs.
+   */
+  Ref getRef(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the specified column value as a BLOB.
+   *
+   * @param columnIndex The index of the column value to return.
+   * @return The value of the column as a BLOB.
+   * @exception SQLException If an error occurs.
+   */
+  Blob getBlob(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the specified column value as a CLOB.
+   *
+   * @param columnIndex The index of the column value to return.
+   * @return The value of the column as a CLOB.
+   * @exception SQLException If an error occurs.
+   */
+  Clob getClob(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the specified column value as an <code>Array</code>.
+   *
+   * @param columnIndex The index of the column value to return.
+   * @return The value of the column as an <code>Array</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Array getArray(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the value of the specified column as a Java
+   * <code>Object</code> using the specified SQL type to Java type map.
+   *
+   * @param columnName The name of the column to return.
+   * @param map The SQL type to Java type map to use.
+   * @return The value of the column as an <code>Object</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Object getObject(String columnName, Map map) throws SQLException;
+
+  /**
+   * This method returns a <code>Ref</code> for the specified column which
+   * represents the structured type for the column.
+   *
+   * @param columnName  The name of the column to return.
+   * @return A <code>Ref</code> object for the column
+   * @exception SQLException If an error occurs.
+   */
+  Ref getRef(String columnName) throws SQLException;
+
+  /**
+   * This method returns the specified column value as a BLOB.
+   *
+   * @param columnName The name of the column value to return.
+   * @return The value of the column as a BLOB.
+   * @exception SQLException If an error occurs.
+   */
+  Blob getBlob(String columnName) throws SQLException;
+
+  /**
+   * This method returns the specified column value as a CLOB.
+   *
+   * @param columnName The name of the column value to return.
+   * @return The value of the column as a CLOB.
+   * @exception SQLException If an error occurs.
+   */
+  Clob getClob(String columnName) throws SQLException;
+
+  /**
+   * This method returns the specified column value as an <code>Array</code>.
+   *
+   * @param columnName The name of the column value to return.
+   * @return The value of the column as an <code>Array</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Array getArray(String columnName) throws SQLException;
+
+  /**
+   * This method returns the specified column value as a 
+   * <code>java.sql.Date</code>.  The specified <code>Calendar</code> is used
+   * to generate a value for the date if the database does not support
+   * timezones.
+   *
+   * @param columnIndex The index of the column value to return.
+   * @param cal The <code>Calendar</code> to use for calculating timezones.
+   * @return The value of the column as a <code>java.sql.Date</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Date getDate(int columnIndex, Calendar cal) throws SQLException;
+
+  /**
+   * This method returns the specified column value as a 
+   * <code>java.sql.Date</code>.  The specified <code>Calendar</code> is used
+   * to generate a value for the date if the database does not support
+   * timezones.
+   *
+   * @param columnName The name of the column value to return.
+   * @param cal The <code>Calendar</code> to use for calculating timezones.
+   * @return The value of the column as a <code>java.sql.Date</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Date getDate(String columnName, Calendar cal) throws SQLException;
+
+  /**
+   * This method returns the specified column value as a 
+   * <code>java.sql.Time</code>.  The specified <code>Calendar</code> is used
+   * to generate a value for the time if the database does not support
+   * timezones.
+   *
+   * @param columnIndex The index of the column value to return.
+   * @param cal The <code>Calendar</code> to use for calculating timezones.
+   * @return The value of the column as a <code>java.sql.Time</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Time getTime(int columnIndex, Calendar cal) throws SQLException;
+
+  /**
+   * This method returns the specified column value as a 
+   * <code>java.sql.Time</code>.  The specified <code>Calendar</code> is used
+   * to generate a value for the time if the database does not support
+   * timezones.
+   *
+   * @param columnName The name of the column value to return.
+   * @param cal The <code>Calendar</code> to use for calculating timezones.
+   * @return The value of the column as a <code>java.sql.Time</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Time getTime(String columnName, Calendar cal) throws SQLException;
+
+  /**
+   * This method returns the specified column value as a 
+   * <code>java.sql.Timestamp</code>.  The specified <code>Calendar</code> is used
+   * to generate a value for the timestamp if the database does not support
+   * timezones.
+   *
+   * @param columnIndex The index of the column value to return.
+   * @param cal The <code>Calendar</code> to use for calculating timezones.
+   * @return The value of the column as a <code>java.sql.Timestamp</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Timestamp getTimestamp(int columnIndex, Calendar cal)
+    throws SQLException;
+
+  /**
+   * This method returns the specified column value as a 
+   * <code>java.sql.Timestamp</code>.  The specified <code>Calendar</code> is used
+   * to generate a value for the timestamp if the database does not support
+   * timezones.
+   *
+   * @param columnName The name of the column value to return.
+   * @param cal The <code>Calendar</code> to use for calculating timezones.
+   *
+   * @return The value of the column as a <code>java.sql.Timestamp</code>.
+   *
+   * @exception SQLException If an error occurs.
+   */
+  Timestamp getTimestamp(String columnName, Calendar cal)
+    throws SQLException;
+
+  /**
+   * This method returns the specified column value as a 
+   * <code>java.net.URL</code>.
+   * 
+   * @param columnIndex The index of the column value to return.
+   * @exception SQLException If an error occurs.
+   * @since 1.4
+   */
+  URL getURL(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the specified column value as a
+   * <code>java.net.URL</code>.
+   * 
+   * @param columnName The name of the column value to return.
+   * @exception SQLException If an error occurs.
+   * @since 1.4
+   */
+  URL getURL(String columnName) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a 
+   * <code>java.sql.Ref</code> value. 
+   * This does not update the actual database. <code>updateRow</code> must be
+   * called in order to do that.
+   * 
+   * @parm columnIndex The index of the column value to update.
+   * @parm value The <code>java.sql.Ref</code> used to set the new value 
+   *             of the column.
+   * @exception SQLException If an error occurs.
+   * @since 1.4
+   */
+  void updateRef(int columnIndex, Ref value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a 
+   * <code>java.sql.Ref</code> value. 
+   * This does not update the actual database. <code>updateRow</code> must be
+   * called in order to do that.
+   * 
+   * @parm columnName The name of the column value to update.
+   * @parm value The <code>java.sql.Ref</code> used to set the new value 
+   *             of the column.
+   * @exception SQLException If an error occurs.
+   * @since 1.4
+   */
+  void updateRef(String columnName, Ref value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a 
+   * <code>java.sql.Blob</code> value. 
+   * This does not update the actual database. <code>updateRow</code> must be
+   * called in order to do that.
+   * 
+   * @parm columnIndex The index of the column value to update.
+   * @parm value The <code>java.sql.Blob</code> used to set the new value 
+   *             of the column.
+   * @exception SQLException If an error occurs.
+   * @since 1.4
+   */
+  void updateBlob(int columnIndex, Blob value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a 
+   * <code>java.sql.Blob</code> value. 
+   * This does not update the actual database. <code>updateRow</code> must be
+   * called in order to do that.
+   * 
+   * @parm columnName The name of the column value to update.
+   * @parm value The <code>java.sql.Blob</code> used to set the new value 
+   *             of the column.
+   * @exception SQLException If an error occurs.
+   * @since 1.4
+   */
+  void updateBlob(String columnName, Blob value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a 
+   * <code>java.sql.Clob</code> value. 
+   * This does not update the actual database. <code>updateRow</code> must be
+   * called in order to do that.
+   * 
+   * @parm columnIndex The index of the column value to update.
+   * @parm value The <code>java.sql.Clob</code> used to set the new value 
+   *             of the column.
+   * @exception SQLException If an error occurs.
+   * @since 1.4
+   */
+  void updateClob(int columnIndex, Clob value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a 
+   * <code>java.sql.Clob</code> value. 
+   * This does not update the actual database. <code>updateRow</code> must be
+   * called in order to do that.
+   * 
+   * @parm columnName The name of the column value to update.
+   * @parm value The <code>java.sql.Clob</code> used to set the new value 
+   *             of the column.
+   * @exception SQLException If an error occurs.
+   * @since 1.4
+   */
+  void updateClob(String columnName, Clob value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a 
+   * <code>java.sqlArray</code> value. 
+   * This does not update the actual database. <code>updateRow</code> must be
+   * called in order to do that.
+   * 
+   * @parm columnIndex The index of the column value to update.
+   * @parm value The new value of the column.
+   * @exception SQLException If an error occurs.
+   * @since 1.4
+   */
+  void updateArray(int columnIndex, Array value) throws SQLException;
+
+  /**
+   * This method updates the specified column to have a 
+   * <code>java.sqlArray</code> value. 
+   * This does not update the actual database. <code>updateRow</code> must be
+   * called in order to do that.
+   * 
+   * @parm columnName The name of the column value to update.
+   * @parm value The new value of the column.
+   * @exception SQLException If an error occurs.
+   * @since 1.4
+   */
+  void updateArray(String columnName, Array value) throws SQLException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/ResultSetMetaData.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/ResultSetMetaData.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/ResultSetMetaData.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/ResultSetMetaData.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,281 @@
+/* ResultSetMetaData.java -- Returns information about the ResultSet
+   Copyright (C) 1999, 2000, 2002, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.sql;
+
+/**
+ * This interface provides a mechanism for obtaining information about
+ * the columns that are present in a <code>ResultSet</code>.
+ * 
+ * <p> Note that in this class column indices start at 1, not 0.</p>
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public interface ResultSetMetaData 
+{
+  /**
+   * The column does not allow NULL's.
+   */
+  int columnNoNulls = 0;
+
+  /**
+   * The column allows NULL's.
+   */
+  int columnNullable = 1;
+
+  /**
+   * It is unknown whether or not the column allows NULL's.
+   */
+  int columnNullableUnknown = 2;
+
+  /**
+   * This method returns the number of columns in the result set.
+   *
+   * @return The number of columns in the result set.
+   * @exception SQLException If an error occurs.
+   */
+  int getColumnCount() throws SQLException;
+
+  /**
+   * This method test whether or not the column is an auto-increment column.
+   * Auto-increment columns are read-only.
+   *
+   * @param columnIndex The index of the column to test.
+   * @return <code>true</code> if the column is auto-increment, <code>false</code>
+   *         otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean isAutoIncrement(int columnIndex) throws SQLException;
+
+  /**
+   * This method tests whether or not a column is case sensitive in its values.
+   *
+   * @param columnIndex The index of the column to test.
+   * @return <code>true</code> if the column value is case sensitive,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean isCaseSensitive(int columnIndex) throws SQLException;
+
+  /**
+   * This method tests whether not the specified column can be used in 
+   * a WHERE clause.
+   *
+   * @param columnIndex The index of the column to test.
+   * @return <code>true</code> if the column may be used in a WHERE clause,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean isSearchable(int columnIndex) throws SQLException;
+
+  /**
+   * This method tests whether or not the column stores a monetary value.
+   *
+   * @param columnIndex The index of the column to test.
+   * @return <code>true</code> if the column contains a monetary value,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean isCurrency(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns a value indicating whether or not the specified
+   * column may contain a NULL value.
+   *
+   * @param columnIndex The index of the column to test.
+   * @return A constant indicating whether or not the column can contain NULL,
+   *         which will be one of <code>columnNoNulls</code>,
+   *         <code>columnNullable</code>, or <code>columnNullableUnknown</code>.
+   * @exception SQLException If an error occurs.
+   */
+  int isNullable(int columnIndex) throws SQLException;
+
+  /**
+   * This method tests whether or not the value of the specified column
+   * is signed or unsigned.
+   *
+   * @param columnIndex The index of the column to test.
+   * @return <code>true</code> if the column value is signed, <code>false</code>
+   *         otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean isSigned(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the maximum number of characters that can be used
+   * to display a value in this column.
+   *
+   * @param columnIndex The index of the column to check.
+   * @return The maximum number of characters that can be used to display a
+   *         value for this column.
+   * @exception SQLException If an error occurs.
+   */
+  int getColumnDisplaySize(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns a string that should be used as a caption for this
+   * column for user display purposes.
+   *
+   * @param columnIndex The index of the column to check.
+   * @return A display string for the column.
+   * @exception SQLException If an error occurs.
+   */
+  String getColumnLabel(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the name of the specified column.
+   *
+   * @param columnIndex The index of the column to return the name of.
+   * @return The name of the column.
+   * @exception SQLException If an error occurs.
+   */
+  String getColumnName(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the name of the schema that contains the specified
+   * column.
+   *
+   * @param columnIndex The index of the column to check the schema name for.
+   * @return The name of the schema that contains the column.
+   * @exception SQLException If an error occurs.
+   */
+  String getSchemaName(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the precision of the specified column, which is the
+   * number of decimal digits it contains.
+   *
+   * @param columnIndex The index of the column to check the precision on.
+   * @return The precision of the specified column.
+   * @exception SQLException If an error occurs.
+   */
+  int getPrecision(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the scale of the specified column, which is the
+   * number of digits to the right of the decimal point.
+   *
+   * @param columnIndex The index column to check the scale of.
+   * @return The scale of the column.
+   * @exception SQLException If an error occurs.
+   */
+  int getScale(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the name of the table containing the specified
+   * column.
+   *
+   * @param columnIndex The index of the column to check the table name for.
+   * @return The name of the table containing the column.
+   * @exception SQLException If an error occurs.
+   */
+  String getTableName(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the name of the catalog containing the specified
+   * column.
+   *
+   * @param columnIndex The index of the column to check the catalog name for.
+   * @return The name of the catalog containing the column.
+   * @exception SQLException If an error occurs.
+   */
+  String getCatalogName(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the SQL type of the specified column.  This will
+   * be one of the constants from <code>Types</code>.
+   *
+   * @param columnIndex The index of the column to check the SQL type of.
+   * @return The SQL type for this column.
+   * @exception SQLException If an error occurs.
+   * @see Types
+   */
+  int getColumnType(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the name of the SQL type for this column.
+   *
+   * @param columnIndex The index of the column to check the SQL type name for.
+   * @return The name of the SQL type for this column.
+   * @exception SQLException If an error occurs.
+   */
+  String getColumnTypeName(int columnIndex) throws SQLException;
+
+  /**
+   * This method tests whether or not the specified column is read only.
+   *
+   * @param columnIndex The index of the column to check.
+   * @return <code>true</code> if the column is read only, <code>false</code>
+   *         otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean isReadOnly(int columnIndex) throws SQLException;
+
+  /**
+   * This method tests whether or not the column may be writable.  This
+   * does not guarantee that a write will be successful.
+   *
+   * @param columnIndex The index of the column to check for writability.
+   * @return <code>true</code> if the column may be writable,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean isWritable(int columnIndex) throws SQLException;
+
+  /**
+   * This method tests whether or not the column is writable.  This
+   * does guarantee that a write will be successful.
+   *
+   * @param columnIndex The index of the column to check for writability.
+   * @return <code>true</code> if the column is writable,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean isDefinitelyWritable(int columnIndex) throws SQLException;
+
+  /**
+   * This method returns the name of the Java class which will be used to
+   * create objects representing the data in this column.
+   *
+   * @param columnIndex The index of the column to check.
+   * @return The name of the Java class that will be used for values in
+   *         this column.
+   * @exception SQLException If an error occurs.
+   */
+  String getColumnClassName(int columnIndex) throws SQLException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLData.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLData.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLData.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLData.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,72 @@
+/* SQLData.java -- Custom mapping for a user defined datatype
+   Copyright (C) 1999, 2000, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.sql;
+
+/**
+ * This interface is used for mapping SQL data to user defined datatypes.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public interface SQLData 
+{
+  /**
+   * This method returns the user defined datatype name for this object.
+   *
+   * @return The user defined data type name for this object.
+   * @exception SQLException If an error occurs.
+   */
+  String getSQLTypeName() throws SQLException;
+
+  /**
+   * This method populates the data in the object from the specified stream.
+   *
+   * @param stream The stream to read the data from.
+   * @param typeName The data type name of the data on the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void readSQL(SQLInput stream, String typeName) throws SQLException;
+
+  /**
+   * This method writes the data in this object to the specified stream.
+   *
+   * @param stream The stream to write the data to.
+   * @exception SQLException If an error occurs.
+   */
+  void writeSQL(SQLOutput stream) throws SQLException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,167 @@
+/* SQLException.java -- General SQL exception
+   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.sql;
+
+/**
+ * This exception is thrown when a database error occurs.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class SQLException extends Exception 
+{
+  static final long serialVersionUID = 2135244094396331484L;
+
+  /**
+   * This is the next exception in the chain
+   */
+  private SQLException next;
+
+  /**
+   * This is the state of the SQL statement at the time of the error.
+   */
+  private String SQLState;
+
+  /**
+   * The vendor error code for this error
+   */
+  private int vendorCode;
+
+  /**
+   * This method initializes a nwe instance of <code>SQLException</code>
+   * with the specified descriptive error message, SQL state string, and
+   * vendor code.
+   *
+   * @param message A string describing the nature of the error.
+   * @param SQLState A string containing the SQL state of the error.
+   * @param vendorCode The vendor error code associated with this error.
+   */
+  public SQLException(String message, String SQLState, int vendorCode)
+  {
+    super(message);
+    this.SQLState = SQLState;
+    this.vendorCode = vendorCode;  
+  }
+
+  /**
+   * This method initializes a new instance of <code>SQLException</code>
+   * with the specified descriptive error message and SQL state string.
+   * The vendor error code of this instance will be 0.
+   *
+   * @param message A string describing the nature of the error.
+   * @param SQLState A string containing the SQL state of the error.
+   */
+  public SQLException(String message, String SQLState)
+  {
+    this(message, SQLState, 0);
+  }
+
+  /**
+   * This method initializes a new instance of <code>SQLException</code>
+   * with the specified descriptive error message.  The SQL state of this
+   * instance will be <code>null</code> and the vendor error code will be 0.
+   *
+   * @param message A string describing the nature of the error.
+   */
+  public SQLException(String message)
+  {
+    this(message, null, 0);  
+  }
+
+  /**
+   * This method initializes a new instance of <code>SQLException</code>
+   * that does not have a descriptive messages and SQL state, and which
+   * has a vendor error code of 0.
+   */
+  public SQLException()
+  {
+    this(null, null, 0);  
+  }
+
+  /**
+   * This method returns the SQLState information associated with this
+   * error.  The value returned is a <code>String</code> which is formatted
+   * using the XOPEN SQL state conventions.
+   *
+   * @return The SQL state, which may be <code>null</code>.
+   */
+  public String getSQLState()
+  {
+    return SQLState;
+  }
+
+  /**
+   * This method returns the vendor specific error code associated with 
+   * this error.
+   *
+   * @return The vendor specific error code associated with this error.
+   */
+  public int getErrorCode()
+  {
+    return vendorCode;
+  }
+
+  /**
+   * This method returns the exception that is chained to this object.
+   *
+   * @return The exception chained to this object, which may be 
+   *         <code>null</code>.
+   */
+  public SQLException getNextException()
+  {
+    return next;
+  }
+
+  /**
+   * This method adds a new exception to the end of the chain of exceptions
+   * that are chained to this object.
+   *
+   * @param e The exception to add to the end of the chain.
+   */
+  public void setNextException(SQLException e)
+  {
+    if (e == null)
+      return;
+
+    SQLException list_entry = this;
+    while (list_entry.getNextException() != null)
+      list_entry = list_entry.getNextException();
+
+    list_entry.next = e;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLInput.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLInput.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLInput.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLInput.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,259 @@
+/* SQLInput.java -- Read SQL values from a stream
+   Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.sql;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.net.URL;
+
+/**
+ * This interface provides methods for reading values from a stream
+ * that is connected to a SQL structured or distinct type.  It is used
+ * for custom mapping of user defined data types.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public interface SQLInput 
+{
+  /**
+   * This method reads the next item from the stream a Java
+   * <code>String</code>.
+   *
+   * @return The value read from the stream as a <code>String</code>.
+   * @exception SQLException If an error occurs.
+   */
+  String readString() throws SQLException;
+
+  /**
+   * This method reads the next item from the stream a Java
+   * <code>boolean</code>.
+   *
+   * @return The value read from the stream as a <code>boolean</code>.
+   * @exception SQLException If an error occurs.
+   */
+  boolean readBoolean() throws SQLException;
+
+  /**
+   * This method reads the next item from the stream a Java
+   * <code>byte</code>.
+   *
+   * @return The value read from the stream as a <code>byte</code>.
+   * @exception SQLException If an error occurs.
+   */
+  byte readByte() throws SQLException;
+
+  /**
+   * This method reads the next item from the stream a Java
+   * <code>short</code>.
+   *
+   * @return The value read from the stream as a <code>short</code>.
+   * @exception SQLException If an error occurs.
+   */
+  short readShort() throws SQLException;
+
+  /**
+   * This method reads the next item from the stream a Java
+   * <code>int</code>.
+   *
+   * @return The value read from the stream as an <code>int</code>.
+   * @exception SQLException If an error occurs.
+   */
+  int readInt() throws SQLException;
+
+  /**
+   * This method reads the next item from the stream a Java
+   * <code>long</code>.
+   *
+   * @return The value read from the stream as a <code>long</code>.
+   * @exception SQLException If an error occurs.
+   */
+  long readLong() throws SQLException;
+
+  /**
+   * This method reads the next item from the stream a Java
+   * <code>float</code>.
+   *
+   * @return The value read from the stream as a <code>float</code>.
+   * @exception SQLException If an error occurs.
+   */
+  float readFloat() throws SQLException;
+
+  /**
+   * This method reads the next item from the stream a Java
+   * <code>double</code>.
+   *
+   * @return The value read from the stream as a <code>double</code>.
+   * @exception SQLException If an error occurs.
+   */
+  double readDouble() throws SQLException;
+
+  /**
+   * This method reads the next item from the stream a Java
+   * <code>BigDecimal</code>.
+   *
+   * @return The value read from the stream as a <code>BigDecimal</code>.
+   * @exception SQLException If an error occurs.
+   */
+  BigDecimal readBigDecimal() throws SQLException;
+
+  /**
+   * This method reads the next item from the stream a Java
+   * byte array
+   *
+   * @return The value read from the stream as a byte array. 
+   * @exception SQLException If an error occurs.
+   */
+  byte[] readBytes() throws SQLException;
+
+  /**
+   * This method reads the next item from the stream a Java
+   * <code>java.sql.Date</code>.
+   *
+   * @return The value read from the stream as a <code>java.sql.Date</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Date readDate() throws SQLException;
+
+  /**
+   * This method reads the next item from the stream a Java
+   * <code>java.sql.Time</code>.
+   *
+   * @return The value read from the stream as a <code>java.sql.Time</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Time readTime() throws SQLException;
+
+  /**
+   * This method reads the next item from the stream a Java
+   * <code>java.sql.Timestamp</code>.
+   *
+   * @return The value read from the stream as a <code>java.sql.Timestamp</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Timestamp readTimestamp() throws SQLException;
+
+  /**
+   * This method reads the next item from the stream a character
+   * <code>Reader</code>.
+   *
+   * @return The value read from the stream as a <code>Reader</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Reader readCharacterStream() throws SQLException;
+
+  /**
+   * This method reads the next item from the stream a ASCII text
+   * <code>InputStream</code>.
+   *
+   * @return The value read from the stream as an <code>InputStream</code>.
+   * @exception SQLException If an error occurs.
+   */
+  InputStream readAsciiStream() throws SQLException;
+
+  /**
+   * This method reads the next item from the stream a binary
+   * <code>InputStream</code>.
+   *
+   * @return The value read from the stream as an <code>InputStream</code>.
+   * @exception SQLException If an error occurs.
+   */
+  InputStream readBinaryStream() throws SQLException;
+
+  /**
+   * This method reads the next item from the stream a Java
+   * <code>Object</code>.
+   *
+   * @return The value read from the stream as an <code>Object</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Object readObject() throws SQLException;
+
+  /**
+   * This method reads the next item from the stream a Java SQL
+   * <code>Ref</code>.
+   *
+   * @return The value read from the stream as an <code>Ref</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Ref readRef() throws SQLException;
+
+  /**
+   * This method reads the next item from the stream a Java SQL
+   * <code>Blob</code>.
+   *
+   * @return The value read from the stream as a <code>Blob</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Blob readBlob() throws SQLException;
+
+  /**
+   * This method reads the next item from the stream a Java SQL
+   * <code>Clob</code>.
+   *
+   * @return The value read from the stream as a <code>Clob</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Clob readClob() throws SQLException;
+
+  /**
+   * This method reads the next item from the stream a Java SQL
+   * <code>Array</code>.
+   *
+   * @return The value read from the stream as an <code>Array</code>.
+   * @exception SQLException If an error occurs.
+   */
+  Array readArray() throws SQLException;
+
+  /**
+   * This method tests whether or not the last value read was a SQL
+   * NULL value.
+   *
+   * @return <code>true</code> if the last value read was a NULL,
+   *         <code>false</code> otherwise.
+   * @exception SQLException If an error occurs.
+   */
+  boolean wasNull() throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  URL readURL() throws SQLException;
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLOutput.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLOutput.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLOutput.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLOutput.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,267 @@
+/* SQLOutput.java -- Write SQL values to a stream
+   Copyright (C) 1999, 2000, 2002, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.sql;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.net.URL;
+
+/**
+ * This interface provides methods for writing Java types to a SQL stream.
+ * It is used for implemented custom type mappings for user defined data
+ * types.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public interface SQLOutput 
+{
+  /**
+   * This method writes the specified Java <code>String</code>
+   * to the SQL stream.
+   *
+   * @param value The value to write to the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void writeString(String value) throws SQLException;
+
+  /**
+   * This method writes the specified Java <code>boolean</code>
+   * to the SQL stream.
+   *
+   * @param value The value to write to the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void writeBoolean(boolean value) throws SQLException;
+
+  /**
+   * This method writes the specified Java <code>byte</code>
+   * to the SQL stream.
+   *
+   * @param value The value to write to the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void writeByte(byte value) throws SQLException;
+
+  /**
+   * This method writes the specified Java <code>short</code>
+   * to the SQL stream.
+   *
+   * @param value The value to write to the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void writeShort(short value) throws SQLException;
+
+  /**
+   * This method writes the specified Java <code>int</code>
+   * to the SQL stream.
+   *
+   * @param value The value to write to the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void writeInt(int value) throws SQLException;
+
+  /**
+   * This method writes the specified Java <code>long</code>
+   * to the SQL stream.
+   *
+   * @param value The value to write to the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void writeLong(long value) throws SQLException;
+
+  /**
+   * This method writes the specified Java <code>float</code>
+   * to the SQL stream.
+   *
+   * @param value The value to write to the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void writeFloat(float value) throws SQLException;
+
+  /**
+   * This method writes the specified Java <code>double</code>
+   * to the SQL stream.
+   *
+   * @param value The value to write to the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void writeDouble(double value) throws SQLException;
+
+  /**
+   * This method writes the specified Java <code>BigDecimal</code>
+   * to the SQL stream.
+   *
+   * @param value The value to write to the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void writeBigDecimal(BigDecimal value) throws SQLException;
+
+  /**
+   * This method writes the specified Java <code>byte</code> array
+   * to the SQL stream.
+   *
+   * @param value The value to write to the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void writeBytes(byte[] value) throws SQLException;
+
+  /**
+   * This method writes the specified Java <code>java.sql.Date</code> 
+   * to the SQL stream.
+   *
+   * @param value The value to write to the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void writeDate(Date value) throws SQLException;
+
+  /**
+   * This method writes the specified Java <code>java.sql.Time</code> 
+   * to the SQL stream.
+   *
+   * @param value The value to write to the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void writeTime(Time value) throws SQLException;
+
+  /**
+   * This method writes the specified Java <code>java.sql.Timestamp</code> 
+   * to the SQL stream.
+   *
+   * @param value The value to write to the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void writeTimestamp(Timestamp value) throws SQLException;
+
+  /**
+   * This method writes the specified Java character stream
+   * to the SQL stream.
+   *
+   * @param stream The stream that holds the character data to write.
+   * @exception SQLException If an error occurs.
+   */
+  void writeCharacterStream(Reader stream) throws SQLException;
+
+  /**
+   * This method writes the specified ASCII text stream
+   * to the SQL stream.
+   *
+   * @param stream The stream that holds the ASCII data to write.
+   * @exception SQLException If an error occurs.
+   */
+  void writeAsciiStream(InputStream stream) throws SQLException;
+
+  /**
+   * This method writes the specified uninterpreted binary byte stream
+   * to the SQL stream.
+   *
+   * @param stream The stream that holds the binary data to write.
+   * @exception SQLException If an error occurs.
+   */
+  void writeBinaryStream(InputStream stream) throws SQLException;
+
+  /**
+   * This method writes the specified Java <code>SQLData</code> object
+   * to the SQL stream.
+   *
+   * @param value The value to write to the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void writeObject(SQLData value) throws SQLException;
+
+  /**
+   * This method writes the specified Java SQL <code>Ref</code> object
+   * to the SQL stream.
+   *
+   * @param value The <code>Ref</code> object to write to the stream.
+   * @exception SQLException If an error occurs.
+   * @see Ref
+   */
+  void writeRef(Ref value) throws SQLException;
+
+
+  /**
+   * This method writes the specified Java SQL <code>Blob</code> object
+   * to the SQL stream.
+   *
+   * @param value The <code>Blob</code> object to write to the stream.
+   * @exception SQLException If an error occurs.
+   * @see Blob
+   */
+  void writeBlob(Blob value) throws SQLException;
+
+  /**
+   * This method writes the specified Java SQL <code>Clob</code> object
+   * to the SQL stream.
+   *
+   * @param value The <code>Clob</code> object to write to the stream.
+   * @exception SQLException If an error occurs.
+   * @see Clob
+   */
+  void writeClob(Clob value) throws SQLException;
+
+  /**
+   * This method writes the specified Java SQL <code>Struct</code> object
+   * to the SQL stream.
+   *
+   * @param value The <code>Struct</code> object to write to the stream.
+   * @exception SQLException If an error occurs.
+   * @see Struct
+   */
+  void writeStruct(Struct value) throws SQLException;
+
+  /**
+   * This method writes the specified Java SQL <code>Array</code> object
+   * to the SQL stream.
+   *
+   * @param value The value to write to the stream.
+   * @exception SQLException If an error occurs.
+   */
+  void writeArray(Array value) throws SQLException;
+
+  /**
+   * This method writes the specified <code>java.net.URL</code> object to the 
+   * SQL stream.
+   * 
+   * @param value The value to write to the stream.
+   * @exception SQLException If an error occurs.
+   * @since 1.4
+   */
+  void writeURL(URL value) throws SQLException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLPermission.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLPermission.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLPermission.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLPermission.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,57 @@
+/* SQLPermission.java
+   Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.sql;
+
+import java.security.BasicPermission;
+
+/**
+ * @since 1.3
+ */
+public final class SQLPermission extends BasicPermission 
+{
+  public SQLPermission(String name)
+  {
+    super(name);
+  }
+
+  public SQLPermission(String name, String actions)
+  {
+    super(name, actions);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLWarning.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLWarning.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLWarning.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/SQLWarning.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,120 @@
+/* SQLWarning.java -- Database access warnings.
+   Copyright (C) 1999, 2000, 2002, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.sql;
+
+/**
+ * This exception is thrown when a database warning occurs.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class SQLWarning extends SQLException 
+{
+  static final long serialVersionUID = 3917336774604784856L;
+
+  /**
+   * This method initializes a nwe instance of <code>SQLWarning</code>
+   * with the specified descriptive error message, SQL state string, and
+   * vendor code.
+   *
+   * @param message A string describing the nature of the error.
+   * @param SQLState A string containing the SQL state of the error.
+   * @param vendorCode The vendor error code associated with this error.
+   */
+  public SQLWarning(String message, String SQLState, int vendorCode)
+  {
+    super(message, SQLState, vendorCode);
+  }
+
+  /**
+   * This method initializes a new instance of <code>SQLWarning</code>
+   * with the specified descriptive error message and SQL state string.
+   * The vendor error code of this instance will be 0.
+   *
+   * @param message A string describing the nature of the error.
+   * @param SQLState A string containing the SQL state of the error.
+   */
+  public SQLWarning(String message, String SQLState)
+  {
+    super(message, SQLState);
+  }
+
+  /**
+   * This method initializes a new instance of <code>SQLWarning</code>
+   * with the specified descriptive error message.  The SQL state of this
+   * instance will be <code>null</code> and the vendor error code will be 0.
+   *
+   * @param message A string describing the nature of the error.
+   */
+  public SQLWarning(String message)
+  {
+    super(message);
+  }
+
+  /**
+   * This method initializes a new instance of <code>SQLWarning</code>
+   * that does not have a descriptive messages and SQL state, and which
+   * has a vendor error code of 0.
+   */
+  public SQLWarning()
+  {
+    super();
+  }
+
+  /**
+   * This method returns the exception that is chained to this object.
+   *
+   * @return The exception chained to this object, which may be 
+   *         <code>null</code>.
+   */
+  public SQLWarning getNextWarning()
+  {
+    return (SQLWarning) super.getNextException();
+  }
+
+  /**
+   * This method adds a new exception to the end of the chain of exceptions
+   * that are chained to this object.
+   *
+   * @param w The exception to add to the end of the chain.
+   */
+  public void setNextWarning(SQLWarning w)
+  {
+    super.setNextException(w);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Savepoint.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Savepoint.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Savepoint.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Savepoint.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,55 @@
+/* SavePoint.java -- Returns information about the ResultSet
+   Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.sql;
+
+/**
+ * @since 1.4
+ */
+public interface Savepoint 
+{
+  /**
+   * @since 1.4
+   */
+  int getSavepointId() throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  String getSavepointName() throws SQLException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Statement.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Statement.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Statement.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Statement.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,375 @@
+/* Statement.java -- Interface for executing SQL statements.
+   Copyright (C) 1999, 2000, 2002, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.sql;
+
+/**
+ * This interface provides a mechanism for executing SQL statements.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public interface Statement 
+{
+  int CLOSE_CURRENT_RESULT = 1;
+  int KEEP_CURRENT_RESULT = 2;
+  int CLOSE_ALL_RESULTS = 3;
+  int SUCCESS_NO_INFO = -2;
+  int EXECUTE_FAILED = -3;
+  int RETURN_GENERATED_KEYS = 1;
+  int NO_GENERATED_KEYS = 2;
+
+  /**
+   * This method executes the specified SQL SELECT statement and returns a
+   * (possibly empty) <code>ResultSet</code> with the results of the query.
+   *
+   * @param sql The SQL statement to execute.
+   * @return The result set of the SQL statement.
+   * @exception SQLException If an error occurs.
+   */
+  ResultSet executeQuery(String sql) throws SQLException;
+
+  /**
+   * This method executes the specified SQL INSERT, UPDATE, or DELETE statement
+   * and returns the number of rows affected, which may be 0.
+   * 
+   * @param sql The SQL statement to execute.
+   * @return The number of rows affected by the SQL statement.
+   * @exception SQLException If an error occurs.
+   */
+  int executeUpdate(String sql) throws SQLException;
+
+  /**
+   * This method closes the statement and frees any associated resources.
+   *
+   * @exception SQLException If an error occurs.
+   */
+  void close() throws SQLException;
+
+  /**
+   * This method returns the maximum length of any column value in bytes.
+   *
+   * @return The maximum length of any column value in bytes.
+   * @exception SQLException If an error occurs.
+   */
+  int getMaxFieldSize() throws SQLException;
+
+  /**
+   * This method sets the limit for the maximum length of any column in bytes.
+   *
+   * @param maxSize The new maximum length of any column in bytes.
+   * @exception SQLException If an error occurs.
+   */
+  void setMaxFieldSize(int maxSize) throws SQLException;
+
+  /**
+   * This method returns the maximum possible number of rows in a result set.
+   *
+   * @return The maximum possible number of rows in a result set.
+   * @exception SQLException If an error occurs.
+   */
+  int getMaxRows() throws SQLException;
+
+  /**
+   * This method sets the maximum number of rows that can be present in a
+   * result set.
+   *
+   * @param maxRows The maximum possible number of rows in a result set.
+   * @exception SQLException If an error occurs.
+   */
+  void setMaxRows(int maxRows) throws SQLException;
+
+  /**
+   * This method sets the local escape processing mode on or off.  The
+   * default value is on.
+   *
+   * @param escape <code>true</code> to enable local escape processing, 
+   *               <code>false</code> to disable it.
+   * @exception SQLException If an error occurs.
+   */
+  void setEscapeProcessing(boolean escape) throws SQLException;
+
+  /**
+   * The method returns the number of seconds a statement may be in process
+   * before timing out.  A value of 0 means there is no timeout.
+   *
+   * @return The SQL statement timeout in seconds.
+   * @exception SQLException If an error occurs.
+   */
+  int getQueryTimeout() throws SQLException;
+
+  /**
+   * This method sets the number of seconds a statement may be in process
+   * before timing out.  A value of 0 means there is no timeout.
+   *
+   * @param seconds The new SQL statement timeout value.
+   * @exception SQLException If an error occurs.
+   */
+  void setQueryTimeout(int seconds) throws SQLException;
+
+  /**
+   * This method cancels an outstanding statement, if the database supports
+   * that operation.
+   *
+   * @exception SQLException If an error occurs.
+   */
+  void cancel() throws SQLException;
+
+  /**
+   * This method returns the first SQL warning attached to this statement.
+   * Subsequent warnings will be chained to this one.
+   *
+   * @return The first SQL warning for this statement.
+   * @exception SQLException If an error occurs.
+   */
+  SQLWarning getWarnings() throws SQLException;
+
+  /**
+   * This method clears any SQL warnings that have been attached to this
+   * statement.
+   *
+   * @exception SQLException If an error occurs.
+   */
+  void clearWarnings() throws SQLException;
+
+  /**
+   * This method sets the cursor name that will be used by the result set.
+   *
+   * @param name The cursor name to use for this statement.
+   * @exception SQLException If an error occurs.
+   */
+  void setCursorName(String name) throws SQLException;
+
+  /**
+   * This method executes an arbitrary SQL statement of any time.  The
+   * methods <code>getResultSet</code>, <code>getMoreResults</code> and
+   * <code>getUpdateCount</code> retrieve the results.
+   *
+   * @return <code>true</code> if a result set was returned, <code>false</code>
+   *         if an update count was returned.
+   * @exception SQLException If an error occurs.
+   */
+  boolean execute(String sql) throws SQLException;
+
+  /**
+   * This method returns the result set of the SQL statement that was
+   * executed.  This should be called only once per result set returned.
+   *
+   * @return The result set of the query, or <code>null</code> if there was
+   *         no result set (for example, if the statement was an UPDATE).
+   * @exception SQLException If an error occurs.
+   * @see #execute(String)
+   * @see #execute(String, int)
+   * @see #execute(String, int[])
+   * @see #execute(String, String[])
+   */
+  ResultSet getResultSet() throws SQLException;
+
+  /**
+   * This method returns the update count of the SQL statement that was
+   * executed.  This should be called only once per executed SQL statement.
+   *
+   * @return The update count of the query, or -1 if there was no update
+   *         count (for example, if the statement was a SELECT).
+   * @exception SQLException If an error occurs.
+   * @see #execute(String)
+   * @see #execute(String, int)
+   * @see #execute(String, int[])
+   * @see #execute(String, String[])
+   */
+  int getUpdateCount() throws SQLException;
+
+  /**
+   * This method advances the result set pointer to the next result set, 
+   * which can then be retrieved using <code>getResultSet</code>
+   *
+   * @return <code>true</code> if there is another result set, 
+   *         <code>false</code> otherwise (for example, the next result is an
+   *         update count).
+   * @exception SQLException If an error occurs.
+   * @see #execute(String)
+   * @see #execute(String, int)
+   * @see #execute(String, int[])
+   * @see #execute(String, String[])
+   */
+  boolean getMoreResults() throws SQLException;
+
+  /**
+   * This method informs the driver which direction the result set will
+   * be accessed in.
+   *
+   * @param direction The direction the result set will be accessed in (?????)
+   * @exception SQLException If an error occurs.
+   */
+  void setFetchDirection(int direction) throws SQLException;
+
+  /**
+   * This method returns the current direction that the driver thinks the
+   * result set will be accessed int.
+   *
+   * @return The direction the result set will be accessed in (????)
+   * @exception SQLException If an error occurs.
+   */
+  int getFetchDirection() throws SQLException;
+
+  /**
+   * This method informs the driver how many rows it should fetch from the
+   * database at a time.
+   *
+   * @param numRows The number of rows the driver should fetch at a time
+   *                to populate the result set.
+   * @exception SQLException If an error occurs.
+   */
+  void setFetchSize(int numRows) throws SQLException;
+
+  /**
+   * This method returns the number of rows the driver believes should be
+   * fetched from the database at a time.
+   *
+   * @return The number of rows that will be fetched from the database at a time.
+   * @exception SQLException If an error occurs.
+   */
+  int getFetchSize() throws SQLException;
+
+  /**
+   * This method returns the concurrency type of the result set for this
+   * statement. This will be one of the concurrency types defined in
+   * <code>ResultSet</code>.
+   *
+   * @return The concurrency type of the result set for this statement.
+   * @exception SQLException If an error occurs.
+   * @see ResultSet
+   */
+  int getResultSetConcurrency() throws SQLException;
+
+  /**
+   * This method returns the result set type for this statement.  This will
+   * be one of the result set types defined in <code>ResultSet</code>.
+   *
+   * @return The result set type for this statement.
+   * @exception SQLException If an error occurs.
+   * @see ResultSet
+   */
+  int getResultSetType() throws SQLException;
+
+  /**
+   * This method adds a SQL statement to a SQL batch.  A driver is not
+   * required to implement this method.
+   *
+   * @param sql The sql statement to add to the batch.
+   * @exception SQLException If an error occurs.
+   */
+  void addBatch(String sql) throws SQLException;
+
+  /**
+   * This method clears out any SQL statements that have been populated in
+   * the current batch.  A driver is not required to implement this method.
+   *
+   * @exception SQLException If an error occurs.
+   */
+  void clearBatch() throws SQLException;
+
+  /**
+   * This method executes the SQL batch and returns an array of update
+   * counts - one for each SQL statement in the batch - ordered in the same
+   * order the statements were added to the batch.  A driver is not required
+   * to implement this method.
+   *
+   * @return An array of update counts for this batch.
+   * @exception SQLException If an error occurs.
+   */
+  int[] executeBatch() throws SQLException;
+
+  /**
+   * This method returns the <code>Connection</code> instance that was
+   * used to create this object.
+   *
+   * @return The connection used to create this object.
+   * @exception SQLException If an error occurs.
+   */
+  Connection getConnection() throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  boolean getMoreResults(int current) throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  ResultSet getGeneratedKeys() throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  int executeUpdate(String sql, int autoGeneratedKeys)
+    throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  int executeUpdate(String sql, int[] columnIndexes)
+    throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  int executeUpdate(String sql, String[] columnNames)
+    throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  boolean execute(String sql, int autoGeneratedKeys)
+    throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  boolean execute(String sql, int[] columnIndexes) throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  boolean execute(String sql, String[] columnNames)
+    throws SQLException;
+
+  /**
+   * @since 1.4
+   */
+  int getResultSetHoldability() throws SQLException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Struct.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Struct.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Struct.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Struct.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,77 @@
+/* Struct.java -- Mapping for a SQL structured type.
+   Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.sql;
+
+import java.util.Map;
+
+/**
+ * This interface implements the standard type mapping for a SQL 
+ * structured type.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public interface Struct 
+{
+  /**
+   * This method returns the name of the SQL structured type for this
+   * object.
+   *
+   * @return The SQL structured type name.
+   * @exception SQLException If an error occurs.
+   */
+  String getSQLTypeName() throws SQLException;
+
+  /**
+   * This method returns the attributes of this SQL structured type.
+   *
+   * @return The attributes of this structure type.
+   * @exception SQLException If an error occurs.
+   */
+  Object[] getAttributes() throws SQLException;
+
+  /**
+   * This method returns the attributes of this SQL structured type.
+   * The specified map of type mappings overrides the default mappings.
+   *
+   * @param map The map of SQL type mappings.
+   * @return The attributes of this structure type.
+   * @exception SQLException If a error occurs.
+   */
+  Object[] getAttributes(Map map) throws SQLException;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Time.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Time.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Time.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Time.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,202 @@
+/* Time.java -- Wrapper around java.util.Date
+   Copyright (C) 1999, 2000, 2002, 2003, 2005, 2006
+   Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.sql;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+
+/**
+ * This class is a wrapper around java.util.Date to allow the JDBC
+ * driver to identify the value as a SQL Time.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class Time extends java.util.Date
+{
+  static final long serialVersionUID = 8397324403548013681L;
+
+  /**
+   * Used for parsing and formatting this date.
+   */
+  private static SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
+
+  /**
+   * This method always throws an IllegalArgumentException.
+   *
+   * @throws IllegalArgumentException when it's called.
+   * @deprecated
+   */
+  public int getDate() throws IllegalArgumentException
+  {
+    throw new IllegalArgumentException();
+  }
+
+  /**
+   * This method always throws an IllegalArgumentException.
+   *
+   * @throws IllegalArgumentException when it's called.
+   * @deprecated
+   */
+  public int getDay() throws IllegalArgumentException
+  {
+    throw new IllegalArgumentException();
+  }
+
+  /**
+   * This method always throws an IllegalArgumentException.
+   *
+   * @throws IllegalArgumentException when it's called.
+   * @deprecated
+   */
+  public int getMonth() throws IllegalArgumentException
+  {
+    throw new IllegalArgumentException();
+  }
+
+  /**
+   * This method always throws an IllegalArgumentException.
+   *
+   * @throws IllegalArgumentException when it's called.
+   * @deprecated
+   */
+  public int getYear() throws IllegalArgumentException
+  {
+    throw new IllegalArgumentException();
+  }
+
+  /**
+   * This method always throws an IllegalArgumentException.
+   *
+   * @throws IllegalArgumentException when it's called.
+   * @deprecated
+   */
+  public void setDate(int newValue) throws IllegalArgumentException
+  {
+    throw new IllegalArgumentException();
+  }
+
+  /**
+   * This method always throws an IllegalArgumentException.
+   *
+   * @throws IllegalArgumentException when it's called.
+   * @deprecated
+   */
+  public void setMonth(int newValue) throws IllegalArgumentException
+  {
+    throw new IllegalArgumentException();
+  }
+
+  /**
+   * This method always throws an IllegalArgumentException.
+   *
+   * @throws IllegalArgumentException when it's called.
+   * @deprecated
+   */
+  public void setYear(int newValue) throws IllegalArgumentException
+  {
+    throw new IllegalArgumentException();
+  }
+
+  /**
+   * This method returns a new instance of this class by parsing a
+   * date in JDBC format into a Java date.
+   *
+   * @param str The string to parse.
+   * @return The resulting <code>java.sql.Time</code> value.
+   */
+  public static Time valueOf (String str)
+  {
+    try
+      {
+	java.util.Date d = (java.util.Date) sdf.parseObject(str);
+
+	if (d == null)
+	  throw new IllegalArgumentException(str);
+	else
+	  return new Time(d.getTime());
+      }
+    catch (ParseException e)
+      {
+	throw new IllegalArgumentException(str);
+      }
+  }
+
+  /**
+    * This method initializes a new instance of this class with the
+    * specified year, month, and day.
+    *
+    * @param hour The hour for this Time (0-23)
+    * @param minute The minute for this time (0-59)
+    * @param second The second for this time (0-59)
+    * @deprecated
+    */
+  public Time(int hour, int minute, int second)
+  {
+    super(System.currentTimeMillis());
+
+    setHours(hour);
+    setMinutes(minute);
+    setSeconds(second);
+  }
+
+  /**
+   * This method initializes a new instance of this class with the
+   * specified time value representing the number of milliseconds since 
+   * Jan 1, 1970 at 12:00 midnight GMT.
+   *
+   * @param date The time value to intialize this <code>Time</code> to.
+   */
+  public Time(long date)
+  {
+    super(date);
+  }
+
+  /**
+   * This method returns this date in JDBC format.
+   *
+   * @return This date as a string.
+   */
+  public String toString ()
+  {
+    return sdf.format (this);
+  }
+
+}
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Timestamp.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Timestamp.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Timestamp.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Timestamp.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,319 @@
+/* Time.java -- Wrapper around java.util.Date
+   Copyright (C) 1999, 2000, 2003, 2004, 2006  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.sql;
+
+import java.text.DecimalFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+
+/**
+ * This class is a wrapper around java.util.Date to allow the JDBC
+ * driver to identify the value as a SQL Timestamp.  Note that this
+ * class also adds an additional field for nano-seconds, and so 
+ * is not completely identical to <code>java.util.Date</code> as
+ * the <code>java.sql.Date</code> and <code>java.sql.Time</code>
+ * classes are.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class Timestamp extends java.util.Date
+{
+  static final long serialVersionUID = 2745179027874758501L;
+
+  /**
+   * Used for parsing and formatting this date.
+   */
+  private static SimpleDateFormat dateFormat =
+    new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+  private static DecimalFormat decimalFormat = new DecimalFormat("000000000");
+  private static StringBuffer sbuf = new StringBuffer(29);
+
+  /**
+    * The nanosecond value for this object
+    */
+  private int nanos;
+
+  /**
+   * This method returns a new instance of this class by parsing a
+   * date in JDBC format into a Java date.
+   *
+   * @param str The string to parse.
+   * @return The resulting <code>java.sql.Timestamp</code> value. 
+   */
+  public static Timestamp valueOf(String str)
+  {
+    int nanos = 0;
+    int dot = str.indexOf('.');
+    if (dot != -1)
+      {
+	if (str.lastIndexOf('.') != dot)
+	  throw new IllegalArgumentException(str);
+
+	int len = str.length() - dot - 1;
+	if (len < 1 || len > 9)
+	  throw new IllegalArgumentException(str);
+
+	nanos = Integer.parseInt(str.substring(dot + 1));
+	for (int i = len; i < 9; i++)
+	  nanos *= 10;
+	
+	str = str.substring(0, dot);
+
+      }
+
+    try
+      {
+        java.util.Date d;
+        synchronized (dateFormat)
+	  {
+	    d = (java.util.Date) dateFormat.parseObject(str);
+	  }
+
+	if (d == null)
+	  throw new IllegalArgumentException(str);
+
+	Timestamp ts = new Timestamp(d.getTime() + nanos / 1000000);
+	ts.nanos = nanos;
+	return ts;
+      }
+    catch (ParseException e)
+      {
+	throw new IllegalArgumentException(str);
+      }
+  }
+
+  /**
+   * This method initializes a new instance of this class with the
+   * specified year, month, and day.
+   *
+   * @param year The year for this Timestamp (year - 1900)
+   * @param month The month for this Timestamp (0-11)
+   * @param day The day for this Timestamp (1-31)
+   * @param hour The hour for this Timestamp (0-23)
+   * @param minute The minute for this Timestamp (0-59)
+   * @param second The second for this Timestamp (0-59)
+   * @param nanos The nanosecond value for this Timestamp (0 to 999,999,9999)
+   * @deprecated
+   */
+  public Timestamp(int year, int month, int day, int hour, int minute, 
+    int second, int nanos)
+  {
+    super(year, month, day, hour, minute, second);
+    this.nanos = nanos;
+  }
+
+  /**
+   * This method initializes a new instance of this class with the
+   * specified time value representing the number of milliseconds since 
+   * Jan 1, 1970 at 12:00 midnight GMT.
+   *
+   * @param date The time value to intialize this <code>Time</code> to.
+   */
+  public Timestamp(long date)
+  {
+    super(date - (date % 1000));
+    nanos = (int) (date % 1000) * 1000000;
+  }
+
+  /**
+   * Return the value of this Timestamp as the number of milliseconds 
+   * since Jan 1, 1970 at 12:00 midnight GMT.
+   */
+  public long getTime()
+  {
+    return super.getTime() + (nanos / 1000000);
+  }
+
+  /**
+   * This method returns this date in JDBC format.
+   *
+   * @return This date as a string.
+   */
+  public String toString()
+  {
+    synchronized (dateFormat)
+      {
+        sbuf.setLength(0);
+	dateFormat.format(this, sbuf, null);
+	sbuf.append('.');
+	decimalFormat.format(nanos, sbuf, null);
+	int end = sbuf.length() - 1;
+	while (end > 20 && sbuf.charAt(end) == '0')
+	  end--;
+	return sbuf.substring(0, end + 1);
+      }
+  }
+
+  /**
+    * This method returns the nanosecond value for this object.
+    * @return The nanosecond value for this object.
+    */
+  public int getNanos()
+  {
+    return nanos;
+  }
+
+  /**
+   * This method sets the nanosecond value for this object.
+   *
+   * @param nanos The nanosecond value for this object.
+   */
+  public void setNanos(int nanos)
+  {
+    this.nanos = nanos;
+  }
+
+  /**
+   * This methods tests whether this object is earlier than the specified
+   * object.
+   *
+   * @param ts The other <code>Timestamp</code> to test against.
+   * @return <code>true</code> if this object is earlier than the other object,
+   *         <code>false</code> otherwise.
+   */
+  public boolean before(Timestamp ts)
+  {
+    long time1 = getTime();
+    long time2 = ts.getTime();
+    if (time1 < time2 || (time1 == time2 && getNanos() < ts.getNanos()))
+      return true;
+    return false;
+  }
+
+  /**
+   * This methods tests whether this object is later than the specified
+   * object.
+   *
+   * @param ts The other <code>Timestamp</code> to test against.
+   *
+   * @return <code>true</code> if this object is later than the other object,
+   * <code>false</code> otherwise.
+   */
+  public boolean after(Timestamp ts)
+  {
+    long time1 = getTime();
+    long time2 = ts.getTime();
+    if (time1 > time2 || (time1 == time2 && getNanos() > ts.getNanos()))
+      return true;
+    return false;
+  }
+
+  /**
+   * This method these the specified <code>Object</code> for equality
+   * against this object.  This will be true if an only if the specified
+   * object is an instance of <code>Timestamp</code> and has the same
+   * time value fields.
+   *
+   * @param obj The object to test against for equality.
+   *
+   * @return <code>true</code> if the specified object is equal to this
+   * object, <code>false</code> otherwise.
+   */
+  public boolean equals(Object obj)
+  {
+    if (!(obj instanceof Timestamp))
+      return false;
+
+    return equals((Timestamp) obj);
+  }
+
+  /**
+   * This method tests the specified timestamp for equality against this
+   * object.  This will be true if and only if the specified object is
+   * not <code>null</code> and contains all the same time value fields
+   * as this object.
+   *
+   * @param ts The <code>Timestamp</code> to test against for equality.
+   *
+   * @return <code>true</code> if the specified object is equal to this
+   * object, <code>false</code> otherwise.
+   */
+  public boolean equals(Timestamp ts)
+  {
+    if (ts == null)
+      return false;
+
+    if (ts.getTime() != getTime())
+      return false;
+
+    if (ts.getNanos() != getNanos())
+      return false;
+
+    return true;
+  }
+
+  /**
+   * Compares this <code>Timestamp</code> to another one.
+   * 
+   * @param ts The other Timestamp.
+   * @return <code>0</code>, if both <code>Timestamp</code>'s represent exactly
+   *         the same date, a negative value if this <code>Timestamp</code> is
+   *         before the specified <code>Timestamp</code> and a positive value
+   *         otherwise.
+   * @since 1.2
+   */
+  public int compareTo(Timestamp ts)
+  {
+    int s = super.compareTo((java.util.Date) ts);
+    if (s != 0)
+      return s;
+    // If Date components were equal, then we check the nanoseconds.
+    return nanos - ts.nanos;
+  }
+
+  /**
+   * Compares this <code>Timestamp</code> to another one. This behaves like
+   * <code>compareTo(Timestamp)</code>, but it may throw a
+   * <code>ClassCastException</code>, if the specified object is not of type
+   * <code>Timestamp</code>.
+   * 
+   * @param obj The object to compare with.
+   * @return <code>0</code>, if both <code>Timestamp</code>'s represent exactly
+   *         the same date, a negative value if this <code>Timestamp</code> is
+   *         before the specified <code>Timestamp</code> and a positive value
+   *         otherwise.
+   * @exception ClassCastException if obj is not of type Timestamp.
+   * @see #compareTo(Timestamp)
+   * @since 1.2
+   */
+  public int compareTo(Object obj)
+  {
+    return compareTo((Timestamp) obj);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Types.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Types.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Types.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/Types.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,85 @@
+/* Types.java -- SQL type constants
+   Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.sql;
+
+/**
+ * This class contains constants that are used to identify SQL data types.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class Types 
+{
+  // These should be self explanatory.  People need a SQL book, not
+  // Javadoc comments for these.
+  public static final int BIT = -7;
+  public static final int TINYINT = -6;
+  public static final int SMALLINT = 5;
+  public static final int INTEGER = 4;
+  public static final int BIGINT = -5;
+  public static final int FLOAT = 6;
+  public static final int REAL = 7;
+  public static final int DOUBLE = 8;
+  public static final int NUMERIC = 2;
+  public static final int DECIMAL = 3;
+  public static final int CHAR = 1;
+  public static final int VARCHAR = 12;
+  public static final int LONGVARCHAR = -1;
+  public static final int DATE = 91;
+  public static final int TIME = 92;
+  public static final int TIMESTAMP = 93;
+  public static final int BINARY = -2;
+  public static final int VARBINARY = -3;
+  public static final int LONGVARBINARY = -4;
+  public static final int NULL = 0;
+  public static final int OTHER = 1111;
+  public static final int JAVA_OBJECT = 2000;
+  public static final int DISTINCT = 2001;
+  public static final int STRUCT = 2002;
+  public static final int ARRAY = 2003;
+  public static final int BLOB = 2004;
+  public static final int CLOB = 2005;
+  public static final int REF = 2006;
+  public static final int DATALINK = 70;
+  public static final int BOOLEAN = 16;
+
+  // This class can't be instantiated.
+  private Types()
+  {
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/sql/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/sql/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/sql/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/sql/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.sql package.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.sql</title></head>
+
+<body>
+<p>Interfaces and classes to connect to a database and wrappers for data
+in the database and result queries.</p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/Annotation.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/Annotation.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/Annotation.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/Annotation.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,113 @@
+/* Annotation.java -- Wrapper for a text attribute object
+   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+/**
+  * This class is used as a wrapper for a text attribute object.  Annotation
+  * objects are associated with a specific range of text.  Changing either
+  * the text range or the underlying text invalidates the object.
+  *
+  * @version 0.0
+  *
+  * @author Aaron M. Renn (arenn at urbanophile.com)
+  */
+public class Annotation
+{
+
+/*
+ * Instance Variables
+ */
+
+/**
+  * This is the attribute object being wrappered
+  */
+private Object attrib;
+
+/*************************************************************************/
+
+/**
+  * Constructors
+  */
+
+/**
+  * This method initializes a new instance of <code>Annotation</code> to
+  * wrapper the specified text attribute object.
+  *
+  * @param attrib The text attribute <code>Object</code> to wrapper.
+  */
+public
+Annotation(Object attrib)
+{
+  this.attrib = attrib;
+}
+
+/*************************************************************************/
+
+/*
+ * Instance Variables
+ */
+
+/**
+  * This method returns the text attribute object this <code>Annotation</code>
+  * instance is wrappering.
+  *
+  * @return The text attribute object for this <code>Annotation</code>.
+  */
+public Object
+getValue()
+{
+  return(attrib);
+}
+
+/*************************************************************************/
+
+/**
+  * This method returns a <code>String</code> representation of this
+  * object.
+  *
+  * @return This object as a <code>String</code>.
+  */
+public String
+toString()
+{
+  return(getClass().getName() + "[value=" + attrib.toString() + "]");
+}
+
+} // class Annotation
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/AttributedCharacterIterator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/AttributedCharacterIterator.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/AttributedCharacterIterator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/AttributedCharacterIterator.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,274 @@
+/* AttributedCharacterIterator.java -- Iterate over attributes
+   Copyright (C) 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+import java.io.InvalidObjectException;
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * This interface extends the <code>CharacterIterator</code> interface
+ * in order to support iteration over character attributes as well as
+ * over the characters themselves.
+ * <p>
+ * In addition to attributes of specific characters, this interface
+ * supports the concept of the "attribute run", which is an attribute
+ * that is defined for a particular value across an entire range of
+ * characters or which is undefined over a range of characters.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public interface AttributedCharacterIterator extends CharacterIterator
+{
+  /**
+   * Defines attribute keys that are used as text attributes.
+   */
+  public static class Attribute implements Serializable
+  {
+    private static final long serialVersionUID = -9142742483513960612L;
+
+    /**
+     * This is the attribute for the language of the text.  The value of
+     * attributes of this key type are instances of <code>Locale</code>.
+     */
+    public static final Attribute LANGUAGE = new Attribute ("LANGUAGE");
+
+    /**
+     * This is the attribute for the reading form of text.  This is used
+     * for storing pronunciation along with the written text for languages
+     * which need it.  The value of attributes of this key type are
+     * instances of <code>Annotation</code> which wrappers a 
+     * <code>String</code>.
+     */
+    public static final Attribute READING = new Attribute ("READING");
+
+    /**
+     * This is the attribute for input method segments.  The value of attributes
+     * of this key type are instances of <code>Annotation</code> which wrapper
+     * a <code>String</code>.
+     */
+    public static final Attribute INPUT_METHOD_SEGMENT =
+      new Attribute ("INPUT_METHOD_SEGMENT");
+
+    /**
+     * The name of the attribute key
+     * @serial
+     */
+    private String name;
+
+    /**
+     * Initializes a new instance of this class with the specified name.
+     *
+     * @param name The name of this attribute key.
+     */
+    protected Attribute (String name)
+    {
+      this.name = name;
+    }
+
+    /**
+     * Returns the name of this attribute.
+     *
+     * @return The attribute name
+     */
+    protected String getName()
+    {
+      return name;
+    }
+
+    /**
+     * Resolves an instance of 
+     * <code>AttributedCharacterIterator.Attribute</code>
+     * that is being deserialized to one of the three pre-defined attribute
+     * constants.  It does this by comparing the names of the attributes.  The
+     * constant that the deserialized object resolves to is returned.
+     *
+     * @return The resolved contant value
+     *
+     * @exception InvalidObjectException If the object being deserialized 
+     *            cannot be resolved.
+     */
+    protected Object readResolve() throws InvalidObjectException
+    {
+      if (getName().equals(READING.getName()))
+        return READING;
+
+      if (getName().equals(LANGUAGE.getName()))
+        return LANGUAGE;
+
+      if (getName().equals(INPUT_METHOD_SEGMENT.getName()))
+        return INPUT_METHOD_SEGMENT;
+
+      throw new InvalidObjectException ("Can't resolve Attribute: " 
+              + getName());
+    }
+    
+    /**
+     * Tests this object for equality against the specified object.
+     * The two objects will be considered equal if and only if:
+     * <ul>
+     * <li>The specified object is not <code>null</code>.
+     * <li>The specified object is an instance of 
+     * <code>AttributedCharacterIterator.Attribute</code>.
+     * <li>The specified object has the same attribute name as this object.
+     * </ul>
+     *
+     * @param obj  the <code>Object</code> to test for equality against this 
+     *             object.
+     *
+     * @return <code>true</code> if the specified object is equal to this one, 
+     *         <code>false</code> otherwise.
+     */
+    public final boolean equals (Object obj)
+    {
+      if (obj == this)
+        return true;
+      else 
+        return false;
+    }
+
+    /**
+     * Returns a hash value for this object.
+     *
+     * @return A hash value for this object.
+     */
+    public final int hashCode()
+    {
+      return super.hashCode();
+    }
+
+    /**
+     * Returns a <code>String</code> representation of this object.
+     *
+     * @return A <code>String</code> representation of this object.
+     */
+    public String toString()
+    {
+      return getClass().getName() + "(" + getName() + ")";
+    }
+
+  } // Inner class Attribute
+
+  /**
+   * Returns a list of all keys that are defined for the 
+   * text range.  This can be an empty list if no attributes are defined.
+   *
+   * @return A list of keys 
+   */
+  Set getAllAttributeKeys();
+
+  /**
+   * Returns a <code>Map</code> of the attributes defined for the current 
+   * character.
+   *
+   * @return A <code>Map</code> of the attributes for the current character.
+   */
+  Map getAttributes();
+
+  /**
+   * Returns the value of the specified attribute for the
+   * current character.  If the attribute is not defined for the current
+   * character, <code>null</code> is returned.
+   *
+   * @param attrib The attribute to retrieve the value of.
+   *
+   * @return The value of the specified attribute
+   */
+  Object getAttribute (AttributedCharacterIterator.Attribute attrib);
+
+  /**
+   * Returns the index of the first character in the run that
+   * contains all attributes defined for the current character.
+   *
+   * @return The start index of the run
+   */
+  int getRunStart();
+
+  /**
+   * Returns the index of the first character in the run that
+   * contains all attributes in the specified <code>Set</code> defined for
+   * the current character.
+   *
+   * @param attribs The <code>Set</code> of attributes.
+   *
+   * @return The start index of the run.
+   */
+  int getRunStart (Set attribs);
+  
+  /**
+   * Returns the index of the first character in the run that
+   * contains the specified attribute defined for the current character.
+   *
+   * @param attrib The attribute.
+   *
+   * @return The start index of the run.
+   */
+  int getRunStart (AttributedCharacterIterator.Attribute attrib);
+  
+  /**
+   * Returns the index of the character after the end of the run
+   * that contains all attributes defined for the current character.
+   *
+   * @return The end index of the run.
+   */
+  int getRunLimit();
+  
+  /**
+   * Returns the index of the character after the end of the run
+   * that contains all attributes in the specified <code>Set</code> defined
+   * for the current character.
+   *
+   * @param attribs The <code>Set</code> of attributes.
+   *
+   * @return The end index of the run.
+   */
+  int getRunLimit (Set attribs);
+  
+  /**
+   * Returns the index of the character after the end of the run
+   * that contains the specified attribute defined for the current character.
+   *
+   * @param attrib The attribute.
+   * 
+   * @return The end index of the run.
+   */
+  int getRunLimit (AttributedCharacterIterator.Attribute attrib);
+
+} // interface AttributedCharacterIterator

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/AttributedString.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/AttributedString.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/AttributedString.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/AttributedString.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,371 @@
+/* AttributedString.java -- Models text with attributes
+   Copyright (C) 1998, 1999, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * This class models a <code>String</code> with attributes over various
+ * subranges of the string.  It allows applications to access this 
+ * information via the <code>AttributedCharacterIterator</code> interface.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class AttributedString
+{
+
+  /** 
+   * The attributes and ranges of text over which those attributes apply. 
+   */
+  final class AttributeRange
+  {
+
+    /** A Map of the attributes */
+    Map attribs;
+
+    /** The beginning index of the attributes */
+    int begin_index;
+
+    /** The ending index of the attributes */
+    int end_index;
+
+    /**
+     * Creates a new attribute range.
+     * 
+     * @param attribs  the attributes.
+     * @param begin_index  the start index.
+     * @param end_index  the end index.
+     */
+    AttributeRange(Map attribs, int begin_index, int end_index) 
+    {
+      this.attribs = attribs;
+      this.begin_index = begin_index;
+      this.end_index = end_index;
+    }
+
+  } // Inner class AttributeRange
+
+  /** The string we are representing. */
+  private StringCharacterIterator sci;
+
+  /** The attribute information */
+  private AttributeRange[] attribs;
+
+  /**
+   * Creates a new instance of <code>AttributedString</code>
+   * that represents the specified <code>String</code> with no attributes.
+   *
+   * @param str The <code>String</code> to be attributed (<code>null</code> not
+   *            permitted).
+   * 
+   * @throws NullPointerException if <code>str</code> is <code>null</code>.
+   */
+  public AttributedString(String str)
+  {
+    sci = new StringCharacterIterator(str);
+    attribs = new AttributeRange[0];
+  }
+
+  /**
+   * Creates a new instance of <code>AttributedString</code>
+   * that represents that specified <code>String</code> with the specified
+   * attributes over the entire length of the <code>String</code>.
+   *
+   * @param str The <code>String</code> to be attributed.
+   * @param attributes The attribute list.
+   */
+  public AttributedString(String str, Map attributes)
+  {
+    this(str);
+
+    attribs = new AttributeRange[1];
+    attribs[0] = new AttributeRange(attributes, 0, str.length());
+  }
+
+  /**
+   * Initializes a new instance of <code>AttributedString</code>
+   * that will use the text and attribute information from the specified
+   * <code>AttributedCharacterIterator</code>.
+   *
+   * @param aci The <code>AttributedCharacterIterator</code> containing the 
+   *            text and attribute information (<code>null</code> not 
+   *            permitted).
+   * 
+   * @throws NullPointerException if <code>aci</code> is <code>null</code>.
+   */
+  public AttributedString(AttributedCharacterIterator aci)
+  {
+    this(aci, aci.getBeginIndex(), aci.getEndIndex(), null);
+  }
+
+  /**
+   * Initializes a new instance of <code>AttributedString</code>
+   * that will use the text and attribute information from the specified
+   * subrange of the specified <code>AttributedCharacterIterator</code>.
+   *
+   * @param aci The <code>AttributedCharacterIterator</code> containing the 
+   *            text and attribute information.
+   * @param begin_index The beginning index of the text subrange.
+   * @param end_index The ending index of the text subrange.
+   */
+  public AttributedString(AttributedCharacterIterator aci, int begin_index,
+                          int end_index)
+  {
+    this(aci, begin_index, end_index, null);
+  }
+
+  /**
+   * Initializes a new instance of <code>AttributedString</code>
+   * that will use the text and attribute information from the specified
+   * subrange of the specified <code>AttributedCharacterIterator</code>.
+   * Only attributes from the source iterator that are present in the
+   * specified array of attributes will be included in the attribute list
+   * for this object.
+   *
+   * @param aci The <code>AttributedCharacterIterator</code> containing the 
+   *            text and attribute information.
+   * @param begin The beginning index of the text subrange.
+   * @param end The ending index of the text subrange.
+   * @param attributes A list of attributes to include from the iterator, or 
+   *                   <code>null</code> to include all attributes.
+   */
+  public AttributedString(AttributedCharacterIterator aci, int begin, int end, 
+                          AttributedCharacterIterator.Attribute[] attributes)
+  {
+    // Validate some arguments
+    if ((begin < 0) || (end < begin) || end > aci.getEndIndex())
+      throw new IllegalArgumentException("Bad index values");
+
+    StringBuffer sb = new StringBuffer("");
+
+    // Get the valid attribute list
+    Set all_attribs = aci.getAllAttributeKeys();
+    if (attributes != null)
+      all_attribs.retainAll(Arrays.asList(attributes));
+
+    // Loop through and extract the attributes
+    char c = aci.setIndex(begin);
+
+    ArrayList accum = new ArrayList();
+    do
+      { 
+        sb.append(c);
+
+        Iterator iter = all_attribs.iterator();
+        while(iter.hasNext())
+          {
+            Object obj = iter.next();
+
+            // What should we do if this is not true?
+            if (!(obj instanceof AttributedCharacterIterator.Attribute))
+              continue;
+
+            AttributedCharacterIterator.Attribute attrib = 
+              (AttributedCharacterIterator.Attribute)obj;
+
+            // Make sure the attribute is defined.
+            int rl = aci.getRunLimit(attrib);
+            if (rl == -1)
+              continue;
+            if (rl > end)
+              rl = end;
+            rl -= begin;
+
+            // Check to see if we already processed this one
+            int rs = aci.getRunStart(attrib);
+            if ((rs < aci.getIndex()) && (aci.getIndex() != begin))
+              continue;
+
+            // If the attribute run starts before the beginning index, we
+            // need to junk it if it is an Annotation.
+            Object attrib_obj = aci.getAttribute(attrib);
+	    rs -= begin;
+            if (rs < 0)
+              {
+                if (attrib_obj instanceof Annotation)
+                   continue;
+
+                rs = 0;
+              }
+
+            // Create a map object.  Yes this will only contain one attribute
+            Map new_map = new Hashtable();
+            new_map.put(attrib, attrib_obj);
+
+            // Add it to the attribute list.
+            accum.add(new AttributeRange(new_map, rs, rl));
+          }
+
+        c = aci.next();
+      }
+    while( aci.getIndex() < end );
+
+    attribs = new AttributeRange[accum.size()];
+    attribs = (AttributeRange[]) accum.toArray(attribs);
+
+    sci = new StringCharacterIterator(sb.toString());
+  }
+
+  /**
+   * Adds a new attribute that will cover the entire string.
+   *
+   * @param attrib The attribute to add.
+   * @param value The value of the attribute.
+   */
+  public void addAttribute(AttributedCharacterIterator.Attribute attrib, 
+          Object value)
+  {
+    addAttribute(attrib, value, 0, sci.getEndIndex());
+  }
+
+  /**
+   * Adds a new attribute that will cover the specified subrange
+   * of the string.
+   *
+   * @param attrib The attribute to add.
+   * @param value The value of the attribute, which may be <code>null</code>.
+   * @param begin The beginning index of the subrange.
+   * @param end The ending index of the subrange.
+   *
+   * @exception IllegalArgumentException If attribute is <code>null</code> or 
+   *            the subrange is not valid.
+   */
+  public void addAttribute(AttributedCharacterIterator.Attribute attrib, 
+          Object value, int begin, int end)
+  {
+    if (attrib == null)
+      throw new IllegalArgumentException("null attribute");
+    if (end <= begin)
+      throw new IllegalArgumentException("Requires end > begin");
+    HashMap hm = new HashMap();
+    hm.put(attrib, value);
+
+    addAttributes(hm, begin, end);
+  }
+
+  /**
+   * Adds all of the attributes in the specified list to the
+   * specified subrange of the string.
+   *
+   * @param attributes The list of attributes.
+   * @param begin_index The beginning index.
+   * @param end_index The ending index
+   *
+   * @throws NullPointerException if <code>attributes</code> is 
+   *         <code>null</code>.
+   * @throws IllegalArgumentException if the subrange is not valid.
+   */
+  public void addAttributes(Map attributes, int begin_index, int end_index)
+  {
+    if (attributes == null)
+      throw new NullPointerException("null attribute");
+
+    if ((begin_index < 0) || (end_index > sci.getEndIndex()) ||
+        (end_index <= begin_index))
+      throw new IllegalArgumentException("bad range");
+
+    AttributeRange[] new_list = new AttributeRange[attribs.length + 1];
+    System.arraycopy(attribs, 0, new_list, 0, attribs.length);
+    attribs = new_list;
+    attribs[attribs.length - 1] = new AttributeRange(attributes, begin_index, 
+                                                     end_index);
+  } 
+
+  /**
+   * Returns an <code>AttributedCharacterIterator</code> that 
+   * will iterate over the entire string.
+   *
+   * @return An <code>AttributedCharacterIterator</code> for the entire string.
+   */
+  public AttributedCharacterIterator getIterator()
+  {
+    return(new AttributedStringIterator(sci, attribs, 0, sci.getEndIndex(), 
+            null));
+  }
+
+  /**
+   * Returns an <code>AttributedCharacterIterator</code> that
+   * will iterate over the entire string.  This iterator will return information
+   * about the list of attributes in the specified array.  Attributes not in
+   * the array may or may not be returned by the iterator.  If the specified
+   * array is <code>null</code>, all attributes will be returned.
+   *
+   * @param attributes A list of attributes to include in the returned iterator.
+   *
+   * @return An <code>AttributedCharacterIterator</code> for this string.
+   */
+  public AttributedCharacterIterator getIterator(
+          AttributedCharacterIterator.Attribute[] attributes)
+  {
+    return(getIterator(attributes, 0, sci.getEndIndex()));
+  }
+
+  /**
+   * Returns an <code>AttributedCharacterIterator</code> that
+   * will iterate over the specified subrange.  This iterator will return 
+   * information about the list of attributes in the specified array.  
+   * Attributes not in the array may or may not be returned by the iterator.  
+   * If the specified array is <code>null</code>, all attributes will be 
+   * returned.  
+   *
+   * @param attributes A list of attributes to include in the returned iterator.
+   * @param begin_index The beginning index of the subrange.
+   * @param end_index The ending index of the subrange.
+   *
+   * @return An <code>AttributedCharacterIterator</code> for this string.
+   */
+  public AttributedCharacterIterator getIterator(
+          AttributedCharacterIterator.Attribute[] attributes, 
+          int begin_index, int end_index)
+  {
+    if ((begin_index < 0) || (end_index > sci.getEndIndex()) ||
+        (end_index < begin_index))
+      throw new IllegalArgumentException("bad range");
+
+    return(new AttributedStringIterator(sci, attribs, begin_index, end_index,
+                                        attributes));
+  }
+
+} // class AttributedString

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/AttributedStringIterator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/AttributedStringIterator.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/AttributedStringIterator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/AttributedStringIterator.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,384 @@
+/* AttributedStringIterator.java -- Class to iterate over AttributedString
+   Copyright (C) 1998, 1999, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+  * This class implements the AttributedCharacterIterator interface.  It
+  * is used by AttributedString.getIterator().
+  *
+  * @version 0.0
+  *
+  * @author Aaron M. Renn (arenn at urbanophile.com)
+  */
+class AttributedStringIterator implements AttributedCharacterIterator
+{
+
+  /*************************************************************************/
+
+  /** The character iterator containing the text */
+  private CharacterIterator ci;
+
+  /** The list of attributes and ranges */
+  private AttributedString.AttributeRange[] attribs;
+
+  /**
+   * The list of attributes that the user is interested in.  We may,
+   * at our option, not return any other attributes.
+   */
+  private AttributedCharacterIterator.Attribute[] restricts;
+
+  /*************************************************************************/
+
+  AttributedStringIterator(StringCharacterIterator sci, 
+                           AttributedString.AttributeRange[] attribs,
+                           int begin_index, int end_index,
+                           AttributedCharacterIterator.Attribute[] restricts)
+  {
+    this.ci = new StringCharacterIterator(sci, begin_index, end_index);
+    this.attribs = attribs;
+    this.restricts = restricts;
+  }
+
+  /*************************************************************************/
+
+  // First we have a bunch of stupid redirects.  If StringCharacterIterator
+  // weren't final, I just would have extended that for this class.  Alas, no.
+
+  public Object clone()
+  {
+    return(ci.clone());
+  }
+
+  public char current()
+  {
+    return(ci.current());
+  }
+
+  public char next()
+  {
+    return(ci.next());
+  }
+
+  public char previous()
+  {
+    return(ci.previous());
+  }
+
+  public char first()
+  {
+    return(ci.first());
+  }
+
+  public char last()
+  {
+    return(ci.last());
+  }
+
+  public int getIndex()
+  {
+    return(ci.getIndex());
+  }
+
+  public char setIndex(int index)
+  {
+    return(ci.setIndex(index));  
+  }
+
+  public int getBeginIndex()
+  {
+    return(ci.getBeginIndex());
+  }
+
+  public int getEndIndex()
+  {
+    return(ci.getEndIndex());
+  }
+
+  /*
+   * Here is where the AttributedCharacterIterator methods start.
+   */ 
+
+  /*************************************************************************/
+
+  /**
+   * Returns a list of all the attribute keys that are defined anywhere
+   * on this string.
+   */
+  public Set getAllAttributeKeys()
+  {
+    HashSet s = new HashSet();
+    if (attribs == null)
+      return(s);
+
+    for (int i = 0; i < attribs.length; i++)
+    {
+      if (attribs[i].begin_index > getEndIndex()
+	  || attribs[i].end_index <= getBeginIndex())
+	continue;
+
+      Set key_set = attribs[i].attribs.keySet();
+      Iterator iter = key_set.iterator();
+      while (iter.hasNext())
+        {
+          s.add(iter.next());
+        }
+    }
+
+    return(s);
+  }
+
+  /*************************************************************************/
+
+  /**
+   * Various methods that determine how far the run extends for various
+   * attribute combinations.
+   */
+
+  public int getRunLimit()
+  {
+    return(getRunLimit(getAttributes().keySet()));
+  }
+
+  public int getRunLimit(AttributedCharacterIterator.Attribute attrib)
+  {
+    HashSet s = new HashSet();
+    s.add(attrib);
+    return(getRunLimit(s));
+  }
+
+  public synchronized int getRunLimit(Set attributeSet)
+  {
+    if (attributeSet == null)
+      return ci.getEndIndex();
+    
+    int current = ci.getIndex();
+    int end = ci.getEndIndex();
+    int limit = current;
+    if (current == end) 
+      return end;
+    Map runValues = getAttributes();
+    while (limit < end) 
+    {
+      Iterator iterator = attributeSet.iterator();
+      while (iterator.hasNext()) 
+      {
+	// Qualified name is a workaround for a gcj 4.0 bug.
+        AttributedCharacterIterator.Attribute attributeKey
+	  = (AttributedCharacterIterator.Attribute) iterator.next();
+        Object v1 = runValues.get(attributeKey);
+        Object v2 = getAttribute(attributeKey, limit + 1);
+        boolean changed = false;
+        // check for equal or both null, if NO return start
+        if (v1 != null) 
+          {
+            changed = !v1.equals(v2);
+          }
+        else 
+          {
+            changed = (v2 != null);  
+          }
+        if (changed)
+          return limit + 1;
+      }
+      // no differences, so increment limit and next and loop again
+      limit++;
+    }
+    return end;
+  }
+
+  /*************************************************************************/
+
+  /**
+   * Various methods that determine where the run begins for various
+   * attribute combinations.
+   */
+
+  /**
+   * Returns the index of the first character in the run containing the current
+   * character and defined by all the attributes defined for that character
+   * position.
+   * 
+   * @return The run start index.
+   */
+  public int getRunStart()
+  {
+    return(getRunStart(getAttributes().keySet()));
+  }
+
+  /**
+   * Returns the index of the first character in the run, defined by the 
+   * specified attribute, that contains the current character.
+   * 
+   * @param attrib  the attribute (<code>null</code> permitted).
+   * 
+   * return The index of the first character in the run.
+   */
+  public int getRunStart(AttributedCharacterIterator.Attribute attrib)
+  {
+    if (attrib == null)
+      return ci.getBeginIndex();
+    HashSet s = new HashSet();
+    s.add(attrib);
+    return(getRunStart(s));
+  }
+
+  /**
+   * Returns the index of the first character in the run, defined by the 
+   * specified attribute set, that contains the current character.
+   * 
+   * @param attributeSet  the attribute set (<code>null</code> permitted).
+   * 
+   * return The index of the first character in the run.
+   */
+  public int getRunStart(Set attributeSet)
+  {
+    if (attributeSet == null)
+      return ci.getBeginIndex();
+    
+    int current = ci.getIndex();
+    int begin = ci.getBeginIndex();
+    int start = current;
+    if (start == begin) 
+      return begin;
+    Map runValues = getAttributes();
+    int prev = start - 1;
+    while (start > begin) 
+    {
+      Iterator iterator = attributeSet.iterator();
+      while (iterator.hasNext()) 
+      {
+	// Qualified name is a workaround for a gcj 4.0 bug.
+        AttributedCharacterIterator.Attribute attributeKey
+	  = (AttributedCharacterIterator.Attribute) iterator.next();
+        Object v1 = runValues.get(attributeKey);
+        Object v2 = getAttribute(attributeKey, prev);
+        boolean changed = false;
+        // check for equal or both null, if NO return start
+        if (v1 != null) 
+          {
+            changed = !v1.equals(v2);
+          }
+        else 
+          {
+            changed = (v2 != null);  
+          }
+        if (changed)
+          return start;
+      }
+      // no differences, so decrement start and prev and loop again
+      start--;
+      prev--;
+    }
+    return start;
+  }
+
+  /*************************************************************************/
+
+  /**
+   * Returns the value for an attribute at the specified position.  If the
+   * attribute key (<code>key</code>) is <code>null</code>, the method returns
+   * <code>null</code>.
+   * 
+   * @param key  the key (<code>null</code> permitted).
+   * @param pos  the character position.
+   * 
+   * @return The attribute value (possibly <code>null</code>).
+   */
+  private Object getAttribute(AttributedCharacterIterator.Attribute key, 
+          int pos)
+  {
+    if (attribs == null)
+      return null;
+    for (int i = attribs.length - 1; i >= 0; i--)
+      {
+        if (pos >= attribs[i].begin_index && pos < attribs[i].end_index)
+          {
+            Set keys = attribs[i].attribs.keySet();
+            if (keys.contains(key)) 
+              {
+                return attribs[i].attribs.get(key);
+              }
+          }
+      }
+    return null;   
+  }
+  
+  /**
+   * Returns the value for an attribute at the current position.  If the
+   * attribute key (<code>key</code>) is <code>null</code>, the method returns
+   * <code>null</code>.
+   * 
+   * @param key  the key (<code>null</code> permitted).
+   * 
+   * @return The attribute value (possibly <code>null</code>).
+   */
+  public Object getAttribute(AttributedCharacterIterator.Attribute key)
+  {
+    return getAttribute(key, ci.getIndex());
+  }
+
+  /*************************************************************************/
+
+  /**
+   * Return a list of all the attributes and values defined for this
+   * character
+   */
+  public Map getAttributes()
+  {
+    HashMap m = new HashMap();
+    if (attribs == null)
+      return(m);
+  
+    for (int i = 0; i < attribs.length; i++)
+      {
+         if ((ci.getIndex() >= attribs[i].begin_index) &&
+             (ci.getIndex() < attribs[i].end_index))
+           m.putAll(attribs[i].attribs);
+      }
+
+    return(m);
+  }
+
+} // class AttributedStringIterator

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/Bidi.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/Bidi.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/Bidi.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/Bidi.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1000 @@
+/* Bidi.java -- Bidirectional Algorithm implementation
+   Copyright (C) 2005, 2006  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+import java.awt.font.NumericShaper;
+import java.awt.font.TextAttribute;
+import java.util.ArrayList;
+
+
+/**
+ * Bidirectional Algorithm implementation.
+ *
+ * The full algorithm is
+ * <a href="http://www.unicode.org/unicode/reports/tr9/">Unicode Standard
+ * Annex #9: The Bidirectional Algorithm</a>.
+ *
+ * @since 1.4
+ */
+public final class Bidi
+{
+  /**
+   * This indicates that a strongly directional character in the text should
+   * set the initial direction, but if no such character is found, then the
+   * initial direction will be left-to-right.
+   */
+  public static final int DIRECTION_DEFAULT_LEFT_TO_RIGHT = -2;
+
+  /**
+   * This indicates that a strongly directional character in the text should
+   * set the initial direction, but if no such character is found, then the
+   * initial direction will be right-to-left.
+   */
+  public static final int DIRECTION_DEFAULT_RIGHT_TO_LEFT = -1;
+
+  /**
+   * This indicates that the initial direction should be left-to-right.
+   */
+  public static final int DIRECTION_LEFT_TO_RIGHT = 0;
+
+  /**
+   * This indicates that the initial direction should be right-to-left.
+   */
+  public static final int DIRECTION_RIGHT_TO_LEFT = 1;
+
+  // Flags used when computing the result.
+  private static final int LTOR = 1 << DIRECTION_LEFT_TO_RIGHT;
+  private static final int RTOL = 1 << DIRECTION_RIGHT_TO_LEFT;
+
+  // The text we are examining, and the starting offset.
+  // If we had a better way to handle createLineBidi, we wouldn't
+  // need this at all -- which for the String case would be an
+  // efficiency win.
+  private char[] text;
+  private int textOffset;
+  // The embeddings corresponding to the text, and the starting offset.
+  private byte[] embeddings;
+  private int embeddingOffset;
+  // The length of the text (and embeddings) to use.
+  private int length;
+  // The flags.
+  private int flags;
+
+  // All instance fields following this point are initialized
+  // during analysis.  Fields before this must be set by the constructor.
+
+  // The initial embedding level.
+  private int baseEmbedding;
+  // The type of each character in the text.
+  private byte[] types;
+  // The levels we compute.
+  private byte[] levels;
+
+  // A list of indices where a formatting code was found.  These
+  // are indicies into the original text -- not into the text after
+  // the codes have been removed.
+  private ArrayList formatterIndices;
+
+  // Indices of the starts of runs in the text. 
+  private int[] runs;
+
+  // A convenience field where we keep track of what kinds of runs
+  // we've seen.
+  private int resultFlags;
+
+  /**
+   * Create a new Bidi object given an attributed character iterator.
+   * This constructor will examine various attributes of the text:
+   * <ul>
+   * <li> {@link TextAttribute#RUN_DIRECTION} is used to determine the
+   * paragraph's base embedding level.  This constructor will recognize
+   * either {@link TextAttribute#RUN_DIRECTION_LTR} or
+   * {@link TextAttribute#RUN_DIRECTION_RTL}.  If neither is given,
+   * {@link #DIRECTION_DEFAULT_LEFT_TO_RIGHT} is assumed.
+   * </li>
+   * 
+   * <li> If {@link TextAttribute#NUMERIC_SHAPING} is seen, then numeric
+   * shaping will be done before the Bidi algorithm is run.
+   * </li>
+   * 
+   * <li> If {@link TextAttribute#BIDI_EMBEDDING} is seen on a given
+   * character, then the value of this attribute will be used as an
+   * embedding level override.
+   * </li>
+   * </ul>
+   * @param iter the attributed character iterator to use
+   */
+  public Bidi(AttributedCharacterIterator iter)
+  {
+    // If set, this attribute should be set on all characters.
+    // We don't check this (should we?) but we do assume that we
+    // can simply examine the first character.
+    Object val = iter.getAttribute(TextAttribute.RUN_DIRECTION);
+    if (val == TextAttribute.RUN_DIRECTION_LTR)
+      this.flags = DIRECTION_LEFT_TO_RIGHT;
+    else if (val == TextAttribute.RUN_DIRECTION_RTL)
+      this.flags = DIRECTION_RIGHT_TO_LEFT;
+    else
+      this.flags = DIRECTION_DEFAULT_LEFT_TO_RIGHT;
+
+    // Likewise this attribute should be specified on the whole text.
+    // We read it here and then, if it is set, we apply the numeric shaper
+    // to the text before processing it.
+    NumericShaper shaper = null;
+    val = iter.getAttribute(TextAttribute.NUMERIC_SHAPING);
+    if (val instanceof NumericShaper)
+      shaper = (NumericShaper) val;
+
+    char[] text = new char[iter.getEndIndex() - iter.getBeginIndex()];
+    this.embeddings = new byte[this.text.length];
+    this.embeddingOffset = 0;
+    this.length = text.length;
+    for (int i = 0; i < this.text.length; ++i)
+      {
+        this.text[i] = iter.current();
+
+        val = iter.getAttribute(TextAttribute.BIDI_EMBEDDING);
+        if (val instanceof Integer)
+          {
+            int ival = ((Integer) val).intValue();
+            byte bval;
+            if (ival < -62 || ival > 62)
+              bval = 0;
+            else
+              bval = (byte) ival;
+            this.embeddings[i] = bval;
+          }
+      }
+
+    // Invoke the numeric shaper, if specified.
+    if (shaper != null)
+      shaper.shape(this.text, 0, this.length);
+
+    runBidi();
+  }
+
+  /**
+   * Create a new Bidi object with the indicated text and, possibly, explicit
+   * embedding settings.
+   * 
+   * If the embeddings array is null, it is ignored.  Otherwise it is taken to
+   * be explicit embedding settings corresponding to the text.  Positive values
+   * from 1 to 61 are embedding levels, and negative values from -1 to -61 are
+   * embedding overrides.  (FIXME: not at all clear what this really means.)
+   * 
+   * @param text the text to use
+   * @param offset the offset of the first character of the text
+   * @param embeddings the explicit embeddings, or null if there are none
+   * @param embedOffset the offset of the first embedding value to use
+   * @param length the length of both the text and the embeddings
+   * @param flags a flag indicating the base embedding direction
+   */
+  public Bidi(char[] text, int offset, byte[] embeddings, int embedOffset,
+              int length, int flags)
+  {
+    if (flags != DIRECTION_DEFAULT_LEFT_TO_RIGHT
+        && flags != DIRECTION_DEFAULT_RIGHT_TO_LEFT
+        && flags != DIRECTION_LEFT_TO_RIGHT
+        && flags != DIRECTION_RIGHT_TO_LEFT)
+      throw new IllegalArgumentException("unrecognized 'flags' argument: "
+                                         + flags);
+    this.text = text;
+    this.textOffset = offset;
+    this.embeddings = embeddings;
+    this.embeddingOffset = embedOffset;
+    this.length = length;
+    this.flags = flags;
+
+    runBidi();
+  }
+
+  /**
+   * Create a new Bidi object using the contents of the given String
+   * as the text.
+   * @param text the text to use
+   * @param flags a flag indicating the base embedding direction
+   */
+  public Bidi(String text, int flags)
+  {
+    if (flags != DIRECTION_DEFAULT_LEFT_TO_RIGHT
+        && flags != DIRECTION_DEFAULT_RIGHT_TO_LEFT
+        && flags != DIRECTION_LEFT_TO_RIGHT
+        && flags != DIRECTION_RIGHT_TO_LEFT)
+      throw new IllegalArgumentException("unrecognized 'flags' argument: "
+                                         + flags);
+
+    // This is inefficient, but it isn't clear whether it matters.
+    // If it does we can change our implementation a bit to allow either
+    // a String or a char[].
+    this.text = text.toCharArray();
+    this.textOffset = 0;
+    this.embeddings = null;
+    this.embeddingOffset = 0;
+    this.length = text.length();
+    this.flags = flags;
+
+    runBidi();
+  }
+
+  /**
+   * Implementation function which computes the initial type of
+   * each character in the input.
+   */
+  private void computeTypes()
+  {
+    types = new byte[length];
+    for (int i = 0; i < length; ++i)
+      types[i] = Character.getDirectionality(text[textOffset + i]);
+  }
+
+  /**
+   * An internal function which implements rules P2 and P3.
+   * This computes the base embedding level.
+   * @return the paragraph's base embedding level
+   */
+  private int computeParagraphEmbeddingLevel()
+  {
+    // First check to see if the user supplied a directionality override.
+    if (flags == DIRECTION_LEFT_TO_RIGHT
+        || flags == DIRECTION_RIGHT_TO_LEFT)
+      return flags;
+
+    // This implements rules P2 and P3.
+    // (Note that we don't need P1, as the user supplies
+    // a paragraph.)
+    for (int i = 0; i < length; ++i)
+      {
+        int dir = types[i];
+        if (dir == Character.DIRECTIONALITY_LEFT_TO_RIGHT)
+          return DIRECTION_LEFT_TO_RIGHT;
+        if (dir == Character.DIRECTIONALITY_RIGHT_TO_LEFT
+            || dir == Character.DIRECTIONALITY_RIGHT_TO_LEFT)
+          return DIRECTION_RIGHT_TO_LEFT;
+      }
+    return (flags == DIRECTION_DEFAULT_LEFT_TO_RIGHT
+            ? DIRECTION_LEFT_TO_RIGHT
+            : DIRECTION_RIGHT_TO_LEFT);
+  }
+
+  /**
+   * An internal function which implements rules X1 through X9.
+   * This computes the initial levels for the text, handling
+   * explicit overrides and embeddings.
+   */
+  private void computeExplicitLevels()
+  {
+    levels = new byte[length];
+    byte currentEmbedding = (byte) baseEmbedding;
+    // The directional override is a Character directionality
+    // constant.  -1 means there is no override.
+    byte directionalOverride = -1;
+    // The stack of pushed embeddings, and the stack pointer.
+    // Note that because the direction is inherent in the depth,
+    // and because we have a bit left over in a byte, we can encode
+    // the override, if any, directly in this value on the stack.
+    final int MAX_DEPTH = 62;
+    byte[] embeddingStack = new byte[MAX_DEPTH];
+    int sp = 0;
+
+    for (int i = 0; i < length; ++i)
+      {
+        // If we see an explicit embedding, we use that, even if
+        // the current character is itself a directional override.
+        if (embeddings != null && embeddings[embeddingOffset + i] != 0)
+          {
+            // It isn't at all clear what we're supposed to do here.
+            // What does a negative value really mean?
+            // Should we push on the embedding stack here?
+            currentEmbedding = embeddings[embeddingOffset + i]; 
+            if (currentEmbedding < 0)
+              {
+                currentEmbedding = (byte) -currentEmbedding;
+                directionalOverride
+                  = (((currentEmbedding % 2) == 0)
+                      ? Character.DIRECTIONALITY_LEFT_TO_RIGHT
+                      : Character.DIRECTIONALITY_RIGHT_TO_LEFT);
+              }
+            else
+              directionalOverride = -1;
+            continue;
+          }
+        // No explicit embedding.
+        boolean isLtoR = false;
+        boolean isSpecial = true;
+        switch (types[i])
+          {
+            case Character.DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING:
+            case Character.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE:
+              isLtoR = true;
+              // Fall through.
+            case Character.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING:
+            case Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE:
+              {
+                byte newEmbedding;
+                if (isLtoR)
+                  {
+                    // Least greater even.
+                    newEmbedding = (byte) ((currentEmbedding & ~1) + 2);
+                  }
+                else
+                  {
+                    // Least greater odd.
+                    newEmbedding = (byte) ((currentEmbedding + 1) | 1);
+                  }
+                // FIXME: we don't properly handle invalid pushes.
+                if (newEmbedding < MAX_DEPTH)
+                  {
+                    // The new level is valid.  Push the old value.
+                    // See above for a comment on the encoding here.
+                    if (directionalOverride != -1)
+                      currentEmbedding |= Byte.MIN_VALUE;
+                    embeddingStack[sp++] = currentEmbedding;
+                    currentEmbedding = newEmbedding;
+                    if (types[i] == Character.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE)
+                      directionalOverride = Character.DIRECTIONALITY_LEFT_TO_RIGHT;
+                    else if (types[i] == Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE)
+                      directionalOverride = Character.DIRECTIONALITY_RIGHT_TO_LEFT;
+                    else
+                      directionalOverride = -1;
+                  }
+                }
+              break;
+            case Character.DIRECTIONALITY_POP_DIRECTIONAL_FORMAT:
+              {
+                // FIXME: we don't properly handle a pop with a corresponding
+                // invalid push.
+                if (sp == 0)
+                  {
+                    // We saw a pop without a push.  Just ignore it.
+                    break;
+                  }
+                byte newEmbedding = embeddingStack[--sp];
+                currentEmbedding = (byte) (newEmbedding & 0x7f);
+                if (newEmbedding < 0)
+                  directionalOverride
+                  = (((newEmbedding & 1) == 0)
+                      ? Character.DIRECTIONALITY_LEFT_TO_RIGHT
+                      : Character.DIRECTIONALITY_RIGHT_TO_LEFT);
+                else
+                  directionalOverride = -1;
+              }
+              break;
+            default:
+              isSpecial = false;
+              break;
+          }
+        levels[i] = currentEmbedding;
+        if (isSpecial)
+          {
+            // Mark this character for removal.
+            if (formatterIndices == null)
+              formatterIndices = new ArrayList();
+            formatterIndices.add(Integer.valueOf(i));
+          }
+        else if (directionalOverride != -1)
+          types[i] = directionalOverride;
+      }
+
+    // Remove the formatting codes and update both the arrays
+    // and 'length'.  It would be more efficient not to remove
+    // these codes, but it is also more complicated.  Also, the
+    // Unicode algorithm reference does not properly describe
+    // how this is to be done -- from what I can tell, their suggestions
+    // in this area will not yield the correct results.
+    if (formatterIndices == null)
+      return;
+    int output = 0, input = 0;
+    final int size = formatterIndices.size();
+    for (int i = 0; i <= size; ++i)
+      {
+        int nextFmt;
+        if (i == size)
+          nextFmt = length;
+        else
+          nextFmt = ((Integer) formatterIndices.get(i)).intValue();
+        // Non-formatter codes are from 'input' to 'nextFmt'.
+        int len = nextFmt - input;
+        System.arraycopy(levels, input, levels, output, len);
+        System.arraycopy(types, input, types, output, len);
+        output += len;
+        input = nextFmt + 1;
+      }
+    length -= formatterIndices.size();
+  }
+
+  /**
+   * An internal function to compute the boundaries of runs
+   * in the text.  It isn't strictly necessary to do this, but
+   * it lets us write some following passes in a less complicated
+   * way.  Also it lets us efficiently implement some of the public
+   * methods.  A run is simply a sequence of characters at the
+   * same level.
+   */
+  private void computeRuns()
+  {
+    int runCount = 0;
+    int currentEmbedding = baseEmbedding;
+    for (int i = 0; i < length; ++i)
+      {
+        if (levels[i] != currentEmbedding)
+          {
+            currentEmbedding = levels[i];
+            ++runCount;
+          }
+      }
+
+    // This may be called multiple times.  If so, and if
+    // the number of runs has not changed, then don't bother
+    // allocating a new array.
+    if (runs == null || runs.length != runCount + 1)
+      runs = new int[runCount + 1];
+    int where = 0;
+    int lastRunStart = 0;
+    currentEmbedding = baseEmbedding;
+    for (int i = 0; i < length; ++i)
+      {
+        if (levels[i] != currentEmbedding)
+          {
+            runs[where++] = lastRunStart;
+            lastRunStart = i;
+            currentEmbedding = levels[i];
+          }
+      }
+    runs[where++] = lastRunStart;
+  }
+
+  /**
+   * An internal method to resolve weak types.  This implements
+   * rules W1 through W7.
+   */
+  private void resolveWeakTypes()
+  {
+    final int runCount = getRunCount();
+    
+    int previousLevel = baseEmbedding;
+    for (int run = 0; run < runCount; ++run)
+      {
+        int start = getRunStart(run);
+        int end = getRunLimit(run);
+        int level = getRunLevel(run);
+
+        // These are the names used in the Bidi algorithm.
+        byte sor = (((Math.max(previousLevel, level) % 2) == 0)
+                      ? Character.DIRECTIONALITY_LEFT_TO_RIGHT
+                      : Character.DIRECTIONALITY_RIGHT_TO_LEFT);
+        int nextLevel;
+        if (run == runCount - 1)
+          nextLevel = baseEmbedding;
+        else
+          nextLevel = getRunLevel(run + 1);
+        byte eor = (((Math.max(level, nextLevel) % 2) == 0)
+                      ? Character.DIRECTIONALITY_LEFT_TO_RIGHT
+                      : Character.DIRECTIONALITY_RIGHT_TO_LEFT);
+
+        byte prevType = sor;
+        byte prevStrongType = sor;
+        for (int i = start; i < end; ++i)
+          {
+            final byte nextType = (i == end - 1) ? eor : types[i + 1];
+
+            // Rule W1: change NSM to the prevailing direction.
+            if (types[i] == Character.DIRECTIONALITY_NONSPACING_MARK)
+              types[i] = prevType;
+            else
+              prevType = types[i];
+
+            // Rule W2: change EN to AN in some cases.
+            if (types[i] == Character.DIRECTIONALITY_EUROPEAN_NUMBER)
+              {
+                if (prevStrongType == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC)
+                  types[i] = Character.DIRECTIONALITY_ARABIC_NUMBER;
+              }
+            else if (types[i] == Character.DIRECTIONALITY_LEFT_TO_RIGHT
+                     || types[i] == Character.DIRECTIONALITY_RIGHT_TO_LEFT
+                     || types[i] == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC)
+              prevStrongType = types[i];
+
+            // Rule W3: change AL to R.
+            if (types[i] == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC)
+              types[i] = Character.DIRECTIONALITY_RIGHT_TO_LEFT;
+
+            // Rule W4: handle separators between two numbers.
+            if (prevType == Character.DIRECTIONALITY_EUROPEAN_NUMBER
+                && nextType == Character.DIRECTIONALITY_EUROPEAN_NUMBER)
+              {
+                if (types[i] == Character.DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR
+                    || types[i] == Character.DIRECTIONALITY_COMMON_NUMBER_SEPARATOR)
+                  types[i] = nextType;
+              }
+            else if (prevType == Character.DIRECTIONALITY_ARABIC_NUMBER
+                     && nextType == Character.DIRECTIONALITY_ARABIC_NUMBER
+                     && types[i] == Character.DIRECTIONALITY_COMMON_NUMBER_SEPARATOR)
+              types[i] = nextType;
+
+            // Rule W5: change a sequence of european terminators to
+            // european numbers, if they are adjacent to european numbers.
+            // We also include BN characters in this.
+            if (types[i] == Character.DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR
+                || types[i] == Character.DIRECTIONALITY_BOUNDARY_NEUTRAL)
+              {
+                if (prevType == Character.DIRECTIONALITY_EUROPEAN_NUMBER)
+                  types[i] = prevType;
+                else
+                  {
+                    // Look ahead to see if there is an EN terminating this
+                    // sequence of ETs.
+                    int j = i + 1;
+                    while (j < end
+                           && (types[j] == Character.DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR
+                               || types[j] == Character.DIRECTIONALITY_BOUNDARY_NEUTRAL))
+                      ++j;
+                    if (j < end
+                        && types[j] == Character.DIRECTIONALITY_EUROPEAN_NUMBER)
+                      {
+                        // Change them all to EN now.
+                        for (int k = i; k < j; ++k)
+                          types[k] = Character.DIRECTIONALITY_EUROPEAN_NUMBER;
+                      }
+                  }
+              }
+
+            // Rule W6: separators and terminators change to ON.
+            // Again we include BN.
+            if (types[i] == Character.DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR
+                || types[i] == Character.DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR
+                || types[i] == Character.DIRECTIONALITY_COMMON_NUMBER_SEPARATOR
+                || types[i] == Character.DIRECTIONALITY_BOUNDARY_NEUTRAL)
+              types[i] = Character.DIRECTIONALITY_OTHER_NEUTRALS;
+
+            // Rule W7: change european number types.
+            if (prevStrongType == Character.DIRECTIONALITY_LEFT_TO_RIGHT
+                && types[i] == Character.DIRECTIONALITY_EUROPEAN_NUMBER)
+              types[i] = prevStrongType;
+          }
+
+        previousLevel = level;
+      }
+  }
+
+  /**
+   * An internal method to resolve neutral types.  This implements
+   * rules N1 and N2.
+   */
+  private void resolveNeutralTypes()
+  {
+    // This implements rules N1 and N2.
+    final int runCount = getRunCount();
+    
+    int previousLevel = baseEmbedding;
+    for (int run = 0; run < runCount; ++run)
+      {
+        int start = getRunStart(run);
+        int end = getRunLimit(run);
+        int level = getRunLevel(run);
+
+        byte embeddingDirection
+          = (((level % 2) == 0) ? Character.DIRECTIONALITY_LEFT_TO_RIGHT
+                                : Character.DIRECTIONALITY_RIGHT_TO_LEFT);
+        // These are the names used in the Bidi algorithm.
+        byte sor = (((Math.max(previousLevel, level) % 2) == 0)
+                      ? Character.DIRECTIONALITY_LEFT_TO_RIGHT
+                      : Character.DIRECTIONALITY_RIGHT_TO_LEFT);
+        int nextLevel;
+        if (run == runCount - 1)
+          nextLevel = baseEmbedding;
+        else
+          nextLevel = getRunLevel(run + 1);
+        byte eor = (((Math.max(level, nextLevel) % 2) == 0)
+                      ? Character.DIRECTIONALITY_LEFT_TO_RIGHT
+                      : Character.DIRECTIONALITY_RIGHT_TO_LEFT);
+
+        byte prevStrong = sor;
+        int neutralStart = -1;
+        for (int i = start; i <= end; ++i)
+          {
+            byte newStrong = -1;
+            byte thisType = i == end ? eor : types[i];
+            switch (thisType)
+              {
+              case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
+                newStrong = Character.DIRECTIONALITY_LEFT_TO_RIGHT;
+                break;
+              case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
+              case Character.DIRECTIONALITY_ARABIC_NUMBER:
+              case Character.DIRECTIONALITY_EUROPEAN_NUMBER:
+                newStrong = Character.DIRECTIONALITY_RIGHT_TO_LEFT;
+                break;
+              case Character.DIRECTIONALITY_BOUNDARY_NEUTRAL:
+              case Character.DIRECTIONALITY_OTHER_NEUTRALS:
+              case Character.DIRECTIONALITY_SEGMENT_SEPARATOR:
+              case Character.DIRECTIONALITY_PARAGRAPH_SEPARATOR:
+	      case Character.DIRECTIONALITY_WHITESPACE:
+                if (neutralStart == -1)
+                  neutralStart = i;
+                break;
+              }
+            // If we see a strong character, update all the neutrals.
+            if (newStrong != -1)
+              {
+                if (neutralStart != -1)
+                  {
+                    byte override = (prevStrong == newStrong
+                                     ? prevStrong
+                                     : embeddingDirection);
+                    for (int j = neutralStart; j < i; ++j)
+                      types[j] = override;
+                  }
+                prevStrong = newStrong;
+                neutralStart = -1;
+              }
+          }
+
+        previousLevel = level;
+      }
+  }
+
+  /**
+   * An internal method to resolve implicit levels.
+   * This implements rules I1 and I2.
+   */
+  private void resolveImplicitLevels()
+  {
+    // This implements rules I1 and I2.
+    for (int i = 0; i < length; ++i)
+      {
+        if ((levels[i] & 1) == 0)
+          {
+            if (types[i] == Character.DIRECTIONALITY_RIGHT_TO_LEFT)
+              ++levels[i];
+            else if (types[i] == Character.DIRECTIONALITY_ARABIC_NUMBER
+                     || types[i] == Character.DIRECTIONALITY_EUROPEAN_NUMBER)
+              levels[i] += 2;
+          }
+        else
+          {
+            if (types[i] == Character.DIRECTIONALITY_LEFT_TO_RIGHT
+                || types[i] == Character.DIRECTIONALITY_ARABIC_NUMBER
+                || types[i] == Character.DIRECTIONALITY_EUROPEAN_NUMBER)
+              ++levels[i];
+          }
+
+        // Update the result flags.
+        resultFlags |= 1 << (levels[i] & 1);
+      }
+    // One final update of the result flags, using the base level.
+    resultFlags |= 1 << baseEmbedding;
+  }
+
+  /**
+   * This reinserts the formatting codes that we removed early on.
+   * Actually it does not insert formatting codes per se, but rather
+   * simply inserts new levels at the appropriate locations in the
+   * 'levels' array.
+   */
+  private void reinsertFormattingCodes()
+  {
+    if (formatterIndices == null)
+      return;
+    int input = length;
+    int output = levels.length;
+    // Process from the end as we are copying the array over itself here.
+    for (int index = formatterIndices.size() - 1; index >= 0; --index)
+      {
+        int nextFmt = ((Integer) formatterIndices.get(index)).intValue();
+
+        // nextFmt points to a location in the original array.  So,
+        // nextFmt+1 is the target of our copying.  output is the location
+        // to which we last copied, thus we can derive the length of the
+        // copy from it.
+        int len = output - nextFmt - 1;
+        output = nextFmt;
+        input -= len;
+        // Note that we no longer need 'types' at this point, so we
+        // only edit 'levels'.
+        if (nextFmt + 1 < levels.length)
+          System.arraycopy(levels, input, levels, nextFmt + 1, len);
+
+        // Now set the level at the reinsertion point.
+        int rightLevel;
+        if (output == levels.length - 1)
+          rightLevel = baseEmbedding;
+        else
+          rightLevel = levels[output + 1];
+        int leftLevel;
+        if (input == 0)
+          leftLevel = baseEmbedding;
+        else
+          leftLevel = levels[input];
+        levels[output] = (byte) Math.max(leftLevel, rightLevel);
+      }
+    length = levels.length;
+  }
+
+  /**
+   * This is the main internal entry point.  After a constructor
+   * has initialized the appropriate local state, it will call
+   * this method to do all the work.
+   */
+  private void runBidi()
+  {
+    computeTypes();
+    baseEmbedding = computeParagraphEmbeddingLevel();
+    computeExplicitLevels();
+    computeRuns();
+    resolveWeakTypes();
+    resolveNeutralTypes();
+    resolveImplicitLevels();
+    // We're done with the types.  Let the GC clean up.
+    types = null;
+    reinsertFormattingCodes();
+    // After resolving the implicit levels, the number
+    // of runs may have changed.
+    computeRuns();
+  }
+
+  /**
+   * Return true if the paragraph base embedding is left-to-right,
+   * false otherwise.
+   */
+  public boolean baseIsLeftToRight()
+  {
+    return baseEmbedding == DIRECTION_LEFT_TO_RIGHT;
+  }
+
+  /**
+   * Create a new Bidi object for a single line of text, taken
+   * from the text used when creating the current Bidi object.
+   * @param start the index of the first character of the line
+   * @param end the index of the final character of the line
+   * @return a new Bidi object for the indicated line of text
+   */
+  public Bidi createLineBidi(int start, int end)
+  {
+    // This isn't the most efficient implementation possible.
+    // This probably does not matter, so we choose simplicity instead.
+    int level = getLevelAt(start);
+    int flag = (((level % 2) == 0)
+                ? DIRECTION_LEFT_TO_RIGHT
+                : DIRECTION_RIGHT_TO_LEFT);
+    return new Bidi(text, textOffset + start,
+                    embeddings, embeddingOffset + start,
+                    end - start, flag);
+  }
+
+  /**
+   * Return the base embedding level of the paragraph.
+   */
+  public int getBaseLevel()
+  {
+    return baseEmbedding;
+  }
+
+  /**
+   * Return the length of the paragraph, in characters.
+   */
+  public int getLength()
+  {
+    return length;
+  }
+
+  /**
+   * Return the level at the indicated character.  If the
+   * supplied index is less than zero or greater than the length
+   * of the text, then the paragraph's base embedding level will
+   * be returned.
+   * @param offset the character to examine
+   * @return the level of that character
+   */
+  public int getLevelAt(int offset)
+  {
+    if (offset < 0 || offset >= length)
+      return getBaseLevel();
+    return levels[offset];
+  }
+
+  /**
+   * Return the number of runs in the result.  A run is
+   * a sequence of characters at the same embedding level.
+   */
+  public int getRunCount()
+  {
+    return runs.length;
+  }
+
+  /**
+   * Return the level of the indicated run.
+   * @param which the run to examine
+   * @return the level of that run
+   */
+  public int getRunLevel(int which)
+  {
+    return levels[runs[which]];
+  }
+
+  /**
+   * Return the index of the character just following the end
+   * of the indicated run.
+   * @param which the run to examine
+   * @return the index of the character after the final character
+   * of the run
+   */
+  public int getRunLimit(int which)
+  {
+    if (which == runs.length - 1)
+      return length;
+    return runs[which + 1];
+  }
+
+  /**
+   * Return the index of the first character in the indicated run.
+   * @param which the run to examine
+   * @return the index of the first character of the run
+   */
+  public int getRunStart(int which)
+  {
+    return runs[which];
+  }
+
+  /**
+   * Return true if the text is entirely left-to-right, and the
+   * base embedding is also left-to-right.
+   */
+  public boolean isLeftToRight()
+  {
+    return resultFlags == LTOR;
+  }
+
+  /**
+   * Return true if the text consists of mixed left-to-right and
+   * right-to-left runs, or if the text consists of one kind of run
+   * which differs from the base embedding direction.
+   */
+  public boolean isMixed()
+  {
+    return resultFlags == (LTOR | RTOL);
+  }
+
+  /**
+   * Return true if the text is entirely right-to-left, and the
+   * base embedding is also right-to-left.
+   */
+  public boolean isRightToLeft()
+  {
+    return resultFlags == RTOL;
+  }
+
+  /**
+   * Return a String describing the internal state of this object.
+   * This is only useful for debugging.
+   */
+  public String toString()
+  {
+    return "Bidi Bidi Bidi I like you, Buck!";
+  }
+
+  /**
+   * Reorder objects according to the levels passed in.  This implements
+   * reordering as defined by the Unicode bidirectional layout specification.
+   * The levels are integers from 0 to 62; even numbers represent left-to-right
+   * runs, and odd numbers represent right-to-left runs.
+   *
+   * @param levels the levels associated with each object
+   * @param levelOffset the index of the first level to use
+   * @param objs the objects to reorder according to the levels
+   * @param objOffset the index of the first object to use
+   * @param count the number of objects (and levels) to manipulate
+   */
+  public static void reorderVisually(byte[] levels, int levelOffset,
+                                     Object[] objs, int objOffset, int count)
+  {
+    // We need a copy of the 'levels' array, as we are going to modify it.
+    // This is unfortunate but difficult to avoid.
+    byte[] levelCopy = new byte[count];
+    // Do this explicitly so we can also find the maximum depth at the
+    // same time.
+    int max = 0;
+    int lowestOdd = 63;
+    for (int i = 0; i < count; ++i)
+      {
+        levelCopy[i] = levels[levelOffset + i];
+        max = Math.max(levelCopy[i], max);
+        if (levelCopy[i] % 2 != 0)
+          lowestOdd = Math.min(lowestOdd, levelCopy[i]);
+      }
+
+    // Reverse the runs starting with the deepest.
+    for (int depth = max; depth >= lowestOdd; --depth)
+      {
+        int start = 0;
+        while (start < count)
+          {
+            // Find the start of a run >= DEPTH.
+            while (start < count && levelCopy[start] < depth)
+              ++start;
+            if (start == count)
+              break;
+            // Find the end of the run.
+            int end = start + 1;
+            while (end < count && levelCopy[end] >= depth)
+              ++end;
+
+            // Reverse this run.
+            for (int i = 0; i < (end - start) / 2; ++i)
+              {
+                byte tmpb = levelCopy[end - i - 1];
+                levelCopy[end - i - 1] = levelCopy[start + i];
+                levelCopy[start + i] = tmpb;
+                Object tmpo = objs[objOffset + end - i - 1];
+                objs[objOffset + end - i - 1] = objs[objOffset + start + i];
+                objs[objOffset + start + i] = tmpo;
+              }
+
+            // Handle the next run.
+            start = end + 1;
+          }
+      }
+  }
+
+  /**
+   * Returns false if all characters in the text between start and end
+   * are all left-to-right text. This implementation is just calls
+   * <code>Character.getDirectionality(char)</code> on all characters
+   * and makes sure all characters are either explicitly left-to-right
+   * or neutral in directionality (character types L, EN, ES, ET, AN,
+   * CS, S and WS).
+   */
+  public static boolean requiresBidi(char[] text, int start, int end)
+  {
+    for (int i = start; i < end; i++)
+      {
+	byte dir = Character.getDirectionality(text[i]);
+	if (dir != Character.DIRECTIONALITY_LEFT_TO_RIGHT
+	    && dir != Character.DIRECTIONALITY_EUROPEAN_NUMBER
+	    && dir != Character.DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR
+	    && dir != Character.DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR
+	    && dir != Character.DIRECTIONALITY_ARABIC_NUMBER
+	    && dir != Character.DIRECTIONALITY_COMMON_NUMBER_SEPARATOR
+	    && dir != Character.DIRECTIONALITY_SEGMENT_SEPARATOR
+	    && dir != Character.DIRECTIONALITY_WHITESPACE)
+	  return true;
+      }
+
+    return false;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/BreakIterator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/BreakIterator.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/BreakIterator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/BreakIterator.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,373 @@
+/* BreakIterator.java -- Breaks text into elements
+   Copyright (C) 1998, 1999, 2001, 2004, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * This class iterates over text elements such as words, lines, sentences,
+ * and characters.  It can only iterate over one of these text elements at
+ * a time.  An instance of this class configured for the desired iteration
+ * type is created by calling one of the static factory methods, not
+ * by directly calling a constructor.
+ *
+ * The standard iterators created by the factory methods in this
+ * class will be valid upon creation.  That is, their methods will
+ * not cause exceptions if called before you call setText().
+ *
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @date March 19, 1999
+ */
+/* Written using "Java Class Libraries", 2nd edition, plus online
+ * API docs for JDK 1.2 beta from http://www.javasoft.com.
+ * Status:  Believed complete and correct to 1.1.
+ */
+public abstract class BreakIterator implements Cloneable
+{
+  /**
+   * This value is returned by the <code>next()</code> and
+   * <code>previous</code> in order to indicate that the end of the
+   * text has been reached.
+   */
+  // The value was discovered by writing a test program.
+  public static final int DONE = -1;
+
+  /**
+   * This method initializes a new instance of <code>BreakIterator</code>.
+   * This protected constructor is available to subclasses as a default
+   * no-arg superclass constructor.
+   */
+  protected BreakIterator ()
+  {
+  }
+
+  /**
+   * Create a clone of this object.
+   */
+  public Object clone ()
+  {
+    try
+      {
+        return super.clone();
+      }
+    catch (CloneNotSupportedException e)
+      {
+        return null;
+      }
+  }
+  
+  /**
+   * This method returns the index of the current text element boundary.
+   *
+   * @return The current text boundary.
+   */
+  public abstract int current ();
+
+  /**
+   * This method returns the first text element boundary in the text being
+   * iterated over.
+   *
+   * @return The first text boundary.
+   */
+  public abstract int first ();
+
+  /**
+   * This methdod returns the offset of the text element boundary following
+   * the specified offset.
+   *
+   * @param pos The text index from which to find the next text boundary.
+   *
+   * @return The next text boundary following the specified index.
+   */
+  public abstract int following (int pos);
+
+  /**
+   * This method returns a list of locales for which instances of
+   * <code>BreakIterator</code> are available.
+   *
+   * @return A list of available locales
+   */
+  public static synchronized Locale[] getAvailableLocales ()
+  {
+    Locale[] l = new Locale[1];
+    l[0] = Locale.US;
+    return l;
+  }
+
+  private static BreakIterator getInstance (String type, Locale loc)
+  {
+    String className;
+    try
+      {
+	ResourceBundle res
+	  = ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
+				     loc, ClassLoader.getSystemClassLoader());
+	className = res.getString(type);
+      }
+    catch (MissingResourceException x)
+      {
+	return null;
+      }
+    try
+      {
+	Class k = Class.forName(className);
+	return (BreakIterator) k.newInstance();
+      }
+    catch (ClassNotFoundException x1)
+      {
+	return null;
+      }
+    catch (InstantiationException x2)
+      {
+	return null;
+      }
+    catch (IllegalAccessException x3)
+      {
+	return null;
+      }
+  }
+
+  /**
+   * This method returns an instance of <code>BreakIterator</code> that will
+   * iterate over characters as defined in the default locale.
+   *
+   * @return A <code>BreakIterator</code> instance for the default locale.
+   */
+  public static BreakIterator getCharacterInstance ()
+  {
+    return getCharacterInstance (Locale.getDefault());
+  }
+
+  /**
+   * This method returns an instance of <code>BreakIterator</code> that will
+   * iterate over characters as defined in the specified locale.  If the
+   * desired locale is not available, the default locale is used.
+   *
+   * @param locale The desired locale.
+   *
+   * @return A <code>BreakIterator</code> instance for the default locale.
+   */
+  public static BreakIterator getCharacterInstance (Locale locale)
+  {
+    BreakIterator r = getInstance ("CharacterIterator", locale);
+    if (r == null)
+      r = new gnu.java.text.CharacterBreakIterator ();
+    return r;
+  }
+
+  /**
+   * This method returns an instance of <code>BreakIterator</code> that will
+   * iterate over line breaks as defined in the default locale.
+   *
+   * @return A <code>BreakIterator</code> instance for the default locale.
+   */
+  public static BreakIterator getLineInstance ()
+  {
+    return getLineInstance (Locale.getDefault());
+  }
+
+  /**
+   * This method returns an instance of <code>BreakIterator</code> that will
+   * iterate over line breaks as defined in the specified locale.  If the
+   * desired locale is not available, the default locale is used.
+   *
+   * @param locale The desired locale.
+   *
+   * @return A <code>BreakIterator</code> instance for the default locale.
+   */
+  public static BreakIterator getLineInstance (Locale locale)
+  {
+    BreakIterator r = getInstance ("LineIterator", locale);
+    if (r == null)
+      r = new gnu.java.text.LineBreakIterator ();
+    return r;
+  }
+
+  /**
+   * This method returns an instance of <code>BreakIterator</code> that will
+   * iterate over sentences as defined in the default locale.
+   *
+   * @return A <code>BreakIterator</code> instance for the default locale.
+   */
+  public static BreakIterator getSentenceInstance ()
+  {
+    return getSentenceInstance (Locale.getDefault());
+  }
+
+  /**
+   * This method returns an instance of <code>BreakIterator</code> that will
+   * iterate over sentences as defined in the specified locale.  If the
+   * desired locale is not available, the default locale is used.
+   *
+   * @param locale The desired locale.
+   *
+   * @return A <code>BreakIterator</code> instance for the default locale.
+   */
+  public static BreakIterator getSentenceInstance (Locale locale)
+  {
+    BreakIterator r = getInstance ("SentenceIterator", locale);
+    if (r == null)
+      r = new gnu.java.text.SentenceBreakIterator ();
+    return r;
+  }
+
+  /**
+   * This method returns the text this object is iterating over as a
+   * <code>CharacterIterator</code>.
+   *
+   * @return The text being iterated over.
+   */
+  public abstract CharacterIterator getText ();
+
+  /**
+   * This method returns an instance of <code>BreakIterator</code> that will
+   * iterate over words as defined in the default locale.
+   *
+   * @return A <code>BreakIterator</code> instance for the default locale.
+   */
+  public static BreakIterator getWordInstance ()
+  {
+    return getWordInstance (Locale.getDefault());
+  }
+
+  /**
+   * This method returns an instance of <code>BreakIterator</code> that will
+   * iterate over words as defined in the specified locale.  If the
+   * desired locale is not available, the default locale is used.
+   *
+   * @param locale The desired locale.
+   *
+   * @return A <code>BreakIterator</code> instance for the default locale.
+   */
+  public static BreakIterator getWordInstance (Locale locale)
+  {
+    BreakIterator r = getInstance ("WordIterator", locale);
+    if (r == null)
+      r = new gnu.java.text.WordBreakIterator ();
+    return r;
+  }
+
+  /**
+   * This method tests whether or not the specified position is a text
+   * element boundary.
+   *
+   * @param pos The text position to test.
+   *
+   * @return <code>true</code> if the position is a boundary,
+   * <code>false</code> otherwise. 
+   */
+  public boolean isBoundary (int pos)
+  {
+    if (pos == 0)
+      return true;
+    return following (pos - 1) == pos;
+  }
+
+  /**
+   * This method returns the last text element boundary in the text being
+   * iterated over.
+   *
+   * @return The last text boundary.
+   */
+  public abstract int last ();
+
+  /**
+   * This method returns the text element boundary following the current
+   * text position.
+   *
+   * @return The next text boundary.
+   */
+  public abstract int next ();
+
+  /**
+   * This method returns the n'th text element boundary following the current
+   * text position.
+   *
+   * @param n The number of text element boundaries to skip.
+   *
+   * @return The next text boundary.
+   */
+  public abstract int next (int n);
+
+  /**
+   * This methdod returns the offset of the text element boundary preceding
+   * the specified offset.
+   *
+   * @param pos The text index from which to find the preceding text boundary. 
+   *
+   * @returns The next text boundary preceding the specified index.
+   */
+  public int preceding (int pos)
+  {
+    if (following (pos) == DONE)
+      last ();
+    while (previous () >= pos)
+      ;
+    return current ();
+  }
+
+  /**
+   * This method returns the text element boundary preceding the current
+   * text position.
+   *
+   * @return The previous text boundary.
+   */
+  public abstract int previous ();
+
+  /**
+   * This method sets the text string to iterate over.
+   *
+   * @param newText The <code>String</code> to iterate over.
+   */
+  public void setText (String newText)
+  {
+    setText (new StringCharacterIterator (newText));
+  }
+
+  /**
+   * This method sets the text to iterate over from the specified
+   * <code>CharacterIterator</code>.
+   * 
+   * @param newText The desired <code>CharacterIterator</code>.
+   */
+  public abstract void setText (CharacterIterator newText);
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/CharacterIterator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/CharacterIterator.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/CharacterIterator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/CharacterIterator.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,148 @@
+/* CharacterIterator.java -- Iterate over a character range
+   Copyright (C) 1998, 2001, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+/**
+  * This interface defines a mechanism for iterating over a range of
+  * characters.  For a given range of text, a beginning and ending index,
+  * as well as a current index are defined.  These values can be queried
+  * by the methods in this interface.  Additionally, various methods allow
+  * the index to be set. 
+  *
+  * @author Aaron M. Renn (arenn at urbanophile.com)
+  */
+public interface CharacterIterator extends Cloneable
+{
+  /**
+   * This is a special constant value that is returned when the beginning or
+   * end of the character range has been reached.
+   */
+  char DONE = '\uFFFF';
+
+  /**
+   * This method returns the character at the current index position
+   *
+   * @return The character at the current index position.
+   */
+  char current();
+
+  /**
+   * This method increments the current index and then returns the character
+   * at the new index value.  If the index is already at 
+   * <code>getEndIndex() - 1</code>, it will not be incremented.
+   *
+   * @return The character at the position of the incremented index value,
+   * or {@link #DONE} if the index has reached getEndIndex() - 1
+   */
+  char next();
+
+  /**
+   * This method decrements the current index and then returns the character
+   * at the new index value.  If the index value is already at the beginning
+   * index, it will not be decremented.
+   *
+   * @return The character at the position of the decremented index value,
+   *         or {@link #DONE} if index was already equal to the beginning index
+   *         value.
+   */
+  char previous();
+
+  /**
+   * This method sets the index value to the beginning of the range and returns
+   * the character there.
+   *
+   * @return The character at the beginning of the range, or {@link #DONE} if 
+   *         the range is empty.
+   */
+  char first();
+
+  /**
+   * This method sets the index value to <code>getEndIndex() - 1</code> and
+   * returns the character there.  If the range is empty, then the index value
+   * will be set equal to the beginning index.
+   *
+   * @return The character at the end of the range, or {@link #DONE} if the 
+   *         range is empty.
+   */
+  char last();  
+
+  /**
+   * This method returns the current value of the index.
+   *
+   * @return The current index value
+   */
+  int getIndex();
+
+  /**
+   * This method sets the value of the index to the specified value, then
+   * returns the character at that position.
+   *
+   * @param index The new index value.
+   *
+   * @return The character at the new index value or {@link #DONE} if the index
+   *         value is equal to {@link #getEndIndex()}.
+   */
+  char setIndex (int index) throws IllegalArgumentException;
+
+  /**
+   * This method returns the character position of the first character in the
+   * range.
+   *
+   * @return The index of the first character in the range.
+   */
+  int getBeginIndex();
+
+  /**
+   * This method returns the character position of the end of the text range.
+   * This will actually be the index of the first character following the
+   * end of the range.  In the event the text range is empty, this will be
+   * equal to the first character in the range.
+   *
+   * @return The index of the end of the range.
+   */
+  int getEndIndex();
+
+  /**
+   * This method creates a copy of this <code>CharacterIterator</code>.
+   *
+   * @return A copy of this <code>CharacterIterator</code>.
+   */
+  Object clone();
+
+} // interface CharacterIterator

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/ChoiceFormat.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/ChoiceFormat.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/ChoiceFormat.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/ChoiceFormat.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,504 @@
+/* ChoiceFormat.java -- Format over a range of numbers
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005
+   Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+import java.util.Vector;
+
+/**
+ * This class allows a format to be specified based on a range of numbers.
+ * To use this class, first specify two lists of formats and range terminators.
+ * These lists must be arrays of equal length.  The format of index 
+ * <code>i</code> will be selected for value <code>X</code> if 
+ * <code>terminator[i] <= X < limit[i + 1]</code>.  If the value X is not
+ * included in any range, then either the first or last format will be 
+ * used depending on whether the value X falls outside the range.
+ * <p>
+ * This sounds complicated, but that is because I did a poor job of
+ * explaining it.  Consider the following example:
+ * <p>
+ *
+<pre>terminators = { 1, ChoiceFormat.nextDouble(1) }
+formats = { "file", "files" }</pre>
+ *
+ * <p>
+ * In this case if the actual number tested is one or less, then the word
+ * "file" is used as the format value.  If the number tested is greater than
+ * one, then "files" is used.  This allows plurals to be handled
+ * gracefully.  Note the use of the method <code>nextDouble</code>.  This
+ * method selects the next highest double number than its argument.  This
+ * effectively makes any double greater than 1.0 cause the "files" string
+ * to be selected.  (Note that all terminator values are specified as
+ * doubles.
+ * <p>
+ * Note that in order for this class to work properly, the range terminator
+ * array must be sorted in ascending order and the format string array
+ * must be the same length as the terminator array.
+ *
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @date March 9, 1999
+ */
+/* Written using "Java Class Libraries", 2nd edition, plus online
+ * API docs for JDK 1.2 from http://www.javasoft.com.
+ * Status:  Believed complete and correct to 1.1.
+ */
+public class ChoiceFormat extends NumberFormat
+{
+  /**
+   * This method sets new range terminators and format strings for this
+   * object based on the specified pattern. This pattern is of the form 
+   * "term#string|term#string...".  For example "1#Sunday|2#Monday|#Tuesday".
+   *
+   * @param newPattern The pattern of terminators and format strings.
+   *
+   * @exception IllegalArgumentException If the pattern is not valid
+   */
+  public void applyPattern (String newPattern)
+  {
+    // Note: we assume the same kind of quoting rules apply here.
+    // This isn't explicitly documented.  But for instance we accept
+    // '#' as a literal hash in a format string.
+    int index = 0, max = newPattern.length();
+    Vector stringVec = new Vector ();
+    Vector limitVec = new Vector ();
+    StringBuffer buf = new StringBuffer ();
+    
+    while (true)
+      {
+	// Find end of double.
+	int dstart = index;
+	while (index < max)
+	  {
+	    char c = newPattern.charAt(index);
+	    if (c == '#' || c == '\u2064' || c == '<')
+	      break;
+	    ++index;
+	  }
+	
+	if (index == max)
+	  throw new IllegalArgumentException ("unexpected end of text");
+	Double d = new Double (newPattern.substring(dstart, index));
+
+	if (newPattern.charAt(index) == '<')
+	  d = new Double (nextDouble (d.doubleValue()));
+
+	limitVec.addElement(d);
+
+	// Scan text.
+	++index;
+	buf.setLength(0);
+	while (index < max)
+	  {
+	    char c = newPattern.charAt(index);
+	    if (c == '\'' && index < max + 1
+		&& newPattern.charAt(index + 1) == '\'')
+	      {
+		buf.append(c);
+		++index;
+	      }
+	    else if (c == '\'' && index < max + 2)
+	      {
+		buf.append(newPattern.charAt(index + 1));
+		index += 2;
+	      }
+	    else if (c == '|')
+	      break;
+	    else
+	      buf.append(c);
+	    ++index;
+	  }
+
+	stringVec.addElement(buf.toString());
+	if (index == max)
+	  break;
+	++index;
+      }
+
+    choiceFormats = new String[stringVec.size()];
+    stringVec.copyInto(choiceFormats);
+
+    choiceLimits = new double[limitVec.size()];
+    for (int i = 0; i < choiceLimits.length; ++i)
+      {
+	Double d = (Double) limitVec.elementAt(i);
+	choiceLimits[i] = d.doubleValue();
+      }
+  }
+
+  /**
+   * This method initializes a new instance of <code>ChoiceFormat</code> that
+   * generates its range terminator and format string arrays from the
+   * specified pattern.  This pattern is of the form 
+   * "term#string|term#string...".  For example "1#Sunday|2#Monday|#Tuesday".
+   * This is the same pattern type used by the <code>applyPattern</code>
+   * method.
+   *
+   * @param newPattern The pattern of terminators and format strings.
+   *
+   * @exception IllegalArgumentException If the pattern is not valid
+   */
+  public ChoiceFormat (String newPattern)
+  {
+    super ();
+    applyPattern (newPattern);
+  }
+
+  /**
+   * This method initializes a new instance of <code>ChoiceFormat</code> that
+   * will use the specified range terminators and format strings.
+   *
+   * @param choiceLimits The array of range terminators
+   * @param choiceFormats The array of format strings
+   */
+  public ChoiceFormat (double[] choiceLimits, String[] choiceFormats)
+  {
+    super ();
+    setChoices (choiceLimits, choiceFormats);
+  }
+
+  /**
+   * This method tests this object for equality with the specified 
+   * object.  This will be true if and only if:
+   * <ul>
+   * <li>The specified object is not <code>null</code>.</li>
+   * <li>The specified object is an instance of <code>ChoiceFormat</code>.</li>
+   * <li>The termination ranges and format strings are identical to
+   *     this object's. </li>
+   * </ul>
+   *
+   * @param obj The object to test for equality against.
+   *
+   * @return <code>true</code> if the specified object is equal to
+   * this one, <code>false</code> otherwise. 
+   */
+  public boolean equals (Object obj)
+  {
+    if (! (obj instanceof ChoiceFormat))
+      return false;
+    ChoiceFormat cf = (ChoiceFormat) obj;
+    if (choiceLimits.length != cf.choiceLimits.length)
+      return false;
+    for (int i = choiceLimits.length - 1; i >= 0; --i)
+      {
+	if (choiceLimits[i] != cf.choiceLimits[i]
+	    || !choiceFormats[i].equals(cf.choiceFormats[i]))
+	  return false;
+      }
+    return true;
+  }
+
+  /**
+   * This method appends the appropriate format string to the specified
+   * <code>StringBuffer</code> based on the supplied <code>long</code>
+   * argument.
+   *
+   * @param num The number used for determine (based on the range
+   *               terminators) which format string to append. 
+   * @param appendBuf The <code>StringBuffer</code> to append the format string 
+   *                  to.
+   * @param pos Unused.
+   *
+   * @return The <code>StringBuffer</code> with the format string appended.
+   */
+  public StringBuffer format (long num, StringBuffer appendBuf,
+			      FieldPosition pos)
+  {
+    return format ((double) num, appendBuf, pos);
+  }
+
+  /**
+   * This method appends the appropriate format string to the specified
+   * <code>StringBuffer</code> based on the supplied <code>double</code>
+   * argument.
+   *
+   * @param num The number used for determine (based on the range
+   *               terminators) which format string to append. 
+   * @param appendBuf The <code>StringBuffer</code> to append the format string to.
+   * @param pos Unused.
+   *
+   * @return The <code>StringBuffer</code> with the format string appended.
+   */
+  public StringBuffer format (double num, StringBuffer appendBuf,
+			      FieldPosition pos)
+  {
+    if (choiceLimits.length == 0)
+      return appendBuf;
+
+    int index = 0;
+    if (! Double.isNaN(num) && num >= choiceLimits[0])
+      {
+	for (; index < choiceLimits.length - 1; ++index)
+	  {
+	    if (choiceLimits[index] <= num && num < choiceLimits[index + 1])
+	      break;
+	  }
+      }
+
+    return appendBuf.append(choiceFormats[index]);
+  }
+
+  /**
+   * This method returns the list of format strings in use.
+   *
+   * @return The list of format objects.
+   */
+  public Object[] getFormats ()
+  {
+    return (Object[]) choiceFormats.clone();
+  }
+
+  /**
+   * This method returns the list of range terminators in use.
+   *
+   * @return The list of range terminators.
+   */
+  public double[] getLimits ()
+  {
+    return (double[]) choiceLimits.clone();
+  }
+
+  /**
+   * This method returns a hash value for this object
+   * 
+   * @return A hash value for this object.
+   */
+  public int hashCode ()
+  {
+    int hash = 0;
+    for (int i = 0; i < choiceLimits.length; ++i)
+      {
+	long v = Double.doubleToLongBits(choiceLimits[i]);
+	hash ^= (v ^ (v >>> 32));
+	hash ^= choiceFormats[i].hashCode();
+      }
+    return hash;
+  }
+
+  /**
+   * This method returns the lowest possible double greater than the 
+   * specified double.  If the specified double value is equal to
+   * <code>Double.NaN</code> then that is the value returned.
+   *
+   * @param d The specified double
+   *
+   * @return The lowest double value greater than the specified double.
+   */
+  public static final double nextDouble (double d)
+  {
+    return nextDouble (d, true);
+  }
+
+  /**
+   * This method returns a double that is either the next highest double
+   * or next lowest double compared to the specified double depending on the
+   * value of the passed boolean parameter.  If the boolean parameter is
+   * <code>true</code>, then the lowest possible double greater than the 
+   * specified double will be returned.  Otherwise the highest possible
+   * double less than the specified double will be returned.
+   *
+   * @param d The specified double
+   * @param next <code>true</code> to return the next highest
+   *                 double, <code>false</code> otherwise. 
+   *
+   * @return The next highest or lowest double value.
+   */
+  public static double nextDouble (double d, boolean next)
+  {
+    if (Double.isInfinite(d) || Double.isNaN(d))
+      return d;
+
+    long bits = Double.doubleToLongBits(d);
+
+    long mantMask = (1L << mantissaBits) - 1;
+    long mantissa = bits & mantMask;
+
+    long expMask = (1L << exponentBits) - 1;
+    long exponent = (bits >>> mantissaBits) & expMask;
+
+    if (next ^ (bits < 0)) // Increment magnitude
+      {
+	if (mantissa == (1L << mantissaBits) - 1)
+	  {
+	    mantissa = 0L;
+	    exponent++;
+	     
+	    // Check for absolute overflow.
+	    if (exponent >= (1L << mantissaBits))
+	      return (bits > 0) ? Double.POSITIVE_INFINITY 
+		: Double.NEGATIVE_INFINITY;		      
+	  }
+	else
+	  mantissa++;
+      }
+    else // Decrement magnitude
+      {
+	if (exponent == 0L && mantissa == 0L)
+	  {
+	    // The only case where there is a change of sign
+	    return next ? Double.MIN_VALUE : -Double.MIN_VALUE;
+	  }
+	else
+	  {
+	    if (mantissa == 0L)
+	      {
+		mantissa = (1L << mantissaBits) - 1;
+		exponent--;
+	      }
+	    else
+	      mantissa--;
+	  }
+      }
+
+    long result = bits < 0 ? 1 : 0;
+    result = (result << exponentBits) | exponent;
+    result = (result << mantissaBits) | mantissa;
+    return Double.longBitsToDouble(result);
+  }
+
+  /**
+   * I'm not sure what this method is really supposed to do, as it is
+   * not documented.
+   */
+  public Number parse (String sourceStr, ParsePosition pos)
+  {
+    int index = pos.getIndex();
+    for (int i = 0; i < choiceLimits.length; ++i)
+      {
+	if (sourceStr.startsWith(choiceFormats[i], index))
+	  {
+	    pos.setIndex(index + choiceFormats[i].length());
+	    return new Double (choiceLimits[i]);
+	  }
+      }
+    pos.setErrorIndex(index);
+    return new Double (Double.NaN);
+  }
+
+  /**
+   * This method returns the highest possible double less than the 
+   * specified double.  If the specified double value is equal to
+   * <code>Double.NaN</code> then that is the value returned.
+   *
+   * @param d The specified double
+   *
+   * @return The highest double value less than the specified double.
+   */
+  public static final double previousDouble (double d)
+  {
+    return nextDouble (d, false);
+  }
+
+  /**
+   * This method sets new range terminators and format strings for this
+   * object.
+   *
+   * @param choiceLimits The new range terminators
+   * @param choiceFormats The new choice formats
+   */
+  public void setChoices (double[] choiceLimits, String[] choiceFormats)
+  {
+    if (choiceLimits == null || choiceFormats == null)
+      throw new NullPointerException ();
+    if (choiceLimits.length != choiceFormats.length)
+      throw new IllegalArgumentException ();
+    this.choiceFormats = (String[]) choiceFormats.clone();
+    this.choiceLimits = (double[]) choiceLimits.clone();
+  }
+
+  private void quoteString (StringBuffer dest, String text)
+  {
+    int max = text.length();
+    for (int i = 0; i < max; ++i)
+      {
+	char c = text.charAt(i);
+	if (c == '\'')
+	  {
+	    dest.append(c);
+	    dest.append(c);
+	  }
+	else if (c == '#' || c == '|' || c == '\u2064' || c == '<')
+	  {
+	    dest.append('\'');
+	    dest.append(c);
+	    dest.append('\'');
+	  }
+	else
+	  dest.append(c);
+      }
+  }
+
+  /**
+   * This method returns the range terminator list and format string list
+   * as a <code>String</code> suitable for using with the 
+   * <code>applyPattern</code> method.
+   *
+   * @return A pattern string for this object
+   */
+  public String toPattern ()
+  {
+    StringBuffer result = new StringBuffer ();
+    for (int i = 0; i < choiceLimits.length; ++i)
+      {
+	result.append(choiceLimits[i]);
+	result.append('#');
+	quoteString (result, choiceFormats[i]);
+      }
+    return result.toString();
+  }
+
+  /**
+   * This is the list of format strings.  Note that this variable is
+   * specified by the serialization spec of this class.
+   */
+  private String[] choiceFormats;
+
+  /**
+   * This is the list of range terminator values.  Note that this variable is
+   * specified by the serialization spec of this class.
+   */
+  private double[] choiceLimits;
+
+  // Number of mantissa bits in double.
+  private static final int mantissaBits = 52;
+  // Number of exponent bits in a double.
+  private static final int exponentBits = 11;
+
+  private static final long serialVersionUID = 1795184449645032964L;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/CollationElementIterator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/CollationElementIterator.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/CollationElementIterator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/CollationElementIterator.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,473 @@
+/* CollationElementIterator.java -- Walks through collation elements
+   Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004  Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+import java.util.ArrayList;
+
+/* Written using "Java Class Libraries", 2nd edition, plus online
+ * API docs for JDK 1.2 from http://www.javasoft.com.
+ * Status: Believed complete and correct to JDK 1.1.
+ */
+
+/**
+ * This class walks through the character collation elements of a 
+ * <code>String</code> as defined by the collation rules in an instance of 
+ * <code>RuleBasedCollator</code>.  There is no public constructor for
+ * this class.  An instance is created by calling the
+ * <code>getCollationElementIterator</code> method on 
+ * <code>RuleBasedCollator</code>.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @author Guilhem Lavaux (guilhem.lavaux at free.fr)
+ */
+public final class CollationElementIterator
+{
+  /**
+   * This is a constant value that is returned to indicate that the end of 
+   * the string was encountered.
+   */
+  public static final int NULLORDER = -1;
+
+  /**
+   * This is the RuleBasedCollator this object was created from.
+   */
+  RuleBasedCollator collator;
+
+  /**
+   * This is the String that is being iterated over.
+   */
+  String text;
+
+  /**
+   * This is the index into the collation decomposition where we are currently scanning.
+   */
+  int index;
+
+  /**
+   * This is the index into the String where we are currently scanning.
+   */
+  int textIndex;
+
+  /**
+   * Array containing the collation decomposition of the
+   * text given to the constructor.
+   */
+  private RuleBasedCollator.CollationElement[] text_decomposition;
+
+  /**
+   * Array containing the index of the specified block.
+   */
+  private int[] text_indexes;
+
+  /**
+   * This method initializes a new instance of <code>CollationElementIterator</code>
+   * to iterate over the specified <code>String</code> using the rules in the
+   * specified <code>RuleBasedCollator</code>.
+   *
+   * @param collator The <code>RuleBasedCollation</code> used for calculating collation values
+   * @param text The <code>String</code> to iterate over.
+   */
+  CollationElementIterator(RuleBasedCollator collator, String text)
+  {
+    this.collator = collator;
+    
+    setText (text);    
+  }
+
+  RuleBasedCollator.CollationElement nextBlock()
+  {
+    if (index >= text_decomposition.length)
+      return null;
+    
+    RuleBasedCollator.CollationElement e = text_decomposition[index];
+    
+    textIndex = text_indexes[index+1];
+
+    index++;
+
+    return e;
+  }
+
+  RuleBasedCollator.CollationElement previousBlock()
+  {
+    if (index == 0)
+      return null;
+    
+    index--;
+    RuleBasedCollator.CollationElement e = text_decomposition[index];
+
+    textIndex = text_indexes[index+1];
+    
+    return e;
+  }
+
+  /**
+   * This method returns the collation ordering value of the next character sequence
+   * in the string (it may be an extended character following collation rules).
+   * This method will return <code>NULLORDER</code> if the
+   * end of the string was reached.
+   *
+   * @return The collation ordering value.
+   */
+  public int next()
+  {
+    RuleBasedCollator.CollationElement e = nextBlock();
+
+    if (e == null)
+      return NULLORDER;
+    
+    return e.getValue();
+  }
+
+  /**
+   * This method returns the collation ordering value of the previous character
+   * in the string.  This method will return <code>NULLORDER</code> if the
+   * beginning of the string was reached.
+   *
+   * @return The collation ordering value.
+   */
+  public int previous()
+  {
+    RuleBasedCollator.CollationElement e = previousBlock();
+
+    if (e == null)
+      return NULLORDER;
+    
+    return e.getValue();
+  }
+
+  /**
+   * This method returns the primary order value for the given collation
+   * value.
+   *
+   * @param order The collation value returned from <code>next()</code> or 
+   *              <code>previous()</code>.
+   *
+   * @return The primary order value of the specified collation value.  This is
+   *         the high 16 bits.
+   */
+  public static int primaryOrder(int order)
+  {
+    // From the JDK 1.2 spec.
+    return order >>> 16;
+  }
+
+  /**
+   * This method resets the internal position pointer to read from the
+   * beginning of the <code>String</code> again.
+   */
+  public void reset()
+  {
+    index = 0;
+    textIndex = 0;
+  }
+
+  /**
+   * This method returns the secondary order value for the given collation
+   * value.
+   *
+   * @param order The collation value returned from <code>next()</code> or 
+   *              <code>previous()</code>.
+   *
+   * @return The secondary order value of the specified collation value.  This 
+   *         is the bits 8-15.
+   */
+  public static short secondaryOrder(int order)
+  {
+    // From the JDK 1.2 spec.
+    return (short) ((order >>> 8) & 255);
+  }
+
+  /**
+   * This method returns the tertiary order value for the given collation
+   * value.
+   *
+   * @param order The collation value returned from <code>next()</code> or 
+   *              <code>previous()</code>.
+   *
+   * @return The tertiary order value of the specified collation value.  This 
+   *         is the low eight bits.
+   */
+  public static short tertiaryOrder(int order)
+  {
+    // From the JDK 1.2 spec.
+    return (short) (order & 255);
+  }
+
+  /**
+   * This method sets the <code>String</code> that it is iterating over
+   * to the specified <code>String</code>.
+   *
+   * @param text The new <code>String</code> to iterate over.
+   *
+   * @since 1.2
+   */
+  public void setText(String text)
+  {
+    int idx = 0;
+    int idx_idx = 0;
+    int alreadyExpanded = 0;
+    int idxToMove = 0;
+
+    this.text = text;
+    this.index = 0;
+
+    String work_text = text.intern();
+
+    ArrayList a_element = new ArrayList();
+    ArrayList a_idx = new ArrayList();
+
+    // Build element collection ordered as they come in "text".
+    while (idx < work_text.length())
+      {
+	String key, key_old;
+
+	Object object = null;
+	int p = 1;
+	
+	// IMPROVE: use a TreeMap with a prefix-ordering rule.
+	key_old = key = null;
+	do
+	  {
+	    if (object != null)
+	      key_old = key;
+	    key = work_text.substring (idx, idx+p);
+	    object = collator.prefix_tree.get (key);
+	    if (object != null && idx < alreadyExpanded)
+	      {
+		RuleBasedCollator.CollationElement prefix = (RuleBasedCollator.CollationElement)object;
+		if (prefix.expansion != null && 
+		    prefix.expansion.startsWith(work_text.substring(0, idx)))
+		{
+		  object = null;
+		  key = key_old;
+		}
+	      }
+	    p++;
+	  }
+	while (idx+p <= work_text.length());
+	
+	if (object == null)
+	  key = key_old;
+	
+	RuleBasedCollator.CollationElement prefix =
+	  (RuleBasedCollator.CollationElement) collator.prefix_tree.get (key);
+
+	/*
+	 * First case: There is no such sequence in the database.
+	 * We will have to build one from the context.
+	 */
+	if (prefix == null)
+	  {
+	    /*
+	     * We are dealing with sequences in an expansion. They
+	     * are treated as accented characters (tertiary order).
+	     */
+	    if (alreadyExpanded > 0)
+	      {
+		RuleBasedCollator.CollationElement e =
+		  collator.getDefaultAccentedElement (work_text.charAt (idx));
+		
+		a_element.add (e);
+		a_idx.add (new Integer(idx_idx));
+		idx++;
+		alreadyExpanded--;
+		if (alreadyExpanded == 0)
+		  {
+		    /* There is not any characters left in the expansion set.
+		     * We can increase the pointer in the source string.
+		     */
+		    idx_idx += idxToMove;
+		    idxToMove = 0; 
+		  }
+		else
+		  idx_idx++;
+	      }
+	    else
+	      {
+		/* This is a normal character. */
+		RuleBasedCollator.CollationElement e =
+		  collator.getDefaultElement (work_text.charAt (idx));
+		Integer i_ref = new Integer(idx_idx);
+
+		/* Don't forget to mark it as a special sequence so the
+		 * string can be ordered.
+		 */
+		a_element.add (RuleBasedCollator.SPECIAL_UNKNOWN_SEQ);
+		a_idx.add (i_ref);
+		a_element.add (e);
+		a_idx.add (i_ref);
+		idx_idx++;
+		idx++;
+	      }
+	    continue;
+	  }
+ 
+	/*
+	 * Second case: Here we have found a matching sequence.
+	 * Here we have an expansion string prepend it to the "work text" and
+	 * add the corresponding sorting element. We must also mark 
+	 */
+	if (prefix.expansion != null)
+	  {
+	    work_text = prefix.expansion
+	      + work_text.substring (idx+prefix.key.length());
+	    idx = 0;
+	    a_element.add (prefix);
+	    a_idx.add (new Integer(idx_idx));
+	    if (alreadyExpanded == 0)
+	      idxToMove = prefix.key.length();
+	    alreadyExpanded += prefix.expansion.length()-prefix.key.length();
+	  }
+	else
+	  {
+	    /* Third case: the simplest. We have got the prefix and it
+	     * has not to be expanded.
+	     */
+	    a_element.add (prefix);
+	    a_idx.add (new Integer(idx_idx));
+	    idx += prefix.key.length();
+	    /* If the sequence is in an expansion, we must decrease the
+	     * counter.
+	     */
+	    if (alreadyExpanded > 0)
+	      {
+		alreadyExpanded -= prefix.key.length();
+		if (alreadyExpanded == 0)
+		  {
+		    idx_idx += idxToMove;
+		    idxToMove = 0;
+		  }
+	      }
+	    else
+	      idx_idx += prefix.key.length();
+	  }
+      }
+    
+    text_decomposition = (RuleBasedCollator.CollationElement[])
+	   a_element.toArray(new RuleBasedCollator.CollationElement[a_element.size()]);
+    text_indexes = new int[a_idx.size()+1];
+    for (int i = 0; i < a_idx.size(); i++) 
+      {
+	text_indexes[i] = ((Integer)a_idx.get(i)).intValue();
+      }
+    text_indexes[a_idx.size()] = text.length();
+  }
+
+  /**
+   * This method sets the <code>String</code> that it is iterating over
+   * to the <code>String</code> represented by the specified
+   * <code>CharacterIterator</code>.
+   *
+   * @param source The <code>CharacterIterator</code> containing the new
+   * <code>String</code> to iterate over.
+   */
+  public void setText(CharacterIterator source)
+  {
+    StringBuffer expand = new StringBuffer();
+
+    // For now assume we read from the beginning of the string.
+    for (char c = source.first();
+	 c != CharacterIterator.DONE;
+	 c = source.next())
+      expand.append(c);
+
+    setText(expand.toString());
+  }
+
+  /**
+   * This method returns the current offset into the <code>String</code>
+   * that is being iterated over.
+   *
+   * @return The iteration index position.
+   *
+   * @since 1.2
+   */
+  public int getOffset()
+  {
+    return textIndex;
+  }
+
+  /**
+   * This method sets the iteration index position into the current
+   * <code>String</code> to the specified value.  This value must not
+   * be negative and must not be greater than the last index position
+   * in the <code>String</code>.
+   *
+   * @param offset The new iteration index position.
+   *
+   * @exception IllegalArgumentException If the new offset is not valid.
+   */
+  public void setOffset(int offset)
+  {
+    if (offset < 0)
+      throw new IllegalArgumentException("Negative offset: " + offset);
+
+    if (offset > (text.length() - 1))
+      throw new IllegalArgumentException("Offset too large: " + offset);
+    
+    for (index = 0; index < text_decomposition.length; index++)
+      {	
+	if (offset <= text_indexes[index])
+	  break;
+      }
+    /*
+     * As text_indexes[0] == 0, we should not have to take care whether index is
+     * greater than 0. It is always.
+     */
+    if (text_indexes[index] == offset)
+      textIndex = offset;
+    else
+      textIndex = text_indexes[index-1];
+  }
+
+  /**
+   * This method returns the maximum length of any expansion sequence that
+   * ends with the specified collation order value.  (Whatever that means).
+   *
+   * @param value The collation order value
+   *
+   * @return The maximum length of an expansion sequence.
+   */
+  public int getMaxExpansion(int value)
+  {
+    return 1;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/CollationKey.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/CollationKey.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/CollationKey.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/CollationKey.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,201 @@
+/* CollationKey.java -- Precomputed collation value
+   Copyright (C) 1998, 1999, 2000, 2003, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+import java.util.Arrays;
+
+/* Written using "Java Class Libraries", 2nd edition, plus online
+ * API docs for JDK 1.2 from http://www.javasoft.com.
+ * Status: Believed complete and correct.
+ */
+
+/**
+ * This class represents a pre-computed series of bits representing a
+ * <code>String</code> for under a particular <code>Collator</code>.  This
+ * value may be compared bitwise against another <code>CollationKey</code>
+ * representing a different <code>String</code> under the same
+ * <code>Collator</code> in a manner than is usually more efficient than
+ * using the raw <code>Collator</code> compare methods.  There is overhead
+ * associated with calculating this value, so it is generally not
+ * advisable to compute <code>CollationKey</code>'s unless multiple 
+ * comparisons against a <code>String</code> will be done.  (For example,
+ * in a sort routine).
+ * <p>
+ * This class cannot be instantiated directly.  Instead, a 
+ * <code>CollationKey</code> is created by calling the
+ * <code>getCollationKey</code> method on an instance of <code>Collator</code>.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @date March 25, 1999
+ */
+public final class CollationKey implements Comparable
+{
+  /**
+   * This is the <code>Collator</code> this object was created from.
+   */
+  private Collator collator;
+
+  /**
+   * This is the <code>String</code> this object represents.
+   */
+  private String originalText;
+
+  /**
+   * This is the bit value for this key.
+   */
+  private byte[] key;
+
+  CollationKey (Collator collator, String originalText, byte[] key)
+  {
+    this.collator = collator;
+    this.originalText = originalText;
+    this.key = key;
+  }
+
+  /**
+   * This method compares the specified object to this one.  An integer is 
+   * returned which indicates whether the specified object is less than, 
+   * greater than, or equal to this object.
+   *
+   * @param ck The <code>CollationKey</code> to compare against this one.
+   *
+   * @return A negative integer if this object is less than the specified object, 0 if it is equal or a positive integer if it is greater than the specified object.
+   */
+  public int compareTo (CollationKey ck)
+  {
+    int max = Math.min (key.length, ck.key.length);
+
+    for (int i = 0; i < max; ++i)
+      {
+	if (key[i] != ck.key[i])
+	  return key[i] - ck.key[i];
+      }
+
+    return key.length - ck.key.length;
+  }
+
+  /**
+   * This method compares the specified object to this one.  The specified
+   * object must be an instance of <code>CollationKey</code> or an exception
+   * will be thrown.  An integer is returned which indicates whether the
+   * specified object is less than, greater than, or equal to this object.
+   *
+   * @param obj The <code>Object</code> to compare against this one.
+   *
+   * @return A negative integer if this object is less than the specified object, 0 if it is equal or a positive integer if it is greater than the specified object.
+   */
+  public int compareTo (Object obj)
+  {
+    return compareTo ((CollationKey) obj);
+  }
+
+  /**
+   * This method tests the specified <code>Object</code> for equality with
+   * this object.  This will be true if and only if:
+   * <p>
+   * <ul>
+   * <li>The specified object must not be <code>null</code></li>
+   * <li>The specified object is an instance of <code>CollationKey</code>.</li>
+   * <li>The specified object was created from the same <code>Collator</code>
+   * as this object.</li>
+   * <li>The specified object has the same source string and bit key as
+   * this object.</li>
+   * </ul>
+   *
+   * @param obj The <code>Object</code> to test for equality.
+   *
+   * @return <code>true</code> if the specified object is equal to this one, <code>false</code> otherwise.
+   */
+  public boolean equals (Object obj)
+  {
+    if (! (obj instanceof CollationKey))
+      return false;
+
+    CollationKey ck = (CollationKey) obj;
+
+    if (ck.collator != collator)
+      return false;
+
+    if (!ck.getSourceString ().equals (getSourceString ()))
+      return false;
+
+    if (! Arrays.equals (ck.toByteArray (), toByteArray ()))
+      return false;
+
+    return true;
+  }
+
+  /**
+   * This method returns the <code>String</code> that this object was created
+   * from.
+   *
+   * @return The source <code>String</code> for this object.
+   */
+  public String getSourceString()
+  {
+    return originalText;
+  }
+
+  /**
+   * This method returns a hash value for this object.  The hash value
+   * returned will be the hash code of the bit key so that identical bit
+   * keys will return the same value.
+   *
+   * @return A hash value for this object.
+   */
+  public int hashCode()
+  {
+    // We just follow BitSet instead of thinking up something new.
+    long h = originalText.hashCode();
+    for (int i = key.length - 1; i >= 0; --i)
+      h ^= key[i] * (i + 1);
+    return (int) ((h >> 32) ^ h);
+  }
+  
+  /**
+   * This method returns the collation bit sequence as a byte array.
+   *
+   * @return A byte array containing the collation bit sequence.
+   */
+  public byte[] toByteArray()
+  {
+    return key;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/Collator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/Collator.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/Collator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/Collator.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,395 @@
+/* Collator.java -- Perform locale dependent String comparisons.
+   Copyright (C) 1998, 1999, 2000, 2001, 2004, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+import gnu.java.locale.LocaleHelper;
+
+import java.util.Comparator;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * This class is the abstract superclass of classes which perform 
+ * locale dependent <code>String</code> comparisons.  A caller requests
+ * an instance of <code>Collator</code> for a particular locale using
+ * the <code>getInstance()</code> static method in this class.  That method
+ * will return a locale specific subclass of <code>Collator</code> which
+ * can be used to perform <code>String</code> comparisons for that locale.
+ * If a subclass of <code>Collator</code> cannot be located for a particular
+ * locale, a default instance for the current locale will be returned.  
+ *
+ * In addition to setting the correct locale, there are two additional
+ * settings that can be adjusted to affect <code>String</code> comparisons:
+ * strength and decomposition.  The strength value determines the level
+ * of signficance of character differences required for them to sort
+ * differently.  (For example, whether or not capital letters are considered
+ * different from lower case letters).  The decomposition value affects how
+ * variants of the same character are treated for sorting purposes.  (For
+ * example, whether or not an accent is signficant or not).  These settings
+ * are described in detail in the documentation for the methods and values
+ * that are related to them.
+ *
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @date March 18, 1999
+ */
+public abstract class Collator implements Comparator, Cloneable
+{
+  /**
+   * This constant is a strength value which indicates that only primary
+   * differences between characters will be considered signficant.  As an
+   * example, two completely different English letters such as 'a' and 'b'
+   * are considered to have a primary difference.
+   */
+  public static final int PRIMARY = 0;
+  
+  /**
+   * This constant is a strength value which indicates that only secondary
+   * or primary differences between characters will be considered
+   * significant.  An example of a secondary difference between characters
+   * are instances of the same letter with different accented forms.
+   */
+  public static final int SECONDARY = 1;
+  
+  /**
+   * This constant is a strength value which indicates that tertiary,
+   * secondary, and primary differences will be considered during sorting.
+   * An example of a tertiary difference is capitalization of a given letter.
+   * This is the default value for the strength setting.
+   */
+  public static final int TERTIARY = 2;
+  
+  /**
+   * This constant is a strength value which indicates that any difference
+   * at all between character values are considered significant.
+   */
+  public static final int IDENTICAL = 3;
+  
+  /**
+   * This constant indicates that accented characters won't be decomposed
+   * when performing comparisons.  This will yield the fastest results, but
+   * will only work correctly in call cases for languages which do not
+   * use accents such as English.
+   */
+  public static final int NO_DECOMPOSITION = 0;
+  
+  /**
+   * This constant indicates that only characters which are canonical variants
+   * in Unicode 2.0 will be decomposed prior to performing comparisons.  This
+   * will cause accented languages to be sorted correctly.  This is the
+   * default decomposition value.
+   */
+  public static final int CANONICAL_DECOMPOSITION = 1;
+  
+  /**
+   * This constant indicates that both canonical variants and compatibility
+   * variants in Unicode 2.0 will be decomposed prior to performing
+   * comparisons.  This is the slowest mode, but is required to get the
+   * correct sorting for certain languages with certain special formats.
+   */
+  public static final int FULL_DECOMPOSITION = 2;
+
+  /**
+   * This method initializes a new instance of <code>Collator</code> to have
+   * the default strength (TERTIARY) and decomposition 
+   * (CANONICAL_DECOMPOSITION) settings.  This constructor is protected and
+   * is for use by subclasses only.  Non-subclass callers should use the
+   * static <code>getInstance()</code> methods of this class to instantiate
+   * <code>Collation</code> objects for the desired locale.
+   */
+  protected Collator ()
+  {
+    strength = TERTIARY;
+    decmp = CANONICAL_DECOMPOSITION;
+  }
+
+  /**
+   * This method compares the two <code>String</code>'s and returns an
+   * integer indicating whether or not the first argument is less than,
+   * equal to, or greater than the second argument.  The comparison is
+   * performed according to the rules of the locale for this 
+   * <code>Collator</code> and the strength and decomposition rules in
+   * effect.
+   *
+   * @param source The first object to compare
+   * @param target The second object to compare
+   *
+   * @return A negative integer if str1 < str2, 0 if str1 == str2, or
+   * a positive integer if str1 > str2. 
+   */
+  public abstract int compare (String source, String target);
+
+  /**
+   * This method compares the two <code>Object</code>'s and returns an
+   * integer indicating whether or not the first argument is less than,
+   * equal to, or greater than the second argument.  These two objects
+   * must be <code>String</code>'s or an exception will be thrown.
+   *
+   * @param o1 The first object to compare
+   * @param o2 The second object to compare
+   *
+   * @return A negative integer if obj1 < obj2, 0 if obj1 == obj2, or
+   * a positive integer if obj1 > obj2. 
+   *
+   * @exception ClassCastException If the arguments are not instances
+   * of <code>String</code>. 
+   */
+  public int compare (Object o1, Object o2)
+  {
+    return compare ((String) o1, (String) o2);
+  }
+
+  /**
+   * This method tests the specified object for equality against this
+   * object.  This will be true if and only if the following conditions are
+   * met:
+   * <ul>
+   * <li>The specified object is not <code>null</code>.</li>
+   * <li>The specified object is an instance of <code>Collator</code>.</li>
+   * <li>The specified object has the same strength and decomposition
+   * settings as this object.</li>
+   * </ul>
+   *
+   * @param obj The <code>Object</code> to test for equality against
+   *            this object. 
+   *
+   * @return <code>true</code> if the specified object is equal to
+   * this one, <code>false</code> otherwise.
+   */
+  public boolean equals (Object obj)
+  {
+    if (! (obj instanceof Collator))
+      return false;
+    Collator c = (Collator) obj;
+    return decmp == c.decmp && strength == c.strength;
+  }
+
+  /**
+   * This method tests whether the specified <code>String</code>'s are equal
+   * according to the collation rules for the locale of this object and
+   * the current strength and decomposition settings.
+   *
+   * @param source The first <code>String</code> to compare
+   * @param target The second <code>String</code> to compare
+   *
+   * @return <code>true</code> if the two strings are equal,
+   * <code>false</code> otherwise. 
+   */
+  public boolean equals (String source, String target)
+  {
+    return compare (source, target) == 0;
+  }
+
+  /**
+   * This method returns a copy of this <code>Collator</code> object.
+   *
+   * @return A duplicate of this object.
+   */
+  public Object clone ()
+  {
+    try
+      {
+	return super.clone ();
+      }
+    catch (CloneNotSupportedException _)
+      {
+	return null;
+      }
+  }
+
+  /**
+   * This method returns an array of <code>Locale</code> objects which is
+   * the list of locales for which <code>Collator</code> objects exist.
+   *
+   * @return The list of locales for which <code>Collator</code>'s exist.
+   */
+  public static synchronized Locale[] getAvailableLocales ()
+  {
+    return LocaleHelper.getCollatorLocales();
+  }
+
+  /**
+   * This method transforms the specified <code>String</code> into a
+   * <code>CollationKey</code> for faster comparisons.  This is useful when
+   * comparisons against a string might be performed multiple times, such
+   * as during a sort operation.
+   *
+   * @param source The <code>String</code> to convert.
+   *
+   * @return A <code>CollationKey</code> for the specified <code>String</code>.
+   */
+  public abstract CollationKey getCollationKey (String source);
+
+  /**
+   * This method returns the current decomposition setting for this
+   * object.  This * will be one of NO_DECOMPOSITION,
+   * CANONICAL_DECOMPOSITION, or * FULL_DECOMPOSITION.  See the
+   * documentation for those constants for an * explanation of this
+   * setting.
+   *
+   * @return The current decomposition setting.
+   */
+  public synchronized int getDecomposition ()
+  {
+    return decmp;
+  }
+
+  /**
+   * This method returns an instance of <code>Collator</code> for the
+   * default locale.
+   *
+   * @return A <code>Collator</code> for the default locale.
+   */
+  public static Collator getInstance ()
+  {
+    return getInstance (Locale.getDefault());
+  }
+
+  /**
+   * This method returns an instance of <code>Collator</code> for the
+   * specified locale.  If no <code>Collator</code> exists for the desired
+   * locale, a <code>Collator</code> for the default locale will be returned.
+   *
+   * @param loc The desired locale to load a <code>Collator</code> for.
+   *
+   * @return A <code>Collator</code> for the requested locale
+   */
+  public static Collator getInstance (Locale loc)
+  {
+    ResourceBundle res;
+    String pattern;
+    try
+      {
+	res = ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
+				       loc, ClassLoader.getSystemClassLoader());
+	pattern = res.getString("collation_rules");
+      }
+    catch (MissingResourceException x)
+      {
+	pattern = "<0<1<2<3<4<5<6<7<8<9<A,a<b,B<c,C<d,D<e,E<f,F<g,G<h,H<i,I<j,J<k,K" +
+		"<l,L<m,M<n,N<o,O<p,P<q,Q<r,R<s,S<t,T<u,U<v,V<w,W<x,X<y,Y<z,Z";
+      }
+    try
+      {
+	return new RuleBasedCollator (pattern);
+      }
+    catch (ParseException x)
+      {
+	throw (InternalError)new InternalError().initCause(x);
+      }
+  }
+
+  /**
+   * This method returns the current strength setting for this object.  This
+   * will be one of PRIMARY, SECONDARY, TERTIARY, or IDENTICAL.  See the
+   * documentation for those constants for an explanation of this setting.
+   *
+   * @return The current strength setting.
+   */
+  public synchronized int getStrength ()
+  {
+    return strength;
+  }
+
+  /**
+   * This method returns a hash code value for this object.
+   *
+   * @return A hash value for this object.
+   */
+  public abstract int hashCode ();
+
+  /**
+   * This method sets the decomposition setting for this object to the
+   * specified value.  This must be one of NO_DECOMPOSITION,
+   * CANONICAL_DECOMPOSITION, or FULL_DECOMPOSITION.  Otherwise an
+   * exception will be thrown.  See the documentation for those
+   * contants for an explanation of this setting.
+   *
+   * @param mode The new decomposition setting.
+   *
+   * @exception IllegalArgumentException If the requested
+   * decomposition setting is not valid.
+   */
+  public synchronized void setDecomposition (int mode)
+  {
+    if (mode != NO_DECOMPOSITION
+	&& mode != CANONICAL_DECOMPOSITION
+	&& mode != FULL_DECOMPOSITION)
+      throw new IllegalArgumentException ();
+    decmp = mode;
+  }
+
+  /**
+   * This method sets the strength setting for this object to the specified
+   * value.  This must be one of PRIMARY, SECONDARY, TERTIARY, or IDENTICAL.
+   * Otherwise an exception is thrown. See the documentation for these
+   * constants for an explanation of this setting.
+   * 
+   * @param strength The new strength setting.
+   *
+   * @exception IllegalArgumentException If the requested strength
+   * setting value is not valid.
+   */
+  public synchronized void setStrength (int strength)
+  {
+    if (strength != PRIMARY && strength != SECONDARY
+	&& strength != TERTIARY && strength != IDENTICAL)
+      throw new IllegalArgumentException ();
+    this.strength = strength;
+  }
+
+  // Decompose a single character and append results to the buffer.
+  // FIXME: for libgcj this is a native method which handles
+  // decomposition.  For Classpath, for now, it does nothing.
+  final void decomposeCharacter (char c, StringBuffer buf)
+  {
+    buf.append (c);
+  }
+
+  /**
+   * This is the current collation decomposition setting.
+   */
+  int decmp;
+
+  /**
+   * This is the current collation strength setting.
+   */
+  int strength;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/DateFormat.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/DateFormat.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/DateFormat.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/DateFormat.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,921 @@
+/* DateFormat.java -- Class for formatting/parsing date/times
+   Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005
+   Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+import java.io.InvalidObjectException;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.TimeZone;
+
+/**
+ * @author Per Bothner (bothner at cygnus.com)
+ * @date October 25, 1998.
+ */
+/* Written using "Java Class Libraries", 2nd edition, plus online
+ * API docs for JDK 1.2 beta from http://www.javasoft.com.
+ * Status:  Mostly complete; search for FIXME to see omissions.
+ */
+
+public abstract class DateFormat extends Format implements Cloneable
+{
+  private static final long serialVersionUID = 7218322306649953788L;
+
+  // Names fixed by serialization spec.
+  protected Calendar calendar;
+  protected NumberFormat numberFormat;
+
+  // (Values determined using a test program.)
+  public static final int FULL = 0;
+  public static final int LONG = 1;
+  public static final int MEDIUM = 2;
+  public static final int SHORT = 3;
+  public static final int DEFAULT = MEDIUM;
+
+  /* These constants need to have these exact values.  They
+   * correspond to index positions within the localPatternChars
+   * string for a given locale.  Each locale may specify its
+   * own character for a particular field, but the position
+   * of these characters must correspond to an appropriate field
+   * number (as listed below), in order for their meaning to
+   * be determined.  For example, the US locale uses
+   * the string "GyMdkHmsSEDFwWahKzYeugAZ", where 'G' is the character
+   * for era, 'y' for year, and so on down to 'Z' for time zone.
+   */
+  /**
+   * Represents the position of the era
+   * pattern character in the array of
+   * localized pattern characters. 
+   * For example, 'AD' is an era used
+   * in the Gregorian calendar system.
+   * In the U.S. locale, this is 'G'.
+   */  
+  public static final int ERA_FIELD = 0;
+  /**
+   * Represents the position of the year
+   * pattern character in the array of
+   * localized pattern characters.
+   * In the U.S. locale, this is 'y'.
+   */
+  public static final int YEAR_FIELD = 1;
+  /**
+   * Represents the position of the month
+   * pattern character in the array of
+   * localized pattern characters.
+   * In the U.S. locale, this is 'M'.
+   */
+  public static final int MONTH_FIELD = 2;
+  /**
+   * Represents the position of the date
+   * or day of the month pattern character
+   * in the array of localized pattern
+   * characters.  In the U.S. locale,
+   * this is 'd'.
+   */
+  public static final int DATE_FIELD = 3;
+  /**
+   * Represents the position of the 24
+   * hour pattern character in the array of
+   * localized pattern characters.
+   * In the U.S. locale, this is 'k'.
+   * This field numbers hours from 1 to 24.
+   */
+  public static final int HOUR_OF_DAY1_FIELD = 4;
+  /**
+   * Represents the position of the 24
+   * hour pattern character in the array of
+   * localized pattern characters.
+   * In the U.S. locale, this is 'H'.
+   * This field numbers hours from 0 to 23.
+   */
+  public static final int HOUR_OF_DAY0_FIELD = 5;
+  /**
+   * Represents the position of the minute
+   * pattern character in the array of
+   * localized pattern characters.
+   * In the U.S. locale, this is 'm'.
+   */
+  public static final int MINUTE_FIELD = 6;
+  /**
+   * Represents the position of the second
+   * pattern character in the array of
+   * localized pattern characters.
+   * In the U.S. locale, this is 's'.
+   */
+  public static final int SECOND_FIELD = 7;
+  /**
+   * Represents the position of the millisecond
+   * pattern character in the array of
+   * localized pattern characters.
+   * In the U.S. locale, this is 'S'.
+   */
+  public static final int MILLISECOND_FIELD = 8;
+  /**
+   * Represents the position of the day of the
+   * week pattern character in the array of
+   * localized pattern characters.
+   * In the U.S. locale, this is 'E'.
+   */
+  public static final int DAY_OF_WEEK_FIELD = 9;
+  /**
+   * Represents the position of the day of the
+   * year pattern character in the array of
+   * localized pattern characters.
+   * In the U.S. locale, this is 'D'.
+   */
+  public static final int DAY_OF_YEAR_FIELD = 10;
+  /**
+   * Represents the position of the day of the
+   * week in the month pattern character in the
+   * array of localized pattern characters.
+   * In the U.S. locale, this is 'F'.
+   */
+  public static final int DAY_OF_WEEK_IN_MONTH_FIELD = 11;
+  /**
+   * Represents the position of the week of the
+   * year pattern character in the array of
+   * localized pattern characters.
+   * In the U.S. locale, this is 'w'.
+   */
+  public static final int WEEK_OF_YEAR_FIELD = 12;
+  /**
+   * Represents the position of the week of the
+   * month pattern character in the array of
+   * localized pattern characters.
+   * In the U.S. locale, this is 'W'.
+   */
+  public static final int WEEK_OF_MONTH_FIELD = 13;
+  /**
+   * Represents the position of the am/pm
+   * pattern character in the array of
+   * localized pattern characters.
+   * In the U.S. locale, this is 'a'.
+   */
+  public static final int AM_PM_FIELD = 14;
+  /**
+   * Represents the position of the 12 
+   * hour pattern character in the array of
+   * localized pattern characters.
+   * In the U.S. locale, this is 'h'.
+   * This field numbers hours from 1 to 12.
+   */
+  public static final int HOUR1_FIELD = 15;
+  /**
+   * Represents the position of the 12 
+   * hour pattern character in the array of
+   * localized pattern characters.
+   * In the U.S. locale, this is 'K'.
+   * This field numbers hours from 0 to 11.
+   */
+  public static final int HOUR0_FIELD = 16;
+  /**
+   * Represents the position of the generic
+   * timezone pattern character in the array of
+   * localized pattern characters.
+   * In the U.S. locale, this is 'z'.
+   */
+  public static final int TIMEZONE_FIELD = 17;
+  /**
+   * Represents the position of the ISO year
+   * pattern character in the array of
+   * localized pattern characters.
+   * In the U.S. locale, this is 'Y'.
+   * This is a GNU extension in accordance with
+   * the CLDR data used.  This value may
+   * differ from the normal year value.
+   */
+  public static final int ISO_YEAR_FIELD = 18;
+  /**
+   * Represents the position of the localized
+   * day of the week pattern character in the
+   * array of localized pattern characters.
+   * In the U.S. locale, this is 'e'.
+   * This is a GNU extension in accordance with
+   * the CLDR data used.  This value only
+   * differs from the day of the week with
+   * numeric formatting, in which case the
+   * locale's first day of the week is used.
+   */
+  public static final int LOCALIZED_DAY_OF_WEEK_FIELD = 19;
+  /**
+   * Represents the position of the extended year
+   * pattern character in the array of
+   * localized pattern characters.
+   * In the U.S. locale, this is 'u'.
+   * This is a GNU extension in accordance with
+   * the CLDR data used.  This value modifies
+   * the year value, so as to incorporate the era.
+   * For example, in the Gregorian calendar system,
+   * the extended year is negative instead of being
+   * marked as BC.
+   */
+  public static final int EXTENDED_YEAR_FIELD = 20;
+  /**
+   * Represents the position of the modified Julian
+   * day pattern character in the array of
+   * localized pattern characters.
+   * In the U.S. locale, this is 'g'.
+   * This is a GNU extension in accordance with
+   * the CLDR data used.  This value differs
+   * from the standard Julian day in that days
+   * are marked from midnight onwards rather than
+   * noon, and the local time zone affects the value.
+   * In simple terms, it can be thought of as all
+   * the date fields represented as a single number.
+   */
+  public static final int MODIFIED_JULIAN_DAY_FIELD = 21;
+  /**
+   * Represents the position of the millisecond
+   * in the day pattern character in the array of
+   * localized pattern characters.
+   * In the U.S. locale, this is 'A'.
+   * This is a GNU extension in accordance with
+   * the CLDR data used.  This value represents
+   * all the time fields (excluding the time zone)
+   * numerically, giving the number of milliseconds
+   * into the day (e.g. 10 in the morning would
+   * be 10 * 60 * 60 * 1000).  Any daylight savings
+   * offset also affects this value.
+   */
+  public static final int MILLISECOND_IN_DAY_FIELD = 22;
+  /**
+   * Represents the position of the RFC822
+   * timezone pattern character in the array of
+   * localized pattern characters.
+   * In the U.S. locale, this is 'Z'.
+   * This is a GNU extension in accordance with
+   * the CLDR data used.  The value is the offset
+   * of the current time from GMT e.g. -0500 would
+   * be five hours prior to GMT.
+   */
+  public static final int RFC822_TIMEZONE_FIELD = 23;
+
+  public static class Field extends Format.Field
+  {
+    static final long serialVersionUID = 7441350119349544720L;
+    
+    private int calendarField;
+
+    public static final DateFormat.Field ERA
+	= new Field("era", Calendar.ERA);
+    public static final DateFormat.Field YEAR
+	= new Field("year", Calendar.YEAR);
+    public static final DateFormat.Field MONTH
+	= new Field("month", Calendar.MONTH);
+    public static final DateFormat.Field DAY_OF_MONTH
+	= new Field("day of month", Calendar.DAY_OF_MONTH);
+    public static final DateFormat.Field HOUR_OF_DAY1
+	= new Field("hour of day 1", Calendar.HOUR_OF_DAY);
+    public static final DateFormat.Field HOUR_OF_DAY0
+	= new Field("hour of day 0", Calendar.HOUR_OF_DAY);
+    public static final DateFormat.Field MINUTE
+	= new Field("minute", Calendar.MINUTE);
+    public static final DateFormat.Field SECOND
+	= new Field("second", Calendar.SECOND);
+    public static final DateFormat.Field MILLISECOND
+	= new Field("millisecond", Calendar.MILLISECOND);
+    public static final DateFormat.Field DAY_OF_WEEK
+	= new Field("day of week", Calendar.DAY_OF_WEEK);
+    public static final DateFormat.Field DAY_OF_YEAR
+	= new Field("day of year", Calendar.DAY_OF_YEAR);
+    public static final DateFormat.Field DAY_OF_WEEK_IN_MONTH
+	= new Field("day of week in month", Calendar.DAY_OF_WEEK_IN_MONTH);
+    public static final DateFormat.Field WEEK_OF_YEAR
+	= new Field("week of year", Calendar.WEEK_OF_YEAR);
+    public static final DateFormat.Field WEEK_OF_MONTH
+	= new Field("week of month", Calendar.WEEK_OF_MONTH);
+    public static final DateFormat.Field AM_PM
+	= new Field("am/pm", Calendar.AM_PM);
+    public static final DateFormat.Field HOUR1
+	= new Field("hour1", Calendar.HOUR);
+    public static final DateFormat.Field HOUR0
+	= new Field("hour0", Calendar.HOUR);
+    public static final DateFormat.Field TIME_ZONE
+	= new Field("timezone", Calendar.ZONE_OFFSET);
+    public static final DateFormat.Field ISO_YEAR
+	= new Field("iso year", Calendar.YEAR);
+    public static final DateFormat.Field LOCALIZED_DAY_OF_WEEK
+	= new Field("localized day of week", Calendar.DAY_OF_WEEK);
+    public static final DateFormat.Field EXTENDED_YEAR
+      = new Field("extended year", Calendar.YEAR);
+    public static final DateFormat.Field MODIFIED_JULIAN_DAY
+	= new Field("julian day", -1);
+    public static final DateFormat.Field MILLISECOND_IN_DAY
+	= new Field("millisecond in day", -1);
+    public static final DateFormat.Field RFC822_TIME_ZONE
+	= new Field("rfc822 timezone", Calendar.ZONE_OFFSET);
+
+    static final DateFormat.Field[] allFields =
+    {
+      ERA, YEAR, MONTH, DAY_OF_MONTH, HOUR_OF_DAY1,
+      HOUR_OF_DAY0, MINUTE, SECOND, MILLISECOND,
+      DAY_OF_WEEK, DAY_OF_YEAR, DAY_OF_WEEK_IN_MONTH,
+      WEEK_OF_YEAR, WEEK_OF_MONTH, AM_PM, HOUR1, HOUR0,
+      TIME_ZONE, ISO_YEAR, LOCALIZED_DAY_OF_WEEK,
+      EXTENDED_YEAR, MODIFIED_JULIAN_DAY, MILLISECOND_IN_DAY,
+      RFC822_TIME_ZONE
+    };
+
+    // For deserialization
+    private Field()
+    {
+      super("");
+    }
+
+    protected Field(String name, int calendarField)
+    {
+      super(name);
+      this.calendarField = calendarField;
+    }
+    
+    public int getCalendarField()
+    {
+      return calendarField;
+    }
+
+    public static Field ofCalendarField(int calendarField)
+    {
+      if (calendarField >= allFields.length || calendarField < 0)
+	throw new IllegalArgumentException("no such calendar field ("
+					   + calendarField + ")");
+      
+      return allFields[calendarField];
+    }
+    
+    protected Object readResolve() throws InvalidObjectException
+    {
+      String s = getName();
+
+      for (int i=0;i<allFields.length;i++)
+	if (s.equals(allFields[i].getName()))
+	  return allFields[i];
+      
+      throw new InvalidObjectException("no such DateFormat field called " + s);
+    }
+  }
+
+  /**
+   * This method initializes a new instance of <code>DateFormat</code>.
+   */
+  protected DateFormat ()
+  {
+  }
+
+  /**
+   * This method tests this object for equality against the specified object.
+   * The two objects will be considered equal if an only if the specified
+   * object:
+   * <P>
+   * <ul>
+   * <li>Is not <code>null</code>.</li>
+   * <li>Is an instance of <code>DateFormat</code>.</li>
+   * <li>Has equal numberFormat field as this object.</li>
+   * <li>Has equal (Calendar) TimeZone rules as this object.</li>
+   * <li>Has equal (Calendar) isLenient results.</li> 
+   * <li>Has equal Calendar first day of week and minimal days in week
+   * values.</li>
+   * </ul>
+   * Note that not all properties of the Calendar are relevant for a
+   * DateFormat. For formatting only the fact whether or not the
+   * TimeZone has the same rules and whether the calendar is lenient
+   * and has the same week rules is compared for this implementation
+   * of equals. Other properties of the Calendar (such as the time)
+   * are not taken into account.
+   *
+   * @param obj The object to test for equality against.
+   * 
+   * @return <code>true</code> if the specified object is equal to this object,
+   * <code>false</code> otherwise.
+   */
+  public boolean equals (Object obj)
+  {
+    if (!(obj instanceof DateFormat))
+      return false;
+
+    DateFormat d = (DateFormat) obj;
+    TimeZone tz = getTimeZone();
+    TimeZone tzd = d.getTimeZone();
+    if (tz.hasSameRules(tzd))
+      if (isLenient() == d.isLenient())
+	{
+	  Calendar c = getCalendar();
+	  Calendar cd = d.getCalendar();
+	  if ((c == null && cd == null)
+	      ||
+	      (c.getFirstDayOfWeek() == cd.getFirstDayOfWeek()
+	       &&
+	       c.getMinimalDaysInFirstWeek()
+	       == cd.getMinimalDaysInFirstWeek()))
+	    return ((numberFormat == null && d.numberFormat == null)
+		    || numberFormat.equals(d.numberFormat));
+	}
+
+    return false;
+  }
+
+  /**
+   * This method returns a copy of this object.
+   *
+   * @return A copy of this object.
+   */
+  public Object clone ()
+  {
+    // We know the superclass just call's Object's generic cloner.
+    return super.clone ();
+  }
+
+  /**
+   * This method formats the specified <code>Object</code> into a date string
+   * and appends it to the specified <code>StringBuffer</code>.
+   * The specified object must be an instance of <code>Number</code> or
+   * <code>Date</code> or an <code>IllegalArgumentException</code> will be
+   * thrown.
+   *
+   * @param obj The <code>Object</code> to format.
+   * @param buf The <code>StringBuffer</code> to append the resultant
+   * <code>String</code> to.
+   * @param pos Is updated to the start and end index of the
+   * specified field.
+   *
+   * @return The <code>StringBuffer</code> supplied on input, with the
+   * formatted date/time appended.
+   */
+  public final StringBuffer format (Object obj,
+				    StringBuffer buf, FieldPosition pos)
+  {
+    if (obj instanceof Number)
+      obj = new Date(((Number) obj).longValue());
+    else if (! (obj instanceof Date))
+      throw new IllegalArgumentException
+	("Cannot format given Object as a Date");
+
+    return format ((Date) obj, buf, pos);
+  }
+
+  /**  
+    * Formats the date argument according to the pattern specified. 
+    *
+    * @param date The formatted date.
+    */
+  public final String format (Date date)
+  {
+    StringBuffer sb = new StringBuffer ();
+    format (date, sb, new FieldPosition (MONTH_FIELD));
+    return sb.toString();
+  }
+
+  /**
+   * This method formats a <code>Date</code> into a string and appends it
+   * to the specified <code>StringBuffer</code>.
+   *
+   * @param date The <code>Date</code> value to format.
+   * @param buf The <code>StringBuffer</code> to append the resultant
+   * <code>String</code> to.
+   * @param pos Is updated to the start and end index of the
+   * specified field.
+   *
+   * @return The <code>StringBuffer</code> supplied on input, with the
+   * formatted date/time appended.
+   */
+  public abstract StringBuffer format (Date date,
+				       StringBuffer buf, FieldPosition pos);
+
+  /**
+   * This method returns a list of available locales supported by this
+   * class.
+   */
+  public static Locale[] getAvailableLocales()
+  {
+    return Locale.getAvailableLocales();
+  }
+
+  /**
+    * This method returns the <code>Calendar</code> object being used by
+    * this object to parse/format datetimes.
+    *
+    * @return The <code>Calendar</code> being used by this object.
+    *
+    * @see java.util.Calendar
+    */
+  public Calendar getCalendar ()
+  {
+    return calendar;
+  }
+
+  private static DateFormat computeInstance (int style, Locale loc,
+                                             boolean use_date, boolean use_time)
+  {
+    return computeInstance (style, style, loc, use_date, use_time);
+  }
+
+  private static DateFormat computeInstance (int dateStyle, int timeStyle,
+                                             Locale loc, boolean use_date,
+                                             boolean use_time)
+  {
+    ResourceBundle res;
+    try
+      {
+	res = ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
+				       loc, ClassLoader.getSystemClassLoader());
+      }
+    catch (MissingResourceException x)
+      {
+	res = null;
+      }
+
+    String pattern = null;
+    if (use_date)
+      {
+	String name, def;
+	switch (dateStyle)
+	  {
+	  case FULL:
+	    name = "fullDateFormat";
+	    def = "EEEE MMMM d, yyyy G";
+	    break;
+	  case LONG:
+	    name = "longDateFormat";
+	    def = "MMMM d, yyyy";
+	    break;
+	  case MEDIUM:
+	    name = "mediumDateFormat";
+	    def = "d-MMM-yy";
+	    break;
+	  case SHORT:
+	    name = "shortDateFormat";
+	    def = "M/d/yy";
+	    break;
+	  default:
+	    throw new IllegalArgumentException ();
+	  }
+	try
+	  {
+	    pattern = res == null ? def : res.getString(name);
+	  }
+	catch (MissingResourceException x)
+	  {
+	    pattern = def;
+	  }
+      }
+
+    if (use_time)
+      {
+	if (pattern == null)
+	  pattern = "";
+	else
+	  pattern += " ";
+
+	String name, def;
+	switch (timeStyle)
+	  {
+	  case FULL:
+	    name = "fullTimeFormat";
+	    def = "h:mm:ss;S 'o''clock' a z";
+	    break;
+	  case LONG:
+	    name = "longTimeFormat";
+	    def = "h:mm:ss a z";
+	    break;
+	  case MEDIUM:
+	    name = "mediumTimeFormat";
+	    def = "h:mm:ss a";
+	    break;
+	  case SHORT:
+	    name = "shortTimeFormat";
+	    def = "h:mm a";
+	    break;
+	  default:
+	    throw new IllegalArgumentException ();
+	  }
+
+	String s;
+	try
+	  {
+	    s = res == null ? def : res.getString(name);
+	  }
+	catch (MissingResourceException x)
+	  {
+	    s = def;
+	  }
+	pattern += s;
+      }
+
+    return new SimpleDateFormat (pattern, loc);
+  }
+
+ /**
+   * This method returns an instance of <code>DateFormat</code> that will
+   * format using the default formatting style for dates.
+   *
+   * @return A new <code>DateFormat</code> instance.
+   */
+  public static final DateFormat getDateInstance ()
+  {
+    return getDateInstance (DEFAULT, Locale.getDefault());
+  }
+
+  /**
+   * This method returns an instance of <code>DateFormat</code> that will
+   * format using the specified formatting style for dates.
+   *
+   * @param style The type of formatting to perform. 
+   * 
+   * @return A new <code>DateFormat</code> instance.
+   */
+  public static final DateFormat getDateInstance (int style)
+  {
+    return getDateInstance (style, Locale.getDefault());
+  }
+
+  /**
+   * This method returns an instance of <code>DateFormat</code> that will
+   * format using the specified formatting style for dates.  The specified
+   * localed will be used in place of the default.
+   *
+   * @param style The type of formatting to perform. 
+   * @param loc The desired locale.
+   * 
+   * @return A new <code>DateFormat</code> instance.
+   */
+  public static final DateFormat getDateInstance (int style, Locale loc)
+  {
+    return computeInstance (style, loc, true, false);
+  }
+
+  /**
+   * This method returns a new instance of <code>DateFormat</code> that
+   * formats both dates and times using the <code>SHORT</code> style.
+   *
+   * @return A new <code>DateFormat</code>instance.
+   */
+  public static final DateFormat getDateTimeInstance ()
+  {
+    return getDateTimeInstance (DEFAULT, DEFAULT, Locale.getDefault());
+  }
+
+  /**
+   * This method returns a new instance of <code>DateFormat</code> that
+   * formats both dates and times using the <code>DEFAULT</code> style.
+   *
+   * @return A new <code>DateFormat</code>instance.
+   */
+  public static final DateFormat getDateTimeInstance (int dateStyle, 
+						      int timeStyle)
+  {
+    return getDateTimeInstance (dateStyle, timeStyle, Locale.getDefault());
+  }
+
+  /**
+   * This method returns a new instance of <code>DateFormat</code> that
+   * formats both dates and times using the specified styles.
+   * 
+   * @param dateStyle The desired style for date formatting.
+   * @param timeStyle The desired style for time formatting
+   *
+   * @return A new <code>DateFormat</code>instance.
+   */
+  public static final DateFormat getDateTimeInstance (int dateStyle, 
+						      int timeStyle, 
+						      Locale loc)
+  {
+    return computeInstance (dateStyle, timeStyle, loc, true, true);
+  }
+
+  /**
+   * This method returns a new instance of <code>DateFormat</code> that
+   * formats both dates and times using the <code>SHORT</code> style.
+   *
+   * @return A new <code>DateFormat</code>instance.
+   */
+  public static final DateFormat getInstance ()
+  {
+    // JCL book says SHORT.
+    return getDateTimeInstance (SHORT, SHORT, Locale.getDefault());
+  }
+
+  /**
+   * This method returns the <code>NumberFormat</code> object being used
+   * by this object to parse/format time values.
+   *
+   * @return The <code>NumberFormat</code> in use by this object.
+   */
+  public NumberFormat getNumberFormat ()
+  {
+    return numberFormat;
+  }
+
+ /**
+   * This method returns an instance of <code>DateFormat</code> that will
+   * format using the default formatting style for times.
+   *
+   * @return A new <code>DateFormat</code> instance.
+   */
+  public static final DateFormat getTimeInstance ()
+  {
+    return getTimeInstance (DEFAULT, Locale.getDefault());
+  }
+
+  /**
+   * This method returns an instance of <code>DateFormat</code> that will
+   * format using the specified formatting style for times.
+   *
+   * @param style The type of formatting to perform. 
+   * 
+   * @return A new <code>DateFormat</code> instance.
+   */
+  public static final DateFormat getTimeInstance (int style)
+  {
+    return getTimeInstance (style, Locale.getDefault());
+  }
+
+  /**
+   * This method returns an instance of <code>DateFormat</code> that will
+   * format using the specified formatting style for times.  The specified
+   * localed will be used in place of the default.
+   *
+   * @param style The type of formatting to perform. 
+   * @param loc The desired locale.
+   * 
+   * @return A new <code>DateFormat</code> instance.
+   */
+  public static final DateFormat getTimeInstance (int style, Locale loc)
+  {
+    return computeInstance (style, loc, false, true);
+  }
+
+  /**
+   * This method returns the <code>TimeZone</code> object being used by
+   * this instance.
+   *
+   * @return The time zone in use.
+   */
+  public TimeZone getTimeZone ()
+  {
+    return calendar.getTimeZone();
+  }
+
+  /**
+   * This method returns a hash value for this object.
+   * 
+   * @return A hash value for this object.
+   */
+  public int hashCode ()
+  {
+    if (numberFormat != null)
+      return numberFormat.hashCode();
+    else
+      return 0;
+  }
+
+  /**
+   * This method indicates whether or not the parsing of date and time
+   * values should be done in a lenient value.
+   *
+   * @return <code>true</code> if date/time parsing is lenient,
+   * <code>false</code> otherwise.
+   */
+  public boolean isLenient ()
+  {
+    return calendar.isLenient();
+  }
+
+  /**
+   * This method parses the specified date/time string.
+   *
+   * @param source The string to parse.
+   * @return The resultant date.
+   *
+   * @exception ParseException If the specified string cannot be parsed.
+   */
+  public Date parse (String source) throws ParseException
+  {
+    ParsePosition pos = new ParsePosition(0);
+    Date result = parse (source, pos);
+    if (result == null)
+      {
+	int index = pos.getErrorIndex();
+	if (index < 0)
+	  index = pos.getIndex();
+	throw new ParseException("invalid Date syntax in \""
+				 + source + '\"', index);
+      }
+    return result;
+  }
+
+  /** 
+   * This method parses the specified <code>String</code> into a 
+   * <code>Date</code>.  The <code>pos</code> argument contains the
+   * starting parse position on method entry and the ending parse
+   * position on method exit.
+   *
+   * @param source The string to parse.
+   * @param pos The starting parse position in entry, the ending parse
+   * position on exit.
+   *
+   * @return The parsed date, or <code>null</code> if the string cannot
+   * be parsed.
+   */
+  public abstract Date parse (String source, ParsePosition pos);
+
+  /**
+   * This method is identical to <code>parse(String, ParsePosition)</code>,
+   * but returns its result as an <code>Object</code> instead of a
+   * <code>Date</code>.
+   * 
+   * @param source The string to parse.
+   * @param pos The starting parse position in entry, the ending parse
+   * position on exit.
+   *
+   * @return The parsed date, or <code>null</code> if the string cannot
+   * be parsed.
+   */
+  public Object parseObject (String source, ParsePosition pos)
+  {
+    return parse(source, pos);
+  }
+
+  /**
+   * This method specified the <code>Calendar</code> that should be used 
+   * by this object to parse/format datetimes.
+   *
+   * @param calendar The new <code>Calendar</code> for this object.
+   *
+   * @see java.util.Calendar
+   */
+  public void setCalendar (Calendar calendar)
+  {
+    this.calendar = calendar;
+  }
+
+  /**
+   * This method specifies whether or not this object should be lenient in 
+   * the syntax it accepts while parsing date/time values.
+   *
+   * @param lenient <code>true</code> if parsing should be lenient,
+   * <code>false</code> otherwise.
+   */
+  public void setLenient (boolean lenient)
+  {
+    calendar.setLenient(lenient);
+  }
+
+  /**
+   * This method specifies the <code>NumberFormat</code> object that should
+   * be used by this object to parse/format times.
+   *
+   * @param numberFormat The <code>NumberFormat</code> in use by this object.
+   */
+  public void setNumberFormat (NumberFormat numberFormat)
+  {
+    this.numberFormat = numberFormat;
+  }
+
+  /**
+   * This method sets the time zone that should be used by this object.
+   *
+   * @param timeZone The new time zone.
+   */
+  public void setTimeZone (TimeZone timeZone)
+  {
+    calendar.setTimeZone(timeZone);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/DateFormatSymbols.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/DateFormatSymbols.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/DateFormatSymbols.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/DateFormatSymbols.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,540 @@
+/* DateFormatSymbols.java -- Format over a range of numbers
+   Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * This class acts as container for locale specific date/time formatting
+ * information such as the days of the week and the months of the year.
+ * @author Per Bothner (bothner at cygnus.com)
+ * @date October 24, 1998.
+ */
+/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3.
+ * Status:  Believed complete and correct.
+ */
+public class DateFormatSymbols implements java.io.Serializable, Cloneable
+{
+  String[] ampms;
+  String[] eras;
+  private String localPatternChars;
+  String[] months;
+  String[] shortMonths;
+  String[] shortWeekdays;
+  String[] weekdays;
+  private String[][] zoneStrings;
+
+  private static final long serialVersionUID = -5987973545549424702L;
+
+  // The order of these prefixes must be the same as in DateFormat
+  private static final String[] formatPrefixes =
+  {
+    "full", "long", "medium", "short"
+  };
+
+  // These are each arrays with a value for SHORT, MEDIUM, LONG, FULL,
+  // and DEFAULT (constants defined in java.text.DateFormat).  While
+  // not part of the official spec, we need a way to get at locale-specific
+  // default formatting patterns.  They are declared package scope so
+  // as to be easily accessible where needed (DateFormat, SimpleDateFormat).
+  transient String[] dateFormats;
+  transient String[] timeFormats;
+
+  private static String[] getStringArray(ResourceBundle res, String name)
+  { 
+    return res.getString(name).split("\u00ae");
+  }
+
+  private String[][] getZoneStrings(ResourceBundle res)
+  {
+    try
+      {
+        int index = 0;
+        String data = res.getString("zoneStrings");
+	String[] zones = data.split("\u00a9");
+	String[][] array = new String[zones.length][];
+	for (int a = 0; a < zones.length; ++a)
+	  array[a] = zones[a].split("\u00ae");
+	return array;
+      }
+    catch (MissingResourceException e)
+      {
+	return new String[0][];
+      }
+  }
+  
+  private String[] formatsForKey(ResourceBundle res, String key) 
+  {
+    String[] values = new String[formatPrefixes.length];
+    
+    for (int i = 0; i < formatPrefixes.length; i++)
+      values[i] = res.getString(formatPrefixes[i] + key);
+  
+    return values;
+  }
+
+  /**
+   * This method initializes a new instance of <code>DateFormatSymbols</code>
+   * by loading the date format information for the specified locale.
+   *
+   * @param locale The locale for which date formatting symbols should
+   *               be loaded. 
+   */
+  public DateFormatSymbols (Locale locale) throws MissingResourceException
+  {
+    ResourceBundle res
+      = ResourceBundle.getBundle("gnu.java.locale.LocaleInformation", locale,
+      				 ClassLoader.getSystemClassLoader());
+
+    ampms = getStringArray(res, "ampms");
+    eras = getStringArray(res, "eras");
+    localPatternChars = res.getString("localPatternChars");
+    months = getStringArray(res, "months");
+    shortMonths = getStringArray(res, "shortMonths");
+    shortWeekdays = getStringArray(res, "shortWeekdays");
+    weekdays = getStringArray(res, "weekdays");
+    zoneStrings = getZoneStrings(res);
+    dateFormats = formatsForKey(res, "DateFormat");
+    timeFormats = formatsForKey(res, "TimeFormat");
+  }
+
+  /**
+   * This method loads the format symbol information for the default
+   * locale.
+   */
+  public DateFormatSymbols () throws MissingResourceException
+  {
+    this (Locale.getDefault());
+  }
+
+  /**
+   * This method returns the list of strings used for displaying AM or PM.
+   * This is a two element <code>String</code> array indexed by
+   * <code>Calendar.AM</code> and <code>Calendar.PM</code>
+   *
+   * @return The list of AM/PM display strings.
+   */
+  public String[] getAmPmStrings()
+  {
+    return ampms;
+  }
+
+  /**
+    * This method returns the list of strings used for displaying eras
+    * (e.g., "BC" and "AD").  This is a two element <code>String</code>
+    * array indexed by <code>Calendar.BC</code> and <code>Calendar.AD</code>.
+    *
+    * @return The list of era disply strings.
+    */
+  public String[] getEras()
+  {
+    return eras;
+  }
+
+  /**
+    * This method returns the pattern character information for this
+    * object.  This is an 18 character string that contains the characters
+    * that are used in creating the date formatting strings in 
+    * <code>SimpleDateFormat</code>.   The following are the character
+    * positions in the string and which format character they correspond
+    * to (the character in parentheses is the default value in the US English
+    * locale):
+    * <p>
+    * <ul>
+    * <li>0 - era (G)</li>
+    * <li>1 - year (y)</li>
+    * <li>2 - month (M)</li>
+    * <li>3 - day of month (d)</li>
+    * <li>4 - hour out of 12, from 1-12 (h)</li>
+    * <li>5 - hour out of 24, from 0-23 (H)</li>
+    * <li>6 - minute (m)</li>
+    * <li>7 - second (s)</li>
+    * <li>8 - millisecond (S)</li>
+    * <li>9 - date of week (E)</li>
+    * <li>10 - date of year (D)</li>
+    * <li>11 - day of week in month, eg. "4th Thur in Nov" (F)</li>
+    * <li>12 - week in year (w)</li>
+    * <li>13 - week in month (W)</li>
+    * <li>14 - am/pm (a)</li>
+    * <li>15 - hour out of 24, from 1-24 (k)</li>
+    * <li>16 - hour out of 12, from 0-11 (K)</li>
+    * <li>17 - time zone (z)</li>
+    * </ul>
+    *
+    * @return The format patter characters
+    */
+  public String getLocalPatternChars()
+  {
+    return localPatternChars;
+  }
+
+  /**
+   * This method returns the list of strings used for displaying month
+   * names (e.g., "January" and "February").  This is a thirteen element
+   * string array indexed by <code>Calendar.JANUARY</code> through
+   * <code>Calendar.UNDECEMBER</code>.  Note that there are thirteen
+   * elements because some calendars have thriteen months.
+   *
+   * @return The list of month display strings.
+   */
+  public String[] getMonths ()
+  {
+    return months;
+  }
+
+  /**
+   * This method returns the list of strings used for displaying abbreviated
+   * month names (e.g., "Jan" and "Feb").  This is a thirteen element
+   * <code>String</code> array indexed by <code>Calendar.JANUARY</code>
+   * through <code>Calendar.UNDECEMBER</code>.  Note that there are thirteen
+   * elements because some calendars have thirteen months.
+   *
+   * @return The list of abbreviated month display strings.
+   */
+  public String[] getShortMonths ()
+  {
+    return shortMonths;
+  }
+
+  /**
+   * This method returns the list of strings used for displaying abbreviated 
+   * weekday names (e.g., "Sun" and "Mon").  This is an eight element
+   * <code>String</code> array indexed by <code>Calendar.SUNDAY</code>
+   * through <code>Calendar.SATURDAY</code>.  Note that the first element
+   * of this array is ignored.
+   *
+   * @return This list of abbreviated weekday display strings.
+   */
+  public String[] getShortWeekdays ()
+  {
+    return shortWeekdays;
+  }
+
+  /**
+   * This method returns the list of strings used for displaying weekday
+   * names (e.g., "Sunday" and "Monday").  This is an eight element
+   * <code>String</code> array indexed by <code>Calendar.SUNDAY</code>
+   * through <code>Calendar.SATURDAY</code>.  Note that the first element
+   * of this array is ignored.
+   *
+   * @return This list of weekday display strings.
+   */
+  public String[] getWeekdays ()
+  {
+    return weekdays;
+  }
+
+  /**
+   * This method returns this list of localized timezone display strings.
+   * This is a two dimensional <code>String</code> array where each row in
+   * the array contains five values:
+   * <P>
+   * <ul>
+   * <li>0 - The non-localized time zone id string.</li>
+   * <li>1 - The long name of the time zone (standard time).</li>
+   * <li>2 - The short name of the time zone (standard time).</li>
+   * <li>3 - The long name of the time zone (daylight savings time).</li>
+   * <li>4 - the short name of the time zone (daylight savings time).</li>
+   * </ul>
+   *
+   * @return The list of time zone display strings.
+   */
+  public String[] [] getZoneStrings ()
+  {
+    return zoneStrings;
+  }
+
+  /**
+   * This method sets the list of strings used to display AM/PM values to
+   * the specified list.
+   * This is a two element <code>String</code> array indexed by
+   * <code>Calendar.AM</code> and <code>Calendar.PM</code>
+   *
+   * @param value The new list of AM/PM display strings.
+   */
+  public void setAmPmStrings (String[] value)
+  {
+    if(value==null)
+      throw new NullPointerException();
+    ampms = value;
+  }
+
+  /**
+   * This method sets the list of strings used to display time eras to
+   * to the specified list.
+   * This is a two element <code>String</code>
+   * array indexed by <code>Calendar.BC</code> and <code>Calendar.AD</code>.
+   *
+   * @param labels The new list of era display strings.
+   */
+  public void setEras (String[] labels)
+  {
+    if(labels==null)
+      throw new NullPointerException();
+    eras = labels;
+  }
+
+  /**
+    * This method sets the list of characters used to specific date/time
+    * formatting strings.
+    * This is an 18 character string that contains the characters
+    * that are used in creating the date formatting strings in 
+    * <code>SimpleDateFormat</code>.   The following are the character
+    * positions in the string and which format character they correspond
+    * to (the character in parentheses is the default value in the US English
+    * locale):
+    * <p>
+    * <ul>
+    * <li>0 - era (G)</li>
+    * <li>1 - year (y)</li>
+    * <li>2 - month (M)</li>
+    * <li>3 - day of month (d)</li>
+    * <li>4 - hour out of 12, from 1-12 (h)</li>
+    * <li>5 - hour out of 24, from 0-23 (H)</li>
+    * <li>6 - minute (m)</li>
+    * <li>7 - second (s)</li>
+    * <li>8 - millisecond (S)</li>
+    * <li>9 - date of week (E)</li>
+    * <li>10 - date of year (D)</li>
+    * <li>11 - day of week in month, eg. "4th Thur in Nov" (F)</li>
+    * <li>12 - week in year (w)</li>
+    * <li>13 - week in month (W)</li>
+    * <li>14 - am/pm (a)</li>
+    * <li>15 - hour out of 24, from 1-24 (k)</li>
+    * <li>16 - hour out of 12, from 0-11 (K)</li>
+    * <li>17 - time zone (z)</li>
+    * </ul>
+    *
+    * @param chars The new format pattern characters
+    */
+  public void setLocalPatternChars (String chars)
+  {
+    if(chars==null)
+      throw new NullPointerException();
+    localPatternChars = chars;
+  }
+
+  /**
+    * This method sets the list of strings used to display month names.
+    * This is a thirteen element
+    * string array indexed by <code>Calendar.JANUARY</code> through
+    * <code>Calendar.UNDECEMBER</code>.  Note that there are thirteen
+    * elements because some calendars have thriteen months.
+    *
+    * @param labels The list of month display strings.
+    */
+  public void setMonths (String[] labels)
+  {
+    if(labels==null)
+      throw new NullPointerException();
+    months = labels;
+  }
+
+  /**
+   * This method sets the list of strings used to display abbreviated month
+   * names.
+   * This is a thirteen element
+   * <code>String</code> array indexed by <code>Calendar.JANUARY</code>
+   * through <code>Calendar.UNDECEMBER</code>.  Note that there are thirteen
+   * elements because some calendars have thirteen months.
+   *
+   * @param labels The new list of abbreviated month display strings.
+   */
+  public void setShortMonths (String[] labels)
+  {
+    if(labels==null)
+      throw new NullPointerException();
+    shortMonths = labels;
+  }
+
+  /**
+   * This method sets the list of strings used to display abbreviated
+   * weekday names.
+   * This is an eight element
+   * <code>String</code> array indexed by <code>Calendar.SUNDAY</code>
+   * through <code>Calendar.SATURDAY</code>.  Note that the first element
+   * of this array is ignored.
+   *
+   * @param labels This list of abbreviated weekday display strings.
+   */
+  public void setShortWeekdays (String[] labels)
+  {
+    if(labels==null)
+      throw new NullPointerException();
+    shortWeekdays = labels;
+  }
+
+  /**
+   * This method sets the list of strings used to display weekday names.
+   * This is an eight element
+   * <code>String</code> array indexed by <code>Calendar.SUNDAY</code>
+   * through <code>Calendar.SATURDAY</code>.  Note that the first element
+   * of this array is ignored.
+   *
+   * @param labels This list of weekday display strings.
+   */
+  public void setWeekdays (String[] labels)
+  {
+    if(labels==null)
+      throw new NullPointerException();
+    weekdays = labels;
+  }
+
+  /**
+   * This method sets the list of display strings for time zones.
+   * This is a two dimensional <code>String</code> array where each row in
+   * the array contains five values:
+   * <P>
+   * <ul>
+   * <li>0 - The non-localized time zone id string.</li>
+   * <li>1 - The long name of the time zone (standard time).</li>
+   * <li>2 - The short name of the time zone (standard time).</li>
+   * <li>3 - The long name of the time zone (daylight savings time).</li>
+   * <li>4 - the short name of the time zone (daylight savings time).</li>
+   * </ul>
+   *
+   * @params zones The list of time zone display strings.
+   */
+  public void setZoneStrings (String[][] zones)
+  {
+    if(zones==null)
+      throw new NullPointerException();
+    zoneStrings = zones;
+  }
+
+  /* Does a "deep" equality test - recurses into arrays. */
+  private static boolean equals (Object x, Object y)
+  {
+    if (x == y)
+      return true;
+    if (x == null || y == null)
+      return false;
+    if (! (x instanceof Object[]) || ! (y instanceof Object[]))
+      return x.equals(y);
+    Object[] xa = (Object[]) x;
+    Object[] ya = (Object[]) y;
+    if (xa.length != ya.length)
+      return false;
+    for (int i = xa.length;  --i >= 0; )
+      {
+	if (! equals(xa[i], ya[i]))
+	  return false;
+      }
+    return true;
+  }
+
+  private static int hashCode (Object x)
+  {
+    if (x == null)
+      return 0;
+    if (! (x instanceof Object[]))
+      return x.hashCode();
+    Object[] xa = (Object[]) x;
+    int hash = 0;
+    for (int i = 0;  i < xa.length;  i++)
+      hash = 37 * hashCode(xa[i]);
+    return hash;
+  }
+
+  /**
+   * This method tests a specified object for equality against this object.
+   * This will be true if and only if the specified object:
+   * <p>
+   * <ul>
+   * <li> Is not <code>null</code>.</li>
+   * <li> Is an instance of <code>DateFormatSymbols</code>.</li>
+   * <li> Contains identical formatting symbols to this object.</li>
+   * </ul>
+   * 
+   * @param obj The <code>Object</code> to test for equality against.
+   *
+   * @return <code>true</code> if the specified object is equal to this one,
+   * <code>false</code> otherwise.
+   */
+  public boolean equals (Object obj)
+  {
+    if (! (obj instanceof DateFormatSymbols))
+      return false;
+    DateFormatSymbols other = (DateFormatSymbols) obj;
+    return (equals(ampms, other.ampms)
+	    && equals(eras, other.eras)
+	    && equals(localPatternChars, other.localPatternChars)
+	    && equals(months, other.months)
+	    && equals(shortMonths, other.shortMonths)
+	    && equals(shortWeekdays, other.shortWeekdays)
+	    && equals(weekdays, other.weekdays)
+	    && equals(zoneStrings, other.zoneStrings));
+  }
+
+  /**
+   * Returns a new copy of this object.
+   *
+   * @return A copy of this object
+   */
+  public Object clone ()
+  {
+    try
+      {
+        return super.clone ();
+      } 
+    catch (CloneNotSupportedException e) 
+      {
+        return null;
+      }
+  }
+
+  /**
+   * This method returns a hash value for this object.
+   *
+   * @return A hash value for this object.
+   */
+  public int hashCode ()
+  {
+    return (hashCode(ampms)
+	    ^ hashCode(eras)
+	    ^ hashCode(localPatternChars)
+	    ^ hashCode(months)
+	    ^ hashCode(shortMonths)
+	    ^ hashCode(shortWeekdays)
+	    ^ hashCode(weekdays)
+	    ^ hashCode(zoneStrings));
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/DecimalFormat.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/DecimalFormat.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/DecimalFormat.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/DecimalFormat.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1437 @@
+/* DecimalFormat.java -- Formats and parses numbers
+   Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.text;
+
+import gnu.java.text.AttributedFormatBuffer;
+import gnu.java.text.FormatBuffer;
+import gnu.java.text.FormatCharacterIterator;
+import gnu.java.text.StringFormatBuffer;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.util.Currency;
+import java.util.HashMap;
+import java.util.Locale;
+
+/**
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @date March 4, 1999
+ */
+/* Written using "Java Class Libraries", 2nd edition, plus online
+ * API docs for JDK 1.2 from http://www.javasoft.com.
+ * Status:  Believed complete and correct to 1.2.
+ * Note however that the docs are very unclear about how format parsing
+ * should work.  No doubt there are problems here.
+ */
+public class DecimalFormat extends NumberFormat
+{
+  // This is a helper for applyPatternWithSymbols.  It reads a prefix
+  // or a suffix.  It can cause some side-effects.
+  private int scanFix (String pattern, int index, FormatBuffer buf,
+                       String patChars, DecimalFormatSymbols syms,
+                       boolean is_suffix)
+    {
+    int len = pattern.length();
+    boolean quoteStarted = false;
+    buf.clear();
+    
+    boolean multiplierSet = false;
+    while (index < len)
+      {
+	char c = pattern.charAt(index);
+
+	if (quoteStarted)
+	  {
+	    if (c == '\'')
+	      quoteStarted = false;
+	    else
+	      buf.append(c);
+	    index++;
+	    continue;
+	  }
+
+	if (c == '\'' && index + 1 < len
+	    && pattern.charAt(index + 1) == '\'')
+	  {
+	    buf.append(c);
+	    index++;
+	  }
+	else if (c == '\'')
+	  {
+	    quoteStarted = true;
+	  }
+	else if (c == '\u00a4')
+	  {
+			/* Currency interpreted later */
+			buf.append(c);
+		}
+	else if (c == syms.getPercent())
+	  {
+	    if (multiplierSet)
+	      throw new IllegalArgumentException ("multiplier already set " +
+						  "- index: " + index);
+	    multiplierSet = true;
+	    multiplier = 100;
+	    buf.append(c, NumberFormat.Field.PERCENT);
+	  }
+	else if (c == syms.getPerMill())
+	  {
+	    if (multiplierSet)
+	      throw new IllegalArgumentException ("multiplier already set " +
+						  "- index: " + index);
+	    multiplierSet = true;
+	    multiplier = 1000;
+	    buf.append(c, NumberFormat.Field.PERMILLE);
+	  }
+	else if (patChars.indexOf(c) != -1)
+	  {
+	    // This is a pattern character.
+	    break;
+	  }
+	else
+		{
+			buf.append(c);
+		}
+	index++;
+      }
+
+    if (quoteStarted)
+      throw new IllegalArgumentException ("pattern is lacking a closing quote");
+
+    return index;
+  }
+
+  // A helper which reads a number format.
+  private int scanFormat (String pattern, int index, String patChars,
+                          DecimalFormatSymbols syms, boolean is_positive)
+  {
+    int max = pattern.length();
+
+    int countSinceGroup = 0;
+    int zeroCount = 0;
+    boolean saw_group = false;
+
+    //
+    // Scan integer part.
+    //
+    while (index < max)
+      {
+	char c = pattern.charAt(index);
+
+	if (c == syms.getDigit())
+	  {
+	    if (zeroCount > 0)
+	      throw new IllegalArgumentException ("digit mark following " +
+						  "zero - index: " + index);
+	    ++countSinceGroup;
+	  }
+	else if (c == syms.getZeroDigit())
+	  {
+	    ++zeroCount;
+	    ++countSinceGroup;
+	  }
+	else if (c == syms.getGroupingSeparator())
+	  {
+	    countSinceGroup = 0;
+	    saw_group = true;
+	  }
+	else
+	  break;
+
+	++index;
+      }
+
+    // We can only side-effect when parsing the positive format.
+    if (is_positive)
+      {
+	groupingUsed = saw_group;
+	groupingSize = (byte) countSinceGroup;
+	// Checking "zeroCount > 0" avoids 0 being formatted into "" with "#".
+	if (zeroCount > 0)
+	  minimumIntegerDigits = zeroCount;
+      }
+
+    // Early termination.
+    if (index == max || pattern.charAt(index) == syms.getGroupingSeparator())
+      {
+	if (is_positive)
+	  decimalSeparatorAlwaysShown = false;
+	return index;
+      }
+
+    if (pattern.charAt(index) == syms.getDecimalSeparator())
+      {
+	++index;
+
+	//
+	// Scan fractional part.
+	//
+	int hashCount = 0;
+	zeroCount = 0;
+	while (index < max)
+	  {
+	    char c = pattern.charAt(index);
+	    if (c == syms.getZeroDigit())
+	      {
+		if (hashCount > 0)
+		  throw new IllegalArgumentException ("zero mark " +
+						      "following digit - index: " + index);
+		++zeroCount;
+	      }
+	    else if (c == syms.getDigit())
+	      {
+		++hashCount;
+	      }
+	    else if (c != syms.getExponential()
+		     && c != syms.getPatternSeparator()
+		     && c != syms.getPercent()
+		     && c != syms.getPerMill()
+		     && patChars.indexOf(c) != -1)
+	      throw new IllegalArgumentException ("unexpected special " +
+						  "character - index: " + index);
+	    else
+	      break;
+
+	    ++index;
+	  }
+
+	if (is_positive)
+	  {
+	    maximumFractionDigits = hashCount + zeroCount;
+	    minimumFractionDigits = zeroCount;
+	  }
+
+	if (index == max)
+	  return index;
+      }
+
+    if (pattern.charAt(index) == syms.getExponential())
+      {
+	//
+	// Scan exponential format.
+	//
+	zeroCount = 0;
+	++index;
+	while (index < max)
+	  {
+	    char c = pattern.charAt(index);
+	    if (c == syms.getZeroDigit())
+	      ++zeroCount;
+	    else if (c == syms.getDigit())
+	      {
+		if (zeroCount > 0)
+		  throw new
+		    IllegalArgumentException ("digit mark following zero " +
+					      "in exponent - index: " +
+					      index);
+	      }
+	    else if (patChars.indexOf(c) != -1)
+	      throw new IllegalArgumentException ("unexpected special " +
+						  "character - index: " +
+						  index);
+	    else
+	      break;
+
+	    ++index;
+	  }
+
+	if (is_positive)
+	  {
+	    useExponentialNotation = true;
+	    minExponentDigits = (byte) zeroCount;
+	  }
+
+	maximumIntegerDigits = groupingSize;
+	groupingSize = 0;
+	if (maximumIntegerDigits > minimumIntegerDigits && maximumIntegerDigits > 0)
+	  {
+	    minimumIntegerDigits = 1;
+	    exponentRound = maximumIntegerDigits;
+	  }
+	else
+	  exponentRound = 1;
+      }
+
+    return index;
+  }
+
+  // This helper function creates a string consisting of all the
+  // characters which can appear in a pattern and must be quoted.
+  private String patternChars (DecimalFormatSymbols syms)
+  {
+    StringBuffer buf = new StringBuffer ();
+    buf.append(syms.getDecimalSeparator());
+    buf.append(syms.getDigit());
+    buf.append(syms.getExponential());
+    buf.append(syms.getGroupingSeparator());
+    // Adding this one causes pattern application to fail.
+    // Of course, omitting is causes toPattern to fail.
+    // ... but we already have bugs there.  FIXME.
+    // buf.append(syms.getMinusSign());
+    buf.append(syms.getPatternSeparator());
+    buf.append(syms.getPercent());
+    buf.append(syms.getPerMill());
+    buf.append(syms.getZeroDigit());
+    buf.append('\u00a4');
+    return buf.toString();
+  }
+
+  private void applyPatternWithSymbols(String pattern, DecimalFormatSymbols syms)
+  {
+    // Initialize to the state the parser expects.
+    negativePrefix = "";
+    negativeSuffix = "";
+    positivePrefix = "";
+    positiveSuffix = "";
+    decimalSeparatorAlwaysShown = false;
+    groupingSize = 0;
+    minExponentDigits = 0;
+    multiplier = 1;
+    useExponentialNotation = false;
+    groupingUsed = false;
+    maximumFractionDigits = 0;
+    maximumIntegerDigits = MAXIMUM_INTEGER_DIGITS;
+    minimumFractionDigits = 0;
+    minimumIntegerDigits = 1;
+
+    AttributedFormatBuffer buf = new AttributedFormatBuffer ();
+    String patChars = patternChars (syms);
+
+    int max = pattern.length();
+    int index = scanFix (pattern, 0, buf, patChars, syms, false);
+    buf.sync();
+    positivePrefix = buf.getBuffer().toString();
+    positivePrefixRanges = buf.getRanges();
+    positivePrefixAttrs = buf.getAttributes();
+
+    index = scanFormat (pattern, index, patChars, syms, true);
+
+    index = scanFix (pattern, index, buf, patChars, syms, true);
+    buf.sync();
+    positiveSuffix = buf.getBuffer().toString();
+    positiveSuffixRanges = buf.getRanges();
+    positiveSuffixAttrs = buf.getAttributes();
+
+    if (index == pattern.length())
+      {
+	// No negative info.
+	negativePrefix = null;
+	negativeSuffix = null;
+      }
+    else
+      {
+	if (pattern.charAt(index) != syms.getPatternSeparator())
+	  throw new IllegalArgumentException ("separator character " +
+					      "expected - index: " + index);
+
+	index = scanFix (pattern, index + 1, buf, patChars, syms, false);
+	buf.sync();
+	negativePrefix = buf.getBuffer().toString();
+	negativePrefixRanges = buf.getRanges();
+	negativePrefixAttrs = buf.getAttributes();
+
+	// We parse the negative format for errors but we don't let
+	// it side-effect this object.
+	index = scanFormat (pattern, index, patChars, syms, false);
+
+	index = scanFix (pattern, index, buf, patChars, syms, true);
+	buf.sync();
+	negativeSuffix = buf.getBuffer().toString();
+	negativeSuffixRanges = buf.getRanges();
+	negativeSuffixAttrs = buf.getAttributes();
+
+	if (index != pattern.length())
+	  throw new IllegalArgumentException ("end of pattern expected " +
+					      "- index: " + index);
+      }
+  }
+
+  public void applyLocalizedPattern (String pattern)
+  {
+    // JCL p. 638 claims this throws a ParseException but p. 629
+    // contradicts this.  Empirical tests with patterns of "0,###.0"
+    // and "#.#.#" corroborate the p. 629 statement that an
+    // IllegalArgumentException is thrown.
+    applyPatternWithSymbols (pattern, symbols);
+  }
+
+  public void applyPattern (String pattern)
+  {
+    // JCL p. 638 claims this throws a ParseException but p. 629
+    // contradicts this.  Empirical tests with patterns of "0,###.0"
+    // and "#.#.#" corroborate the p. 629 statement that an
+    // IllegalArgumentException is thrown.
+    applyPatternWithSymbols (pattern, nonLocalizedSymbols);
+  }
+
+  public Object clone ()
+  {
+    DecimalFormat c = (DecimalFormat) super.clone ();
+    c.symbols = (DecimalFormatSymbols) symbols.clone ();
+    return c;
+  }
+
+  /**
+   * Constructs a <code>DecimalFormat</code> which uses the default
+   * pattern and symbols.
+   */
+  public DecimalFormat ()
+  {
+    this ("#,##0.###");
+  }
+
+  /**
+   * Constructs a <code>DecimalFormat</code> which uses the given
+   * pattern and the default symbols for formatting and parsing.
+   *
+   * @param pattern the non-localized pattern to use.
+   * @throws NullPointerException if any argument is null.
+   * @throws IllegalArgumentException if the pattern is invalid.
+   */
+  public DecimalFormat (String pattern)
+  {
+    this (pattern, new DecimalFormatSymbols ());
+  }
+
+  /**
+   * Constructs a <code>DecimalFormat</code> using the given pattern
+   * and formatting symbols.  This construction method is used to give
+   * complete control over the formatting process.  
+   *
+   * @param pattern the non-localized pattern to use.
+   * @param symbols the set of symbols used for parsing and formatting.
+   * @throws NullPointerException if any argument is null.
+   * @throws IllegalArgumentException if the pattern is invalid.
+   */
+  public DecimalFormat(String pattern, DecimalFormatSymbols symbols)
+  {
+    this.symbols = (DecimalFormatSymbols) symbols.clone();
+    applyPattern(pattern);
+  }
+
+  private boolean equals(String s1, String s2)
+  {
+    if (s1 == null || s2 == null)
+      return s1 == s2;
+    return s1.equals(s2);
+  }
+
+  /**
+   * Tests this instance for equality with an arbitrary object.  This method
+   * returns <code>true</code> if:
+   * <ul>
+   * <li><code>obj</code> is not <code>null</code>;</li>
+   * <li><code>obj</code> is an instance of <code>DecimalFormat</code>;</li>
+   * <li>this instance and <code>obj</code> have the same attributes;</li>
+   * </ul>
+   * 
+   * @param obj  the object (<code>null</code> permitted).
+   * 
+   * @return A boolean.
+   */
+  public boolean equals(Object obj)
+  {
+    if (! (obj instanceof DecimalFormat))
+      return false;
+    DecimalFormat dup = (DecimalFormat) obj;
+    return (decimalSeparatorAlwaysShown == dup.decimalSeparatorAlwaysShown 
+           && groupingUsed == dup.groupingUsed 
+           && groupingSize == dup.groupingSize 
+           && multiplier == dup.multiplier
+           && useExponentialNotation == dup.useExponentialNotation
+           && minExponentDigits == dup.minExponentDigits
+           && minimumIntegerDigits == dup.minimumIntegerDigits
+           && maximumIntegerDigits == dup.maximumIntegerDigits
+           && minimumFractionDigits == dup.minimumFractionDigits
+           && maximumFractionDigits == dup.maximumFractionDigits
+           && equals(negativePrefix, dup.negativePrefix)
+           && equals(negativeSuffix, dup.negativeSuffix)
+           && equals(positivePrefix, dup.positivePrefix)
+           && equals(positiveSuffix, dup.positiveSuffix)
+           && symbols.equals(dup.symbols));
+  }
+
+  private void formatInternal (double number, FormatBuffer dest,
+			       FieldPosition fieldPos)
+  {
+    // A very special case.
+    if (Double.isNaN(number))
+      {
+	dest.append(symbols.getNaN());
+	if (fieldPos != null && 
+	    (fieldPos.getField() == INTEGER_FIELD ||
+	     fieldPos.getFieldAttribute() == NumberFormat.Field.INTEGER))
+	  {
+	    int index = dest.length();
+	    fieldPos.setBeginIndex(index - symbols.getNaN().length());
+	    fieldPos.setEndIndex(index);
+	  }
+	return;
+      }
+		
+    boolean is_neg = number < 0;
+    if (is_neg)
+      {
+	if (negativePrefix != null)
+	  {
+	    dest.append(substituteCurrency(negativePrefix, number),
+			negativePrefixRanges, negativePrefixAttrs);
+	  }
+	else
+	  {
+	    dest.append(symbols.getMinusSign(), NumberFormat.Field.SIGN);
+	    dest.append(substituteCurrency(positivePrefix, number),
+			positivePrefixRanges, positivePrefixAttrs);
+	  }
+	number = - number;
+      }
+    else
+      {
+	dest.append(substituteCurrency(positivePrefix, number),
+		    positivePrefixRanges, positivePrefixAttrs);
+      }
+    int integerBeginIndex = dest.length();
+    int integerEndIndex = 0;
+    int zeroStart = symbols.getZeroDigit() - '0';
+		
+    if (Double.isInfinite (number))
+      {
+	dest.append(symbols.getInfinity());
+	integerEndIndex = dest.length();
+      }
+    else
+      {
+	number *= multiplier;
+	
+	// Compute exponent.
+	long exponent = 0;
+	double baseNumber;
+	if (useExponentialNotation && number > 0)
+	  {
+	    exponent = (long) Math.floor (Math.log10(number));
+	    exponent = exponent - (exponent % exponentRound);
+	    if (minimumIntegerDigits > 0)
+	      exponent -= minimumIntegerDigits - 1;
+	    baseNumber = (number / Math.pow(10.0, exponent));
+	  }
+	else
+	  baseNumber = number;
+
+	// Round to the correct number of digits.
+	baseNumber += 5 * Math.pow(10.0, - maximumFractionDigits - 1);
+
+	int index = dest.length();
+	//double intPart = Math.floor(baseNumber);
+	String intPart = Long.toString((long)Math.floor(baseNumber));
+	int count, groupPosition = intPart.length();
+
+	dest.setDefaultAttribute(NumberFormat.Field.INTEGER);
+
+	for (count = 0; count < minimumIntegerDigits-intPart.length(); count++)
+	  dest.append(symbols.getZeroDigit());
+
+	for (count = 0;
+	     count < maximumIntegerDigits && count < intPart.length();
+	     count++)
+	  {
+	    int dig = intPart.charAt(count);
+
+	    // Append group separator if required.
+	    if (groupingUsed && count > 0 && groupingSize != 0 && groupPosition % groupingSize == 0)
+	      {
+		dest.append(symbols.getGroupingSeparator(), NumberFormat.Field.GROUPING_SEPARATOR);
+		dest.setDefaultAttribute(NumberFormat.Field.INTEGER);
+	      }
+	    dest.append((char) (zeroStart + dig));
+
+	    groupPosition--;
+	  }
+	dest.setDefaultAttribute(null);
+
+	integerEndIndex = dest.length();
+	   
+	int decimal_index = integerEndIndex;
+	int consecutive_zeros = 0;
+	int total_digits = 0;
+
+	int localMaximumFractionDigits = maximumFractionDigits;
+
+	if (useExponentialNotation)
+	  localMaximumFractionDigits += minimumIntegerDigits - count;
+
+	// Strip integer part from NUMBER.
+	double fracPart = baseNumber - Math.floor(baseNumber);
+	
+	if ( ((fracPart != 0 || minimumFractionDigits > 0) && localMaximumFractionDigits > 0)
+	     || decimalSeparatorAlwaysShown)
+	  {
+	    dest.append (symbols.getDecimalSeparator(), NumberFormat.Field.DECIMAL_SEPARATOR);
+	  }
+
+	int fraction_begin = dest.length();
+	dest.setDefaultAttribute(NumberFormat.Field.FRACTION);
+	for (count = 0;
+	     count < localMaximumFractionDigits
+	       && (fracPart != 0 || count < minimumFractionDigits);
+	     ++count)
+	  {
+	    ++total_digits;
+	    fracPart *= 10;
+	    long dig = (long) fracPart;
+	    if (dig == 0)
+	      ++consecutive_zeros;
+	    else
+	      consecutive_zeros = 0;
+	    dest.append((char) (symbols.getZeroDigit() + dig));
+
+	    // Strip integer part from FRACPART.
+	    fracPart = fracPart - Math.floor (fracPart);
+	  }
+
+	// Strip extraneous trailing `0's.  We can't always detect
+	// these in the loop.
+	int extra_zeros = Math.min (consecutive_zeros,
+				    total_digits - minimumFractionDigits);
+	if (extra_zeros > 0)
+	  {
+	    dest.cutTail(extra_zeros);
+	    total_digits -= extra_zeros;
+	    if (total_digits == 0 && !decimalSeparatorAlwaysShown)
+	      dest.cutTail(1);
+	  }
+
+	if (fieldPos != null && fieldPos.getField() == FRACTION_FIELD)
+	  {
+	    fieldPos.setBeginIndex(fraction_begin);
+	    fieldPos.setEndIndex(dest.length());
+	  }
+
+	// Finally, print the exponent.
+	if (useExponentialNotation)
+	  {
+	    dest.append(symbols.getExponential(), NumberFormat.Field.EXPONENT_SYMBOL);	    
+	    if (exponent < 0)
+	      {
+		dest.append (symbols.getMinusSign (), NumberFormat.Field.EXPONENT_SIGN);
+		exponent = - exponent;
+	      }
+	    index = dest.length();
+	    dest.setDefaultAttribute(NumberFormat.Field.EXPONENT);
+	    String exponentString = Long.toString ((long) exponent);
+
+	    for (count = 0; count < minExponentDigits-exponentString.length();
+		 count++)
+	      dest.append((char) symbols.getZeroDigit());
+
+	    for (count = 0;
+		 count < exponentString.length();
+		 ++count)
+	      {
+		int dig = exponentString.charAt(count);
+		dest.append((char) (zeroStart + dig));
+	      }
+	  }
+      }
+
+    if (fieldPos != null && 
+	(fieldPos.getField() == INTEGER_FIELD ||
+	 fieldPos.getFieldAttribute() == NumberFormat.Field.INTEGER))
+      {
+	fieldPos.setBeginIndex(integerBeginIndex);
+	fieldPos.setEndIndex(integerEndIndex);
+      }
+		
+    if (is_neg && negativeSuffix != null)
+      {
+	dest.append(substituteCurrency(negativeSuffix, number),
+		    negativeSuffixRanges, negativeSuffixAttrs);
+      }
+    else
+      {
+	dest.append(substituteCurrency(positiveSuffix, number),
+		    positiveSuffixRanges, positiveSuffixAttrs);
+      }
+  }
+
+  public StringBuffer format (double number, StringBuffer dest,
+			      FieldPosition fieldPos)
+  {
+    formatInternal (number, new StringFormatBuffer(dest), fieldPos);
+    return dest;
+  }
+
+  public AttributedCharacterIterator formatToCharacterIterator (Object value)
+  {
+    AttributedFormatBuffer sbuf = new AttributedFormatBuffer();
+
+    if (value instanceof Number)
+      formatInternal(((Number) value).doubleValue(), sbuf, null);
+    else
+      throw new IllegalArgumentException 
+	("Cannot format given Object as a Number");
+    
+    sbuf.sync();
+    return new FormatCharacterIterator(sbuf.getBuffer().toString(), 
+				       sbuf.getRanges(), 
+				       sbuf.getAttributes());
+  }
+
+  public StringBuffer format (long number, StringBuffer dest,
+			      FieldPosition fieldPos)
+  {
+    // If using exponential notation, we just format as a double.
+    if (useExponentialNotation)
+       return format ((double) number, dest, fieldPos);
+
+    boolean is_neg = number < 0;
+    if (is_neg)
+      {
+	if (negativePrefix != null)
+	  dest.append(substituteCurrency(negativePrefix, number));
+	else
+	  {
+	    dest.append(symbols.getMinusSign());
+	    dest.append(substituteCurrency(positivePrefix, number));
+	  }
+	number = - number;
+      }
+    else
+      dest.append(substituteCurrency(positivePrefix, number));
+
+    int integerBeginIndex = dest.length();
+    int index = dest.length();
+    int count = 0;
+
+    /* Handle percentages, etc. */
+    number *= multiplier;
+    while (count < maximumIntegerDigits
+	   && (number > 0 || count < minimumIntegerDigits))
+      {
+	long dig = number % 10;
+	number /= 10;
+	// NUMBER and DIG will be less than 0 if the original number
+	// was the most negative long.
+	if (dig < 0)
+	  {
+	    dig = - dig;
+	    number = - number;
+	  }
+
+	// Append group separator if required.
+	if (groupingUsed && count > 0 && groupingSize != 0 && count % groupingSize == 0)
+	  dest.insert(index, symbols.getGroupingSeparator());
+
+	dest.insert(index, (char) (symbols.getZeroDigit() + dig));
+
+	++count;
+      }
+
+    if (fieldPos != null && fieldPos.getField() == INTEGER_FIELD)
+      {
+	fieldPos.setBeginIndex(integerBeginIndex);
+	fieldPos.setEndIndex(dest.length());
+      }
+
+    if (decimalSeparatorAlwaysShown || minimumFractionDigits > 0)
+      {
+	dest.append(symbols.getDecimalSeparator());
+	if (fieldPos != null && fieldPos.getField() == FRACTION_FIELD)
+	  {
+	    fieldPos.setBeginIndex(dest.length());
+	    fieldPos.setEndIndex(dest.length() + minimumFractionDigits);
+	  }
+      }
+
+    for (count = 0; count < minimumFractionDigits; ++count)
+      dest.append(symbols.getZeroDigit());
+
+    dest.append((is_neg && negativeSuffix != null)
+		? substituteCurrency(negativeSuffix, number)
+		: substituteCurrency(positiveSuffix, number));
+    return dest;
+  }
+
+  /**
+   * Returns the currency corresponding to the currency symbol stored
+   * in the instance of <code>DecimalFormatSymbols</code> used by this
+   * <code>DecimalFormat</code>.
+   *
+   * @return A new instance of <code>Currency</code> if
+   * the currency code matches a known one, null otherwise.
+   */
+  public Currency getCurrency()
+  {
+    return symbols.getCurrency();
+  }
+
+  /**
+   * Returns a copy of the symbols used by this instance.
+   * 
+   * @return A copy of the symbols.
+   */
+  public DecimalFormatSymbols getDecimalFormatSymbols()
+  {
+    return (DecimalFormatSymbols) symbols.clone();
+  }
+
+  public int getGroupingSize ()
+  {
+    return groupingSize;
+  }
+
+  public int getMultiplier ()
+  {
+    return multiplier;
+  }
+
+  public String getNegativePrefix ()
+  {
+    return negativePrefix;
+  }
+
+  public String getNegativeSuffix ()
+  {
+    return negativeSuffix;
+  }
+
+  public String getPositivePrefix ()
+  {
+    return positivePrefix;
+  }
+
+  public String getPositiveSuffix ()
+  {
+    return positiveSuffix;
+  }
+
+  /**
+   * Returns a hash code for this object.
+   *
+   * @return A hash code.
+   */
+  public int hashCode()
+  {
+    return toPattern().hashCode();
+  }
+
+  public boolean isDecimalSeparatorAlwaysShown ()
+  {
+    return decimalSeparatorAlwaysShown;
+  }
+
+  public Number parse (String str, ParsePosition pos)
+  {
+    /*
+     * Our strategy is simple: copy the text into separate buffers: one for the int part,
+     * one for the fraction part and for the exponential part.
+     * We translate or omit locale-specific information.  
+     * If exponential is sufficiently big we merge the fraction and int part and
+     * remove the '.' and then we use Long to convert the number. In the other
+     * case, we use Double to convert the full number.
+     */
+
+    boolean is_neg = false;
+    int index = pos.getIndex();
+    StringBuffer int_buf = new StringBuffer ();
+        
+    // We have to check both prefixes, because one might be empty.  We
+    // want to pick the longest prefix that matches.
+    boolean got_pos = str.startsWith(positivePrefix, index);
+    String np = (negativePrefix != null
+		 ? negativePrefix
+		 : positivePrefix + symbols.getMinusSign());
+    boolean got_neg = str.startsWith(np, index);
+
+    if (got_pos && got_neg)
+      {
+	// By checking this way, we preserve ambiguity in the case
+	// where the negative format differs only in suffix.  We
+	// check this again later.
+	if (np.length() > positivePrefix.length())
+	  {
+	    is_neg = true;
+	    index += np.length();
+	  }
+	else
+	  index += positivePrefix.length();
+      }
+    else if (got_neg)
+      {
+	is_neg = true;
+	index += np.length();
+      }
+    else if (got_pos)
+      index += positivePrefix.length();
+    else
+      {
+	pos.setErrorIndex (index);
+	return null;
+      }
+
+    // FIXME: handle Inf and NaN.
+
+    // FIXME: do we have to respect minimum digits?
+    // What about multiplier?
+
+    StringBuffer buf = int_buf;
+    StringBuffer frac_buf = null;
+    StringBuffer exp_buf = null;
+    int start_index = index;
+    int max = str.length();
+    int exp_index = -1;
+    int last = index + maximumIntegerDigits; 
+
+    if (maximumFractionDigits > 0)
+      last += maximumFractionDigits + 1;
+    
+    if (useExponentialNotation)
+      last += minExponentDigits + 1;
+
+    if (last > 0 && max > last)
+      max = last;
+
+    char zero = symbols.getZeroDigit();
+    int last_group = -1;
+    boolean int_part = true;
+    boolean exp_part = false;
+    for (; index < max; ++index)
+      {
+	char c = str.charAt(index);
+
+	// FIXME: what about grouping size?
+	if (groupingUsed && c == symbols.getGroupingSeparator())
+	  {
+	    if (last_group != -1 
+		&& groupingSize != 0  
+		&& (index - last_group) % groupingSize != 0)
+	      {
+		pos.setErrorIndex(index);
+		return null;
+	      }
+	    last_group = index+1;
+	  }
+	else if (c >= zero && c <= zero + 9)
+	  {
+	    buf.append((char) (c - zero + '0'));
+	  }
+	else if (parseIntegerOnly)
+	  break;
+	else if (c == symbols.getDecimalSeparator())
+	  {
+	    if (last_group != -1 
+		&& groupingSize != 0 
+		&& (index - last_group) % groupingSize != 0)
+	      {
+		pos.setErrorIndex(index);
+		return null;
+	      }
+	    buf = frac_buf = new StringBuffer();
+	    frac_buf.append('.');
+	    int_part = false;
+	  }
+	else if (c == symbols.getExponential())
+	  {
+	    buf = exp_buf = new StringBuffer();
+	    int_part = false;
+	    exp_part = true;
+	    exp_index = index+1;
+	  }
+	else if (exp_part
+		 && (c == '+' || c == '-' || c == symbols.getMinusSign()))
+	  {
+	    // For exponential notation.
+	    buf.append(c);
+	  }
+	else
+	  break;
+      }
+
+    if (index == start_index)
+      {
+	// Didn't see any digits.
+	pos.setErrorIndex(index);
+	return null;
+      }
+
+    // Check the suffix.  We must do this before converting the
+    // buffer to a number to handle the case of a number which is
+    // the most negative Long.
+    boolean got_pos_suf = str.startsWith(positiveSuffix, index);
+    String ns = (negativePrefix == null ? positiveSuffix : negativeSuffix);
+    boolean got_neg_suf = str.startsWith(ns, index);
+    if (is_neg)
+      {
+	if (! got_neg_suf)
+	  {
+	    pos.setErrorIndex(index);
+	    return null;
+	  }
+      }
+    else if (got_pos && got_neg && got_neg_suf)
+      {
+	is_neg = true;
+      }
+    else if (got_pos != got_pos_suf && got_neg != got_neg_suf)
+      {
+	pos.setErrorIndex(index);
+	return null;
+      }
+    else if (! got_pos_suf)
+      {
+       pos.setErrorIndex(index);
+       return null;
+      }
+
+    String suffix = is_neg ? ns : positiveSuffix;
+    long parsedMultiplier = 1;
+    boolean use_long;
+
+    if (is_neg)
+      int_buf.insert(0, '-');
+
+    // Now handle the exponential part if there is one.
+    if (exp_buf != null)
+      {
+	int exponent_value;
+
+	try
+	  {
+	    exponent_value = Integer.parseInt(exp_buf.toString());
+	  }
+	catch (NumberFormatException x1)
+	  {
+	    pos.setErrorIndex(exp_index);
+	    return null;
+	  }
+
+	if (frac_buf == null)
+	  {
+	    // We only have to add some zeros to the int part.
+	    // Build a multiplier.
+	    for (int i = 0; i < exponent_value; i++)
+	      int_buf.append('0');
+	    
+	    use_long = true;
+	  }
+	else
+	  {
+	    boolean long_sufficient;
+
+	    if (exponent_value < frac_buf.length()-1)
+	      {
+		int lastNonNull = -1;
+		/* We have to check the fraction buffer: it may only be full of '0'
+		 * or be sufficiently filled with it to convert the number into Long.
+		 */
+		for (int i = 1; i < frac_buf.length(); i++)
+		  if (frac_buf.charAt(i) != '0')
+		    lastNonNull = i;
+
+		long_sufficient = (lastNonNull < 0 || lastNonNull <= exponent_value);
+	      }
+	    else
+	      long_sufficient = true;
+	    
+	    if (long_sufficient)
+	      {
+		for (int i = 1; i < frac_buf.length() && i < exponent_value; i++)
+		  int_buf.append(frac_buf.charAt(i));
+		for (int i = frac_buf.length()-1; i < exponent_value; i++)
+		  int_buf.append('0');
+		use_long = true;
+	      }
+	    else
+	      {
+		/*
+		 * A long type is not sufficient, we build the full buffer to
+		 * be parsed by Double.
+		 */
+		int_buf.append(frac_buf);
+		int_buf.append('E');
+		int_buf.append(exp_buf);
+		use_long = false;
+	      }
+	  }
+      }
+    else
+      {
+	if (frac_buf != null)
+	  {
+	    /* Check whether the fraction buffer contains only '0' */
+	    int i;
+	    for (i = 1; i < frac_buf.length(); i++)
+	      if (frac_buf.charAt(i) != '0')
+		break;
+	   
+	    if (i != frac_buf.length())
+	      {
+		use_long = false;
+		int_buf.append(frac_buf);
+	      }
+	    else
+	      use_long = true;
+	  }
+	else
+	  use_long = true;
+      }
+
+    String t = int_buf.toString();
+    Number result = null;
+    if (use_long)
+      {
+	try
+	  {
+	    result = new Long (t);
+	  }
+	catch (NumberFormatException x1)
+	  {
+	  }
+      }
+    else
+      {
+	try
+	  {
+	    result = new Double (t);
+	  }
+	catch (NumberFormatException x2)
+	  {
+	  }
+      }
+    if (result == null)
+      {
+	pos.setErrorIndex(index);
+	return null;
+      }
+
+    pos.setIndex(index + suffix.length());
+
+    return result;
+  }
+
+  /**
+   * Sets the <code>Currency</code> on the
+   * <code>DecimalFormatSymbols</code> used, which also sets the
+   * currency symbols on those symbols.
+   */
+  public void setCurrency(Currency currency)
+  {
+    symbols.setCurrency(currency);
+  }
+
+  /**
+   * Sets the symbols used by this instance.  This method makes a copy of 
+   * the supplied symbols.
+   * 
+   * @param newSymbols  the symbols (<code>null</code> not permitted).
+   */
+  public void setDecimalFormatSymbols(DecimalFormatSymbols newSymbols)
+  {
+    symbols = (DecimalFormatSymbols) newSymbols.clone();
+  }
+
+  public void setDecimalSeparatorAlwaysShown (boolean newValue)
+  {
+    decimalSeparatorAlwaysShown = newValue;
+  }
+
+  public void setGroupingSize (int groupSize)
+  {
+    groupingSize = (byte) groupSize;
+  }
+
+  public void setMaximumFractionDigits (int newValue)
+  {
+    super.setMaximumFractionDigits(Math.min(newValue, 340));
+  }
+
+  public void setMaximumIntegerDigits (int newValue)
+  {
+    super.setMaximumIntegerDigits(Math.min(newValue, 309));
+  }
+
+  public void setMinimumFractionDigits (int newValue)
+  {
+    super.setMinimumFractionDigits(Math.min(newValue, 340));
+  }
+
+  public void setMinimumIntegerDigits (int newValue)
+  {
+    super.setMinimumIntegerDigits(Math.min(newValue, 309));
+  }
+
+  public void setMultiplier (int newValue)
+  {
+    multiplier = newValue;
+  }
+
+  public void setNegativePrefix (String newValue)
+  {
+    negativePrefix = newValue;
+  }
+
+  public void setNegativeSuffix (String newValue)
+  {
+    negativeSuffix = newValue;
+  }
+
+  public void setPositivePrefix (String newValue)
+  {
+    positivePrefix = newValue;
+  }
+
+  public void setPositiveSuffix (String newValue)
+  {
+    positiveSuffix = newValue;
+  }
+
+  private void quoteFix(StringBuffer buf, String text, String patChars)
+  {
+    int len = text.length();
+    for (int index = 0; index < len; ++index)
+      {
+	char c = text.charAt(index);
+	if (patChars.indexOf(c) != -1)
+	  {
+	    buf.append('\'');
+	    buf.append(c);
+	    buf.append('\'');
+	  }
+	else
+	  buf.append(c);
+      }
+  }
+
+  private String computePattern(DecimalFormatSymbols syms)
+  {
+    StringBuffer mainPattern = new StringBuffer ();
+    // We have to at least emit a zero for the minimum number of
+    // digits.  Past that we need hash marks up to the grouping
+    // separator (and one beyond).
+    int total_digits = Math.max(minimumIntegerDigits,
+				groupingUsed ? groupingSize + 1: groupingSize);
+    for (int i = 0; i < total_digits - minimumIntegerDigits; ++i)
+      mainPattern.append(syms.getDigit());
+    for (int i = total_digits - minimumIntegerDigits; i < total_digits; ++i)
+      mainPattern.append(syms.getZeroDigit());
+    // Inserting the gropuing operator afterwards is easier.
+    if (groupingUsed)
+      mainPattern.insert(mainPattern.length() - groupingSize,
+			 syms.getGroupingSeparator());
+    // See if we need decimal info.
+    if (minimumFractionDigits > 0 || maximumFractionDigits > 0
+	|| decimalSeparatorAlwaysShown)
+      mainPattern.append(syms.getDecimalSeparator());
+    for (int i = 0; i < minimumFractionDigits; ++i)
+      mainPattern.append(syms.getZeroDigit());
+    for (int i = minimumFractionDigits; i < maximumFractionDigits; ++i)
+      mainPattern.append(syms.getDigit());
+    if (useExponentialNotation)
+      {
+	mainPattern.append(syms.getExponential());
+	for (int i = 0; i < minExponentDigits; ++i)
+	  mainPattern.append(syms.getZeroDigit());
+	if (minExponentDigits == 0)
+	  mainPattern.append(syms.getDigit());
+      }
+
+    String main = mainPattern.toString();
+    String patChars = patternChars (syms);
+    mainPattern.setLength(0);
+
+    quoteFix (mainPattern, positivePrefix, patChars);
+    mainPattern.append(main);
+    quoteFix (mainPattern, positiveSuffix, patChars);
+
+    if (negativePrefix != null)
+      {
+	quoteFix (mainPattern, negativePrefix, patChars);
+	mainPattern.append(main);
+	quoteFix (mainPattern, negativeSuffix, patChars);
+      }
+
+    return mainPattern.toString();
+  }
+
+  public String toLocalizedPattern ()
+  {
+    return computePattern (symbols);
+  }
+
+  public String toPattern ()
+  {
+    return computePattern (nonLocalizedSymbols);
+  }
+
+  private static final int MAXIMUM_INTEGER_DIGITS = 309; 
+
+  // These names are fixed by the serialization spec.
+  private boolean decimalSeparatorAlwaysShown;
+  private byte groupingSize;
+  private byte minExponentDigits;
+  private int exponentRound;
+  private int multiplier;
+  private String negativePrefix;
+  private String negativeSuffix;
+  private String positivePrefix;
+  private String positiveSuffix;
+  private int[] negativePrefixRanges, positivePrefixRanges;
+  private HashMap[] negativePrefixAttrs, positivePrefixAttrs;
+  private int[] negativeSuffixRanges, positiveSuffixRanges;
+  private HashMap[] negativeSuffixAttrs, positiveSuffixAttrs;
+  private int serialVersionOnStream = 1;
+  private DecimalFormatSymbols symbols;
+  private boolean useExponentialNotation;
+  private static final long serialVersionUID = 864413376551465018L;
+
+  private void readObject(ObjectInputStream stream)
+    throws IOException, ClassNotFoundException
+  {
+    stream.defaultReadObject();
+    if (serialVersionOnStream < 1)
+      {
+        useExponentialNotation = false;
+	serialVersionOnStream = 1;
+      }
+  }
+
+  // The locale-independent pattern symbols happen to be the same as
+  // the US symbols.
+  private static final DecimalFormatSymbols nonLocalizedSymbols
+    = new DecimalFormatSymbols (Locale.US);
+
+  /**
+   * <p>
+   * Substitutes the currency symbol into the given string,
+   * based on the value used.  Currency symbols can either
+   * be a simple series of characters (e.g. '$'), which are
+   * simply used as is, or they can be of a more complex
+   * form:
+   * </p>
+   * <p>
+   * (lower bound)|(mid value)|(upper bound)
+   * </p>
+   * <p>
+   * where each bound has the syntax '(value)(# or <)(symbol)',
+   * to indicate the bounding value and the symbol used.
+   * </p>
+   * <p>
+   * The currency symbol replaces the currency specifier, '\u00a4',
+   * an unlocalised character, which thus is used as such in all formats.
+   * If this symbol occurs twice, the international currency code is used
+   * instead.
+   * </p>
+   *
+   * @param string The string containing the currency specifier, '\u00a4'.
+   * @param number the number being formatted.
+   * @return a string formatted for the correct currency.
+   */
+  private String substituteCurrency(String string, double number)
+  {
+    int index;
+    int length;
+    char currentChar;
+    StringBuffer buf;
+    
+    index = 0;
+    length = string.length();
+    buf = new StringBuffer();
+    
+    while (index < length)
+      {
+	currentChar = string.charAt(index);
+	if (string.charAt(index) == '\u00a4')
+	  {
+	    if ((index + 1) < length && string.charAt(index + 1) == '\u00a4')
+	      {
+		buf.append(symbols.getInternationalCurrencySymbol());
+		index += 2;
+	      }
+	    else
+	      {
+		String symbol;
+		
+		symbol = symbols.getCurrencySymbol();
+		if (symbol.startsWith("="))
+		  {
+		    String[] bounds;
+		    int[] boundValues;
+		    String[] boundSymbols;
+		    
+		    bounds = symbol.substring(1).split("\\|");
+		    boundValues = new int[3];
+		    boundSymbols = new String[3];
+		    for (int a = 0; a < 3; ++a)
+		      {
+			String[] bound;
+			
+			bound = bounds[a].split("[#<]");
+			boundValues[a] = Integer.parseInt(bound[0]);
+			boundSymbols[a] = bound[1];
+		      }
+		    if (number <= boundValues[0])
+		      {
+			buf.append(boundSymbols[0]);
+		      }
+		    else if (number >= boundValues[2])
+		      {
+			buf.append(boundSymbols[2]);
+		      }
+		    else 
+		      {
+			buf.append(boundSymbols[1]);
+		      }
+		    ++index;
+		  }
+		else
+		  {
+		    buf.append(symbol);
+		    ++index;
+		  }
+	      }
+	  }
+	else
+	  {
+	    buf.append(string.charAt(index));
+	    ++index;
+	  }
+      }
+    return buf.toString();
+  }
+  
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/DecimalFormatSymbols.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/DecimalFormatSymbols.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/DecimalFormatSymbols.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/DecimalFormatSymbols.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,687 @@
+/* DecimalFormatSymbols.java -- Format symbols used by DecimalFormat
+   Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+import java.util.Currency;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * This class is a container for the symbols used by 
+ * <code>DecimalFormat</code> to format numbers and currency
+ * for a particular locale.  These are
+ * normally handled automatically, but an application can override
+ * values as desired using this class.
+ *
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @date February 24, 1999
+ * @see java.text.DecimalFormat
+ */
+/* Written using "Java Class Libraries", 2nd edition, plus online
+ * API docs for JDK 1.2 from http://www.javasoft.com.
+ * Status:  Believed complete and correct to 1.2.
+ */
+public final class DecimalFormatSymbols implements Cloneable, Serializable
+{
+  public Object clone ()
+  {
+    try
+      {
+	return super.clone ();
+      }
+    catch(CloneNotSupportedException e)
+      {
+	return null;
+      }
+  }
+
+  /**
+   * This method initializes a new instance of
+   * <code>DecimalFormatSymbols</code> for the default locale.
+   */
+  public DecimalFormatSymbols ()
+  {
+    this (Locale.getDefault());
+  }
+
+  /**
+   * Retrieves a valid string, either using the supplied resource
+   * bundle or the default value.
+   *
+   * @param bundle the resource bundle to use to find the string.
+   * @param name key for the string in the resource bundle.
+   * @param def default value for the string.
+   */
+  private String safeGetString(ResourceBundle bundle,
+                               String name, String def)
+  {
+    if (bundle != null)
+      {
+	try
+	  {
+	    return bundle.getString(name);
+	  }
+	catch (MissingResourceException x)
+	  {
+	  }
+      }
+    return def;
+  }
+
+  private char safeGetChar(ResourceBundle bundle,
+                           String name, char def)
+  {
+    String r = null;
+    if (bundle != null)
+      {
+	try
+	  {
+	    r = bundle.getString(name);
+	  }
+	catch (MissingResourceException x)
+	  {
+	  }
+      }
+    if (r == null || r.length() < 1)
+      return def;
+    return r.charAt(0);
+  }
+
+  /**
+   * This method initializes a new instance of
+   * <code>DecimalFormatSymbols</code> for the specified locale.
+   * <strong>Note</strong>: if the locale does not have an associated
+   * <code>Currency</code> instance, the currency symbol and
+   * international currency symbol will be set to the strings "?"
+   * and "XXX" respectively.  This generally happens with language
+   * locales (those with no specified country), such as
+   * <code>Locale.ENGLISH</code>.
+   *
+   * @param loc The local to load symbols for.
+   * @throws NullPointerException if the locale is null.
+   */
+  public DecimalFormatSymbols (Locale loc)
+  {
+    ResourceBundle res;
+
+    currency = Currency.getInstance("XXX");
+    currencySymbol = "?";
+    intlCurrencySymbol = "XXX";
+    try
+      {
+	res = ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
+		loc, ClassLoader.getSystemClassLoader());
+      }
+    catch (MissingResourceException x)
+      {
+	res = null;
+      }
+    try
+      {
+	Currency localeCurrency = Currency.getInstance(loc);
+	if (localeCurrency != null)
+	  {
+	    setCurrency(localeCurrency);
+	  }
+      }
+    catch(IllegalArgumentException exception)
+      {
+	/* Locale has an invalid currency */
+      }
+    decimalSeparator = safeGetChar (res, "decimalSeparator", '.');
+    digit = safeGetChar (res, "digit", '#');
+    exponential = safeGetChar (res, "exponential", 'E');
+    groupingSeparator = safeGetChar (res, "groupingSeparator", ',');
+    infinity = safeGetString (res, "infinity", "\u221e");
+    try
+      {
+	monetarySeparator = safeGetChar (res, "monetarySeparator", '.');
+      }
+    catch (MissingResourceException x)
+      {
+	monetarySeparator = decimalSeparator;
+      }
+    minusSign = safeGetChar (res, "minusSign", '-');
+    NaN = safeGetString (res, "NaN", "\ufffd");
+    patternSeparator = safeGetChar (res, "patternSeparator", ';');
+    percent = safeGetChar (res, "percent", '%');
+    perMill = safeGetChar (res, "perMill", '\u2030');
+    zeroDigit = safeGetChar (res, "zeroDigit", '0');
+    locale = loc;
+  }
+
+  /**
+   * This method this this object for equality against the specified object.
+   * This will be true if and only if the following criteria are met with
+   * regard to the specified object:
+   * <p>
+   * <ul>
+   * <li>It is not <code>null</code>.</li>
+   * <li>It is an instance of <code>DecimalFormatSymbols</code>.</li>
+   * <li>All of its symbols are identical to the symbols in this object.</li>
+   * </ul>
+   *
+   * @return <code>true</code> if the specified object is equal to this
+   * object, <code>false</code> otherwise.
+   */
+  public boolean equals (Object obj)
+  {
+    if (! (obj instanceof DecimalFormatSymbols))
+      return false;
+    DecimalFormatSymbols dfs = (DecimalFormatSymbols) obj;
+    return (currencySymbol.equals(dfs.currencySymbol)
+	    && decimalSeparator == dfs.decimalSeparator
+	    && digit == dfs.digit
+	    && exponential == dfs.exponential
+	    && groupingSeparator == dfs.groupingSeparator
+	    && infinity.equals(dfs.infinity)
+	    && intlCurrencySymbol.equals(dfs.intlCurrencySymbol)
+	    && minusSign == dfs.minusSign
+	    && monetarySeparator == dfs.monetarySeparator
+	    && NaN.equals(dfs.NaN)
+	    && patternSeparator == dfs.patternSeparator
+	    && percent == dfs.percent
+	    && perMill == dfs.perMill
+	    && zeroDigit == dfs.zeroDigit);
+  }
+
+  /**
+   * Returns the currency corresponding to the currency symbol stored
+   * in this instance of <code>DecimalFormatSymbols</code>.
+   *
+   * @return An instance of <code>Currency</code> which matches
+   *         the currency used, or null if there is no corresponding
+   *         instance.
+   */
+  public Currency getCurrency ()
+  {
+    return currency;
+  }
+
+  /**
+   * This method returns the currency symbol in local format.  For example,
+   * "$" for Canadian dollars.
+   *
+   * @return The currency symbol in local format.
+   */
+  public String getCurrencySymbol ()
+  {
+    return currencySymbol;
+  }
+
+  /**
+   * This method returns the character used as the decimal point.
+   *
+   * @return The character used as the decimal point.
+   */
+  public char getDecimalSeparator ()
+  {
+    return decimalSeparator;
+  }
+
+  /**
+   * This method returns the character used to represent a digit in a
+   * format pattern string.
+   *
+   * @return The character used to represent a digit in a format
+   * pattern string. 
+   */
+  public char getDigit ()
+  {
+    return digit;
+  }
+
+  /**
+   * This method returns the character used to represent the exponential
+   * format.  This is a GNU Classpath extension.
+   *
+   * @return the character used to represent an exponential in a format
+   *         pattern string.
+   */
+  char getExponential ()
+  {
+    return exponential;
+  }
+
+  /**
+   * This method sets the character used to separate groups of digits.  For
+   * example, the United States uses a comma (,) to separate thousands in
+   * a number.
+   *
+   * @return The character used to separate groups of digits.
+   */
+  public char getGroupingSeparator ()
+  {
+    return groupingSeparator;
+  }
+
+  /**
+   * This method returns the character used to represent infinity.
+   *
+   * @return The character used to represent infinity.
+   */
+  public String getInfinity ()
+  {
+    return infinity;
+  }
+
+  /**
+   * This method returns the ISO 4217 currency code for
+   * the currency used.
+   *
+   * @return the ISO 4217 currency code.
+   */
+  public String getInternationalCurrencySymbol ()
+  {
+    return intlCurrencySymbol;
+  }
+
+  /**
+   * This method returns the character used to represent the minus sign.
+   *
+   * @return The character used to represent the minus sign.
+   */
+  public char getMinusSign ()
+  {
+    return minusSign;
+  }
+
+  /**
+   * This method returns the character used to represent the decimal
+   * point for currency values.
+   *
+   * @return The decimal point character used in currency values.
+   */
+  public char getMonetaryDecimalSeparator ()
+  {
+    return monetarySeparator;
+  }
+
+  /**
+   * This method returns the string used to represent the NaN (not a number)
+   * value.
+   *
+   * @return The string used to represent NaN
+   */
+  public String getNaN ()
+  {
+    return NaN;
+  }
+
+  /**
+   * This method returns the character used to separate positive and negative
+   * subpatterns in a format pattern.
+   *
+   * @return The character used to separate positive and negative subpatterns
+   * in a format pattern.
+   */
+  public char getPatternSeparator ()
+  {
+    return patternSeparator;
+  }
+
+  /**
+   * This method returns the character used as the percent sign.
+   *
+   * @return The character used as the percent sign.
+   */
+  public char getPercent ()
+  {
+    return percent;
+  }
+
+  /**
+   * This method returns the character used as the per mille character.
+   *
+   * @return The per mille character.
+   */
+  public char getPerMill ()
+  {
+    return perMill;
+  }
+
+  /**
+   * This method returns the character used to represent the digit zero.
+   *
+   * @return The character used to represent the digit zero.
+   */
+  public char getZeroDigit ()
+  {
+    return zeroDigit;
+  }
+
+  /**
+   * This method returns a hash value for this object.
+   *
+   * @return A hash value for this object.
+   */
+  public int hashCode ()
+  {
+    // Compute based on zero digit, grouping separator, and decimal
+    // separator -- JCL book.  This probably isn't a very good hash
+    // code.
+    return zeroDigit << 16 + groupingSeparator << 8 + decimalSeparator;
+  }
+
+  /**
+   * This method sets the currency symbol and ISO 4217 currency
+   * code to the values obtained from the supplied currency.
+   *
+   * @param currency the currency from which to obtain the values.
+   * @throws NullPointerException if the currency is null.
+   */
+  public void setCurrency (Currency currency)
+  {
+    intlCurrencySymbol = currency.getCurrencyCode();
+    currencySymbol = currency.getSymbol();
+    this.currency = currency;
+  }
+
+  /**
+   * This method sets the currency symbol to the specified value.
+   *
+   * @param currency The new currency symbol
+   */
+  public void setCurrencySymbol (String currency)
+  {
+    currencySymbol = currency;
+  }
+
+  /**
+   * This method sets the decimal point character to the specified value.
+   *
+   * @param decimalSep The new decimal point character
+   */
+  public void setDecimalSeparator (char decimalSep)
+  {
+    decimalSeparator = decimalSep;
+  }
+
+  /**
+   * This method sets the character used to represents a digit in a format
+   * string to the specified value.
+   *
+   * @param digit The character used to represent a digit in a format pattern.
+   */
+  public void setDigit (char digit)
+  {
+    this.digit = digit;
+  }
+
+  /**
+   * This method sets the exponential character used in the format string to
+   * the specified value.  This is a GNU Classpath extension.
+   *
+   * @param exp the character used for the exponential in a format pattern.
+   */
+  void setExponential (char exp)
+  {
+    exponential = exp;
+  }
+
+  /**
+   * This method sets the character used to separate groups of digits.
+   *
+   * @param groupSep The character used to separate groups of digits.
+   */
+  public void setGroupingSeparator (char groupSep)
+  {
+    groupingSeparator = groupSep;
+  }
+
+  /**
+   * This method sets the string used to represents infinity.
+   *
+   * @param infinity The string used to represent infinity.
+   */
+  public void setInfinity (String infinity)
+  {
+    this.infinity = infinity;
+  }
+
+  /**
+   * This method sets the international currency symbol to the
+   * specified value. If a valid <code>Currency</code> instance
+   * exists for the international currency code, then this is
+   * used for the currency attribute, and the currency symbol
+   * is set to the corresponding value from this instance.
+   * Otherwise, the currency attribute is set to null and the
+   * symbol is left unmodified. 
+   *
+   * @param currencyCode The new international currency symbol.
+   */
+  public void setInternationalCurrencySymbol (String currencyCode)
+  {
+    intlCurrencySymbol = currencyCode;
+    try
+      {
+	currency = Currency.getInstance(currencyCode);
+      }
+    catch (IllegalArgumentException exception)
+      {
+	currency = null;
+      }
+    if (currency != null)
+      {
+        setCurrencySymbol(currency.getSymbol(locale));
+      }
+  }
+
+  /**
+   * This method sets the character used to represent the minus sign.
+   *
+   * @param minusSign The character used to represent the minus sign.
+   */
+  public void setMinusSign (char minusSign)
+  {
+    this.minusSign = minusSign;
+  }
+
+  /**
+   * This method sets the character used for the decimal point in currency
+   * values.
+   *
+   * @param decimalSep The decimal point character used in currency values. 
+   */
+  public void setMonetaryDecimalSeparator (char decimalSep)
+  {
+    monetarySeparator = decimalSep;
+  }
+
+  /**
+   * This method sets the string used to represent the NaN (not a
+   * number) value. 
+   *
+   * @param nan The string used to represent NaN
+   */
+  public void setNaN (String nan)
+  {
+    NaN = nan;
+  }
+
+  /**
+   * This method sets the character used to separate positive and negative
+   * subpatterns in a format pattern.
+   *
+   * @param patternSep The character used to separate positive and
+   * negative subpatterns in a format pattern.
+   */
+  public void setPatternSeparator (char patternSep)
+  {
+    patternSeparator = patternSep;
+  }
+
+  /**
+   * This method sets the character used as the percent sign.
+   *
+   * @param percent  The character used as the percent sign.
+   */
+  public void setPercent (char percent)
+  {
+    this.percent = percent;
+  }
+
+  /**
+   * This method sets the character used as the per mille character.
+   *
+   * @param perMill The per mille character.
+   */
+  public void setPerMill (char perMill)
+  {
+    this.perMill = perMill;
+  }
+
+  /**
+   * This method sets the character used to represent the digit zero.
+   *
+   * @param zeroDigit The character used to represent the digit zero.
+   */
+  public void setZeroDigit (char zeroDigit)
+  {
+    this.zeroDigit = zeroDigit;
+  }
+
+  /**
+   * @serial A string used for the local currency
+   */
+  private String currencySymbol;
+  /**
+   * @serial The <code>char</code> used to separate decimals in a number.
+   */
+  private char decimalSeparator;
+  /**
+   * @serial This is the <code>char</code> used to represent a digit in
+   * a format specification.
+   */
+  private char digit;
+  /**
+   * @serial This is the <code>char</code> used to represent the exponent
+   * separator in exponential notation.
+   */
+  private char exponential;
+  /**
+   * @serial This separates groups of thousands in numbers.
+   */
+  private char groupingSeparator;
+  /**
+   * @serial This string represents infinity.
+   */
+  private String infinity;
+  /**
+   * @serial This string represents the local currency in an international
+   * context, eg, "C$" for Canadian dollars.
+   */
+  private String intlCurrencySymbol;
+  /**
+   * @serial This is the character used to represent the minus sign.
+   */
+  private char minusSign;
+  /**
+   * @serial This character is used to separate decimals when formatting
+   * currency values.
+   */
+  private char monetarySeparator;
+  /**
+   * @serial This string is used the represent the Java NaN value for
+   * "not a number".
+   */
+  private String NaN;
+  /**
+   * @serial This is the character used to separate positive and negative
+   * subpatterns in a format pattern.
+   */
+  private char patternSeparator;
+  /**
+   * @serial This is the percent symbols
+   */
+  private char percent;
+  /**
+   * @serial This character is used for the mille percent sign.
+   */
+  private char perMill;
+  /**
+   * @serial This value represents the type of object being de-serialized.
+   * 0 indicates a pre-Java 1.1.6 version, 1 indicates 1.1.6 or later.
+   * 0 indicates a pre-Java 1.1.6 version, 1 indicates 1.1.6 or later,
+   * 2 indicates 1.4 or later
+    */
+  private int serialVersionOnStream = 2;
+  /**
+   * @serial This is the character used to represent 0.
+   */
+  private char zeroDigit;
+
+  /**
+   * @serial The locale of these currency symbols.
+   */
+  private Locale locale;
+
+  /**
+   * The currency used for the symbols in this instance.
+   * This is stored temporarily for efficiency reasons,
+   * as well as to ensure that the correct instance
+   * is restored from the currency code.
+   *
+   * @serial Ignored.
+   */
+  private transient Currency currency;
+
+  private static final long serialVersionUID = 5772796243397350300L;
+
+  private void readObject(ObjectInputStream stream)
+    throws IOException, ClassNotFoundException
+  {
+    stream.defaultReadObject();
+    if (serialVersionOnStream < 1)
+      {
+        monetarySeparator = decimalSeparator;
+	exponential = 'E';
+      }
+    if (serialVersionOnStream < 2)
+	locale = Locale.getDefault();
+
+    serialVersionOnStream = 2;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/FieldPosition.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/FieldPosition.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/FieldPosition.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/FieldPosition.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,232 @@
+/* FieldPosition.java -- Keeps track of field positions while formatting
+   Copyright (C) 1998, 1999, 2001, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+/**
+ * This class is used by the java.text formatting classes to track
+ * field positions.  A field position is defined by an identifier value
+ * and begin and end index positions.  The formatting classes in java.text
+ * typically define constant values for the field identifiers.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Per Bothner (bothner at cygnus.com)
+ */
+public class FieldPosition
+{
+  /**
+   * This is the field identifier value.
+   */
+  private int field_id;
+
+  /**
+   * This is the beginning index of the field.
+   */
+  private int begin;
+
+  /**
+   * This is the ending index of the field.
+   */
+  private int end;
+
+  /**
+   * This is the field attribute value.
+   */
+  private Format.Field field_attribute;
+
+  /**
+   * This method initializes a new instance of <code>FieldPosition</code>
+   * to have the specified field attribute. The attribute will be used as
+   * an id. It is formally equivalent to calling FieldPosition(field, -1).
+   *
+   * @param field The field format attribute.
+   */
+  public FieldPosition (Format.Field field)
+  {
+    this(field, -1);
+  }
+
+  /**
+   * This method initializes a new instance of <code>FieldPosition</code>
+   * to have the specified field attribute. The attribute will be used as
+   * an id is non null. The integer field id is only used if the Format.Field
+   * attribute is not used by the formatter.
+   *
+   * @param field The field format attribute.
+   * @param field_id The field identifier value.
+   */
+  public FieldPosition (Format.Field field, int field_id)
+  {
+    this.field_attribute = field;
+    this.field_id = field_id;
+  }
+
+  /**
+   * This method initializes a new instance of <code>FieldPosition</code> to
+   * have the specified field id.
+   *
+   * @param field_id The field identifier value.
+   */
+  public FieldPosition (int field_id)
+  {
+    this.field_id = field_id;
+  }
+
+  /**
+   * This method returns the field identifier value for this object.
+   *
+   * @return The field identifier.
+   */
+  public int getField ()
+  {
+    return field_id;
+  }
+
+  public Format.Field getFieldAttribute ()
+  {
+    return field_attribute;
+  }
+
+  /**
+   * This method returns the beginning index for this field.
+   *
+   * @return The beginning index.
+   */
+  public int getBeginIndex ()
+  {
+    return begin;
+  }
+
+  /**
+   * This method sets the beginning index of this field to the specified value.
+   *
+   * @param begin The new beginning index.
+   */
+  public void setBeginIndex (int begin)
+  {
+    this.begin = begin;
+  }
+
+  /**
+   * This method returns the ending index for the field.
+   *
+   * @return The ending index.
+   */
+  public int getEndIndex ()
+  {
+    return end;
+  }
+
+  /**
+   * This method sets the ending index of this field to the specified value.
+   *
+   * @param end The new ending index.
+   */
+  public void setEndIndex (int end)
+  {
+    this.end = end;
+  }
+
+  /**
+   * This method tests this object for equality against the specified object.
+   * The objects will be considered equal if and only if:
+   * <p>
+   * <ul>
+   * <li>The specified object is not <code>null</code>.
+   * <li>The specified object has the same class as this object.
+   * <li>The specified object has the same field identifier, field attribute 
+   * and beginning and ending index as this object.
+   * </ul>
+   *
+   * @param obj The object to test for equality to this object.
+   *
+   * @return <code>true</code> if the specified object is equal to
+   * this object, <code>false</code> otherwise. 
+   */
+  public boolean equals (Object obj)
+  {
+    if (this == obj)
+      return true;
+
+    if (obj == null || obj.getClass() != this.getClass())
+      return false;
+
+    FieldPosition fp = (FieldPosition) obj;
+    return (field_id == fp.field_id
+	    && (field_attribute == fp.field_attribute 
+		|| (field_attribute != null 
+		    && field_attribute.equals(fp.field_attribute)))
+	    && begin == fp.begin
+	    && end == fp.end);
+  }
+
+
+  /**
+   * This method returns a hash value for this object
+   * 
+   * @return A hash value for this object.
+   */
+  public int hashCode ()
+  {
+    int hash = 5;
+
+    hash = 31 * hash + field_id;
+    hash = 31 * hash + begin;
+    hash = 31 * hash + end;
+    hash = 31 * hash + 
+      (null == field_attribute ? 0 : field_attribute.hashCode());
+
+    return hash;
+  }
+
+  /**
+   * This method returns a <code>String</code> representation of this
+   * object.
+   *
+   * @return A <code>String</code> representation of this object.
+   */
+  public String toString ()
+  {
+    return (getClass ().getName ()
+	    + "[field=" + getField ()
+	    + ",attribute=" + getFieldAttribute ()
+	    + ",beginIndex=" + getBeginIndex () 
+	    + ",endIndex=" + getEndIndex () 
+	    + "]");
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/Format.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/Format.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/Format.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/Format.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,181 @@
+/* Format.java -- Abstract superclass for formatting/parsing strings.
+   Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+import gnu.java.text.FormatCharacterIterator;
+
+import java.io.Serializable;
+
+/**
+ * This class is the abstract superclass of classes that format and parse
+ * data to/from <code>Strings</code>.  It is guaranteed that any 
+ * <code>String</code> produced by a concrete subclass of <code>Format</code>
+ * will be parseable by that same subclass.
+ * <p>
+ * In addition to implementing the abstract methods in this class, subclasses
+ * should provide static factory methods of the form 
+ * <code>getInstance()</code> and <code>getInstance(Locale)</code> if the
+ * subclass loads different formatting/parsing schemes based on locale.
+ * These subclasses should also implement a static method called
+ * <code>getAvailableLocales()</code> which returns an array of 
+ * available locales in the current runtime environment.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Per Bothner (bothner at cygnus.com)
+ */
+public abstract class Format implements Serializable, Cloneable
+{
+  /**
+   * For compatability with Sun's JDK 1.4.2 rev. 5
+   */
+  static final long serialVersionUID = -299282585814624189L;
+
+  public static class Field extends AttributedCharacterIterator.Attribute
+  {
+    static final long serialVersionUID = 276966692217360283L;
+   
+    protected Field(String name)
+    {
+      super(name);
+    }
+  }
+  
+  /**
+   * This method initializes a new instance of <code>Format</code>.
+   * It performs no actions, but acts as a default constructor for
+   * subclasses.
+   */
+  public Format ()
+  {
+  }
+
+  /**
+   * This method formats an <code>Object</code> into a <code>String</code>.
+   * 
+   * @param obj The <code>Object</code> to format.
+   *
+   * @return The formatted <code>String</code>.
+   *
+   * @exception IllegalArgumentException If the <code>Object</code>
+   * cannot be formatted. 
+   */
+  public final String format(Object obj) throws IllegalArgumentException
+  {
+    StringBuffer sb = new StringBuffer ();
+    format (obj, sb, new FieldPosition (0));
+    return sb.toString ();
+  }
+
+  /**
+   * This method formats an <code>Object</code> into a <code>String</code> and
+   * appends the <code>String</code> to a <code>StringBuffer</code>.
+   *
+   * @param obj The <code>Object</code> to format.
+   * @param sb The <code>StringBuffer</code> to append to.
+   * @param pos The desired <code>FieldPosition</code>, which is also
+   *            updated by this call. 
+   *
+   * @return The updated <code>StringBuffer</code>.
+   *
+   * @exception IllegalArgumentException If the <code>Object</code>
+   * cannot be formatted. 
+   */
+  public abstract StringBuffer format (Object obj, StringBuffer sb,
+				       FieldPosition pos)
+    throws IllegalArgumentException;
+
+  /**
+   * This method parses a <code>String</code> and converts the parsed 
+   * contents into an <code>Object</code>.
+   *
+   * @param str The <code>String</code> to parse.
+   *
+   * @return The resulting <code>Object</code>.
+   *
+   * @exception ParseException If the <code>String</code> cannot be parsed.
+   */
+  public Object parseObject (String str) throws ParseException
+  {
+    ParsePosition pos = new ParsePosition(0);
+    Object result = parseObject (str, pos);
+    if (result == null)
+      {
+	int index = pos.getErrorIndex();
+	if (index < 0)
+	  index = pos.getIndex();
+	throw new ParseException("parseObject failed", index);
+      }
+    return result;
+  }
+
+  /**
+   * This method parses a <code>String</code> and converts the parsed
+   * contents into an <code>Object</code>. 
+   *
+   * @param str The <code>String</code> to parse.
+   * @param pos The starting parse index on input, the ending parse
+   *            index on output. 
+   *
+   * @return The parsed <code>Object</code>, or <code>null</code> in
+   *         case of error.
+   */
+  public abstract Object parseObject (String str, ParsePosition pos);
+
+  public AttributedCharacterIterator formatToCharacterIterator(Object obj)
+  {
+    return new FormatCharacterIterator(format(obj), null, null);
+  }
+
+  /**
+   * Creates a copy of this object.
+   *
+   * @return The copied <code>Object</code>.
+   */
+  public Object clone ()
+  {
+    try
+      {
+	return super.clone ();
+      }
+    catch (CloneNotSupportedException e)
+      {
+	return null;
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/MessageFormat.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/MessageFormat.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/MessageFormat.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/MessageFormat.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,831 @@
+/* MessageFormat.java - Localized message formatting.
+   Copyright (C) 1999, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+import gnu.java.text.FormatCharacterIterator;
+
+import java.io.InvalidObjectException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Vector;
+
+public class MessageFormat extends Format
+{
+  /**
+   * @author Tom Tromey (tromey at cygnus.com)
+   * @author Jorge Aliss (jaliss at hotmail.com)
+   * @date March 3, 1999
+   */
+  /* Written using "Java Class Libraries", 2nd edition, plus online
+   * API docs for JDK 1.2 from http://www.javasoft.com.
+   * Status:  Believed complete and correct to 1.2, except serialization.
+   *          and parsing.
+   */
+  private static final class MessageFormatElement
+  {
+    // Argument number.
+    int argNumber;
+    // Formatter to be used.  This is the format set by setFormat.
+    Format setFormat;
+    // Formatter to be used based on the type.
+    Format format;
+
+    // Argument will be checked to make sure it is an instance of this
+    // class.
+    Class formatClass;
+
+    // Formatter type.
+    String type;
+    // Formatter style.
+    String style;
+
+    // Text to follow this element.
+    String trailer;
+
+    // Recompute the locale-based formatter.
+    void setLocale (Locale loc)
+    {
+      if (type == null)
+        ;
+      else if (type.equals("number"))
+        {
+	  formatClass = java.lang.Number.class;
+
+	  if (style == null)
+	    format = NumberFormat.getInstance(loc);
+	  else if (style.equals("currency"))
+	    format = NumberFormat.getCurrencyInstance(loc);
+	  else if (style.equals("percent"))
+	    format = NumberFormat.getPercentInstance(loc);
+	  else if (style.equals("integer"))
+	    {
+	      NumberFormat nf = NumberFormat.getNumberInstance(loc);
+	      nf.setMaximumFractionDigits(0);
+	      nf.setGroupingUsed(false);
+	      format = nf;
+	    }
+	  else
+	    {
+	      format = NumberFormat.getNumberInstance(loc);
+	      DecimalFormat df = (DecimalFormat) format;
+	      df.applyPattern(style);
+	    }
+        }
+      else if (type.equals("time") || type.equals("date"))
+        {
+	  formatClass = java.util.Date.class;
+
+	  int val = DateFormat.DEFAULT;
+	  boolean styleIsPattern = false;
+	  if (style == null)
+	    ;
+	  else if (style.equals("short"))
+	    val = DateFormat.SHORT;
+	  else if (style.equals("medium"))
+	    val = DateFormat.MEDIUM;
+	  else if (style.equals("long"))
+	    val = DateFormat.LONG;
+	  else if (style.equals("full"))
+	    val = DateFormat.FULL;
+	  else
+	    styleIsPattern = true;
+
+	  if (type.equals("time"))
+	    format = DateFormat.getTimeInstance(val, loc);
+	  else
+	    format = DateFormat.getDateInstance(val, loc);
+
+	  if (styleIsPattern)
+	    {
+	      SimpleDateFormat sdf = (SimpleDateFormat) format;
+	      sdf.applyPattern(style);
+	    }
+        }
+      else if (type.equals("choice"))
+        {
+	  formatClass = java.lang.Number.class;
+
+	  if (style == null)
+	    throw new
+	      IllegalArgumentException ("style required for choice format");
+	  format = new ChoiceFormat (style);
+        }
+    }
+  }
+
+  private static final long serialVersionUID = 6479157306784022952L;
+
+  public static class Field extends Format.Field
+  {
+    static final long serialVersionUID = 7899943957617360810L;
+
+    /**
+     * This is the attribute set for all characters produced
+     * by MessageFormat during a formatting.
+     */
+    public static final MessageFormat.Field ARGUMENT = new MessageFormat.Field("argument");
+
+    // For deserialization
+    private Field()
+    {
+      super("");
+    }
+    
+    protected Field(String s)
+    {
+      super(s);
+    }
+
+    /**
+     * invoked to resolve the true static constant by
+     * comparing the deserialized object to know name.
+     *
+     * @return object constant
+     */
+    protected Object readResolve() throws InvalidObjectException
+    {
+      if (getName().equals(ARGUMENT.getName()))
+	return ARGUMENT;
+
+      throw new InvalidObjectException("no such MessageFormat field called " + getName());
+    }
+
+  }
+
+  // Helper that returns the text up to the next format opener.  The
+  // text is put into BUFFER.  Returns index of character after end of
+  // string.  Throws IllegalArgumentException on error.
+  private static int scanString(String pat, int index, StringBuffer buffer)
+  {
+    int max = pat.length();
+    buffer.setLength(0);
+    boolean quoted = false;
+    for (; index < max; ++index)
+      {
+	char c = pat.charAt(index);
+	if (quoted)
+	  {
+	    // In a quoted context, a single quote ends the quoting.
+	    if (c == '\'')
+	      quoted = false;
+	    else
+	      buffer.append(c);
+	  }
+	// Check for '', which is a single quote.
+	else if (c == '\'' && index + 1 < max && pat.charAt(index + 1) == '\'')
+	  {
+	    buffer.append(c);
+	    ++index;
+	  }
+	else if (c == '\'')
+	  {
+	    // Start quoting.
+	    quoted = true;
+	  }
+	else if (c == '{')
+	  break;
+	else
+	  buffer.append(c);
+      }
+    // Note that we explicitly allow an unterminated quote.  This is
+    // done for compatibility.
+    return index;
+  }
+
+  // This helper retrieves a single part of a format element.  Returns
+  // the index of the terminating character.
+  private static int scanFormatElement(String pat, int index,
+                                       StringBuffer buffer, char term)
+  {
+    int max = pat.length();
+    buffer.setLength(0);
+    int brace_depth = 1;
+    boolean quoted = false;
+
+    for (; index < max; ++index)
+      {
+	char c = pat.charAt(index);
+	// First see if we should turn off quoting.
+	if (quoted)
+	  {
+	    if (c == '\'')
+	      quoted = false;
+	    // In both cases we fall through to inserting the
+	    // character here.
+	  }
+	// See if we have just a plain quote to insert.
+	else if (c == '\'' && index + 1 < max
+		 && pat.charAt(index + 1) == '\'')
+	  {
+	    buffer.append(c);
+	    ++index;
+	  }
+	// See if quoting should turn on.
+	else if (c == '\'')
+	  quoted = true;
+	else if (c == '{')
+	  ++brace_depth;
+	else if (c == '}')
+	  {
+	    if (--brace_depth == 0)
+	      break;
+	  }
+	// Check for TERM after braces, because TERM might be `}'.
+	else if (c == term)
+	  break;
+	// All characters, including opening and closing quotes, are
+	// inserted here.
+	buffer.append(c);
+      }
+    return index;
+  }
+
+  // This is used to parse a format element and whatever non-format
+  // text might trail it.
+  private static int scanFormat(String pat, int index, StringBuffer buffer,
+                                Vector elts, Locale locale)
+  {
+    MessageFormatElement mfe = new MessageFormatElement ();
+    elts.addElement(mfe);
+
+    int max = pat.length();
+
+    // Skip the opening `{'.
+    ++index;
+
+    // Fetch the argument number.
+    index = scanFormatElement (pat, index, buffer, ',');
+    try
+      {
+	mfe.argNumber = Integer.parseInt(buffer.toString());
+      }
+    catch (NumberFormatException nfx)
+      {
+	IllegalArgumentException iae = new IllegalArgumentException(pat);
+	iae.initCause(nfx);
+	throw iae;
+      }
+
+    // Extract the element format.
+    if (index < max && pat.charAt(index) == ',')
+      {
+	index = scanFormatElement (pat, index + 1, buffer, ',');
+	mfe.type = buffer.toString();
+
+	// Extract the style.
+	if (index < max && pat.charAt(index) == ',')
+	  {
+	    index = scanFormatElement (pat, index + 1, buffer, '}');
+	    mfe.style = buffer.toString ();
+	  }
+      }
+
+    // Advance past the last terminator.
+    if (index >= max || pat.charAt(index) != '}')
+      throw new IllegalArgumentException("Missing '}' at end of message format");
+    ++index;
+
+    // Now fetch trailing string.
+    index = scanString (pat, index, buffer);
+    mfe.trailer = buffer.toString ();
+
+    mfe.setLocale(locale);
+
+    return index;
+  }
+
+  /**
+   * Applies the specified pattern to this MessageFormat.
+   *
+   * @param newPattern The Pattern
+   */
+  public void applyPattern (String newPattern)
+  {
+    pattern = newPattern;
+
+    StringBuffer tempBuffer = new StringBuffer ();
+
+    int index = scanString (newPattern, 0, tempBuffer);
+    leader = tempBuffer.toString();
+
+    Vector elts = new Vector ();
+    while (index < newPattern.length())
+      index = scanFormat (newPattern, index, tempBuffer, elts, locale);
+
+    elements = new MessageFormatElement[elts.size()];
+    elts.copyInto(elements);
+  }
+
+  /**
+   * Overrides Format.clone()
+   */
+  public Object clone ()
+  {
+    MessageFormat c = (MessageFormat) super.clone ();
+    c.elements = (MessageFormatElement[]) elements.clone ();
+    return c;
+  }
+
+  /**
+   * Overrides Format.equals(Object obj)
+   */
+  public boolean equals (Object obj)
+  {
+    if (! (obj instanceof MessageFormat))
+      return false;
+    MessageFormat mf = (MessageFormat) obj;
+    return (pattern.equals(mf.pattern)
+	    && locale.equals(mf.locale));
+  }
+
+  /**
+   * A convinience method to format patterns.
+   *
+   * @param arguments The array containing the objects to be formatted.
+   */
+  public AttributedCharacterIterator formatToCharacterIterator (Object arguments)
+  {
+    Object[] arguments_array = (Object[])arguments;
+    FormatCharacterIterator iterator = new FormatCharacterIterator();
+    
+    formatInternal(arguments_array, new StringBuffer(), null, iterator);
+  
+    return iterator;
+  }
+
+  /**
+   * A convinience method to format patterns.
+   *
+   * @param pattern The pattern used when formatting.
+   * @param arguments The array containing the objects to be formatted.
+   */
+  public static String format (String pattern, Object arguments[])
+  {
+    MessageFormat mf = new MessageFormat (pattern);
+    StringBuffer sb = new StringBuffer ();
+    FieldPosition fp = new FieldPosition (NumberFormat.INTEGER_FIELD);
+    return mf.formatInternal(arguments, sb, fp, null).toString();
+  }
+
+  /**
+   * Returns the pattern with the formatted objects.
+   *
+   * @param arguments The array containing the objects to be formatted.
+   * @param appendBuf The StringBuffer where the text is appened.
+   * @param fp A FieldPosition object (it is ignored).
+   */
+  public final StringBuffer format (Object arguments[], StringBuffer appendBuf,
+				    FieldPosition fp)
+  {
+    return formatInternal(arguments, appendBuf, fp, null);
+  }
+
+  private StringBuffer formatInternal (Object arguments[],
+                                       StringBuffer appendBuf,
+				       FieldPosition fp,
+				       FormatCharacterIterator output_iterator)
+  {
+    appendBuf.append(leader);
+    if (output_iterator != null)
+      output_iterator.append(leader);
+
+    for (int i = 0; i < elements.length; ++i)
+      {
+	Object thisArg = null;
+	boolean unavailable = false;
+	if (arguments == null || elements[i].argNumber >= arguments.length)
+	  unavailable = true;
+	else
+	  thisArg = arguments[elements[i].argNumber];
+
+	AttributedCharacterIterator iterator = null;
+
+	Format formatter = null;
+
+	if (fp != null && i == fp.getField() && fp.getFieldAttribute() == Field.ARGUMENT)
+	  fp.setBeginIndex(appendBuf.length());
+
+	if (unavailable)
+	  appendBuf.append("{" + elements[i].argNumber + "}");
+	else
+	  {
+	    if (elements[i].setFormat != null)
+	      formatter = elements[i].setFormat;
+	    else if (elements[i].format != null)
+	      {
+	        if (elements[i].formatClass != null
+		    && ! elements[i].formatClass.isInstance(thisArg))
+	          throw new IllegalArgumentException("Wrong format class");
+	    
+	        formatter = elements[i].format;
+	      }
+	    else if (thisArg instanceof Number)
+	      formatter = NumberFormat.getInstance(locale);
+	    else if (thisArg instanceof Date)
+	      formatter = DateFormat.getTimeInstance(DateFormat.DEFAULT, locale);
+	    else
+	      appendBuf.append(thisArg);
+	  }
+
+	if (fp != null && fp.getField() == i && fp.getFieldAttribute() == Field.ARGUMENT)
+	  fp.setEndIndex(appendBuf.length());
+
+	if (formatter != null)
+	  {
+	    // Special-case ChoiceFormat.
+	    if (formatter instanceof ChoiceFormat)
+	      {
+		StringBuffer buf = new StringBuffer ();
+		formatter.format(thisArg, buf, fp);
+		MessageFormat mf = new MessageFormat ();
+		mf.setLocale(locale);
+		mf.applyPattern(buf.toString());
+		mf.format(arguments, appendBuf, fp);
+	      }
+	    else
+	      {
+		if (output_iterator != null)
+		  iterator = formatter.formatToCharacterIterator(thisArg);
+		else
+		  formatter.format(thisArg, appendBuf, fp);
+	      }
+
+	    elements[i].format = formatter;
+	  }
+
+	if (output_iterator != null)
+	  {
+	    HashMap hash_argument = new HashMap();
+	    int position = output_iterator.getEndIndex();
+	    
+	    hash_argument.put (MessageFormat.Field.ARGUMENT,
+			       new Integer(elements[i].argNumber));
+
+	    
+	    if (iterator != null)
+	      {
+		output_iterator.append(iterator);
+		output_iterator.addAttributes(hash_argument, position, 
+					      output_iterator.getEndIndex());
+	      }	
+	    else
+	      output_iterator.append(thisArg.toString(), hash_argument);
+	    
+	    output_iterator.append(elements[i].trailer);
+	  }
+	
+	appendBuf.append(elements[i].trailer);
+      }
+    
+    return appendBuf;
+  }
+
+  /**
+   * Returns the pattern with the formatted objects.  The first argument
+   * must be a array of Objects.
+   * This is equivalent to format((Object[]) objectArray, appendBuf, fpos)
+   *
+   * @param objectArray The object array to be formatted.
+   * @param appendBuf The StringBuffer where the text is appened.
+   * @param fpos A FieldPosition object (it is ignored).
+   */
+  public final StringBuffer format (Object objectArray, StringBuffer appendBuf,
+				    FieldPosition fpos)
+  {
+    return format ((Object[])objectArray, appendBuf, fpos);
+  }
+
+  /**
+   * Returns an array with the Formats for
+   * the arguments.
+   */
+  public Format[] getFormats ()
+  {
+    Format[] f = new Format[elements.length];
+    for (int i = elements.length - 1; i >= 0; --i)
+      f[i] = elements[i].setFormat;
+    return f;
+  }
+
+  /**
+   * Returns the locale.
+   */
+  public Locale getLocale ()
+  {
+    return locale;
+  }
+
+  /**
+   * Overrides Format.hashCode()
+   */
+  public int hashCode ()
+  {
+    // FIXME: not a very good hash.
+    return pattern.hashCode() + locale.hashCode();
+  }
+
+  private MessageFormat ()
+  {
+  }
+
+  /**
+   * Creates a new MessageFormat object with
+   * the specified pattern
+   *
+   * @param pattern The Pattern
+   */
+  public MessageFormat(String pattern)
+  {
+    this(pattern, Locale.getDefault());
+  }
+
+  /**
+   * Creates a new MessageFormat object with
+   * the specified pattern
+   *
+   * @param pattern The Pattern
+   * @param locale The Locale to use
+   *
+   * @since 1.4
+   */
+  public MessageFormat(String pattern, Locale locale)
+  {
+    this.locale = locale;
+    applyPattern (pattern);
+  }
+
+  /**
+   * Parse a string <code>sourceStr</code> against the pattern specified
+   * to the MessageFormat constructor.
+   *
+   * @param sourceStr the string to be parsed.
+   * @param pos the current parse position (and eventually the error position).
+   * @return the array of parsed objects sorted according to their argument number
+   * in the pattern.
+   */ 
+  public Object[] parse (String sourceStr, ParsePosition pos)
+  {
+    // Check initial text.
+    int index = pos.getIndex();
+    if (! sourceStr.startsWith(leader, index))
+      {
+	pos.setErrorIndex(index);
+	return null;
+      }
+    index += leader.length();
+
+    Vector results = new Vector (elements.length, 1);
+    // Now check each format.
+    for (int i = 0; i < elements.length; ++i)
+      {
+	Format formatter = null;
+	if (elements[i].setFormat != null)
+	  formatter = elements[i].setFormat;
+	else if (elements[i].format != null)
+	  formatter = elements[i].format;
+
+	Object value = null;
+	if (formatter instanceof ChoiceFormat)
+	  {
+	    // We must special-case a ChoiceFormat because it might
+	    // have recursive formatting.
+	    ChoiceFormat cf = (ChoiceFormat) formatter;
+	    String[] formats = (String[]) cf.getFormats();
+	    double[] limits = (double[]) cf.getLimits();
+	    MessageFormat subfmt = new MessageFormat ();
+	    subfmt.setLocale(locale);
+	    ParsePosition subpos = new ParsePosition (index);
+
+	    int j;
+	    for (j = 0; value == null && j < limits.length; ++j)
+	      {
+		subfmt.applyPattern(formats[j]);
+		subpos.setIndex(index);
+		value = subfmt.parse(sourceStr, subpos);
+	      }
+	    if (value != null)
+	      {
+		index = subpos.getIndex();
+		value = new Double (limits[j]);
+	      }
+	  }
+	else if (formatter != null)
+	  {
+	    pos.setIndex(index);
+	    value = formatter.parseObject(sourceStr, pos);
+	    if (value != null)
+	      index = pos.getIndex();
+	  }
+	else
+	  {
+	    // We have a String format.  This can lose in a number
+	    // of ways, but we give it a shot.
+	    int next_index;
+	    if (elements[i].trailer.length() > 0)
+	      next_index = sourceStr.indexOf(elements[i].trailer, index);
+	    else
+	      next_index = sourceStr.length();
+	    if (next_index == -1)
+	      {
+		pos.setErrorIndex(index);
+		return null;
+	      }
+	    value = sourceStr.substring(index, next_index);
+	    index = next_index;
+	  }
+
+	if (value == null
+	    || ! sourceStr.startsWith(elements[i].trailer, index))
+	  {
+	    pos.setErrorIndex(index);
+	    return null;
+	  }
+
+	if (elements[i].argNumber >= results.size())
+	  results.setSize(elements[i].argNumber + 1);
+	results.setElementAt(value, elements[i].argNumber);
+
+	index += elements[i].trailer.length();
+      }
+
+    Object[] r = new Object[results.size()];
+    results.copyInto(r);
+    return r;
+  }
+
+  public Object[] parse (String sourceStr) throws ParseException
+  {
+    ParsePosition pp = new ParsePosition (0);
+    Object[] r = parse (sourceStr, pp);
+    if (r == null)
+      throw new ParseException ("couldn't parse string", pp.getErrorIndex());
+    return r;
+  }
+
+  public Object parseObject (String sourceStr, ParsePosition pos)
+  {
+    return parse (sourceStr, pos);
+  }
+
+  /**
+   * Sets the format for the argument at an specified
+   * index.
+   *
+   * @param variableNum The index.
+   * @param newFormat The Format object.
+   */
+  public void setFormat (int variableNum, Format newFormat)
+  {
+    elements[variableNum].setFormat = newFormat;
+  }
+
+  /**
+   * Sets the formats for the arguments.
+   *
+   * @param newFormats An array of Format objects.
+   */
+  public void setFormats (Format[] newFormats)
+  {
+    if (newFormats.length < elements.length)
+      throw new IllegalArgumentException("Not enough format objects");
+
+    int len = Math.min(newFormats.length, elements.length);
+    for (int i = 0; i < len; ++i)
+      elements[i].setFormat = newFormats[i];
+  }
+
+  /**
+   * Sets the locale.
+   *
+   * @param loc A Locale
+   */
+  public void setLocale (Locale loc)
+  {
+    locale = loc;
+    if (elements != null)
+      {
+	for (int i = 0; i < elements.length; ++i)
+	  elements[i].setLocale(loc);
+      }
+  }
+
+  /**
+   * Returns the pattern.
+   */
+  public String toPattern ()
+  {
+    return pattern;
+  }
+
+  /**
+   * Return the formatters used sorted by argument index. It uses the
+   * internal table to fill in this array: if a format has been
+   * set using <code>setFormat</code> or <code>setFormatByArgumentIndex</code>
+   * then it returns it at the right index. If not it uses the detected
+   * formatters during a <code>format</code> call. If nothing is known
+   * about that argument index it just puts null at that position.
+   * To get useful informations you may have to call <code>format</code>
+   * at least once.
+   *
+   * @return an array of formatters sorted by argument index.
+   */
+  public Format[] getFormatsByArgumentIndex()
+  {
+    int argNumMax = 0;
+    // First, find the greatest argument number.
+    for (int i=0;i<elements.length;i++)
+      if (elements[i].argNumber > argNumMax)
+	argNumMax = elements[i].argNumber;
+
+    Format[] formats = new Format[argNumMax];
+    for (int i=0;i<elements.length;i++)
+      {
+	if (elements[i].setFormat != null)
+	  formats[elements[i].argNumber] = elements[i].setFormat;
+	else if (elements[i].format != null)
+	  formats[elements[i].argNumber] = elements[i].format;
+      }
+    return formats;
+  }
+
+  /**
+   * Set the format to used using the argument index number.
+   *
+   * @param argumentIndex the argument index.
+   * @param newFormat the format to use for this argument.
+   */
+  public void setFormatByArgumentIndex(int argumentIndex,
+				       Format newFormat)
+  {
+    for (int i=0;i<elements.length;i++)
+      {
+	if (elements[i].argNumber == argumentIndex)
+	  elements[i].setFormat = newFormat;
+      }
+  }
+
+  /**
+   * Set the format for argument using a specified array of formatters
+   * which is sorted according to the argument index. If the number of
+   * elements in the array is fewer than the number of arguments only
+   * the arguments specified by the array are touched.
+   *
+   * @param newFormats array containing the new formats to set.
+   *
+   * @throws NullPointerException if newFormats is null
+   */
+  public void setFormatsByArgumentIndex(Format[] newFormats)
+  {
+    for (int i=0;i<newFormats.length;i++)
+      {
+	// Nothing better than that can exist here.
+	setFormatByArgumentIndex(i, newFormats[i]);
+      }
+  }
+
+  // The pattern string.
+  private String pattern;
+  // The locale.
+  private Locale locale;
+  // Variables.
+  private MessageFormatElement[] elements;
+  // Leader text.
+  private String leader;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/NumberFormat.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/NumberFormat.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/NumberFormat.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/NumberFormat.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,808 @@
+/* NumberFormat.java -- Formats and parses numbers
+   Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Currency;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * This is the abstract superclass of all classes which format and 
+ * parse numeric values such as decimal numbers, integers, currency values,
+ * and percentages.  These classes perform their parsing and formatting
+ * in a locale specific manner, accounting for such items as differing
+ * currency symbols and thousands separators.
+ * <p>
+ * To create an instance of a concrete subclass of <code>NumberFormat</code>,
+ * do not call a class constructor directly.  Instead, use one of the
+ * static factory methods in this class such as 
+ * <code>getCurrencyInstance</code>.
+ * 
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @date March 4, 1999
+ */
+/* Written using "Java Class Libraries", 2nd edition, plus online
+ * API docs for JDK 1.2 from http://www.javasoft.com.
+ * Status:  Believed complete and correct to 1.2, except getAvailableLocales.
+ */
+public abstract class NumberFormat extends Format implements Cloneable
+{
+  /**
+   * This is a constant used to create a <code>FieldPosition</code> object
+   * that will return the integer portion of a formatted number.
+   */
+  public static final int INTEGER_FIELD = 0;
+
+  /**
+   * This is a constant used to create a <code>FieldPosition</code> object
+   * that will return the fractional portion of a formatted number.
+   */
+  public static final int FRACTION_FIELD = 1;
+
+  public static class Field extends Format.Field
+  {
+    static final long serialVersionUID = 7494728892700160890L;
+
+    /**
+     * Attribute set to all characters containing digits of the integer
+     * part.
+     */
+    public static final NumberFormat.Field INTEGER
+      = new Field("integer");
+
+    /**
+     * Attribute set to all characters containing digits of the fractional
+     * part.
+     */
+    public static final NumberFormat.Field FRACTION
+      = new Field("fraction");
+
+    /**
+     * Attribute set to all characters containing digits of the exponential
+     * part.
+     */
+    public static final NumberFormat.Field EXPONENT
+      = new Field("exponent");
+
+    /**
+     * Attribute set to all characters containing a decimal separator.
+     */
+    public static final NumberFormat.Field DECIMAL_SEPARATOR
+      = new Field("decimal separator");
+
+    /**
+     * Attribute set to all characters containing a sign (plus or minus).
+     */
+    public static final NumberFormat.Field SIGN
+      = new Field("sign");
+
+    /**
+     * Attribute set to all characters containing a grouping separator (e.g.
+     * a comma, a white space,...).
+     */
+    public static final NumberFormat.Field GROUPING_SEPARATOR
+      = new Field("grouping separator");
+
+    /**
+     * Attribute set to all characters containing an exponential symbol (e.g.
+     * 'E')
+     */
+    public static final NumberFormat.Field EXPONENT_SYMBOL
+      = new Field("exponent symbol");
+
+    /**
+     * Attribute set to all characters containing a percent symbol (e.g. '%')
+     */
+    public static final NumberFormat.Field PERCENT
+      = new Field("percent");
+
+    /**
+     * Attribute set to all characters containing a permille symbol.
+     */
+    public static final NumberFormat.Field PERMILLE
+      = new Field("permille");
+
+    /**
+     * Attribute set to all characters containing the currency unit.
+     */
+    public static final NumberFormat.Field CURRENCY
+      = new Field("currency");
+
+    /**
+     * Attribute set to all characters containing the exponent sign.
+     */
+    public static final NumberFormat.Field EXPONENT_SIGN
+      = new Field("exponent sign");
+
+    /**
+     * Private fields to register all fields contained in this descriptor.
+     */
+    private static final NumberFormat.Field[] allFields =
+    {
+      INTEGER, FRACTION, EXPONENT, DECIMAL_SEPARATOR, SIGN,
+      GROUPING_SEPARATOR, EXPONENT_SYMBOL, PERCENT,
+      PERMILLE, CURRENCY, EXPONENT_SIGN
+    };
+
+    /**
+     * This constructor is only used by the deserializer. Without it,
+     * it would fail to construct a valid object.
+     */
+    private Field()
+    {
+      super("");
+    }
+
+    /**
+     * Create a Field instance with the specified field name.
+     *
+     * @param field_name Field name for the new Field instance.
+     */
+    protected Field(String field_name)
+    {
+      super (field_name);
+    }
+
+    /**
+     * This function is used by the deserializer to know which object
+     * to use when it encounters an encoded NumberFormat.Field in a 
+     * serialization stream. If the stream is valid it should return
+     * one of the above field. In the other case we throw an exception.
+     *
+     * @return a valid official NumberFormat.Field instance.
+     *
+     * @throws InvalidObjectException if the field name is invalid.
+     */
+    protected Object readResolve() throws InvalidObjectException
+    {
+      String s = getName();
+      for (int i = 0; i < allFields.length; i++)
+	if (s.equals(allFields[i].getName()))
+	  return allFields[i];
+
+      throw new InvalidObjectException("no such NumberFormat field called "
+				       + s);
+    }
+  }
+
+  /**
+   * This method is a specialization of the format method that performs
+   * a simple formatting of the specified <code>long</code> number.
+   *
+   * @param number The <code>long</code> to format.
+   *
+   * @return The formatted number
+   */
+  public final String format (long number)
+  {
+    StringBuffer sbuf = new StringBuffer(50);
+    format (number, sbuf, null);
+    return sbuf.toString();
+  }
+
+  public final StringBuffer format (Object obj, StringBuffer sbuf,
+				    FieldPosition pos)
+  {
+    if (obj instanceof Number)
+      return format(((Number) obj).doubleValue(), sbuf, pos);
+    else
+      throw new IllegalArgumentException 
+	("Cannot format given Object as a Number");
+  }
+
+  /**
+   * This method formats the specified <code>double</code> and appends it to
+   * a <code>StringBuffer</code>.
+   * 
+   * @param number The <code>double</code> to format.
+   * @param sbuf The <code>StringBuffer</code> to append the formatted number 
+   *             to.
+   * @param pos The desired <code>FieldPosition</code>.
+   *
+   * @return The <code>StringBuffer</code> with the appended number.
+   */
+  public abstract StringBuffer format (double number,
+				       StringBuffer sbuf, FieldPosition pos);
+
+  /**
+   * This method formats the specified <code>long</code> and appends it to
+   * a <code>StringBuffer</code>.
+   * 
+   * @param number The <code>long</code> to format.
+   * @param sbuf The <code>StringBuffer</code> to append the formatted number 
+   *             to.
+   * @param pos The desired <code>FieldPosition</code>.
+   *
+   * @return The <code>StringBuffer</code> with the appended number.
+   */
+  public abstract StringBuffer format (long number,
+				       StringBuffer sbuf, FieldPosition pos);
+
+  /**
+   * This method tests the specified object for equality against this object.
+   * This will be <code>true</code> if the following conditions are met:
+   * <p>
+   * <ul>
+   * <li>The specified object is not <code>null</code>.
+   * <li>The specified object is an instance of <code>NumberFormat</code>.
+   * </ul>
+   * <p>
+   * Since this method does not test much, it is highly advised that 
+   * concrete subclasses override this method.
+   *
+   * @param obj The <code>Object</code> to test against equality with
+   *            this object. 
+   * 
+   * @return <code>true</code> if the specified object is equal to
+   * this object, <code>false</code> otherwise. 
+   */
+  public boolean equals (Object obj)
+  {
+    if (! (obj instanceof NumberFormat))
+      return false;
+    NumberFormat nf = (NumberFormat) obj;
+    return (groupingUsed == nf.groupingUsed
+	    && maximumFractionDigits == nf.maximumFractionDigits
+	    && maximumIntegerDigits == nf.maximumIntegerDigits
+	    && minimumFractionDigits == nf.minimumFractionDigits
+	    && minimumIntegerDigits == nf.minimumIntegerDigits
+	    && parseIntegerOnly == nf.parseIntegerOnly);
+  }
+
+  /**
+   * This method returns a list of locales for which concrete instances
+   * of <code>NumberFormat</code> subclasses may be created.
+   *
+   * @return The list of available locales.
+   */
+  public static Locale[] getAvailableLocales ()
+  {
+    Locale[] list = new Locale[1];
+    list[0] = Locale.US;
+    return list;
+  }
+
+  private static NumberFormat computeInstance(Locale loc, String resource,
+                                              String def)
+  {
+    ResourceBundle res;
+    try
+      {
+	res = ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
+		loc, ClassLoader.getSystemClassLoader());
+      }
+    catch (MissingResourceException x)
+      {
+	res = null;
+      }
+    String fmt;
+    try
+      {
+	fmt = res == null ? def : res.getString(resource);
+      }
+    catch (MissingResourceException x)
+      {
+	fmt = def;
+      }
+    DecimalFormatSymbols dfs = new DecimalFormatSymbols (loc);
+    return new DecimalFormat (fmt, dfs);
+  }
+
+  /**
+   * This method returns an instance of <code>NumberFormat</code> suitable
+   * for formatting and parsing currency values in the default locale.
+   *
+   * @return An instance of <code>NumberFormat</code> for handling currencies.
+   */
+  public static final NumberFormat getCurrencyInstance ()
+  {
+    return getCurrencyInstance (Locale.getDefault());
+  }
+
+  /**
+   * This method returns an instance of <code>NumberFormat</code> suitable
+   * for formatting and parsing currency values in the specified locale.
+   *
+   * @return An instance of <code>NumberFormat</code> for handling currencies.
+   */
+  public static NumberFormat getCurrencyInstance (Locale loc)
+  {
+    NumberFormat format;
+    
+    format = computeInstance (loc, "currencyFormat", "$#,##0.00;($#,##0.00)");
+    format.setMaximumFractionDigits(format.getCurrency().getDefaultFractionDigits());  
+    return format;
+  }
+
+  /**
+   * This method returns a default instance for the default locale. This
+   * will be a concrete subclass of <code>NumberFormat</code>, but the 
+   * actual class returned is dependent on the locale.
+   *
+   * @return An instance of the default <code>NumberFormat</code> class.
+   */
+  public static final NumberFormat getInstance ()
+  {
+    return getInstance (Locale.getDefault());
+  }
+
+  /**
+   * This method returns a default instance for the specified locale. This
+   * will be a concrete subclass of <code>NumberFormat</code>, but the 
+   * actual class returned is dependent on the locale.
+   *
+   * @param loc The desired locale.
+   *
+   * @return An instance of the default <code>NumberFormat</code> class.
+   */
+  public static NumberFormat getInstance (Locale loc)
+  {
+    // For now always return a number instance.
+    return getNumberInstance (loc);
+  }
+
+  /**
+   * This method returns the maximum number of digits allowed in the fraction
+   * portion of a number.
+   *
+   * @return The maximum number of digits allowed in the fraction
+   * portion of a number. 
+   */
+  public int getMaximumFractionDigits ()
+  {
+    return maximumFractionDigits;
+  }
+
+  /**
+   * This method returns the maximum number of digits allowed in the integer
+   * portion of a number.
+   *
+   * @return The maximum number of digits allowed in the integer
+   * portion of a number. 
+   */
+  public int getMaximumIntegerDigits ()
+  {
+    return maximumIntegerDigits;
+  }
+
+  /**
+   * This method returns the minimum number of digits allowed in the fraction
+   * portion of a number.
+   *
+   * @return The minimum number of digits allowed in the fraction
+   * portion of a number. 
+   */
+  public int getMinimumFractionDigits ()
+  {
+    return minimumFractionDigits;
+  }
+
+  /**
+   * This method returns the minimum number of digits allowed in the integer
+   * portion of a number.
+   *
+   * @return The minimum number of digits allowed in the integer
+   * portion of a number. 
+   */
+  public int getMinimumIntegerDigits ()
+  {
+    return minimumIntegerDigits;
+  }
+
+  /**
+   * This method returns a default instance for the specified locale. This
+   * will be a concrete subclass of <code>NumberFormat</code>, but the 
+   * actual class returned is dependent on the locale.
+   *
+   * @return An instance of the default <code>NumberFormat</code> class.
+   */
+  public static final NumberFormat getNumberInstance ()
+  {
+    return getNumberInstance (Locale.getDefault());
+  }
+
+  /**
+   * This method returns a general purpose number formatting and parsing
+   * class for the default locale.  This will be a concrete subclass of
+   * <code>NumberFormat</code>, but the actual class returned is dependent
+   * on the locale.
+   *
+   * @return An instance of a generic number formatter for the default locale.
+   */
+  public static NumberFormat getNumberInstance (Locale loc)
+  {
+    return computeInstance (loc, "numberFormat", "#,##0.###");
+  }
+
+  /**
+   * This method returns an integer formatting and parsing class for the
+   * default locale. This will be a concrete subclass of <code>NumberFormat</code>,
+   * but the actual class returned is dependent on the locale.
+   *
+   * @return An instance of an integer number formatter for the default locale.
+   * @since 1.4 
+   */
+  public static final NumberFormat getIntegerInstance()
+  {
+    return getIntegerInstance (Locale.getDefault());
+  }
+
+  /**
+   * This method returns an integer formatting and parsing class for the
+   * default locale. This will be a concrete subclass of <code>NumberFormat</code>,
+   * but the actual class returned is dependent on the locale.
+   *
+   * @param locale the desired locale.
+   *
+   * @return An instance of an integer number formatter for the desired locale.
+   * @since 1.4 
+   */
+  public static NumberFormat getIntegerInstance(Locale locale)
+  {
+    NumberFormat format = computeInstance (locale, "integerFormat", "#,##0");
+    format.setMaximumFractionDigits(0);
+    format.setParseIntegerOnly (true);
+    return format;
+  }
+
+  /**
+   * This method returns an instance of <code>NumberFormat</code> suitable
+   * for formatting and parsing percentage values in the default locale.
+   *
+   * @return An instance of <code>NumberFormat</code> for handling percentages.
+   */
+  public static final NumberFormat getPercentInstance ()
+  {
+    return getPercentInstance (Locale.getDefault());
+  }
+
+  /**
+   * This method returns an instance of <code>NumberFormat</code> suitable
+   * for formatting and parsing percentage values in the specified locale.
+   *
+   * @param loc The desired locale.
+   *
+   * @return An instance of <code>NumberFormat</code> for handling percentages.
+   */
+  public static NumberFormat getPercentInstance (Locale loc)
+  {
+    return computeInstance (loc, "percentFormat", "#,##0%");
+  }
+
+  /**
+   * This method returns a hash value for this object.
+   *
+   * @return The hash code.
+   */
+  public int hashCode ()
+  {
+    int hash = super.hashCode();
+    hash ^= (maximumFractionDigits + maximumIntegerDigits
+	     + minimumFractionDigits + minimumIntegerDigits);
+    if (groupingUsed)
+      hash ^= 0xf0f0;
+    if (parseIntegerOnly)
+      hash ^= 0x0f0f;
+    return hash;
+  }
+
+  /**
+   * This method tests whether or not grouping is in use.  Grouping is
+   * a method of marking separations in numbers, such as thousand separators
+   * in the US English locale.  The grouping positions and symbols are all
+   * locale specific.  As an example, with grouping disabled, the number one
+   * million would appear as "1000000".  With grouping enabled, this number
+   * might appear as "1,000,000".  (Both of these assume the US English
+   * locale).
+   *
+   * @return <code>true</code> if grouping is enabled,
+   * <code>false</code> otherwise. 
+   */
+  public boolean isGroupingUsed ()
+  {
+    return groupingUsed;
+  }
+
+  /**
+   * This method tests whether or not only integer values should be parsed.
+   * If this class is parsing only integers, parsing stops at the decimal
+   * point.
+   *
+   * @return <code>true</code> if only integers are parsed,
+   * <code>false</code> otherwise. 
+   */
+  public boolean isParseIntegerOnly ()
+  {
+    return parseIntegerOnly;
+  }
+
+  /**
+   * This is a default constructor for use by subclasses.
+   */
+  public NumberFormat ()
+  {
+  }
+
+  /**
+   * This method parses the specified string into a <code>Number</code>.  This
+   * will be a <code>Long</code> if possible, otherwise it will be a
+   * <code>Double</code>.    If no number can be parsed, no exception is
+   * thrown.  Instead, the parse position remains at its initial index.
+   *
+   * @param sourceStr The string to parse.
+   * @param pos The desired <code>ParsePosition</code>.
+   *
+   * @return The parsed <code>Number</code>
+   */
+  public abstract Number parse (String sourceStr, ParsePosition pos);
+
+  /**
+   * This method parses the specified string into a <code>Number</code>.  This
+   * will be a <code>Long</code> if possible, otherwise it will be a
+   * <code>Double</code>.  If no number can be parsed, an exception will be
+   * thrown.
+   *
+   * @param sourceStr The string to parse.
+   *
+   * @return The parsed <code>Number</code>
+   *
+   * @exception ParseException If no number can be parsed.
+   */
+  public Number parse (String sourceStr) throws ParseException
+  {
+    ParsePosition pp = new ParsePosition (0);
+    Number r = parse (sourceStr, pp);
+    if (r == null)
+      {
+	int index = pp.getErrorIndex();
+	if (index < 0)
+	  index = pp.getIndex();
+	throw new ParseException ("couldn't parse number", index);
+      }
+    return r;
+  }
+
+  /**
+   * This method parses the specified string into an <code>Object</code>.  This
+   * will be a <code>Long</code> if possible, otherwise it will be a
+   * <code>Double</code>.    If no number can be parsed, no exception is
+   * thrown.  Instead, the parse position remains at its initial index.
+   *
+   * @param sourceStr The string to parse.
+   * @param pos The desired <code>ParsePosition</code>.
+  *
+  * @return The parsed <code>Object</code>
+  */
+  public final Object parseObject (String sourceStr, ParsePosition pos)
+  {
+    return parse (sourceStr, pos);
+  }
+
+  /**
+   * This method sets the grouping behavior of this formatter.  Grouping is
+   * a method of marking separations in numbers, such as thousand separators
+   * in the US English locale.  The grouping positions and symbols are all
+   * locale specific.  As an example, with grouping disabled, the number one
+   * million would appear as "1000000".  With grouping enabled, this number
+   * might appear as "1,000,000".  (Both of these assume the US English
+   * locale).
+   *
+   * @param newValue <code>true</code> to enable grouping,
+   *                     <code>false</code> to disable it. 
+   */
+  public void setGroupingUsed (boolean newValue)
+  {
+    groupingUsed = newValue;
+  }
+
+  /**
+   * This method sets the maximum number of digits allowed in the fraction
+   * portion of a number to the specified value.  If this is less than the
+   * current minimum allowed digits, the minimum allowed digits value will
+   * be lowered to be equal to the new maximum allowed digits value.
+   *
+   * @param digits The new maximum fraction digits value.
+   */
+  public void setMaximumFractionDigits (int digits)
+  {
+    maximumFractionDigits = digits;
+    if (getMinimumFractionDigits () > maximumFractionDigits)
+      setMinimumFractionDigits (maximumFractionDigits);
+  }
+
+  /**
+   * This method sets the maximum number of digits allowed in the integer
+   * portion of a number to the specified value.  If this is less than the
+   * current minimum allowed digits, the minimum allowed digits value will
+   * be lowered to be equal to the new maximum allowed digits value.
+   *
+   * @param digits The new maximum integer digits value.
+   */
+  public void setMaximumIntegerDigits (int digits)
+  {
+    maximumIntegerDigits = digits;
+    if (getMinimumIntegerDigits () > maximumIntegerDigits)
+      setMinimumIntegerDigits (maximumIntegerDigits);
+  }
+
+  /**
+   * This method sets the minimum number of digits allowed in the fraction
+   * portion of a number to the specified value.  If this is greater than the
+   * current maximum allowed digits, the maximum allowed digits value will
+   * be raised to be equal to the new minimum allowed digits value.
+   *
+   * @param digits The new minimum fraction digits value.
+   */
+  public void setMinimumFractionDigits (int digits)
+  {
+    minimumFractionDigits = digits;
+    if (getMaximumFractionDigits () < minimumFractionDigits)
+      setMaximumFractionDigits (minimumFractionDigits);
+  }
+
+  /**
+   * This method sets the minimum number of digits allowed in the integer
+   * portion of a number to the specified value.  If this is greater than the
+   * current maximum allowed digits, the maximum allowed digits value will
+   * be raised to be equal to the new minimum allowed digits value.
+   *
+   * @param digits The new minimum integer digits value.
+   */
+  public void setMinimumIntegerDigits (int digits)
+  {
+    minimumIntegerDigits = digits;
+    if (getMaximumIntegerDigits () < minimumIntegerDigits)
+      setMaximumIntegerDigits (minimumIntegerDigits);
+  }
+
+  /** 
+   * This method sets the parsing behavior of this object to parse only 
+   * integers or not.
+   *
+   * @param value <code>true</code> to parse only integers,
+   *                         <code>false</code> otherwise. 
+   */
+  public void setParseIntegerOnly (boolean value)
+  {
+    parseIntegerOnly = value;
+  }
+
+  /**
+   * This method is a specialization of the format method that performs
+   * a simple formatting of the specified <code>double</code> number.
+   *
+   * @param number The <code>double</code> to format.
+   *
+   * @return The formatted number
+   */
+  public final String format (double number)
+  {
+    StringBuffer sbuf = new StringBuffer(50);
+    format (number, sbuf, null);
+    return sbuf.toString();
+  }
+
+  // These field names are fixed by the serialization spec.
+  boolean groupingUsed;
+  int maximumFractionDigits;
+  private byte maxFractionDigits;
+  int maximumIntegerDigits;
+  private byte maxIntegerDigits;
+  int minimumFractionDigits;
+  private byte minFractionDigits;
+  int minimumIntegerDigits;
+  private byte minIntegerDigits;
+  boolean parseIntegerOnly;
+  private int serialVersionOnStream;
+  private static final long serialVersionUID = -2308460125733713944L;
+
+  private void readObject(ObjectInputStream stream)
+    throws IOException, ClassNotFoundException
+  {
+    stream.defaultReadObject();
+    if (serialVersionOnStream < 1)
+      {
+        maximumFractionDigits = maxFractionDigits;
+	maximumIntegerDigits = maxIntegerDigits;
+	minimumFractionDigits = minFractionDigits;
+	minimumIntegerDigits = minIntegerDigits;
+	serialVersionOnStream = 1;
+      }
+  }
+
+  private void writeObject(ObjectOutputStream stream) throws IOException
+  {
+    maxFractionDigits = maximumFractionDigits < Byte.MAX_VALUE ?
+      (byte) maximumFractionDigits : Byte.MAX_VALUE;
+    maxIntegerDigits = maximumIntegerDigits < Byte.MAX_VALUE ?
+      (byte) maximumIntegerDigits : Byte.MAX_VALUE;
+    minFractionDigits = minimumFractionDigits < Byte.MAX_VALUE ?
+      (byte) minimumFractionDigits : Byte.MAX_VALUE;
+    minIntegerDigits = minimumIntegerDigits < Byte.MAX_VALUE ?
+      (byte) minimumIntegerDigits : Byte.MAX_VALUE;
+    serialVersionOnStream = 1;
+    stream.defaultWriteObject();
+  }
+
+  /**
+   * Returns the currency used by this number format when formatting currency
+   * values.
+   *
+   * The default implementation throws UnsupportedOperationException.
+   *
+   * @return The used currency object, or null.
+   *
+   * @throws UnsupportedOperationException If the number format class doesn't
+   * implement currency formatting.
+   *
+   * @since 1.4
+   */
+  public Currency getCurrency()
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Sets the currency used by this number format when formatting currency
+   * values.
+   *
+   * The default implementation throws UnsupportedOperationException.
+   *
+   * @param currency The new currency to be used by this number format.
+   *
+   * @throws NullPointerException If currenc is null.
+   * @throws UnsupportedOperationException If the number format class doesn't
+   * implement currency formatting.
+   *
+   * @since 1.4
+   */
+  public void setCurrency(Currency currency)
+  {
+    if (currency == null)
+      throw new NullPointerException("currency may not be null");
+    
+    throw new UnsupportedOperationException();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/ParseException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/ParseException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/ParseException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/ParseException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,86 @@
+/* ParseException.java -- an error occurred while parsing
+   Copyright (C) 1998, 1999, 2001, 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+/**
+ * This exception is thrown when an unexpected error occurs during parsing.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Per Bothner (bothner at cygnus.com)
+ * @see Format
+ * @see FieldPosition
+ * @status updated to 1.4
+ */
+public class ParseException extends Exception
+{
+  /**
+   * Compatible with JDK 1.1+.
+   */
+  private static final long serialVersionUID = 2703218443322787634L;
+
+  /**
+   * This is the position where the error was encountered.
+   *
+   * @serial the zero-based offset in the string where the error occurred
+   */
+  private final int errorOffset;
+
+  /**
+   * This method initializes a new instance of <code>ParseException</code>
+   * with a detailed error message and a error position.
+   *
+   * @param s the descriptive message describing the error
+   * @param offset the position where the error was encountered
+   */
+  public ParseException(String s, int offset)
+  {
+    super(s);
+    errorOffset = offset;
+  }
+
+  /**
+   * This method returns the position where the error occurred.
+   *
+   * @return the position where the error occurred
+   */
+  public int getErrorOffset()
+  {
+    return errorOffset;
+  }
+} // class ParseException

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/ParsePosition.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/ParsePosition.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/ParsePosition.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/ParsePosition.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,160 @@
+/* ParsePosition.java -- Keep track of position while parsing.
+   Copyright (C) 1998, 1999, 2001, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+/**
+ * This class is used to keep track of the current position during parsing
+ * operations.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Per Bothner (bothner at cygnus.com)
+ */
+public class ParsePosition
+{
+  /**
+   * This is the index of the current parse position.
+   */
+  private int index;
+
+  /**
+   * This is the index of the position where an error occurred during parsing.
+   */
+  private int error_index;
+
+  /**
+   * This method initializes a new instance of <code>ParsePosition</code> to
+   * have the specified initial index value.
+   *
+   * @param index The initial parsing index.
+   */
+  public ParsePosition (int index)
+  {
+    this.index = index;
+    error_index = -1;
+  }
+
+  /**
+   * This method returns the current parsing index.
+   *
+   * @return The current parsing index
+   */
+  public int getIndex ()
+  {
+    return index;
+  }
+
+  /**
+   * This method sets the current parsing index to the specified value.
+   *
+   * @param index The new parsing index.
+   */
+  public void setIndex (int index)
+  {
+    this.index = index;
+  }
+
+  /**
+   * This method returns the error index value.  This value defaults to -1
+   * unless explicitly set to another value.
+   *
+   * @return The error index.
+   */
+  public int getErrorIndex ()
+  {
+    return error_index;
+  }
+
+  /**
+   * This method sets the error index to the specified value.
+   *
+   * @param error_index The new error index
+   */
+  public void setErrorIndex (int error_index)
+  {
+    this.error_index = error_index;
+  }
+
+  /**
+   * This method tests the specified object for equality with this
+   * object.  The two objects will be considered equal if and only if
+   * all of the following conditions are met.
+   * <p>
+   * <ul>
+   * <li>The specified object is not <code>null</code>.</li>
+   * <li>The specified object is an instance of <code>ParsePosition</code>.</li>
+   * <li>The specified object has the same index and error index as
+   *     this object.</li>
+   * </ul>
+   *
+   * @param obj The <code>Object</code> to test for equality against
+   *            this object. 
+   *
+   * @return <code>true</code> if the specified object is equal to
+   * this object, <code>false</code> otherwise.
+   */
+  public boolean equals (Object obj)
+  {
+    if (! (obj instanceof ParsePosition))
+      return false;
+
+    ParsePosition other = (ParsePosition) obj;
+    return index == other.index && error_index == other.error_index;
+  }
+  
+  /**
+   * Return the hash code for this object.
+   * @return the hash code
+   */
+  public int hashCode()
+  {
+    return index ^ error_index;
+  }
+
+  /**
+   * This method returns a <code>String</code> representation of this
+   * object.
+   *
+   * @return A <code>String</code> that represents this object.
+   */
+  public String toString ()
+  {
+    return (getClass ().getName () + "[index=" + getIndex ()
+	    + ",errorIndex=" + getErrorIndex () + "]");
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/RuleBasedCollator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/RuleBasedCollator.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/RuleBasedCollator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/RuleBasedCollator.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1020 @@
+/* RuleBasedCollator.java -- Concrete Collator Class
+   Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+import gnu.classpath.NotImplementedException;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+/* Written using "Java Class Libraries", 2nd edition, plus online
+ * API docs for JDK 1.2 from http://www.javasoft.com.
+ * Status: Believed complete and correct
+ */
+
+/**
+ * This class is a concrete subclass of <code>Collator</code> suitable
+ * for string collation in a wide variety of languages.  An instance of
+ * this class is normally returned by the <code>getInstance</code> method
+ * of <code>Collator</code> with rules predefined for the requested
+ * locale.  However, an instance of this class can be created manually
+ * with any desired rules.
+ * <p>
+ * Rules take the form of a <code>String</code> with the following syntax
+ * <ul>
+ * <li> Modifier: '@'</li>
+ * <li> Relation: '<' | ';' | ',' | '=' : <text></li>
+ * <li> Reset: '&' : <text></li>
+ * </ul>
+ * The modifier character indicates that accents sort backward as is the
+ * case with French.  The modifier applies to all rules <b>after</b>
+ * the modifier but before the next primary sequence. If placed at the end
+ * of the sequence if applies to all unknown accented character.
+ * The relational operators specify how the text 
+ * argument relates to the previous term.  The relation characters have
+ * the following meanings:
+ * <ul>
+ * <li>'<' - The text argument is greater than the prior term at the primary
+ * difference level.</li>
+ * <li>';' - The text argument is greater than the prior term at the secondary
+ * difference level.</li>
+ * <li>',' - The text argument is greater than the prior term at the tertiary
+ * difference level.</li>
+ * <li>'=' - The text argument is equal to the prior term</li>
+ * </ul>
+ * <p>
+ * As for the text argument itself, this is any sequence of Unicode
+ * characters not in the following ranges: 0x0009-0x000D, 0x0020-0x002F,
+ * 0x003A-0x0040, 0x005B-0x0060, and 0x007B-0x007E. If these characters are 
+ * desired, they must be enclosed in single quotes.  If any whitespace is 
+ * encountered, it is ignored.  (For example, "a b" is equal to "ab").  
+ * <p>
+ * The reset operation inserts the following rule at the point where the
+ * text argument to it exists in the previously declared rule string.  This
+ * makes it easy to add new rules to an existing string by simply including
+ * them in a reset sequence at the end.  Note that the text argument, or
+ * at least the first character of it, must be present somewhere in the
+ * previously declared rules in order to be inserted properly.  If this
+ * is not satisfied, a <code>ParseException</code> will be thrown. 
+ * <p>
+ * This system of configuring <code>RuleBasedCollator</code> is needlessly
+ * complex and the people at Taligent who developed it (along with the folks
+ * at Sun who accepted it into the Java standard library) deserve a slow
+ * and agonizing death.
+ * <p>
+ * Here are a couple of example of rule strings:
+ * <p>
+ * "< a < b < c" - This string says that a is greater than b which is 
+ * greater than c, with all differences being primary differences.
+ * <p>
+ * "< a,A < b,B < c,C" - This string says that 'A' is greater than 'a' with
+ * a tertiary strength comparison.  Both 'b' and 'B' are greater than 'a' and
+ * 'A' during a primary strength comparison.  But 'B' is greater than 'b'
+ * under a tertiary strength comparison.
+ * <p>
+ * "< a < c & a < b " - This sequence is identical in function to the 
+ * "< a < b < c" rule string above.  The '&' reset symbol indicates that
+ * the rule "< b" is to be inserted after the text argument "a" in the
+ * previous rule string segment.
+ * <p>
+ * "< a < b & y < z" - This is an error.  The character 'y' does not appear
+ * anywhere in the previous rule string segment so the rule following the
+ * reset rule cannot be inserted.
+ * <p>
+ * "< a & A @ < e & E < f& F" - This sequence is equivalent to the following
+ * "< a & A < E & e < f & F".
+ * <p>
+ * For a description of the various comparison strength types, see the
+ * documentation for the <code>Collator</code> class.
+ * <p>
+ * As an additional complication to this already overly complex rule scheme,
+ * if any characters precede the first rule, these characters are considered
+ * ignorable.  They will be treated as if they did not exist during 
+ * comparisons.  For example, "- < a < b ..." would make '-' an ignorable
+ * character such that the strings "high-tech" and "hightech" would
+ * be considered identical.
+ * <p>
+ * A <code>ParseException</code> will be thrown for any of the following
+ * conditions:
+ * <ul>
+ * <li>Unquoted punctuation characters in a text argument.</li>
+ * <li>A relational or reset operator not followed by a text argument</li>
+ * <li>A reset operator where the text argument is not present in
+ * the previous rule string section.</li>
+ * </ul>
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @author Guilhem Lavaux (guilhem at kaffe.org)
+ */
+public class RuleBasedCollator extends Collator
+{
+  /**
+   * This class describes what rank has a character (or a sequence of characters) 
+   * in the lexicographic order. Each element in a rule has a collation element.
+   */
+  static final class CollationElement
+  {
+    String key;
+    int primary;
+    short secondary;
+    short tertiary;
+    short equality;
+    boolean ignore;
+    String expansion;
+
+    CollationElement(String key, int primary, short secondary, short tertiary,
+		     short equality, String expansion, boolean ignore)
+    {
+      this.key = key;
+      this.primary = primary;
+      this.secondary = secondary;
+      this.tertiary = tertiary;
+      this.equality = equality;
+      this.ignore = ignore;
+      this.expansion = expansion;
+    }
+
+    int getValue()
+    {
+      return (primary << 16) + (secondary << 8) + tertiary;
+    }
+  }
+
+  /**
+   * Basic collation instruction (internal format) to build the series of
+   * collation elements. It contains an instruction which specifies the new
+   * state of the generator. The sequence of instruction should not contain
+   * RESET (it is used by
+   * {@link #mergeRules(int,java.lang.String,java.util.ArrayList,java.util.ArrayList)})
+   * as a temporary state while merging two sets of instructions.
+   */
+  static final class CollationSorter
+  {
+    static final int GREATERP = 0;
+    static final int GREATERS = 1;
+    static final int GREATERT = 2;
+    static final int EQUAL = 3;
+    static final int RESET = 4;
+    static final int INVERSE_SECONDARY = 5;
+    
+    int comparisonType;
+    String textElement;
+    int hashText;
+    int offset;
+    boolean ignore;
+
+    String expansionOrdering;
+  }
+
+  /**
+   * This the the original rule string.
+   */
+  private String rules;
+
+  /**
+   * This is the table of collation element values
+   */
+  private Object[] ce_table;
+
+  /**
+   * Quick-prefix finder.
+   */
+  HashMap prefix_tree;
+
+  /**
+   * This is the value of the last sequence entered into
+   * <code>ce_table</code>. It is used to compute the
+   * ordering value of unspecified character.
+   */
+  private int last_primary_value;
+
+  /**
+   * This is the value of the last secondary sequence of the
+   * primary 0, entered into
+   * <code>ce_table</code>. It is used to compute the
+   * ordering value of an unspecified accented character.
+   */
+  private int last_tertiary_value;
+
+  /**
+   * This variable is true if accents need to be sorted
+   * in the other direction.
+   */
+  private boolean inverseAccentComparison;
+
+  /**
+   * This collation element is special to unknown sequence.
+   * The JDK uses it to mark and sort the characters which has
+   * no collation rules.
+   */
+  static final CollationElement SPECIAL_UNKNOWN_SEQ = 
+    new CollationElement("", (short) 32767, (short) 0, (short) 0,
+			 (short) 0, null, false);
+  
+  /**
+   * This method initializes a new instance of <code>RuleBasedCollator</code>
+   * with the specified collation rules.  Note that an application normally
+   * obtains an instance of <code>RuleBasedCollator</code> by calling the
+   * <code>getInstance</code> method of <code>Collator</code>.  That method
+   * automatically loads the proper set of rules for the desired locale.
+   *
+   * @param rules The collation rule string.
+   *
+   * @exception ParseException If the rule string contains syntax errors.
+   */
+  public RuleBasedCollator(String rules) throws ParseException
+  {
+    if (rules.equals(""))
+      throw new ParseException("empty rule set", 0);
+    
+    this.rules = rules;
+
+    buildCollationVector(parseString(rules));
+    buildPrefixAccess();
+  }
+
+  /**
+   * This method returns the number of common characters at the beginning
+   * of the string of the two parameters.
+   *
+   * @param prefix A string considered as a prefix to test against
+   * the other string.
+   * @param s A string to test the prefix against.
+   * @return The number of common characters.
+   */
+  static int findPrefixLength(String prefix, String s)
+  {
+    int index;
+    int len = prefix.length();
+
+    for (index = 0; index < len && index < s.length(); ++index)
+      {
+	if (prefix.charAt(index) != s.charAt(index))
+	  return index;
+      }
+
+
+    return index;
+  }
+
+  /**
+   * Here we are merging two sets of sorting instructions: 'patch' into 'main'. This methods
+   * checks whether it is possible to find an anchor point for the rules to be merged and
+   * then insert them at that precise point.
+   *
+   * @param offset Offset in the string containing rules of the beginning of the rules
+   * being merged in.
+   * @param starter Text of the rules being merged.
+   * @param main Repository of all already parsed rules.
+   * @param patch Rules to be merged into the repository.
+   * @throws ParseException if it is impossible to find an anchor point for the new rules.
+   */
+  private void mergeRules(int offset, String starter, ArrayList main, ArrayList patch)
+    throws ParseException 
+  {
+    int insertion_point = -1;
+    int max_length = 0;
+    
+    /* We must check that no rules conflict with another already present. If it
+     * is the case delete the old rule. 
+     */
+    
+    /* For the moment good old O(N^2) algorithm.
+     */
+    for (int i = 0; i < patch.size(); i++)
+      {
+	int j = 0;
+	
+	while (j < main.size())
+	  {
+	    CollationSorter rule1 = (CollationSorter) patch.get(i);
+	    CollationSorter rule2 = (CollationSorter) main.get(j);
+	    
+	    if (rule1.textElement.equals(rule2.textElement))
+	      main.remove(j);
+	    else
+	      j++;
+	  }
+      }
+
+    // Find the insertion point... O(N)
+    for (int i = 0; i < main.size(); i++)
+      {
+	CollationSorter sorter = (CollationSorter) main.get(i);
+	int length = findPrefixLength(starter, sorter.textElement);
+		
+	if (length > max_length)
+	  {
+	    max_length = length;
+	    insertion_point = i+1;
+	  }
+      }
+
+    if (insertion_point < 0)
+      throw new ParseException("no insertion point found for " + starter, offset);
+
+    if (max_length < starter.length())
+      {
+	/*
+	 * We need to expand the first entry. It must be sorted
+	 * like if it was the reference key itself (like the spec
+	 * said. So the first entry is special: the element is
+	 * replaced by the specified text element for the sorting.
+	 * This text replace the old one for comparisons. However
+	 * to preserve the behaviour we replace the first key (corresponding
+	 * to the found prefix) by a new code rightly ordered in the
+	 * sequence. The rest of the subsequence must be appended
+	 * to the end of the sequence.
+	 */
+	CollationSorter sorter = (CollationSorter) patch.get(0);
+	CollationSorter expansionPrefix =
+	  (CollationSorter) main.get(insertion_point-1);
+	
+	sorter.expansionOrdering = starter.substring(max_length); // Skip the first good prefix element
+		
+	main.add(insertion_point, sorter);
+	
+	/*
+	 * This is a new set of rules. Append to the list.
+	 */
+	patch.remove(0);
+	insertion_point++;
+      }
+
+    // Now insert all elements of patch at the insertion point.
+    for (int i = 0; i < patch.size(); i++)
+      main.add(i+insertion_point, patch.get(i));
+  }
+
+  /**
+   * This method parses a string and build a set of sorting instructions. The parsing
+   * may only be partial on the case the rules are to be merged sometime later.
+   * 
+   * @param stop_on_reset If this parameter is true then the parser stops when it
+   * encounters a reset instruction. In the other case, it tries to parse the subrules
+   * and merged it in the same repository.
+   * @param v Output vector for the set of instructions.
+   * @param base_offset Offset in the string to begin parsing.
+   * @param rules Rules to be parsed.
+   * @return -1 if the parser reached the end of the string, an integer representing the
+   * offset in the string at which it stopped parsing. 
+   * @throws ParseException if something turned wrong during the parsing. To get details
+   * decode the message.
+   */
+  private int subParseString(boolean stop_on_reset, ArrayList v,
+			     int base_offset, String rules)
+    throws ParseException
+  {
+    boolean ignoreChars = (base_offset == 0);
+    int operator = -1;
+    StringBuffer sb = new StringBuffer();
+    boolean doubleQuote = false;
+    boolean eatingChars = false;
+    boolean nextIsModifier = false;
+    boolean isModifier = false;
+    int i;
+    
+main_parse_loop:
+    for (i = 0; i < rules.length(); i++)
+      {
+	char c = rules.charAt(i);
+	int type = -1;
+	
+	if (!eatingChars &&
+	    ((c >= 0x09 && c <= 0x0D) || (c == 0x20)))
+	      continue;
+
+	isModifier = nextIsModifier;
+	nextIsModifier = false;
+
+	if (eatingChars && c != '\'')
+	  {
+	    doubleQuote = false;
+	    sb.append(c);
+	    continue;
+	  }
+	if (doubleQuote && eatingChars)
+	  {
+	    sb.append(c);
+	    doubleQuote = false;
+	    continue;
+	  }
+
+	switch (c)
+	  {
+	  case '!':
+	    throw new ParseException
+	      ("Modifier '!' is not yet supported by Classpath", i + base_offset);
+	  case '<':
+	    type = CollationSorter.GREATERP;
+	    break;
+	  case ';':
+	    type = CollationSorter.GREATERS;
+	    break;
+	  case ',':
+	    type = CollationSorter.GREATERT;
+	    break;
+	  case '=':
+	    type = CollationSorter.EQUAL;
+	    break;
+	  case '\'':
+	    eatingChars = !eatingChars;
+	    doubleQuote = true;
+	    break;
+	  case '@':
+	    if (ignoreChars)
+	      throw new ParseException
+		("comparison list has not yet been started. You may only use"
+		 + "(<,;=&)", i + base_offset);
+	    // Inverse the order of secondaries from now on.
+	    nextIsModifier = true;
+	    type = CollationSorter.INVERSE_SECONDARY;
+	    break;
+	  case '&':
+	    type = CollationSorter.RESET;
+	    if (stop_on_reset)
+	      break main_parse_loop;
+	    break;
+	  default:
+	    if (operator < 0)
+	      throw new ParseException
+		("operator missing at " + (i + base_offset), i + base_offset);
+	    if (! eatingChars
+		&& ((c >= 0x21 && c <= 0x2F) 
+		    || (c >= 0x3A && c <= 0x40)
+		    || (c >= 0x5B && c <= 0x60)
+		    || (c >= 0x7B && c <= 0x7E)))
+	      throw new ParseException
+		("unquoted punctuation character '" + c + "'", i + base_offset);
+
+	    //type = ignoreChars ? CollationSorter.IGNORE : -1;
+	    sb.append(c);
+	    break;
+	  }
+
+	if (type  < 0)
+	  continue;
+
+	if (operator < 0)
+	  {
+	    operator = type;
+	    continue;
+	  }
+
+	if (sb.length() == 0 && !isModifier)
+	  throw new ParseException
+	    ("text element empty at " + (i+base_offset), i+base_offset);
+
+	if (operator == CollationSorter.RESET)
+	  {
+	    /* Reposition in the sorting list at the position
+	     * indicated by the text element.
+	     */
+	    String subrules = rules.substring(i);
+	    ArrayList sorted_rules = new ArrayList();
+	    int idx;
+
+	    // Parse the subrules but do not iterate through all
+	    // sublist. This is the privilege of the first call.
+	    idx = subParseString(true, sorted_rules, base_offset+i, subrules);
+    
+	    // Merge new parsed rules into the list.
+	    mergeRules(base_offset+i, sb.toString(), v, sorted_rules);
+	    sb.setLength(0);
+	    
+	    // Reset state to none.
+	    operator = -1;
+	    type = -1;
+	    // We have found a new subrule at 'idx' but it has not been parsed.
+	    if (idx >= 0)
+	      {
+		i += idx-1;
+		continue main_parse_loop;
+	      }
+	    else
+		// No more rules.
+		break main_parse_loop;
+	  }
+
+	CollationSorter sorter = new CollationSorter();
+	
+	if (operator == CollationSorter.GREATERP)
+	  ignoreChars = false;
+
+	sorter.comparisonType = operator;
+	sorter.textElement = sb.toString();
+	sorter.hashText = sorter.textElement.hashCode();
+	sorter.offset = base_offset+rules.length();
+	sorter.ignore = ignoreChars;
+	sb.setLength(0);
+
+	v.add(sorter);
+	operator = type;
+      }
+
+    if (operator >= 0)
+      {
+	CollationSorter sorter = new CollationSorter();
+	int pos = rules.length() + base_offset;
+
+	if ((sb.length() != 0 && nextIsModifier)
+	    || (sb.length() == 0 && !nextIsModifier && !eatingChars))
+	  throw new ParseException("text element empty at " + pos, pos);
+
+	if (operator == CollationSorter.GREATERP)
+	  ignoreChars = false;
+
+	sorter.comparisonType = operator;
+	sorter.textElement = sb.toString();
+ 	sorter.hashText = sorter.textElement.hashCode();
+	sorter.offset = base_offset+pos;
+	sorter.ignore = ignoreChars;
+	v.add(sorter);
+      }
+
+    if (i == rules.length())
+      return -1;
+    else
+      return i;
+  }
+
+  /**
+   * This method creates a copy of this object.
+   *
+   * @return A copy of this object.
+   */
+  public Object clone()
+  {
+    return super.clone();
+  }
+
+  /**
+   * This method completely parses a string 'rules' containing sorting rules.
+   *
+   * @param rules String containing the rules to be parsed. 
+   * @return A set of sorting instructions stored in a Vector.
+   * @throws ParseException if something turned wrong during the parsing. To get details
+   * decode the message.
+   */
+  private ArrayList parseString(String rules) 
+    throws ParseException
+  {
+    ArrayList v = new ArrayList();
+
+    // result of the first subParseString is not absolute (may be -1 or a
+    // positive integer). But we do not care.
+    subParseString(false, v, 0, rules);
+    
+    return v;
+  }
+
+  /**
+   * This method uses the sorting instructions built by {@link #parseString}
+   * to build collation elements which can be directly used to sort strings.
+   *
+   * @param parsedElements Parsed instructions stored in a ArrayList.
+   * @throws ParseException if the order of the instructions are not valid.
+   */
+  private void buildCollationVector(ArrayList parsedElements)
+    throws ParseException
+  {
+    int primary_seq = 0;
+    int last_tertiary_seq = 0;
+    short secondary_seq = 0;
+    short tertiary_seq = 0;
+    short equality_seq = 0;
+    boolean inverseComparisons = false;
+    final boolean DECREASING = false;
+    final boolean INCREASING = true;
+    boolean secondaryType = INCREASING;
+    ArrayList v = new ArrayList();
+
+    // elts is completely sorted.
+element_loop:
+    for (int i = 0; i < parsedElements.size(); i++)
+      {
+	CollationSorter elt = (CollationSorter) parsedElements.get(i);
+	boolean ignoreChar = false;
+
+	switch (elt.comparisonType)
+	  {
+	  case CollationSorter.GREATERP:
+	    primary_seq++;
+	    if (inverseComparisons)
+	      {
+		secondary_seq = Short.MAX_VALUE;
+		secondaryType = DECREASING;
+	      }
+	    else
+	      {
+		secondary_seq = 0;
+		secondaryType = INCREASING;
+	      }
+	    tertiary_seq = 0;
+	    equality_seq = 0;
+	    inverseComparisons = false;
+	    break;
+	  case CollationSorter.GREATERS:
+	    if (secondaryType == DECREASING)
+	      secondary_seq--;
+	    else
+	      secondary_seq++;
+	    tertiary_seq = 0;
+	    equality_seq = 0;
+	    break;
+	  case CollationSorter.INVERSE_SECONDARY:
+	    inverseComparisons = true;
+	    continue element_loop;
+	  case CollationSorter.GREATERT:
+	    tertiary_seq++;
+	    if (primary_seq == 0)
+	      last_tertiary_seq = tertiary_seq;
+	    equality_seq = 0;
+	    break;
+	  case CollationSorter.EQUAL:
+	    equality_seq++;
+	    break;
+	  case CollationSorter.RESET:
+	    throw new ParseException
+	      ("Invalid reached state 'RESET'. Internal error", elt.offset);
+	  default:
+	    throw new ParseException
+	      ("Invalid unknown state '" + elt.comparisonType + "'", elt.offset);
+	  }
+
+	v.add(new CollationElement(elt.textElement, primary_seq,
+				   secondary_seq, tertiary_seq,
+				   equality_seq, elt.expansionOrdering, elt.ignore));
+      }
+
+    this.inverseAccentComparison = inverseComparisons; 
+
+    ce_table = v.toArray();
+
+    last_primary_value = primary_seq+1;
+    last_tertiary_value = last_tertiary_seq+1;
+  }
+
+  /**
+   * Build a tree where all keys are the texts of collation elements and data is
+   * the collation element itself. The tree is used when extracting all prefix
+   * for a given text.
+   */
+  private void buildPrefixAccess()
+  {
+    prefix_tree = new HashMap();
+
+    for (int i = 0; i < ce_table.length; i++)
+      {
+	CollationElement e = (CollationElement) ce_table[i];
+
+	prefix_tree.put(e.key, e);
+      }
+  }
+
+  /**
+   * This method returns an integer which indicates whether the first
+   * specified <code>String</code> is less than, greater than, or equal to
+   * the second.  The value depends not only on the collation rules in
+   * effect, but also the strength and decomposition settings of this object.
+   *
+   * @param source The first <code>String</code> to compare.
+   * @param target A second <code>String</code> to compare to the first.
+   *
+   * @return A negative integer if source < target, a positive integer
+   * if source > target, or 0 if source == target.
+   */
+  public int compare(String source, String target)
+  {
+    CollationElementIterator cs, ct;
+    CollationElement ord1block = null;
+    CollationElement ord2block = null;
+    boolean advance_block_1 = true;
+    boolean advance_block_2 = true;
+
+    cs = getCollationElementIterator(source);
+    ct = getCollationElementIterator(target);
+
+    for(;;)
+      {
+	int ord1;
+	int ord2;
+
+	/*
+	 * We have to check whether the characters are ignorable.
+	 * If it is the case then forget them. 
+	 */
+	if (advance_block_1)
+	  {
+	    ord1block = cs.nextBlock();
+	    if (ord1block != null && ord1block.ignore)
+	      continue;
+	  }
+	
+	if (advance_block_2)
+	  {
+	    ord2block = ct.nextBlock();
+	    if (ord2block != null && ord2block.ignore)
+	      {
+	        advance_block_1 = false;
+	        continue;
+	      }
+	 }
+	else
+	  advance_block_2 = true;
+
+	if (!advance_block_1)
+	  advance_block_1 = true;
+
+	if (ord1block != null)
+	  ord1 = ord1block.getValue();
+	else
+	  {
+	    if (ord2block == null)
+	      return 0;
+	    return -1;
+	  }
+
+	if (ord2block == null)
+	  return 1;
+	
+	ord2 = ord2block.getValue();
+	
+	// We know chars are totally equal, so skip
+        if (ord1 == ord2)
+	  {
+	    if (getStrength() == IDENTICAL)
+	      if (!ord1block.key.equals(ord2block.key))
+		return ord1block.key.compareTo(ord2block.key);
+	    continue;
+	  }
+
+        // Check for primary strength differences
+        int prim1 = CollationElementIterator.primaryOrder(ord1); 
+        int prim2 = CollationElementIterator.primaryOrder(ord2); 
+	
+	if (prim1 == 0 && getStrength() < TERTIARY)
+	  {
+            advance_block_2 = false;
+	    continue;
+	  }
+	else if (prim2 == 0 && getStrength() < TERTIARY)
+	  {
+	    advance_block_1 = false;
+	    continue;
+	  }
+
+        if (prim1 < prim2)
+          return -1;
+        else if (prim1 > prim2)
+          return 1;
+        else if (getStrength() == PRIMARY)
+          continue;
+
+        // Check for secondary strength differences
+        int sec1 = CollationElementIterator.secondaryOrder(ord1);
+        int sec2 = CollationElementIterator.secondaryOrder(ord2);
+
+	if (sec1 < sec2)
+          return -1;
+        else if (sec1 > sec2)
+          return 1;
+        else if (getStrength() == SECONDARY)
+          continue;
+
+        // Check for tertiary differences
+        int tert1 = CollationElementIterator.tertiaryOrder(ord1);
+        int tert2 = CollationElementIterator.tertiaryOrder(ord2);
+
+        if (tert1 < tert2)
+          return -1;
+        else if (tert1 > tert2)
+          return 1;
+	else if (getStrength() == TERTIARY)
+	  continue;
+
+	// Apparently JDK does this (at least for my test case).
+	return ord1block.key.compareTo(ord2block.key);    
+      }
+  }
+
+  /**
+   * This method tests this object for equality against the specified 
+   * object.  This will be true if and only if the specified object is
+   * another reference to this object.
+   *
+   * @param obj The <code>Object</code> to compare against this object.
+   *
+   * @return <code>true</code> if the specified object is equal to this object,
+   * <code>false</code> otherwise.
+   */
+  public boolean equals(Object obj)
+  {
+    if (obj == this)
+      return true;
+    else
+      return false;
+  }
+
+  /**
+   * This method builds a default collation element without invoking
+   * the database created from the rules passed to the constructor.
+   *
+   * @param c Character which needs a collation element.
+   * @return A valid brand new CollationElement instance.
+   */
+  CollationElement getDefaultElement(char c)
+  {
+    int v;
+
+    // Preliminary support for generic accent sorting inversion (I don't know if all
+    // characters in the range should be sorted backward). This is the place
+    // to fix this if needed.
+    if (inverseAccentComparison && (c >= 0x02B9 && c <= 0x0361))
+      v = 0x0361 - ((int) c - 0x02B9);
+    else
+      v = (short) c;
+    return new CollationElement("" + c, last_primary_value + v,
+				(short) 0, (short) 0, (short) 0, null, false);
+  }
+
+  /**
+   * This method builds a default collation element for an accented character
+   * without invoking the database created from the rules passed to the constructor.
+   *
+   * @param c Character which needs a collation element.
+   * @return A valid brand new CollationElement instance.
+   */
+  CollationElement getDefaultAccentedElement(char c)
+  {
+    int v;
+
+    // Preliminary support for generic accent sorting inversion (I don't know if all
+    // characters in the range should be sorted backward). This is the place
+    // to fix this if needed.
+    if (inverseAccentComparison && (c >= 0x02B9 && c <= 0x0361))
+      v = 0x0361 - ((int) c - 0x02B9);
+    else
+      v = (short) c;
+    return new CollationElement("" + c, (short) 0,
+				(short) 0, (short) (last_tertiary_value + v), (short) 0, null, false);
+  }
+
+  /**
+   * This method returns an instance for <code>CollationElementIterator</code>
+   * for the specified <code>String</code> under the collation rules for this
+   * object.
+   *
+   * @param source The <code>String</code> to return the
+   * <code>CollationElementIterator</code> instance for.
+   *
+   * @return A <code>CollationElementIterator</code> for the specified
+   * <code>String</code>.
+   */
+  public CollationElementIterator getCollationElementIterator(String source)
+  {
+    return new CollationElementIterator(this, source);
+  }
+
+  /**
+   * This method returns an instance of <code>CollationElementIterator</code>
+   * for the <code>String</code> represented by the specified
+   * <code>CharacterIterator</code>.
+   *
+   * @param source The <code>CharacterIterator</code> with the desired <code>String</code>.
+   *
+   * @return A <code>CollationElementIterator</code> for the specified <code>String</code>.
+   */
+  public CollationElementIterator getCollationElementIterator(CharacterIterator source)
+    throws NotImplementedException  // Because decomposeCharacter does not work
+  {
+    StringBuffer expand = new StringBuffer("");
+    
+    // Right now we assume that we will read from the beginning of the string.
+    for (char c = source.first();
+	 c != CharacterIterator.DONE;
+	 c = source.next())
+      decomposeCharacter(c, expand);
+
+    return getCollationElementIterator(expand.toString());
+  }
+
+  /**
+   * This method returns an instance of <code>CollationKey</code> for the
+   * specified <code>String</code>.  The object returned will have a
+   * more efficient mechanism for its comparison function that could
+   * provide speed benefits if multiple comparisons are performed, such
+   * as during a sort.
+   *
+   * @param source The <code>String</code> to create a <code>CollationKey</code> for.
+   *
+   * @return A <code>CollationKey</code> for the specified <code>String</code>.
+   */
+  public CollationKey getCollationKey(String source)
+  {
+    CollationElementIterator cei = getCollationElementIterator(source);
+    ArrayList vect = new ArrayList();
+
+    int ord = cei.next();
+    cei.reset(); //set to start of string
+
+    while (ord != CollationElementIterator.NULLORDER)
+      {
+	// If the primary order is null, it means this is an ignorable
+	// character.
+	if (CollationElementIterator.primaryOrder(ord) == 0)
+	  {
+            ord = cei.next();
+	    continue;
+	  }
+        switch (getStrength())
+          {
+            case PRIMARY:
+	      ord = CollationElementIterator.primaryOrder(ord);
+	      break;
+	      
+            case SECONDARY:
+	      ord = CollationElementIterator.primaryOrder(ord) << 8;
+	      ord |= CollationElementIterator.secondaryOrder(ord);
+
+            default:
+               break;
+          }
+
+        vect.add(new Integer(ord)); 
+	ord = cei.next(); //increment to next key
+      }
+
+    Object[] objarr = vect.toArray();
+    byte[] key = new byte[objarr.length * 4];
+
+    for (int i = 0; i < objarr.length; i++)
+      {
+        int j = ((Integer) objarr[i]).intValue();
+        key [i * 4] = (byte) ((j & 0xFF000000) >> 24);
+        key [i * 4 + 1] = (byte) ((j & 0x00FF0000) >> 16);
+        key [i * 4 + 2] = (byte) ((j & 0x0000FF00) >> 8);
+        key [i * 4 + 3] = (byte) (j & 0x000000FF);
+      }
+
+    return new CollationKey(this, source, key);
+  }
+
+  /**
+   * This method returns a <code>String</code> containing the collation rules
+   * for this object.
+   *
+   * @return The collation rules for this object.
+   */
+  public String getRules()
+  {
+    return rules;
+  }
+
+  /**
+   * This method returns a hash value for this object.
+   *
+   * @return A hash value for this object.
+   */
+  public int hashCode()
+  {
+    return System.identityHashCode(this);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/SimpleDateFormat.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/SimpleDateFormat.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/SimpleDateFormat.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/SimpleDateFormat.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1287 @@
+/* SimpleDateFormat.java -- A class for parsing/formating simple 
+   date constructs
+   Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005
+   Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+import gnu.java.text.AttributedFormatBuffer;
+import gnu.java.text.FormatBuffer;
+import gnu.java.text.FormatCharacterIterator;
+import gnu.java.text.StringFormatBuffer;
+
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.TimeZone;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * SimpleDateFormat provides convenient methods for parsing and formatting
+ * dates using Gregorian calendars (see java.util.GregorianCalendar). 
+ */
+public class SimpleDateFormat extends DateFormat 
+{
+  /** 
+   * This class is used by <code>SimpleDateFormat</code> as a
+   * compiled representation of a format string.  The field
+   * ID, size, and character used are stored for each sequence
+   * of pattern characters.
+   */
+  private class CompiledField
+  {
+    /**
+     * The ID of the field within the local pattern characters.
+     * Package private for use in out class.
+     */
+    int field;
+
+    /**
+     * The size of the character sequence.
+     * Package private for use in out class.
+     */
+    int size;
+
+    /**
+     * The character used.
+     */
+    private char character;
+
+    /** 
+     * Constructs a compiled field using the
+     * the given field ID, size and character
+     * values.
+     *
+     * @param f the field ID.
+     * @param s the size of the field.
+     * @param c the character used.
+     */
+    public CompiledField(int f, int s, char c)
+    {
+      field = f;
+      size = s;
+      character = c;
+    }
+
+    /**
+     * Retrieves the ID of the field relative to
+     * the local pattern characters.
+     */
+    public int getField()
+    {
+      return field;
+    }
+
+    /**
+     * Retrieves the size of the character sequence.
+     */
+    public int getSize()
+    {
+      return size;
+    }
+
+    /**
+     * Retrieves the character used in the sequence.
+     */
+    public char getCharacter()
+    {
+      return character;
+    }
+
+    /**
+     * Returns a <code>String</code> representation
+     * of the compiled field, primarily for debugging
+     * purposes.
+     *
+     * @return a <code>String</code> representation.
+     */
+    public String toString()
+    {
+      StringBuffer builder;
+
+      builder = new StringBuffer(getClass().getName());
+      builder.append("[field=");
+      builder.append(field);
+      builder.append(", size=");
+      builder.append(size);
+      builder.append(", character=");
+      builder.append(character);
+      builder.append("]");
+
+      return builder.toString();
+    }
+  }
+
+  /**
+   * A list of <code>CompiledField</code>s,
+   * representing the compiled version of the pattern.
+   *
+   * @see CompiledField
+   * @serial Ignored.
+   */
+  private transient ArrayList tokens;
+
+  /**
+   * The localised data used in formatting,
+   * such as the day and month names in the local
+   * language, and the localized pattern characters.
+   *
+   * @see DateFormatSymbols
+   * @serial The localisation data.  May not be null.
+   */
+  private DateFormatSymbols formatData;
+
+  /**
+   * The date representing the start of the century
+   * used for interpreting two digit years.  For
+   * example, 24/10/2004 would cause two digit
+   * years to be interpreted as representing
+   * the years between 2004 and 2104.
+   *
+   * @see #get2DigitYearStart()
+   * @see #set2DigitYearStart(java.util.Date)
+   * @see Date
+   * @serial The start date of the century for parsing two digit years.
+   *         May not be null.
+   */
+  private Date defaultCenturyStart;
+
+  /**
+   * The year at which interpretation of two
+   * digit years starts.
+   *
+   * @see #get2DigitYearStart()
+   * @see #set2DigitYearStart(java.util.Date)
+   * @serial Ignored.
+   */
+  private transient int defaultCentury;
+
+  /**
+   * The non-localized pattern string.  This
+   * only ever contains the pattern characters
+   * stored in standardChars.  Localized patterns
+   * are translated to this form.
+   *
+   * @see #applyPattern(String)
+   * @see #applyLocalizedPattern(String)
+   * @see #toPattern()
+   * @see #toLocalizedPattern()
+   * @serial The non-localized pattern string.  May not be null.
+   */
+  private String pattern;
+
+  /**
+   * The version of serialized data used by this class.
+   * Version 0 only includes the pattern and formatting
+   * data.  Version 1 adds the start date for interpreting
+   * two digit years.
+   *
+   * @serial This specifies the version of the data being serialized.
+   *         Version 0 (or no version) specifies just <code>pattern</code>
+   *         and <code>formatData</code>.  Version 1 adds
+   *         the <code>defaultCenturyStart</code>.  This implementation
+   *         always writes out version 1 data.
+   */
+  private int serialVersionOnStream = 1; // 0 indicates JDK1.1.3 or earlier
+
+  /**
+   * For compatability.
+   */
+  private static final long serialVersionUID = 4774881970558875024L;
+
+  // This string is specified in the root of the CLDR.  We set it here
+  // rather than doing a DateFormatSymbols(Locale.US).getLocalPatternChars()
+  // since someone could theoretically change those values (though unlikely).
+  private static final String standardChars = "GyMdkHmsSEDFwWahKzYeugAZ";
+
+  /**
+   * Reads the serialized version of this object.
+   * If the serialized data is only version 0,
+   * then the date for the start of the century
+   * for interpreting two digit years is computed.
+   * The pattern is parsed and compiled following the process
+   * of reading in the serialized data.
+   *
+   * @param stream the object stream to read the data from.
+   * @throws IOException if an I/O error occurs.
+   * @throws ClassNotFoundException if the class of the serialized data
+   *         could not be found.
+   * @throws InvalidObjectException if the pattern is invalid.
+   */ 
+  private void readObject(ObjectInputStream stream)
+    throws IOException, ClassNotFoundException
+  {
+    stream.defaultReadObject();
+    if (serialVersionOnStream < 1)
+      {
+        computeCenturyStart ();
+	serialVersionOnStream = 1;
+      }
+    else
+      // Ensure that defaultCentury gets set.
+      set2DigitYearStart(defaultCenturyStart);
+
+    // Set up items normally taken care of by the constructor.
+    tokens = new ArrayList();
+    try
+      {
+	compileFormat(pattern);
+      }
+    catch (IllegalArgumentException e)
+      {
+	throw new InvalidObjectException("The stream pattern was invalid.");
+      }
+  }
+
+  /**
+   * Compiles the supplied non-localized pattern into a form
+   * from which formatting and parsing can be performed.
+   * This also detects errors in the pattern, which will
+   * be raised on later use of the compiled data.
+   *
+   * @param pattern the non-localized pattern to compile.
+   * @throws IllegalArgumentException if the pattern is invalid.
+   */
+  private void compileFormat(String pattern) 
+  {
+    // Any alphabetical characters are treated as pattern characters
+    // unless enclosed in single quotes.
+
+    char thisChar;
+    int pos;
+    int field;
+    CompiledField current = null;
+
+    for (int i = 0; i < pattern.length(); i++)
+      {
+	thisChar = pattern.charAt(i);
+	field = standardChars.indexOf(thisChar);
+	if (field == -1)
+	  {
+	    current = null;
+	    if ((thisChar >= 'A' && thisChar <= 'Z')
+		|| (thisChar >= 'a' && thisChar <= 'z'))
+	      {
+		// Not a valid letter
+		throw new IllegalArgumentException("Invalid letter "
+						   + thisChar +
+						   " encountered at character "
+						   + i + ".");
+	      }
+	    else if (thisChar == '\'')
+	      {
+		// Quoted text section; skip to next single quote
+		pos = pattern.indexOf('\'', i + 1);
+		// First look for '' -- meaning a single quote.
+		if (pos == i + 1)
+		  tokens.add("'");
+		else
+		  {
+		    // Look for the terminating quote.  However, if we
+		    // see a '', that represents a literal quote and
+		    // we must iterate.
+		    StringBuffer buf = new StringBuffer();
+		    int oldPos = i + 1;
+		    do
+		      {
+			if (pos == -1)
+			  throw new IllegalArgumentException("Quotes starting at character "
+							     + i +
+							     " not closed.");
+			buf.append(pattern.substring(oldPos, pos));
+			if (pos + 1 >= pattern.length()
+			    || pattern.charAt(pos + 1) != '\'')
+			  break;
+			buf.append('\'');
+			oldPos = pos + 2;
+			pos = pattern.indexOf('\'', pos + 2);
+		      }
+		    while (true);
+		    tokens.add(buf.toString());
+		  }
+		i = pos;
+	      }
+	    else
+	      {
+		// A special character
+		tokens.add(new Character(thisChar));
+	      }
+	  }
+	else
+	  {
+	    // A valid field
+	    if ((current != null) && (field == current.field))
+	      current.size++;
+	    else
+	      {
+		current = new CompiledField(field, 1, thisChar);
+		tokens.add(current);
+	      }
+	  }
+      }
+  }
+
+  /**
+   * Returns a string representation of this
+   * class.
+   *
+   * @return a string representation of the <code>SimpleDateFormat</code>
+   *         instance.
+   */
+  public String toString() 
+  {
+    StringBuffer output = new StringBuffer(getClass().getName());
+    output.append("[tokens=");
+    output.append(tokens);
+    output.append(", formatData=");
+    output.append(formatData);
+    output.append(", defaultCenturyStart=");
+    output.append(defaultCenturyStart);
+    output.append(", defaultCentury=");
+    output.append(defaultCentury);
+    output.append(", pattern=");
+    output.append(pattern);
+    output.append(", serialVersionOnStream=");
+    output.append(serialVersionOnStream);
+    output.append(", standardChars=");
+    output.append(standardChars);
+    output.append("]");
+    return output.toString();
+  }
+
+  /**
+   * Constructs a SimpleDateFormat using the default pattern for
+   * the default locale.
+   */
+  public SimpleDateFormat() 
+  {
+    /*
+     * There does not appear to be a standard API for determining 
+     * what the default pattern for a locale is, so use package-scope
+     * variables in DateFormatSymbols to encapsulate this.
+     */
+    super();
+    Locale locale = Locale.getDefault();
+    calendar = new GregorianCalendar(locale);
+    computeCenturyStart();
+    tokens = new ArrayList();
+    formatData = new DateFormatSymbols(locale);
+    pattern = (formatData.dateFormats[DEFAULT] + ' '
+	       + formatData.timeFormats[DEFAULT]);
+    compileFormat(pattern);
+    numberFormat = NumberFormat.getInstance(locale);
+    numberFormat.setGroupingUsed (false);
+    numberFormat.setParseIntegerOnly (true);
+    numberFormat.setMaximumFractionDigits (0);
+  }
+  
+  /**
+   * Creates a date formatter using the specified non-localized pattern,
+   * with the default DateFormatSymbols for the default locale.
+   *
+   * @param pattern the pattern to use.
+   * @throws NullPointerException if the pattern is null.
+   * @throws IllegalArgumentException if the pattern is invalid.
+   */
+  public SimpleDateFormat(String pattern) 
+  {
+    this(pattern, Locale.getDefault());
+  }
+
+  /**
+   * Creates a date formatter using the specified non-localized pattern,
+   * with the default DateFormatSymbols for the given locale.
+   *
+   * @param pattern the non-localized pattern to use.
+   * @param locale the locale to use for the formatting symbols.
+   * @throws NullPointerException if the pattern is null.
+   * @throws IllegalArgumentException if the pattern is invalid.
+   */
+  public SimpleDateFormat(String pattern, Locale locale) 
+  {
+    super();
+    calendar = new GregorianCalendar(locale);
+    computeCenturyStart();
+    tokens = new ArrayList();
+    formatData = new DateFormatSymbols(locale);
+    compileFormat(pattern);
+    this.pattern = pattern;
+    numberFormat = NumberFormat.getInstance(locale);
+    numberFormat.setGroupingUsed (false);
+    numberFormat.setParseIntegerOnly (true);
+    numberFormat.setMaximumFractionDigits (0);
+  }
+
+  /**
+   * Creates a date formatter using the specified non-localized
+   * pattern. The specified DateFormatSymbols will be used when
+   * formatting.
+   *
+   * @param pattern the non-localized pattern to use.
+   * @param formatData the formatting symbols to use.
+   * @throws NullPointerException if the pattern or formatData is null.
+   * @throws IllegalArgumentException if the pattern is invalid.
+   */
+  public SimpleDateFormat(String pattern, DateFormatSymbols formatData)
+  {
+    super();
+    calendar = new GregorianCalendar();
+    computeCenturyStart ();
+    tokens = new ArrayList();
+    if (formatData == null)
+      throw new NullPointerException("formatData");
+    this.formatData = formatData;
+    compileFormat(pattern);
+    this.pattern = pattern;
+    numberFormat = NumberFormat.getInstance();
+    numberFormat.setGroupingUsed (false);
+    numberFormat.setParseIntegerOnly (true);
+    numberFormat.setMaximumFractionDigits (0);
+  }
+
+  /**
+   * This method returns a string with the formatting pattern being used
+   * by this object.  This string is unlocalized.
+   *
+   * @return The format string.
+   */
+  public String toPattern()
+  {
+    return pattern;
+  }
+
+  /**
+   * This method returns a string with the formatting pattern being used
+   * by this object.  This string is localized.
+   *
+   * @return The format string.
+   */
+  public String toLocalizedPattern()
+  {
+    String localChars = formatData.getLocalPatternChars();
+    return translateLocalizedPattern(pattern, standardChars, localChars);
+  }
+
+  /**
+   * This method sets the formatting pattern that should be used by this
+   * object.  This string is not localized.
+   *
+   * @param pattern The new format pattern.
+   * @throws NullPointerException if the pattern is null.
+   * @throws IllegalArgumentException if the pattern is invalid.
+   */
+  public void applyPattern(String pattern)
+  {
+    tokens = new ArrayList();
+    compileFormat(pattern);
+    this.pattern = pattern;
+  }
+
+  /**
+   * This method sets the formatting pattern that should be used by this
+   * object.  This string is localized.
+   *
+   * @param pattern The new format pattern.
+   * @throws NullPointerException if the pattern is null.
+   * @throws IllegalArgumentException if the pattern is invalid.
+   */
+  public void applyLocalizedPattern(String pattern)
+  {
+    String localChars = formatData.getLocalPatternChars();
+    pattern = translateLocalizedPattern(pattern, localChars, standardChars);
+    applyPattern(pattern);
+  }
+
+  /**
+   * Translates either from or to a localized variant of the pattern
+   * string.  For example, in the German locale, 't' (for 'tag') is
+   * used instead of 'd' (for 'date').  This method translates
+   * a localized pattern (such as 'ttt') to a non-localized pattern
+   * (such as 'ddd'), or vice versa.  Non-localized patterns use
+   * a standard set of characters, which match those of the U.S. English
+   * locale.
+   *
+   * @param pattern the pattern to translate.
+   * @param oldChars the old set of characters (used in the pattern).
+   * @param newChars the new set of characters (which will be used in the
+   *                 pattern).
+   * @return a version of the pattern using the characters in
+   *         <code>newChars</code>.
+   */
+  private String translateLocalizedPattern(String pattern,
+					   String oldChars, String newChars)
+  {
+    int len = pattern.length();
+    StringBuffer buf = new StringBuffer(len);
+    boolean quoted = false;
+    for (int i = 0;  i < len;  i++)
+      {
+	char ch = pattern.charAt(i);
+	if (ch == '\'')
+	  quoted = ! quoted;
+	if (! quoted)
+	  {
+	    int j = oldChars.indexOf(ch);
+	    if (j >= 0)
+	      ch = newChars.charAt(j);
+	  }
+	buf.append(ch);
+      }
+    return buf.toString();
+  }
+
+  /** 
+   * Returns the start of the century used for two digit years.
+   *
+   * @return A <code>Date</code> representing the start of the century
+   * for two digit years.
+   */
+  public Date get2DigitYearStart()
+  {
+    return defaultCenturyStart;
+  }
+
+  /**
+   * Sets the start of the century used for two digit years.
+   *
+   * @param date A <code>Date</code> representing the start of the century for
+   * two digit years.
+   */
+  public void set2DigitYearStart(Date date)
+  {
+    defaultCenturyStart = date;
+    calendar.clear();
+    calendar.setTime(date);
+    int year = calendar.get(Calendar.YEAR);
+    defaultCentury = year - (year % 100);
+  }
+
+  /**
+   * This method returns a copy of the format symbol information used
+   * for parsing and formatting dates.
+   *
+   * @return a copy of the date format symbols.
+   */
+  public DateFormatSymbols getDateFormatSymbols()
+  {
+    return (DateFormatSymbols) formatData.clone();
+  }
+
+  /**
+   * This method sets the format symbols information used for parsing
+   * and formatting dates.
+   *
+   * @param formatData The date format symbols.
+   * @throws NullPointerException if <code>formatData</code> is null.
+   */
+   public void setDateFormatSymbols(DateFormatSymbols formatData)
+   {
+     if (formatData == null)
+       {
+	 throw new
+	   NullPointerException("The supplied format data was null.");
+       }
+     this.formatData = formatData;
+   }
+
+  /**
+   * This methods tests whether the specified object is equal to this
+   * object.  This will be true if and only if the specified object:
+   * <p>
+   * <ul>
+   * <li>Is not <code>null</code>.</li>
+   * <li>Is an instance of <code>SimpleDateFormat</code>.</li>
+   * <li>Is equal to this object at the superclass (i.e., <code>DateFormat</code>)
+   *     level.</li>
+   * <li>Has the same formatting pattern.</li>
+   * <li>Is using the same formatting symbols.</li>
+   * <li>Is using the same century for two digit years.</li>
+   * </ul>
+   *
+   * @param o The object to compare for equality against.
+   *
+   * @return <code>true</code> if the specified object is equal to this object,
+   * <code>false</code> otherwise.
+   */
+  public boolean equals(Object o)
+  {
+    if (!super.equals(o))
+      return false;
+
+    if (!(o instanceof SimpleDateFormat))
+      return false;
+
+    SimpleDateFormat sdf = (SimpleDateFormat)o;
+
+    if (defaultCentury != sdf.defaultCentury)
+      return false;
+
+    if (!toPattern().equals(sdf.toPattern()))
+      return false;
+
+    if (!getDateFormatSymbols().equals(sdf.getDateFormatSymbols()))
+      return false;
+
+    return true;
+  }
+
+  /**
+   * This method returns a hash value for this object.
+   *
+   * @return A hash value for this object.
+   */
+  public int hashCode()
+  {
+    return super.hashCode() ^ toPattern().hashCode() ^ defaultCentury ^
+      getDateFormatSymbols().hashCode();
+  }
+
+
+  /**
+   * Formats the date input according to the format string in use,
+   * appending to the specified StringBuffer.  The input StringBuffer
+   * is returned as output for convenience.
+   */
+  private void formatWithAttribute(Date date, FormatBuffer buffer, FieldPosition pos)
+  {
+    String temp;
+    AttributedCharacterIterator.Attribute attribute;
+    calendar.setTime(date);
+
+    // go through vector, filling in fields where applicable, else toString
+    Iterator iter = tokens.iterator();
+    while (iter.hasNext())
+      {
+	Object o = iter.next();
+	if (o instanceof CompiledField)
+	  {
+	    CompiledField cf = (CompiledField) o;
+	    int beginIndex = buffer.length();
+	    
+	    switch (cf.getField())
+	      {
+	      case ERA_FIELD:
+		buffer.append (formatData.eras[calendar.get (Calendar.ERA)], DateFormat.Field.ERA);
+		break;
+	      case YEAR_FIELD:
+		// If we have two digits, then we truncate.  Otherwise, we
+		// use the size of the pattern, and zero pad.
+		buffer.setDefaultAttribute (DateFormat.Field.YEAR);
+		if (cf.getSize() == 2)
+		  {
+		    temp = "00"+String.valueOf (calendar.get (Calendar.YEAR));
+		    buffer.append (temp.substring (temp.length() - 2));
+		  }
+		else
+		  withLeadingZeros (calendar.get (Calendar.YEAR), cf.getSize(), buffer);
+		break;
+	      case MONTH_FIELD:
+		buffer.setDefaultAttribute (DateFormat.Field.MONTH);
+		if (cf.getSize() < 3)
+		  withLeadingZeros (calendar.get (Calendar.MONTH) + 1, cf.getSize(), buffer);
+		else if (cf.getSize() < 4)
+		  buffer.append (formatData.shortMonths[calendar.get (Calendar.MONTH)]);
+		else
+		  buffer.append (formatData.months[calendar.get (Calendar.MONTH)]);
+		break;
+	      case DATE_FIELD:
+		buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_MONTH);
+		withLeadingZeros (calendar.get (Calendar.DATE), cf.getSize(), buffer);
+		break;
+	      case HOUR_OF_DAY1_FIELD: // 1-24
+		buffer.setDefaultAttribute(DateFormat.Field.HOUR_OF_DAY1);
+		withLeadingZeros ( ((calendar.get (Calendar.HOUR_OF_DAY) + 23) % 24) + 1, 
+				   cf.getSize(), buffer);
+		break;
+	      case HOUR_OF_DAY0_FIELD: // 0-23
+		buffer.setDefaultAttribute (DateFormat.Field.HOUR_OF_DAY0);
+		withLeadingZeros (calendar.get (Calendar.HOUR_OF_DAY), cf.getSize(), buffer);
+		break;
+	      case MINUTE_FIELD:
+		buffer.setDefaultAttribute (DateFormat.Field.MINUTE);
+		withLeadingZeros (calendar.get (Calendar.MINUTE),
+				  cf.getSize(), buffer);
+		break;
+	      case SECOND_FIELD:
+		buffer.setDefaultAttribute (DateFormat.Field.SECOND);
+		withLeadingZeros(calendar.get (Calendar.SECOND), 
+				 cf.getSize(), buffer);
+		break;
+	      case MILLISECOND_FIELD:
+		buffer.setDefaultAttribute (DateFormat.Field.MILLISECOND);
+		withLeadingZeros (calendar.get (Calendar.MILLISECOND), cf.getSize(), buffer);
+		break;
+	      case DAY_OF_WEEK_FIELD:
+		buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK);
+		if (cf.getSize() < 4)
+		  buffer.append (formatData.shortWeekdays[calendar.get (Calendar.DAY_OF_WEEK)]);
+		else
+		  buffer.append (formatData.weekdays[calendar.get (Calendar.DAY_OF_WEEK)]);
+		break;
+	      case DAY_OF_YEAR_FIELD:
+		buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_YEAR);
+		withLeadingZeros (calendar.get (Calendar.DAY_OF_YEAR), cf.getSize(), buffer);
+		break;
+	      case DAY_OF_WEEK_IN_MONTH_FIELD:
+		buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK_IN_MONTH);
+		withLeadingZeros (calendar.get (Calendar.DAY_OF_WEEK_IN_MONTH), 
+				 cf.getSize(), buffer);
+		break;
+	      case WEEK_OF_YEAR_FIELD:
+		buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_YEAR);
+		withLeadingZeros (calendar.get (Calendar.WEEK_OF_YEAR),
+				  cf.getSize(), buffer);
+		break;
+	      case WEEK_OF_MONTH_FIELD:
+		buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_MONTH);
+		withLeadingZeros (calendar.get (Calendar.WEEK_OF_MONTH),
+				  cf.getSize(), buffer);
+		break;
+	      case AM_PM_FIELD:
+		buffer.setDefaultAttribute (DateFormat.Field.AM_PM);
+		buffer.append (formatData.ampms[calendar.get (Calendar.AM_PM)]);
+		break;
+	      case HOUR1_FIELD: // 1-12
+		buffer.setDefaultAttribute (DateFormat.Field.HOUR1);
+		withLeadingZeros (((calendar.get (Calendar.HOUR) + 11) % 12) + 1,
+				  cf.getSize(), buffer);
+		break;
+	      case HOUR0_FIELD: // 0-11
+		buffer.setDefaultAttribute (DateFormat.Field.HOUR0);
+		withLeadingZeros (calendar.get (Calendar.HOUR), cf.getSize(), buffer);
+		break;
+	      case TIMEZONE_FIELD:
+		buffer.setDefaultAttribute (DateFormat.Field.TIME_ZONE);
+		TimeZone zone = calendar.getTimeZone();
+		boolean isDST = calendar.get (Calendar.DST_OFFSET) != 0;
+		// FIXME: XXX: This should be a localized time zone.
+		String zoneID = zone.getDisplayName
+		  (isDST, cf.getSize() > 3 ? TimeZone.LONG : TimeZone.SHORT);
+		buffer.append (zoneID);
+		break;
+	      case RFC822_TIMEZONE_FIELD:
+		buffer.setDefaultAttribute(DateFormat.Field.RFC822_TIME_ZONE);
+		int pureMinutes = (calendar.get(Calendar.ZONE_OFFSET) +
+				   calendar.get(Calendar.DST_OFFSET)) / (1000 * 60);
+		String sign = (pureMinutes < 0) ? "-" : "+";
+                pureMinutes = Math.abs(pureMinutes);
+		int hours = pureMinutes / 60;
+		int minutes = pureMinutes % 60;
+		buffer.append(sign);
+		withLeadingZeros(hours, 2, buffer);
+		withLeadingZeros(minutes, 2, buffer);
+		break;
+	      default:
+		throw new IllegalArgumentException ("Illegal pattern character " +
+						    cf.getCharacter());
+	      }
+	    if (pos != null && (buffer.getDefaultAttribute() == pos.getFieldAttribute()
+				|| cf.getField() == pos.getField()))
+	      {
+		pos.setBeginIndex(beginIndex);
+		pos.setEndIndex(buffer.length());
+	      }
+	  } 
+      else
+	{  
+	  buffer.append(o.toString(), null);
+	}
+      }
+  }
+  
+  public StringBuffer format(Date date, StringBuffer buffer, FieldPosition pos)
+  {
+    formatWithAttribute(date, new StringFormatBuffer (buffer), pos);
+
+    return buffer;
+  }
+
+  public AttributedCharacterIterator formatToCharacterIterator(Object date)
+    throws IllegalArgumentException
+  {
+    if (date == null)
+      throw new NullPointerException("null argument");
+    if (!(date instanceof Date))
+      throw new IllegalArgumentException("argument should be an instance of java.util.Date");
+
+    AttributedFormatBuffer buf = new AttributedFormatBuffer();
+    formatWithAttribute((Date)date, buf,
+			null);
+    buf.sync();
+        
+    return new FormatCharacterIterator(buf.getBuffer().toString(),
+				       buf.getRanges(),
+				       buf.getAttributes());
+  }
+
+  private void withLeadingZeros(int value, int length, FormatBuffer buffer) 
+  {
+    String valStr = String.valueOf(value);
+    for (length -= valStr.length(); length > 0; length--)
+      buffer.append('0');
+    buffer.append(valStr);
+  }
+
+  private boolean expect(String source, ParsePosition pos, char ch)
+  {
+    int x = pos.getIndex();
+    boolean r = x < source.length() && source.charAt(x) == ch;
+    if (r)
+      pos.setIndex(x + 1);
+    else
+      pos.setErrorIndex(x);
+    return r;
+  }
+
+  /**
+   * This method parses the specified string into a date.
+   * 
+   * @param dateStr The date string to parse.
+   * @param pos The input and output parse position
+   *
+   * @return The parsed date, or <code>null</code> if the string cannot be
+   * parsed.
+   */
+  public Date parse (String dateStr, ParsePosition pos)
+  {
+    int fmt_index = 0;
+    int fmt_max = pattern.length();
+
+    calendar.clear();
+    boolean saw_timezone = false;
+    int quote_start = -1;
+    boolean is2DigitYear = false;
+    try
+      {
+	for (; fmt_index < fmt_max; ++fmt_index)
+	  {
+	    char ch = pattern.charAt(fmt_index);
+	    if (ch == '\'')
+	      {
+		int index = pos.getIndex();
+		if (fmt_index < fmt_max - 1
+		    && pattern.charAt(fmt_index + 1) == '\'')
+		  {
+		    if (! expect (dateStr, pos, ch))
+		      return null;
+		    ++fmt_index;
+		  }
+		else
+		  quote_start = quote_start < 0 ? fmt_index : -1;
+		continue;
+	      }
+	    
+	    if (quote_start != -1
+		|| ((ch < 'a' || ch > 'z')
+		    && (ch < 'A' || ch > 'Z')))
+	      {
+		if (! expect (dateStr, pos, ch))
+		  return null;
+		continue;
+	      }
+	    
+	    // We've arrived at a potential pattern character in the
+	    // pattern.
+	    int fmt_count = 1;
+	    while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch)
+	      {
+		++fmt_count;
+	      }
+	    
+	    // We might need to limit the number of digits to parse in
+	    // some cases.  We look to the next pattern character to
+	    // decide.
+	    boolean limit_digits = false;
+	    if (fmt_index < fmt_max
+		&& standardChars.indexOf(pattern.charAt(fmt_index)) >= 0)
+	      limit_digits = true;
+	    --fmt_index;
+	    
+	    // We can handle most fields automatically: most either are
+	    // numeric or are looked up in a string vector.  In some cases
+	    // we need an offset.  When numeric, `offset' is added to the
+	    // resulting value.  When doing a string lookup, offset is the
+	    // initial index into the string array.
+	    int calendar_field;
+	    boolean is_numeric = true;
+	    int offset = 0;
+	    boolean maybe2DigitYear = false;
+	    boolean oneBasedHour = false;
+	    boolean oneBasedHourOfDay = false;
+	    Integer simpleOffset;
+	    String[] set1 = null;
+	    String[] set2 = null;
+	    switch (ch)
+	      {
+	      case 'd':
+		calendar_field = Calendar.DATE;
+		break;
+	      case 'D':
+		calendar_field = Calendar.DAY_OF_YEAR;
+		break;
+	      case 'F':
+		calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH;
+		break;
+	      case 'E':
+		is_numeric = false;
+		offset = 1;
+		calendar_field = Calendar.DAY_OF_WEEK;
+		set1 = formatData.getWeekdays();
+		set2 = formatData.getShortWeekdays();
+		break;
+	      case 'w':
+		calendar_field = Calendar.WEEK_OF_YEAR;
+		break;
+	      case 'W':
+		calendar_field = Calendar.WEEK_OF_MONTH;
+		break;
+	      case 'M':
+		calendar_field = Calendar.MONTH;
+		if (fmt_count <= 2)
+		  offset = -1;
+		else
+		  {
+		    is_numeric = false;
+		    set1 = formatData.getMonths();
+		    set2 = formatData.getShortMonths();
+		  }
+		break;
+	      case 'y':
+		calendar_field = Calendar.YEAR;
+		if (fmt_count <= 2)
+		  maybe2DigitYear = true;
+		break;
+	      case 'K':
+		calendar_field = Calendar.HOUR;
+		break;
+	      case 'h':
+		calendar_field = Calendar.HOUR;
+		oneBasedHour = true;
+		break;
+	      case 'H':
+		calendar_field = Calendar.HOUR_OF_DAY;
+		break;
+	      case 'k':
+		calendar_field = Calendar.HOUR_OF_DAY;
+		oneBasedHourOfDay = true;
+		break;
+	      case 'm':
+		calendar_field = Calendar.MINUTE;
+		break;
+	      case 's':
+		calendar_field = Calendar.SECOND;
+		break;
+	      case 'S':
+		calendar_field = Calendar.MILLISECOND;
+		break;
+	      case 'a':
+		is_numeric = false;
+		calendar_field = Calendar.AM_PM;
+		set1 = formatData.getAmPmStrings();
+		break;
+	      case 'z':
+	      case 'Z':
+		// We need a special case for the timezone, because it
+		// uses a different data structure than the other cases.
+		is_numeric = false;
+		calendar_field = Calendar.ZONE_OFFSET;
+		String[][] zoneStrings = formatData.getZoneStrings();
+		int zoneCount = zoneStrings.length;
+		int index = pos.getIndex();
+		boolean found_zone = false;
+		simpleOffset = computeOffset(dateStr.substring(index), pos);
+		if (simpleOffset != null)
+		  {
+		    found_zone = true;
+		    saw_timezone = true;
+		    calendar.set(Calendar.DST_OFFSET, 0);
+		    offset = simpleOffset.intValue();
+		  }
+		else
+		  {
+		    for (int j = 0;  j < zoneCount;  j++)
+		      {
+			String[] strings = zoneStrings[j];
+			int k;
+			for (k = 0; k < strings.length; ++k)
+			  {
+			    if (dateStr.startsWith(strings[k], index))
+			      break;
+			  }
+			if (k != strings.length)
+			  {
+			    found_zone = true;
+			    saw_timezone = true;
+			    TimeZone tz = TimeZone.getTimeZone (strings[0]);
+			    // Check if it's a DST zone or ordinary 
+			    if(k == 3 || k == 4)
+			      calendar.set (Calendar.DST_OFFSET, tz.getDSTSavings());
+			    else
+			      calendar.set (Calendar.DST_OFFSET, 0);
+                            offset = tz.getRawOffset ();
+			    pos.setIndex(index + strings[k].length());
+			    break;
+			  }
+		      }
+		  }
+		if (! found_zone)
+		  {
+			pos.setErrorIndex(pos.getIndex());
+			return null;
+		  }
+		break;
+	      default:
+		pos.setErrorIndex(pos.getIndex());
+		return null;
+	      }
+      
+	    // Compute the value we should assign to the field.
+	    int value;
+	    int index = -1;
+	    if (is_numeric)
+	      {
+		numberFormat.setMinimumIntegerDigits(fmt_count);
+		if (limit_digits)
+		  numberFormat.setMaximumIntegerDigits(fmt_count);
+		if (maybe2DigitYear)
+		  index = pos.getIndex();
+		Number n = numberFormat.parse(dateStr, pos);
+		if (pos == null || ! (n instanceof Long))
+		  return null;
+		value = n.intValue() + offset;
+	      }
+	    else if (set1 != null)
+	      {
+		index = pos.getIndex();
+		int i;
+		boolean found = false;
+		for (i = offset; i < set1.length; ++i)
+		  {
+		    if (set1[i] != null)
+		      if (dateStr.toUpperCase().startsWith(set1[i].toUpperCase(),
+							   index))
+			{
+			  found = true;
+			  pos.setIndex(index + set1[i].length());
+			  break;
+			}
+		  }
+		if (!found && set2 != null)
+		  {
+		    for (i = offset; i < set2.length; ++i)
+		      {
+			if (set2[i] != null)
+			  if (dateStr.toUpperCase().startsWith(set2[i].toUpperCase(),
+							       index))
+			    {
+			      found = true;
+			      pos.setIndex(index + set2[i].length());
+			      break;
+			    }
+		      }
+		  }
+		if (!found)
+		  {
+		    pos.setErrorIndex(index);
+		    return null;
+		  }
+		value = i;
+	      }
+	    else
+	      value = offset;
+	  
+	    if (maybe2DigitYear)
+	      {
+		// Parse into default century if the numeric year string has 
+		// exactly 2 digits.
+		int digit_count = pos.getIndex() - index;
+		if (digit_count == 2)
+		  {
+		    is2DigitYear = true;
+		    value += defaultCentury;
+		  }
+	      }
+	    
+	    // Calendar uses 0-based hours. 
+	    // I.e. 00:00 AM is midnight, not 12 AM or 24:00
+	    if (oneBasedHour && value == 12)
+	      value = 0;
+
+	    if (oneBasedHourOfDay && value == 24)
+	      value = 0;
+	    
+	    // Assign the value and move on.
+	    calendar.set(calendar_field, value);
+	  }
+    
+	if (is2DigitYear)
+	  {
+	    // Apply the 80-20 heuristic to dermine the full year based on 
+	    // defaultCenturyStart. 
+	    int year = calendar.get(Calendar.YEAR);
+	    if (calendar.getTime().compareTo(defaultCenturyStart) < 0)
+	      calendar.set(Calendar.YEAR, year + 100);      
+	  }
+	if (! saw_timezone)
+	  {
+	    // Use the real rules to determine whether or not this
+	    // particular time is in daylight savings.
+	    calendar.clear (Calendar.DST_OFFSET);
+	    calendar.clear (Calendar.ZONE_OFFSET);
+	  }
+        return calendar.getTime();
+      }
+    catch (IllegalArgumentException x)
+      {
+        pos.setErrorIndex(pos.getIndex());
+	return null;
+      }
+      }
+
+  /**
+   * <p>
+   * Computes the time zone offset in milliseconds
+   * relative to GMT, based on the supplied
+   * <code>String</code> representation.
+   * </p>
+   * <p>
+   * The supplied <code>String</code> must be a three
+   * or four digit signed number, with an optional 'GMT'
+   * prefix.  The first one or two digits represents the hours,
+   * while the last two represent the minutes.  The
+   * two sets of digits can optionally be separated by
+   * ':'.  The mandatory sign prefix (either '+' or '-')
+   * indicates the direction of the offset from GMT.
+   * </p>
+   * <p>
+   * For example, 'GMT+0200' specifies 2 hours after
+   * GMT, while '-05:00' specifies 5 hours prior to
+   * GMT.  The special case of 'GMT' alone can be used
+   * to represent the offset, 0.
+   * </p>
+   * <p>
+   * If the <code>String</code> can not be parsed,
+   * the result will be null.  The resulting offset
+   * is wrapped in an <code>Integer</code> object, in
+   * order to allow such failure to be represented.
+   * </p>
+   *
+   * @param zoneString a string in the form 
+   *        (GMT)? sign hours : minutes
+   *        where sign = '+' or '-', hours
+   *        is a one or two digits representing
+   *        a number between 0 and 23, and
+   *        minutes is two digits representing
+   *        a number between 0 and 59.
+   * @return the parsed offset, or null if parsing
+   *         failed.
+   */
+  private Integer computeOffset(String zoneString, ParsePosition pos)
+  {
+    Pattern pattern = 
+      Pattern.compile("(GMT)?([+-])([012])?([0-9]):?([0-9]{2})");
+    Matcher matcher = pattern.matcher(zoneString);
+
+    // Match from start, but ignore trailing parts
+    boolean hasAll = matcher.lookingAt();
+    try
+      {
+	// Do we have at least the sign, hour and minute?
+	matcher.group(2);
+	matcher.group(4);
+	matcher.group(5);
+      }
+    catch (IllegalStateException ise)
+      {
+	hasAll = false;
+      }
+    if (hasAll)
+      {
+	int sign = matcher.group(2).equals("+") ? 1 : -1;
+	int hour = Integer.parseInt(matcher.group(4));
+	if (!matcher.group(3).equals(""))
+	  hour += (Integer.parseInt(matcher.group(3)) * 10);
+	int minutes = Integer.parseInt(matcher.group(5));
+
+	if (hour > 23)
+	  return null;
+	int offset = sign * ((hour * 60) + minutes) * 60000;
+
+	// advance the index
+	pos.setIndex(pos.getIndex() + matcher.end());
+	return new Integer(offset);
+      }
+    else if (zoneString.startsWith("GMT"))
+      {
+	pos.setIndex(pos.getIndex() + 3);
+	return new Integer(0);
+      }
+    return null;
+  }
+
+  // Compute the start of the current century as defined by
+  // get2DigitYearStart.
+  private void computeCenturyStart()
+  {
+    int year = calendar.get(Calendar.YEAR);
+    calendar.set(Calendar.YEAR, year - 80);
+    set2DigitYearStart(calendar.getTime());
+  }
+
+  /**
+   * Returns a copy of this instance of
+   * <code>SimpleDateFormat</code>.  The copy contains
+   * clones of the formatting symbols and the 2-digit
+   * year century start date.
+   */
+  public Object clone()
+  {
+    SimpleDateFormat clone = (SimpleDateFormat) super.clone();
+    clone.setDateFormatSymbols((DateFormatSymbols) formatData.clone());
+    clone.set2DigitYearStart((Date) defaultCenturyStart.clone());
+    return clone;
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/StringCharacterIterator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/StringCharacterIterator.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/StringCharacterIterator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/StringCharacterIterator.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,369 @@
+/* StringCharacterIterator.java -- Iterate over a character range in a string
+   Copyright (C) 1998, 1999, 2001, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.text;
+
+/**
+ * This class iterates over a range of characters in a <code>String</code>.  
+ * For a given range of text, a beginning and ending index,
+ * as well as a current index are defined.  These values can be queried
+ * by the methods in this interface.  Additionally, various methods allow
+ * the index to be set. 
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Tom Tromey (tromey at cygnus.com)
+ */
+public final class StringCharacterIterator implements CharacterIterator
+{
+  /**
+   * This is the string to iterate over
+   */
+  private String text;
+
+  /**
+   * This is the value of the start position of the text range.
+   */
+  private int begin;
+
+  /**
+   * This is the value of the ending position of the text range.
+   */
+  private int end;
+
+  /**
+   * This is the current value of the scan index.
+   */
+  private int index;
+
+  /**
+   * This method initializes a new instance of
+   * <code>StringCharacterIterator</code> to iterate over the entire
+   * text of the specified <code>String</code>.  The initial index
+   * value will be set to the first character in the string.
+   *
+   * @param text The <code>String</code> to iterate through (<code>null</code> 
+   *             not permitted).
+   * 
+   * @throws NullPointerException if <code>text</code> is <code>null</code>.
+   */
+  public StringCharacterIterator (String text)
+  {
+    this (text, 0, text.length (), 0);
+  }
+
+  /*************************************************************************/
+
+  /**
+   * This method initializes a new instance of
+   * <code>StringCharacterIterator</code> to iterate over the entire
+   * text of the specified <code>String</code>.  The initial index
+   * value will be set to the specified value.
+   *
+   * @param text The <code>String</code> to iterate through.
+   * @param index The initial index position.
+   */
+  public StringCharacterIterator (String text, int index)
+  {
+    this (text, 0, text.length (), index);
+  }
+
+  /*************************************************************************/
+
+  /**
+   * This method initializes a new instance of
+   * <code>StringCharacterIterator</code> that iterates over the text
+   * in a subrange of the specified <code>String</code>.  The
+   * beginning and end of the range are specified by the caller, as is
+   * the initial index position.
+   *
+   * @param text The <code>String</code> to iterate through.
+   * @param begin The beginning position in the character range.
+   * @param end The ending position in the character range.
+   * @param index The initial index position.
+   *
+   * @throws IllegalArgumentException If any of the range values are
+   * invalid.
+   */
+  public StringCharacterIterator (String text, int begin, int end, int index)
+  {
+    int len = text.length ();
+
+    if ((begin < 0) || (begin > len))
+      throw new IllegalArgumentException ("Bad begin position");
+
+    if ((end < begin) || (end > len))
+      throw new IllegalArgumentException ("Bad end position");
+
+    if ((index < begin) || (index > end))
+      throw new IllegalArgumentException ("Bad initial index position");
+
+    this.text = text;
+    this.begin = begin;
+    this.end = end;
+    this.index = index;
+  }
+
+  /**
+   * This is a package level constructor that copies the text out of
+   * an existing StringCharacterIterator and resets the beginning and
+   * ending index.
+   *
+   * @param sci The StringCharacterIterator to copy the info from
+   * @param begin The beginning index of the range we are interested in.
+   * @param end The ending index of the range we are interested in.
+   */
+  StringCharacterIterator (StringCharacterIterator sci, int begin, int end)
+  {
+    this (sci.text, begin, end, begin);
+  }
+
+  /**
+   * This method returns the character at the current index position
+   *
+   * @return The character at the current index position.
+   */
+  public char current ()
+  {
+    return (index < end) ? text.charAt (index) : DONE;
+  }
+
+  /*************************************************************************/
+
+  /**
+   * This method increments the current index and then returns the
+   * character at the new index value.  If the index is already at
+   * <code>getEndIndex () - 1</code>, it will not be incremented.
+   *
+   * @return The character at the position of the incremented index
+   * value, or <code>DONE</code> if the index has reached
+   * getEndIndex () - 1.
+   */
+  public char next ()
+  {
+    if (index == end)
+      return DONE;
+
+    ++index;
+    return current ();
+  }
+
+  /*************************************************************************/
+
+  /**
+   * This method decrements the current index and then returns the
+   * character at the new index value.  If the index value is already
+   * at the beginning index, it will not be decremented.
+   *
+   * @return The character at the position of the decremented index
+   * value, or <code>DONE</code> if index was already equal to the
+   * beginning index value.
+   */
+  public char previous ()
+  {
+    if (index == begin)
+      return DONE;
+
+    --index;
+    return current ();
+  }
+
+  /*************************************************************************/
+
+  /**
+   * This method sets the index value to the beginning of the range and returns
+   * the character there.
+   *
+   * @return The character at the beginning of the range, or
+   * <code>DONE</code> if the range is empty. 
+   */
+  public char first ()
+  {
+    index = begin;
+    return current ();
+  }
+
+  /*************************************************************************/
+
+  /**
+   * This method sets the index value to <code>getEndIndex () - 1</code> and
+   * returns the character there.  If the range is empty, then the index value
+   * will be set equal to the beginning index.
+   *
+   * @return The character at the end of the range, or
+   * <code>DONE</code> if the range is empty. 
+   */
+  public char last ()
+  {
+    if (end == begin)
+      return DONE;
+
+    index = end - 1;
+    return current ();
+  }
+
+  /*************************************************************************/
+
+  /**
+   * This method returns the current value of the index.
+   *
+   * @return The current index value
+   */
+  public int getIndex ()
+  {
+    return index;
+  }
+
+  /*************************************************************************/
+
+  /**
+   * This method sets the value of the index to the specified value, then
+   * returns the character at that position.
+   *
+   * @param index The new index value.
+   *
+   * @return The character at the new index value or <code>DONE</code>
+   * if the index value is equal to <code>getEndIndex</code>. 
+   *
+   * @exception IllegalArgumentException If the specified index is not valid
+   */
+  public char setIndex (int index)
+  {
+    if ((index < begin) || (index > end))
+      throw new IllegalArgumentException ("Bad index specified");
+
+    this.index = index;
+    return current ();
+  }
+
+  /*************************************************************************/
+
+  /**
+   * This method returns the character position of the first character in the
+   * range.
+   *
+   * @return The index of the first character in the range.
+   */
+  public int getBeginIndex ()
+  {
+    return begin;
+  }
+
+  /*************************************************************************/
+
+  /**
+   * This method returns the character position of the end of the text range.
+   * This will actually be the index of the first character following the
+   * end of the range.  In the event the text range is empty, this will be
+   * equal to the first character in the range.
+   *
+   * @return The index of the end of the range.
+   */
+  public int getEndIndex ()
+  {
+    return end;
+  }
+
+  /*************************************************************************/
+
+  /**
+   * This method creates a copy of this <code>CharacterIterator</code>.
+   *
+   * @return A copy of this <code>CharacterIterator</code>.
+   */
+  public Object clone ()
+  {
+    return new StringCharacterIterator (text, begin, end, index);
+  }
+
+  /*************************************************************************/
+
+  /**
+   * This method tests this object for equality againt the specified 
+   * object.  This will be true if and only if the specified object:
+   * <p>
+   * <ul>
+   * <li>is not <code>null</code>.</li>
+   * <li>is an instance of <code>StringCharacterIterator</code></li>
+   * <li>has the same text as this object</li>
+   * <li>has the same beginning, ending, and current index as this object.</li>
+   * </ul>
+   *
+   * @param obj The object to test for equality against.
+   *
+   * @return <code>true</code> if the specified object is equal to this
+   * object, <code>false</code> otherwise.
+   */
+  public boolean equals (Object obj)
+  {
+    if (! (obj instanceof StringCharacterIterator))
+      return false;
+
+    StringCharacterIterator sci = (StringCharacterIterator) obj;
+
+    return (begin == sci.begin
+	    && end == sci.end
+	    && index == sci.index
+	    && text.equals (sci.text));
+  }
+  
+  /**
+   * Return the hash code for this object.
+   * @return the hash code
+   */
+  public int hashCode()
+  {
+    // Incorporate all the data in a goofy way.
+    return begin ^ end ^ index ^ text.hashCode();
+  }
+
+  /*************************************************************************/
+
+  /**
+   * This method allows other classes in java.text to change the value
+   * of the underlying text being iterated through.
+   *
+   * @param text The new <code>String</code> to iterate through.
+   */
+  public void setText (String text)
+  {
+    this.text = text;
+    this.begin = 0;
+    this.end = text.length ();
+    this.index = 0;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/class-dependencies.conf
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/class-dependencies.conf?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/class-dependencies.conf (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/class-dependencies.conf Thu Nov  8 16:56:19 2007
@@ -0,0 +1,220 @@
+# This property file contains dependencies of classes, methods, and
+# field on other methods or classes.
+#
+# Syntax: 
+#
+#   <used>: <needed 1> [... <needed N>]
+#
+# means that when <used> is included, <needed 1> (... <needed N>) must
+# be included as well.
+#
+# <needed X> and <used> are of the form
+#
+#   <class.methodOrField(signature)>
+#
+# or just
+#
+#   <class>
+#
+# Within dependencies, variables can be used. A variable is defined as 
+# follows: 
+#
+#   {variable}: value1 value2 ... value<n>
+#
+# variables can be used on the right side of dependencies as follows: 
+#
+#    <used>: com.bla.blu.{variable}.Class.m()V
+#
+# The use of the variable will expand to <n> dependencies of the form
+#
+#    <used>: com.bla.blu.value1.Class.m()V
+#    <used>: com.bla.blu.value2.Class.m()V
+#    ...
+#    <used>: com.bla.blu.value<n>.Class.m()V
+#
+# Variables can be redefined when building a system to select the 
+# required support for features like encodings, protocols, etc. 
+#
+# Hints:
+#
+#  - For methods and fields, the signature is mandatory. For
+#    specification, please see the Java Virtual Machine Specification by
+#    SUN. Unlike in the spec, field signatures (types) are in brackets.
+#
+#  - Package names must be separated by '/' (and not '.'). E.g.,
+#    java/lang/Class (this is necessary, because the '.' is used to
+#    separate method or field names from classes)
+#
+#  - In case <needed> refers to a class, only the class itself will be
+#    included in the resulting binary, NOT necessarily all its methods
+#    and fields. If you want to refer to all methods and fields, you can
+#    write class.* as an abbreviation.
+#
+# -  Abbreviations for packages are also possible: my/package/* means all
+#    methods and fields of all classes in my/package.
+#
+# -  A line with a trailing '\' continues in the next line.
+
+# end of file
+
+# All locales supported are loaded via classes from java.text (see below)
+# from class gnu/java/locale/LocaleInformation_<locale_id>
+#
+# This introduces a dependency for all locales. To allow an easy selection
+# and addition of locales, the library variable {text_locales} can be set to 
+# the set of supported locales.
+#
+
+{text_locales}: \
+	af_ZA \
+	ar_AE \
+	ar_BH \
+	ar_DZ \
+	ar_EG \
+	ar_IN \
+	ar_IQ \
+	ar_JO \
+	ar_KW \
+	ar_LB \
+	ar_LY \
+	ar_MA \
+	ar_OM \
+	ar_QA \
+	ar_SD \
+	ar_SY \
+	ar_TN \
+	ar_YE \
+	be_BY \
+	bn_IN \
+	br_FR \
+	bs_BA \
+	ca_ES \
+	cs_CZ \
+	cy_GB \
+	da_DK \
+	de \
+	de_AT \
+	de_BE \
+	de_CH \
+	de_DE \
+	de_LU \
+	el_GR \
+	en \
+	en_AU \
+	en_BW \
+	en_CA \
+	en_DK \
+	en_GB \
+	en_HK \
+	en_IE \
+	en_IN \
+	en_NZ \
+	en_PH \
+	en_SG \
+	en_US \
+	en_ZA \
+	en_ZW \
+	es_AR \
+	es_BO \
+	es_CL \
+	es_CO \
+	es_CR \
+	es_DO \
+	es_EC \
+	es_ES \
+	es_GT \
+	es_HN \
+	es_MX \
+	es_NI \
+	es_PA \
+	es_PE \
+	es_PR \
+	es_PY \
+	es_SV \
+	es_US \
+	es_UY \
+	es_VE \
+	et_EE \
+	eu_ES \
+	fa_IR \
+	fi_FI \
+	fo_FO \
+	fr_BE \
+	fr_CA \
+	fr_CH \
+	fr_FR \
+	fr_LU \
+	ga_IE \
+	gd_GB \
+	gl_ES \
+	gv_GB \
+	he_IL \
+	hi_IN \
+	hr_HR \
+	hu_HU \
+	id_ID \
+	it_CH \
+	it_IT \
+	iw_IL \
+	ja_JP \
+	ka_GE \
+	kl_GL \
+	ko_KR \
+	kw_GB \
+	lt_LT \
+	lv_LV \
+	mi_NZ \
+	mk_MK \
+	mr_IN \
+	mt_MT \
+	nl \
+	nl_BE \
+	nl_NL \
+	nn_NO \
+	no_NO \
+	oc_FR \
+	pl_PL \
+	pt_BR \
+	pt_PT \
+	ro_RO \
+	ru_RU \
+	ru_UA \
+	se_NO \
+	sk_SK \
+	sl_SI \
+	sq_AL \
+	sr_YU \
+	sv_FI \
+	sv_SE \
+	ta_IN \
+	te_IN \
+	tg_TJ \
+	tl_PH \
+	tr_TR \
+	uk_UA \
+	ur_PK \
+	uz_UZ \
+	vi_VN \
+	yi_US \
+	zh_CN \
+	zh_HK \
+	zh_SG \
+	zh_TW 
+
+java/text/Collator.getInstance(Ljava/util/Locale;)Ljava/text/Collator;: \
+	gnu/java/locale/LocaleInformation_{text_locales}.*
+
+java/text/DateFormatSymbols.<init>(Ljava/util/Locale;)V: \
+	gnu/java/locale/LocaleInformation_{text_locales}.*
+
+java/text/DecimalFormatSymbols.<init>(Ljava/util/Locale;)V: \
+	gnu/java/locale/LocaleInformation_{text_locales}.*
+
+java/text/BreakIterator.getInstance(Ljava/lang/String;Ljava/util/Locale;)Ljava/text/BreakIterator;: \
+	gnu/java/locale/LocaleInformation_{text_locales}.*
+
+java/text/NumberFormat.computeInstance(Ljava/util/Locale;Ljava/lang/String;Ljava/lang/String;)Ljava/text/NumberFormat;: \
+	gnu/java/locale/LocaleInformation_{text_locales}.*
+
+java/text/DateFormat.computeInstance(IILjava/util/Locale;ZZ)Ljava/text/DateFormat;: \
+	gnu/java/locale/LocaleInformation_{text_locales}.*

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/text/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/text/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/text/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/text/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.text package.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.text</title></head>
+
+<body>
+<p>Classes to iterate over strings and to format texts according to a
+specific locale.</p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/AbstractCollection.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/AbstractCollection.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/AbstractCollection.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/AbstractCollection.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,478 @@
+/* AbstractCollection.java -- Abstract implementation of most of Collection
+   Copyright (C) 1998, 2000, 2001, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+import java.lang.reflect.Array;
+
+/**
+ * A basic implementation of most of the methods in the Collection interface to
+ * make it easier to create a collection. To create an unmodifiable Collection,
+ * just subclass AbstractCollection and provide implementations of the
+ * iterator() and size() methods. The Iterator returned by iterator() need only
+ * provide implementations of hasNext() and next() (that is, it may throw an
+ * UnsupportedOperationException if remove() is called). To create a modifiable
+ * Collection, you must in addition provide an implementation of the
+ * add(Object) method and the Iterator returned by iterator() must provide an
+ * implementation of remove(). Other methods should be overridden if the
+ * backing data structure allows for a more efficient implementation. The
+ * precise implementation used by AbstractCollection is documented, so that
+ * subclasses can tell which methods could be implemented more efficiently.
+ * <p>
+ *
+ * The programmer should provide a no-argument constructor, and one that
+ * accepts another Collection, as recommended by the Collection interface.
+ * Unfortunately, there is no way to enforce this in Java.
+ *
+ * @author Original author unknown
+ * @author Bryce McKinlay
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Collection
+ * @see AbstractSet
+ * @see AbstractList
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public abstract class AbstractCollection implements Collection
+{
+  /**
+   * The main constructor, for use by subclasses.
+   */
+  protected AbstractCollection()
+  {
+  }
+
+  /**
+   * Return an Iterator over this collection. The iterator must provide the
+   * hasNext and next methods and should in addition provide remove if the
+   * collection is modifiable.
+   *
+   * @return an iterator
+   */
+  public abstract Iterator iterator();
+
+  /**
+   * Return the number of elements in this collection. If there are more than
+   * Integer.MAX_VALUE elements, return Integer.MAX_VALUE.
+   *
+   * @return the size
+   */
+  public abstract int size();
+
+  /**
+   * Add an object to the collection (optional operation). This implementation
+   * always throws an UnsupportedOperationException - it should be
+   * overridden if the collection is to be modifiable. If the collection
+   * does not accept duplicates, simply return false. Collections may specify
+   * limitations on what may be added.
+   *
+   * @param o the object to add
+   * @return true if the add operation caused the Collection to change
+   * @throws UnsupportedOperationException if the add operation is not
+   *         supported on this collection
+   * @throws NullPointerException if the collection does not support null
+   * @throws ClassCastException if the object is of the wrong type
+   * @throws IllegalArgumentException if some aspect of the object prevents
+   *         it from being added
+   */
+  public boolean add(Object o)
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Add all the elements of a given collection to this collection (optional
+   * operation). This implementation obtains an Iterator over the given
+   * collection and iterates over it, adding each element with the
+   * add(Object) method (thus this method will fail with an
+   * UnsupportedOperationException if the add method does). The behavior is
+   * unspecified if the specified collection is modified during the iteration,
+   * including the special case of trying addAll(this) on a non-empty
+   * collection.
+   *
+   * @param c the collection to add the elements of to this collection
+   * @return true if the add operation caused the Collection to change
+   * @throws UnsupportedOperationException if the add operation is not
+   *         supported on this collection
+   * @throws NullPointerException if the specified collection is null
+   * @throws ClassCastException if the type of any element in c is
+   *         not a valid type for addition.
+   * @throws IllegalArgumentException if some aspect of any element
+   *         in c prevents it being added.
+   * @throws NullPointerException if any element in c is null and this
+   *         collection doesn't allow null values.
+   * @see #add(Object)
+   */
+  public boolean addAll(Collection c)
+  {
+    Iterator itr = c.iterator();
+    boolean modified = false;
+    int pos = c.size();
+    while (--pos >= 0)
+      modified |= add(itr.next());
+    return modified;
+  }
+
+  /**
+   * Remove all elements from the collection (optional operation). This
+   * implementation obtains an iterator over the collection and calls next
+   * and remove on it repeatedly (thus this method will fail with an
+   * UnsupportedOperationException if the Iterator's remove method does)
+   * until there are no more elements to remove.
+   * Many implementations will have a faster way of doing this.
+   *
+   * @throws UnsupportedOperationException if the Iterator returned by
+   *         iterator does not provide an implementation of remove
+   * @see Iterator#remove()
+   */
+  public void clear()
+  {
+    Iterator itr = iterator();
+    int pos = size();
+    while (--pos >= 0)
+      {
+        itr.next();
+        itr.remove();
+      }
+  }
+
+  /**
+   * Test whether this collection contains a given object. That is, if the
+   * collection has an element e such that (o == null ? e == null :
+   * o.equals(e)). This implementation obtains an iterator over the collection
+   * and iterates over it, testing each element for equality with the given
+   * object. If it is equal, true is returned. Otherwise false is returned when
+   * the end of the collection is reached.
+   *
+   * @param o the object to remove from this collection
+   * @return true if this collection contains an object equal to o
+   */
+  public boolean contains(Object o)
+  {
+    Iterator itr = iterator();
+    int pos = size();
+    while (--pos >= 0)
+      if (equals(o, itr.next()))
+        return true;
+    return false;
+  }
+
+  /**
+   * Tests whether this collection contains all the elements in a given
+   * collection. This implementation iterates over the given collection,
+   * testing whether each element is contained in this collection. If any one
+   * is not, false is returned. Otherwise true is returned.
+   *
+   * @param c the collection to test against
+   * @return true if this collection contains all the elements in the given
+   *         collection
+   * @throws NullPointerException if the given collection is null
+   * @see #contains(Object)
+   */
+  public boolean containsAll(Collection c)
+  {
+    Iterator itr = c.iterator();
+    int pos = c.size();
+    while (--pos >= 0)
+      if (!contains(itr.next()))
+        return false;
+    return true;
+  }
+
+  /**
+   * Test whether this collection is empty. This implementation returns
+   * size() == 0.
+   *
+   * @return true if this collection is empty.
+   * @see #size()
+   */
+  public boolean isEmpty()
+  {
+    return size() == 0;
+  }
+
+  /**
+   * Remove a single instance of an object from this collection (optional
+   * operation). That is, remove one element e such that
+   * <code>(o == null ? e == null : o.equals(e))</code>, if such an element
+   * exists. This implementation obtains an iterator over the collection
+   * and iterates over it, testing each element for equality with the given
+   * object. If it is equal, it is removed by the iterator's remove method
+   * (thus this method will fail with an UnsupportedOperationException if
+   * the Iterator's remove method does). After the first element has been
+   * removed, true is returned; if the end of the collection is reached, false
+   * is returned.
+   *
+   * @param o the object to remove from this collection
+   * @return true if the remove operation caused the Collection to change, or
+   *         equivalently if the collection did contain o.
+   * @throws UnsupportedOperationException if this collection's Iterator
+   *         does not support the remove method
+   * @see Iterator#remove()
+   */
+  public boolean remove(Object o)
+  {
+    Iterator itr = iterator();
+    int pos = size();
+    while (--pos >= 0)
+      if (equals(o, itr.next()))
+        {
+          itr.remove();
+          return true;
+        }
+    return false;
+  }
+
+  /**
+   * Remove from this collection all its elements that are contained in a given
+   * collection (optional operation). This implementation iterates over this
+   * collection, and for each element tests if it is contained in the given
+   * collection. If so, it is removed by the Iterator's remove method (thus
+   * this method will fail with an UnsupportedOperationException if the
+   * Iterator's remove method does).
+   *
+   * @param c the collection to remove the elements of
+   * @return true if the remove operation caused the Collection to change
+   * @throws UnsupportedOperationException if this collection's Iterator
+   *         does not support the remove method
+   * @throws NullPointerException if the collection, c, is null.
+   * @see Iterator#remove()
+   */
+  public boolean removeAll(Collection c)
+  {
+    return removeAllInternal(c);
+  }
+
+  /**
+   * Remove from this collection all its elements that are contained in a given
+   * collection (optional operation). This implementation iterates over this
+   * collection, and for each element tests if it is contained in the given
+   * collection. If so, it is removed by the Iterator's remove method (thus
+   * this method will fail with an UnsupportedOperationException if the
+   * Iterator's remove method does). This method is necessary for ArrayList,
+   * which cannot publicly override removeAll but can optimize this call.
+   *
+   * @param c the collection to remove the elements of
+   * @return true if the remove operation caused the Collection to change
+   * @throws UnsupportedOperationException if this collection's Iterator
+   *         does not support the remove method
+   * @throws NullPointerException if the collection, c, is null.
+   * @see Iterator#remove()
+   */
+  // Package visible for use throughout java.util.
+  boolean removeAllInternal(Collection c)
+  {
+    Iterator itr = iterator();
+    boolean modified = false;
+    int pos = size();
+    while (--pos >= 0)
+      if (c.contains(itr.next()))
+        {
+          itr.remove();
+          modified = true;
+        }
+    return modified;
+  }
+
+  /**
+   * Remove from this collection all its elements that are not contained in a
+   * given collection (optional operation). This implementation iterates over
+   * this collection, and for each element tests if it is contained in the
+   * given collection. If not, it is removed by the Iterator's remove method
+   * (thus this method will fail with an UnsupportedOperationException if
+   * the Iterator's remove method does).
+   *
+   * @param c the collection to retain the elements of
+   * @return true if the remove operation caused the Collection to change
+   * @throws UnsupportedOperationException if this collection's Iterator
+   *         does not support the remove method
+   * @throws NullPointerException if the collection, c, is null.
+   * @see Iterator#remove()
+   */
+  public boolean retainAll(Collection c)
+  {
+    return retainAllInternal(c);
+  }
+
+  /**
+   * Remove from this collection all its elements that are not contained in a
+   * given collection (optional operation). This implementation iterates over
+   * this collection, and for each element tests if it is contained in the
+   * given collection. If not, it is removed by the Iterator's remove method
+   * (thus this method will fail with an UnsupportedOperationException if
+   * the Iterator's remove method does). This method is necessary for
+   * ArrayList, which cannot publicly override retainAll but can optimize
+   * this call.
+   *
+   * @param c the collection to retain the elements of
+   * @return true if the remove operation caused the Collection to change
+   * @throws UnsupportedOperationException if this collection's Iterator
+   *         does not support the remove method
+   * @throws NullPointerException if the collection, c, is null.
+   * @see Iterator#remove()
+   */
+  // Package visible for use throughout java.util.
+  boolean retainAllInternal(Collection c)
+  {
+    Iterator itr = iterator();
+    boolean modified = false;
+    int pos = size();
+    while (--pos >= 0)
+      if (!c.contains(itr.next()))
+        {
+          itr.remove();
+          modified = true;
+        }
+    return modified;
+  }
+
+  /**
+   * Return an array containing the elements of this collection. This
+   * implementation creates an Object array of size size() and then iterates
+   * over the collection, setting each element of the array from the value
+   * returned by the iterator. The returned array is safe, and is not backed
+   * by the collection.
+   *
+   * @return an array containing the elements of this collection
+   */
+  public Object[] toArray()
+  {
+    Iterator itr = iterator();
+    int size = size();
+    Object[] a = new Object[size];
+    for (int pos = 0; pos < size; pos++)
+      a[pos] = itr.next();
+    return a;
+  }
+
+  /**
+   * Copy the collection into a given array if it will fit, or into a
+   * dynamically created array of the same run-time type as the given array if
+   * not. If there is space remaining in the array, the first element after the
+   * end of the collection is set to null (this is only useful if the
+   * collection is known to contain no null elements, however). This
+   * implementation first tests whether the given array is large enough to hold
+   * all the elements of the collection. If not, the reflection API is used to
+   * allocate a new array of the same run-time type. Next an iterator is
+   * obtained over the collection and the elements are placed in the array as
+   * they are returned by the iterator. Finally the first spare element, if
+   * any, of the array is set to null, and the created array is returned.
+   * The returned array is safe; it is not backed by the collection. Note that
+   * null may not mark the last element, if the collection allows null
+   * elements.
+   *
+   * @param a the array to copy into, or of the correct run-time type
+   * @return the array that was produced
+   * @throws NullPointerException if the given array is null
+   * @throws ArrayStoreException if the type of the array precludes holding
+   *         one of the elements of the Collection
+   */
+  public Object[] toArray(Object[] a)
+  {
+    int size = size();
+    if (a.length < size)
+      a = (Object[]) Array.newInstance(a.getClass().getComponentType(),
+                                       size);
+    else if (a.length > size)
+      a[size] = null;
+
+    Iterator itr = iterator();
+    for (int pos = 0; pos < size; pos++)
+      a[pos] = itr.next();
+
+    return a;
+  }
+
+  /**
+   * Creates a String representation of the Collection. The string returned is
+   * of the form "[a, b, ...]" where a and b etc are the results of calling
+   * toString on the elements of the collection. This implementation obtains an
+   * Iterator over the Collection and adds each element to a StringBuffer as it
+   * is returned by the iterator. "<this>" is inserted when the collection
+   * contains itself (only works for direct containment, not for collections
+   * inside collections).
+   *
+   * @return a String representation of the Collection
+   */
+  public String toString()
+  {
+    Iterator itr = iterator();
+    StringBuffer r = new StringBuffer("[");
+    boolean hasNext = itr.hasNext();
+    while (hasNext)
+      {
+        Object o = itr.next();
+	if (o == this)
+	  r.append("<this>");
+	else
+	  r.append(o);
+	hasNext = itr.hasNext();
+        if (hasNext)
+          r.append(", ");
+      }
+    r.append("]");
+    return r.toString();
+  }
+
+  /**
+   * Compare two objects according to Collection semantics.
+   *
+   * @param o1 the first object
+   * @param o2 the second object
+   * @return o1 == null ? o2 == null : o1.equals(o2)
+   */
+  // Package visible for use throughout java.util.
+  // It may be inlined since it is final.
+  static final boolean equals(Object o1, Object o2)
+  {
+    return o1 == null ? o2 == null : o1.equals(o2);
+  }
+
+  /**
+   * Hash an object according to Collection semantics.
+   *
+   * @param o the object to hash
+   * @return o1 == null ? 0 : o1.hashCode()
+   */
+  // Package visible for use throughout java.util.
+  // It may be inlined since it is final.
+  static final int hashCode(Object o)
+  {
+    return o == null ? 0 : o.hashCode();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/AbstractList.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/AbstractList.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/AbstractList.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/AbstractList.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1200 @@
+/* AbstractList.java -- Abstract implementation of most of List
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/**
+ * A basic implementation of most of the methods in the List interface to make
+ * it easier to create a List based on a random-access data structure. If
+ * the list is sequential (such as a linked list), use AbstractSequentialList.
+ * To create an unmodifiable list, it is only necessary to override the
+ * size() and get(int) methods (this contrasts with all other abstract
+ * collection classes which require an iterator to be provided). To make the
+ * list modifiable, the set(int, Object) method should also be overridden, and
+ * to make the list resizable, the add(int, Object) and remove(int) methods
+ * should be overridden too. Other methods should be overridden if the
+ * backing data structure allows for a more efficient implementation.
+ * The precise implementation used by AbstractList is documented, so that
+ * subclasses can tell which methods could be implemented more efficiently.
+ * <p>
+ *
+ * As recommended by Collection and List, the subclass should provide at
+ * least a no-argument and a Collection constructor. This class is not
+ * synchronized.
+ *
+ * @author Original author unknown
+ * @author Bryce McKinlay
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Collection
+ * @see List
+ * @see AbstractSequentialList
+ * @see AbstractCollection
+ * @see ListIterator
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public abstract class AbstractList extends AbstractCollection implements List
+{
+  /**
+   * A count of the number of structural modifications that have been made to
+   * the list (that is, insertions and removals). Structural modifications
+   * are ones which change the list size or affect how iterations would
+   * behave. This field is available for use by Iterator and ListIterator,
+   * in order to throw a {@link ConcurrentModificationException} in response
+   * to the next operation on the iterator. This <i>fail-fast</i> behavior
+   * saves the user from many subtle bugs otherwise possible from concurrent
+   * modification during iteration.
+   * <p>
+   *
+   * To make lists fail-fast, increment this field by just 1 in the
+   * <code>add(int, Object)</code> and <code>remove(int)</code> methods.
+   * Otherwise, this field may be ignored.
+   */
+  protected transient int modCount;
+
+  /**
+   * The main constructor, for use by subclasses.
+   */
+  protected AbstractList()
+  {
+  }
+
+  /**
+   * Returns the elements at the specified position in the list.
+   *
+   * @param index the element to return
+   * @return the element at that position
+   * @throws IndexOutOfBoundsException if index < 0 || index >= size()
+   */
+  public abstract Object get(int index);
+
+  /**
+   * Insert an element into the list at a given position (optional operation).
+   * This shifts all existing elements from that position to the end one
+   * index to the right.  This version of add has no return, since it is
+   * assumed to always succeed if there is no exception. This implementation
+   * always throws UnsupportedOperationException, and must be overridden to
+   * make a modifiable List.  If you want fail-fast iterators, be sure to
+   * increment modCount when overriding this.
+   *
+   * @param index the location to insert the item
+   * @param o the object to insert
+   * @throws UnsupportedOperationException if this list does not support the
+   *         add operation
+   * @throws IndexOutOfBoundsException if index < 0 || index > size()
+   * @throws ClassCastException if o cannot be added to this list due to its
+   *         type
+   * @throws IllegalArgumentException if o cannot be added to this list for
+   *         some other reason
+   * @see #modCount
+   */
+  public void add(int index, Object o)
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Add an element to the end of the list (optional operation). If the list
+   * imposes restraints on what can be inserted, such as no null elements,
+   * this should be documented. This implementation calls
+   * <code>add(size(), o);</code>, and will fail if that version does.
+   *
+   * @param o the object to add
+   * @return true, as defined by Collection for a modified list
+   * @throws UnsupportedOperationException if this list does not support the
+   *         add operation
+   * @throws ClassCastException if o cannot be added to this list due to its
+   *         type
+   * @throws IllegalArgumentException if o cannot be added to this list for
+   *         some other reason
+   * @see #add(int, Object)
+   */
+  public boolean add(Object o)
+  {
+    add(size(), o);
+    return true;
+  }
+
+  /**
+   * Insert the contents of a collection into the list at a given position
+   * (optional operation). Shift all elements at that position to the right
+   * by the number of elements inserted. This operation is undefined if
+   * this list is modified during the operation (for example, if you try
+   * to insert a list into itself). This implementation uses the iterator of
+   * the collection, repeatedly calling add(int, Object); this will fail
+   * if add does. This can often be made more efficient.
+   *
+   * @param index the location to insert the collection
+   * @param c the collection to insert
+   * @return true if the list was modified by this action, that is, if c is
+   *         non-empty
+   * @throws UnsupportedOperationException if this list does not support the
+   *         addAll operation
+   * @throws IndexOutOfBoundsException if index < 0 || index > size()
+   * @throws ClassCastException if some element of c cannot be added to this
+   *         list due to its type
+   * @throws IllegalArgumentException if some element of c cannot be added
+   *         to this list for some other reason
+   * @throws NullPointerException if the specified collection is null
+   * @see #add(int, Object)
+   */
+  public boolean addAll(int index, Collection c)
+  {
+    Iterator itr = c.iterator();
+    int size = c.size();
+    for (int pos = size; pos > 0; pos--)
+      add(index++, itr.next());
+    return size > 0;
+  }
+
+  /**
+   * Clear the list, such that a subsequent call to isEmpty() would return
+   * true (optional operation). This implementation calls
+   * <code>removeRange(0, size())</code>, so it will fail unless remove
+   * or removeRange is overridden.
+   *
+   * @throws UnsupportedOperationException if this list does not support the
+   *         clear operation
+   * @see #remove(int)
+   * @see #removeRange(int, int)
+   */
+  public void clear()
+  {
+    removeRange(0, size());
+  }
+
+  /**
+   * Test whether this list is equal to another object. A List is defined to be
+   * equal to an object if and only if that object is also a List, and the two
+   * lists have the same sequence. Two lists l1 and l2 are equal if and only
+   * if <code>l1.size() == l2.size()</code>, and for every integer n between 0
+   * and <code>l1.size() - 1</code> inclusive, <code>l1.get(n) == null ?
+   * l2.get(n) == null : l1.get(n).equals(l2.get(n))</code>.
+   * <p>
+   *
+   * This implementation returns true if the object is this, or false if the
+   * object is not a List.  Otherwise, it iterates over both lists (with
+   * iterator()), returning false if two elements compare false or one list
+   * is shorter, and true if the iteration completes successfully.
+   *
+   * @param o the object to test for equality with this list
+   * @return true if o is equal to this list
+   * @see Object#equals(Object)
+   * @see #hashCode()
+   */
+  public boolean equals(Object o)
+  {
+    if (o == this)
+      return true;
+    if (! (o instanceof List))
+      return false;
+    int size = size();
+    if (size != ((List) o).size())
+      return false;
+
+    Iterator itr1 = iterator();
+    Iterator itr2 = ((List) o).iterator();
+
+    while (--size >= 0)
+      if (! equals(itr1.next(), itr2.next()))
+        return false;
+    return true;
+  }
+
+  /**
+   * Obtains a hash code for this list. In order to obey the general
+   * contract of the hashCode method of class Object, this value is
+   * calculated as follows:
+   * 
+<pre>hashCode = 1;
+Iterator i = list.iterator();
+while (i.hasNext())
+{
+  Object obj = i.next();
+  hashCode = 31 * hashCode + (obj == null ? 0 : obj.hashCode());
+}</pre>
+   *
+   * This ensures that the general contract of Object.hashCode() is adhered to.
+   *
+   * @return the hash code of this list
+   *
+   * @see Object#hashCode()
+   * @see #equals(Object)
+   */
+  public int hashCode()
+  {
+    int hashCode = 1;
+    Iterator itr = iterator();
+    int pos = size();
+    while (--pos >= 0)
+      hashCode = 31 * hashCode + hashCode(itr.next());
+    return hashCode;
+  }
+
+  /**
+   * Obtain the first index at which a given object is to be found in this
+   * list. This implementation follows a listIterator() until a match is found,
+   * or returns -1 if the list end is reached.
+   *
+   * @param o the object to search for
+   * @return the least integer n such that <code>o == null ? get(n) == null :
+   *         o.equals(get(n))</code>, or -1 if there is no such index
+   */
+  public int indexOf(Object o)
+  {
+    ListIterator itr = listIterator();
+    int size = size();
+    for (int pos = 0; pos < size; pos++)
+      if (equals(o, itr.next()))
+        return pos;
+    return -1;
+  }
+
+  /**
+   * Obtain an Iterator over this list, whose sequence is the list order.
+   * This implementation uses size(), get(int), and remove(int) of the
+   * backing list, and does not support remove unless the list does. This
+   * implementation is fail-fast if you correctly maintain modCount.
+   * Also, this implementation is specified by Sun to be distinct from
+   * listIterator, although you could easily implement it as
+   * <code>return listIterator(0)</code>.
+   *
+   * @return an Iterator over the elements of this list, in order
+   * @see #modCount
+   */
+  public Iterator iterator()
+  {
+    // Bah, Sun's implementation forbids using listIterator(0).
+    return new Iterator()
+    {
+      private int pos = 0;
+      private int size = size();
+      private int last = -1;
+      private int knownMod = modCount;
+
+      // This will get inlined, since it is private.
+      /**
+       * Checks for modifications made to the list from
+       * elsewhere while iteration is in progress.
+       *
+       * @throws ConcurrentModificationException if the
+       *         list has been modified elsewhere.
+       */
+      private void checkMod()
+      {
+        if (knownMod != modCount)
+          throw new ConcurrentModificationException();
+      }
+
+      /**
+       * Tests to see if there are any more objects to
+       * return.
+       *
+       * @return True if the end of the list has not yet been
+       *         reached.
+       */
+      public boolean hasNext()
+      {
+        return pos < size;
+      }
+
+      /**
+       * Retrieves the next object from the list.
+       *
+       * @return The next object.
+       * @throws NoSuchElementException if there are
+       *         no more objects to retrieve.
+       * @throws ConcurrentModificationException if the
+       *         list has been modified elsewhere.
+       */
+      public Object next()
+      {
+        checkMod();
+        if (pos == size)
+          throw new NoSuchElementException();
+        last = pos;
+        return get(pos++);
+      }
+
+      /**
+       * Removes the last object retrieved by <code>next()</code>
+       * from the list, if the list supports object removal.
+       *
+       * @throws ConcurrentModificationException if the list
+       *         has been modified elsewhere.
+       * @throws IllegalStateException if the iterator is positioned
+       *         before the start of the list or the last object has already
+       *         been removed.
+       * @throws UnsupportedOperationException if the list does
+       *         not support removing elements.
+       */
+      public void remove()
+      {
+        checkMod();
+        if (last < 0)
+          throw new IllegalStateException();
+        AbstractList.this.remove(last);
+        pos--;
+        size--;
+        last = -1;
+        knownMod = modCount;
+      }
+    };
+  }
+
+  /**
+   * Obtain the last index at which a given object is to be found in this
+   * list. This implementation grabs listIterator(size()), then searches
+   * backwards for a match or returns -1.
+   *
+   * @return the greatest integer n such that <code>o == null ? get(n) == null
+   *         : o.equals(get(n))</code>, or -1 if there is no such index
+   */
+  public int lastIndexOf(Object o)
+  {
+    int pos = size();
+    ListIterator itr = listIterator(pos);
+    while (--pos >= 0)
+      if (equals(o, itr.previous()))
+        return pos;
+    return -1;
+  }
+
+  /**
+   * Obtain a ListIterator over this list, starting at the beginning. This
+   * implementation returns listIterator(0).
+   *
+   * @return a ListIterator over the elements of this list, in order, starting
+   *         at the beginning
+   */
+  public ListIterator listIterator()
+  {
+    return listIterator(0);
+  }
+
+  /**
+   * Obtain a ListIterator over this list, starting at a given position.
+   * A first call to next() would return the same as get(index), and a
+   * first call to previous() would return the same as get(index - 1).
+   * <p>
+   *
+   * This implementation uses size(), get(int), set(int, Object),
+   * add(int, Object), and remove(int) of the backing list, and does not
+   * support remove, set, or add unless the list does. This implementation
+   * is fail-fast if you correctly maintain modCount.
+   *
+   * @param index the position, between 0 and size() inclusive, to begin the
+   *        iteration from
+   * @return a ListIterator over the elements of this list, in order, starting
+   *         at index
+   * @throws IndexOutOfBoundsException if index < 0 || index > size()
+   * @see #modCount
+   */
+  public ListIterator listIterator(final int index)
+  {
+    if (index < 0 || index > size())
+      throw new IndexOutOfBoundsException("Index: " + index + ", Size:"
+                                          + size());
+
+    return new ListIterator()
+    {
+      private int knownMod = modCount;
+      private int position = index;
+      private int lastReturned = -1;
+      private int size = size();
+
+      // This will get inlined, since it is private.
+      /**
+       * Checks for modifications made to the list from
+       * elsewhere while iteration is in progress.
+       *
+       * @throws ConcurrentModificationException if the
+       *         list has been modified elsewhere.
+       */
+      private void checkMod()
+      {
+        if (knownMod != modCount)
+          throw new ConcurrentModificationException();
+      }
+
+      /**
+       * Tests to see if there are any more objects to
+       * return.
+       *
+       * @return True if the end of the list has not yet been
+       *         reached.
+       */
+      public boolean hasNext()
+      {
+        return position < size;
+      }
+
+      /**
+       * Tests to see if there are objects prior to the
+       * current position in the list.
+       *
+       * @return True if objects exist prior to the current
+       *         position of the iterator.
+       */
+      public boolean hasPrevious()
+      {
+        return position > 0;
+      }
+
+      /**
+       * Retrieves the next object from the list.
+       *
+       * @return The next object.
+       * @throws NoSuchElementException if there are no
+       *         more objects to retrieve.
+       * @throws ConcurrentModificationException if the
+       *         list has been modified elsewhere.
+       */
+      public Object next()
+      {
+        checkMod();
+        if (position == size)
+          throw new NoSuchElementException();
+        lastReturned = position;
+        return get(position++);
+      }
+
+      /**
+       * Retrieves the previous object from the list.
+       *
+       * @return The next object.
+       * @throws NoSuchElementException if there are no
+       *         previous objects to retrieve.
+       * @throws ConcurrentModificationException if the
+       *         list has been modified elsewhere.
+       */
+      public Object previous()
+      {
+        checkMod();
+        if (position == 0)
+          throw new NoSuchElementException();
+        lastReturned = --position;
+        return get(lastReturned);
+      }
+
+      /**
+       * Returns the index of the next element in the
+       * list, which will be retrieved by <code>next()</code>
+       *
+       * @return The index of the next element.
+       */
+      public int nextIndex()
+      {
+        return position;
+      }
+
+      /**
+       * Returns the index of the previous element in the
+       * list, which will be retrieved by <code>previous()</code>
+       *
+       * @return The index of the previous element.
+       */
+      public int previousIndex()
+      {
+        return position - 1;
+      }
+
+     /**
+      * Removes the last object retrieved by <code>next()</code>
+      * or <code>previous()</code> from the list, if the list
+      * supports object removal.
+      *
+      * @throws IllegalStateException if the iterator is positioned
+      *         before the start of the list or the last object has already
+      *         been removed.
+      * @throws UnsupportedOperationException if the list does
+      *         not support removing elements.
+      * @throws ConcurrentModificationException if the list
+      *         has been modified elsewhere.
+      */
+      public void remove()
+      {
+        checkMod();
+        if (lastReturned < 0)
+          throw new IllegalStateException();
+        AbstractList.this.remove(lastReturned);
+        size--;
+        position = lastReturned;
+        lastReturned = -1;
+        knownMod = modCount;
+      }
+
+     /**
+      * Replaces the last object retrieved by <code>next()</code>
+      * or <code>previous</code> with o, if the list supports object
+      * replacement and an add or remove operation has not already
+      * been performed.
+      *
+      * @throws IllegalStateException if the iterator is positioned
+      *         before the start of the list or the last object has already
+      *         been removed.
+      * @throws UnsupportedOperationException if the list doesn't support
+      *         the addition or removal of elements.
+      * @throws ClassCastException if the type of o is not a valid type
+      *         for this list.
+      * @throws IllegalArgumentException if something else related to o
+      *         prevents its addition.
+      * @throws ConcurrentModificationException if the list
+      *         has been modified elsewhere.
+      */
+      public void set(Object o)
+      {
+        checkMod();
+        if (lastReturned < 0)
+          throw new IllegalStateException();
+        AbstractList.this.set(lastReturned, o);
+      }
+
+      /**
+       * Adds the supplied object before the element that would be returned
+       * by a call to <code>next()</code>, if the list supports addition.
+       * 
+       * @param o The object to add to the list.
+       * @throws UnsupportedOperationException if the list doesn't support
+       *         the addition of new elements.
+       * @throws ClassCastException if the type of o is not a valid type
+       *         for this list.
+       * @throws IllegalArgumentException if something else related to o
+       *         prevents its addition.
+       * @throws ConcurrentModificationException if the list
+       *         has been modified elsewhere.
+       */
+      public void add(Object o)
+      {
+        checkMod();
+        AbstractList.this.add(position++, o);
+        size++;
+        lastReturned = -1;
+        knownMod = modCount;
+      }
+    };
+  }
+
+  /**
+   * Remove the element at a given position in this list (optional operation).
+   * Shifts all remaining elements to the left to fill the gap. This
+   * implementation always throws an UnsupportedOperationException.
+   * If you want fail-fast iterators, be sure to increment modCount when
+   * overriding this.
+   *
+   * @param index the position within the list of the object to remove
+   * @return the object that was removed
+   * @throws UnsupportedOperationException if this list does not support the
+   *         remove operation
+   * @throws IndexOutOfBoundsException if index < 0 || index >= size()
+   * @see #modCount
+   */
+  public Object remove(int index)
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Remove a subsection of the list. This is called by the clear and
+   * removeRange methods of the class which implements subList, which are
+   * difficult for subclasses to override directly. Therefore, this method
+   * should be overridden instead by the more efficient implementation, if one
+   * exists. Overriding this can reduce quadratic efforts to constant time
+   * in some cases!
+   * <p>
+   *
+   * This implementation first checks for illegal or out of range arguments. It
+   * then obtains a ListIterator over the list using listIterator(fromIndex).
+   * It then calls next() and remove() on this iterator repeatedly, toIndex -
+   * fromIndex times.
+   *
+   * @param fromIndex the index, inclusive, to remove from.
+   * @param toIndex the index, exclusive, to remove to.
+   * @throws UnsupportedOperationException if the list does
+   *         not support removing elements.
+   */
+  protected void removeRange(int fromIndex, int toIndex)
+  {
+    ListIterator itr = listIterator(fromIndex);
+    for (int index = fromIndex; index < toIndex; index++)
+      {
+        itr.next();
+        itr.remove();
+      }
+  }
+
+  /**
+   * Replace an element of this list with another object (optional operation).
+   * This implementation always throws an UnsupportedOperationException.
+   *
+   * @param index the position within this list of the element to be replaced
+   * @param o the object to replace it with
+   * @return the object that was replaced
+   * @throws UnsupportedOperationException if this list does not support the
+   *         set operation
+   * @throws IndexOutOfBoundsException if index < 0 || index >= size()
+   * @throws ClassCastException if o cannot be added to this list due to its
+   *         type
+   * @throws IllegalArgumentException if o cannot be added to this list for
+   *         some other reason
+   */
+  public Object set(int index, Object o)
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Obtain a List view of a subsection of this list, from fromIndex
+   * (inclusive) to toIndex (exclusive). If the two indices are equal, the
+   * sublist is empty. The returned list should be modifiable if and only
+   * if this list is modifiable. Changes to the returned list should be
+   * reflected in this list. If this list is structurally modified in
+   * any way other than through the returned list, the result of any subsequent
+   * operations on the returned list is undefined.
+   * <p>
+   *
+   * This implementation returns a subclass of AbstractList. It stores, in
+   * private fields, the offset and size of the sublist, and the expected
+   * modCount of the backing list. If the backing list implements RandomAccess,
+   * the sublist will also.
+   * <p>
+   *
+   * The subclass's <code>set(int, Object)</code>, <code>get(int)</code>,
+   * <code>add(int, Object)</code>, <code>remove(int)</code>,
+   * <code>addAll(int, Collection)</code> and
+   * <code>removeRange(int, int)</code> methods all delegate to the
+   * corresponding methods on the backing abstract list, after
+   * bounds-checking the index and adjusting for the offset. The
+   * <code>addAll(Collection c)</code> method merely returns addAll(size, c).
+   * The <code>listIterator(int)</code> method returns a "wrapper object"
+   * over a list iterator on the backing list, which is created with the
+   * corresponding method on the backing list. The <code>iterator()</code>
+   * method merely returns listIterator(), and the <code>size()</code> method
+   * merely returns the subclass's size field.
+   * <p>
+   *
+   * All methods first check to see if the actual modCount of the backing
+   * list is equal to its expected value, and throw a
+   * ConcurrentModificationException if it is not. 
+   *
+   * @param fromIndex the index that the returned list should start from
+   *        (inclusive)
+   * @param toIndex the index that the returned list should go to (exclusive)
+   * @return a List backed by a subsection of this list
+   * @throws IndexOutOfBoundsException if fromIndex < 0
+   *         || toIndex > size()
+   * @throws IllegalArgumentException if fromIndex > toIndex
+   * @see ConcurrentModificationException
+   * @see RandomAccess
+   */
+  public List subList(int fromIndex, int toIndex)
+  {
+    // This follows the specification of AbstractList, but is inconsistent
+    // with the one in List. Don't you love Sun's inconsistencies?
+    if (fromIndex > toIndex)
+      throw new IllegalArgumentException(fromIndex + " > " + toIndex);
+    if (fromIndex < 0 || toIndex > size())
+      throw new IndexOutOfBoundsException();
+
+    if (this instanceof RandomAccess)
+      return new RandomAccessSubList(this, fromIndex, toIndex);
+    return new SubList(this, fromIndex, toIndex);
+  }
+
+  /**
+   * This class follows the implementation requirements set forth in
+   * {@link AbstractList#subList(int, int)}. It matches Sun's implementation
+   * by using a non-public top-level class in the same package.
+   *
+   * @author Original author unknown
+   * @author Eric Blake (ebb9 at email.byu.edu)
+   */
+  private static class SubList extends AbstractList
+  {
+    // Package visible, for use by iterator.
+    /** The original list. */
+    final AbstractList backingList;
+    /** The index of the first element of the sublist. */
+    final int offset;
+    /** The size of the sublist. */
+    int size;
+
+    /**
+     * Construct the sublist.
+     *
+     * @param backing the list this comes from
+     * @param fromIndex the lower bound, inclusive
+     * @param toIndex the upper bound, exclusive
+     */
+    SubList(AbstractList backing, int fromIndex, int toIndex)
+    {
+      backingList = backing;
+      modCount = backing.modCount;
+      offset = fromIndex;
+      size = toIndex - fromIndex;
+    }
+
+    /**
+     * This method checks the two modCount fields to ensure that there has
+     * not been a concurrent modification, returning if all is okay.
+     *
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     */
+    // This can be inlined. Package visible, for use by iterator.
+    void checkMod()
+    {
+      if (modCount != backingList.modCount)
+        throw new ConcurrentModificationException();
+    }
+
+    /**
+     * This method checks that a value is between 0 and size (inclusive). If
+     * it is not, an exception is thrown.
+     *
+     * @param index the value to check
+     * @throws IndexOutOfBoundsException if index < 0 || index > size()
+     */
+    // This will get inlined, since it is private.
+    private void checkBoundsInclusive(int index)
+    {
+      if (index < 0 || index > size)
+        throw new IndexOutOfBoundsException("Index: " + index + ", Size:"
+                                            + size);
+    }
+
+    /**
+     * This method checks that a value is between 0 (inclusive) and size
+     * (exclusive). If it is not, an exception is thrown.
+     *
+     * @param index the value to check
+     * @throws IndexOutOfBoundsException if index < 0 || index >= size()
+     */
+    // This will get inlined, since it is private.
+    private void checkBoundsExclusive(int index)
+    {
+      if (index < 0 || index >= size)
+        throw new IndexOutOfBoundsException("Index: " + index + ", Size:"
+                                            + size);
+    }
+
+    /**
+     * Specified by AbstractList.subList to return the private field size.
+     *
+     * @return the sublist size
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     */
+    public int size()
+    {
+      checkMod();
+      return size;
+    }
+
+    /**
+     * Specified by AbstractList.subList to delegate to the backing list.
+     *
+     * @param index the location to modify
+     * @param o the new value
+     * @return the old value
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws UnsupportedOperationException if the backing list does not
+     *         support the set operation
+     * @throws IndexOutOfBoundsException if index < 0 || index >= size()
+     * @throws ClassCastException if o cannot be added to the backing list due
+     *         to its type
+     * @throws IllegalArgumentException if o cannot be added to the backing list
+     *         for some other reason
+     */
+    public Object set(int index, Object o)
+    {
+      checkMod();
+      checkBoundsExclusive(index);
+      return backingList.set(index + offset, o);
+    }
+
+    /**
+     * Specified by AbstractList.subList to delegate to the backing list.
+     *
+     * @param index the location to get from
+     * @return the object at that location
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws IndexOutOfBoundsException if index < 0 || index >= size()
+     */
+    public Object get(int index)
+    {
+      checkMod();
+      checkBoundsExclusive(index);
+      return backingList.get(index + offset);
+    }
+
+    /**
+     * Specified by AbstractList.subList to delegate to the backing list.
+     *
+     * @param index the index to insert at
+     * @param o the object to add
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws IndexOutOfBoundsException if index < 0 || index > size()
+     * @throws UnsupportedOperationException if the backing list does not
+     *         support the add operation.
+     * @throws ClassCastException if o cannot be added to the backing list due
+     *         to its type.
+     * @throws IllegalArgumentException if o cannot be added to the backing
+     *         list for some other reason.
+     */
+    public void add(int index, Object o)
+    {
+      checkMod();
+      checkBoundsInclusive(index);
+      backingList.add(index + offset, o);
+      size++;
+      modCount = backingList.modCount;
+    }
+
+    /**
+     * Specified by AbstractList.subList to delegate to the backing list.
+     *
+     * @param index the index to remove
+     * @return the removed object
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws IndexOutOfBoundsException if index < 0 || index >= size()
+     * @throws UnsupportedOperationException if the backing list does not
+     *         support the remove operation
+     */
+    public Object remove(int index)
+    {
+      checkMod();
+      checkBoundsExclusive(index);
+      Object o = backingList.remove(index + offset);
+      size--;
+      modCount = backingList.modCount;
+      return o;
+    }
+
+    /**
+     * Specified by AbstractList.subList to delegate to the backing list.
+     * This does no bounds checking, as it assumes it will only be called
+     * by trusted code like clear() which has already checked the bounds.
+     *
+     * @param fromIndex the lower bound, inclusive
+     * @param toIndex the upper bound, exclusive
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws UnsupportedOperationException if the backing list does
+     *         not support removing elements.
+     */
+    protected void removeRange(int fromIndex, int toIndex)
+    {
+      checkMod();
+
+      backingList.removeRange(offset + fromIndex, offset + toIndex);
+      size -= toIndex - fromIndex;
+      modCount = backingList.modCount;
+    }
+
+    /**
+     * Specified by AbstractList.subList to delegate to the backing list.
+     *
+     * @param index the location to insert at
+     * @param c the collection to insert
+     * @return true if this list was modified, in other words, c is non-empty
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws IndexOutOfBoundsException if index < 0 || index > size()
+     * @throws UnsupportedOperationException if this list does not support the
+     *         addAll operation
+     * @throws ClassCastException if some element of c cannot be added to this
+     *         list due to its type
+     * @throws IllegalArgumentException if some element of c cannot be added
+     *         to this list for some other reason
+     * @throws NullPointerException if the specified collection is null
+     */
+    public boolean addAll(int index, Collection c)
+    {
+      checkMod();
+      checkBoundsInclusive(index);
+      int csize = c.size();
+      boolean result = backingList.addAll(offset + index, c);
+      size += csize;
+      modCount = backingList.modCount;
+      return result;
+    }
+
+    /**
+     * Specified by AbstractList.subList to return addAll(size, c).
+     *
+     * @param c the collection to insert
+     * @return true if this list was modified, in other words, c is non-empty
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws UnsupportedOperationException if this list does not support the
+     *         addAll operation
+     * @throws ClassCastException if some element of c cannot be added to this
+     *         list due to its type
+     * @throws IllegalArgumentException if some element of c cannot be added
+     *         to this list for some other reason
+     * @throws NullPointerException if the specified collection is null
+     */
+    public boolean addAll(Collection c)
+    {
+      return addAll(size, c);
+    }
+
+    /**
+     * Specified by AbstractList.subList to return listIterator().
+     *
+     * @return an iterator over the sublist
+     */
+    public Iterator iterator()
+    {
+      return listIterator();
+    }
+
+    /**
+     * Specified by AbstractList.subList to return a wrapper around the
+     * backing list's iterator.
+     *
+     * @param index the start location of the iterator
+     * @return a list iterator over the sublist
+     * @throws ConcurrentModificationException if the backing list has been
+     *         modified externally to this sublist
+     * @throws IndexOutOfBoundsException if the value is out of range
+     */
+    public ListIterator listIterator(final int index)
+    {
+      checkMod();
+      checkBoundsInclusive(index);
+
+      return new ListIterator()
+      {
+        private final ListIterator i = backingList.listIterator(index + offset);
+        private int position = index;
+
+        /**
+         * Tests to see if there are any more objects to
+         * return.
+         *
+         * @return True if the end of the list has not yet been
+         *         reached.
+         */
+        public boolean hasNext()
+        {
+          return position < size;
+        }
+
+        /**
+         * Tests to see if there are objects prior to the
+         * current position in the list.
+         *
+         * @return True if objects exist prior to the current
+         *         position of the iterator.
+         */
+        public boolean hasPrevious()
+        {
+          return position > 0;
+        }
+
+        /**
+         * Retrieves the next object from the list.
+         *
+         * @return The next object.
+         * @throws NoSuchElementException if there are no
+         *         more objects to retrieve.
+         * @throws ConcurrentModificationException if the
+         *         list has been modified elsewhere.
+         */
+        public Object next()
+        {
+          if (position == size)
+            throw new NoSuchElementException();
+          position++;
+          return i.next();
+        }
+
+        /**
+         * Retrieves the previous object from the list.
+         *
+         * @return The next object.
+         * @throws NoSuchElementException if there are no
+         *         previous objects to retrieve.
+         * @throws ConcurrentModificationException if the
+         *         list has been modified elsewhere.
+         */
+        public Object previous()
+        {
+          if (position == 0)
+            throw new NoSuchElementException();
+          position--;
+          return i.previous();
+        }
+
+        /**
+         * Returns the index of the next element in the
+         * list, which will be retrieved by <code>next()</code>
+         *
+         * @return The index of the next element.
+         */
+        public int nextIndex()
+        {
+          return i.nextIndex() - offset;
+        }
+
+        /**
+         * Returns the index of the previous element in the
+         * list, which will be retrieved by <code>previous()</code>
+         *
+         * @return The index of the previous element.
+         */
+        public int previousIndex()
+        {
+          return i.previousIndex() - offset;
+        }
+
+        /**
+         * Removes the last object retrieved by <code>next()</code>
+         * from the list, if the list supports object removal.
+         *
+         * @throws IllegalStateException if the iterator is positioned
+         *         before the start of the list or the last object has already
+         *         been removed.
+         * @throws UnsupportedOperationException if the list does
+         *         not support removing elements.
+         */
+        public void remove()
+        {
+          i.remove();
+          size--;
+          position = nextIndex();
+          modCount = backingList.modCount;
+        }
+
+
+       /**
+        * Replaces the last object retrieved by <code>next()</code>
+        * or <code>previous</code> with o, if the list supports object
+        * replacement and an add or remove operation has not already
+        * been performed.
+        *
+        * @throws IllegalStateException if the iterator is positioned
+        *         before the start of the list or the last object has already
+        *         been removed.
+        * @throws UnsupportedOperationException if the list doesn't support
+        *         the addition or removal of elements.
+        * @throws ClassCastException if the type of o is not a valid type
+        *         for this list.
+        * @throws IllegalArgumentException if something else related to o
+        *         prevents its addition.
+        * @throws ConcurrentModificationException if the list
+        *         has been modified elsewhere.
+        */
+        public void set(Object o)
+        {
+          i.set(o);
+        }
+
+        /**
+         * Adds the supplied object before the element that would be returned
+         * by a call to <code>next()</code>, if the list supports addition.
+         * 
+         * @param o The object to add to the list.
+         * @throws UnsupportedOperationException if the list doesn't support
+         *         the addition of new elements.
+         * @throws ClassCastException if the type of o is not a valid type
+         *         for this list.
+         * @throws IllegalArgumentException if something else related to o
+         *         prevents its addition.
+         * @throws ConcurrentModificationException if the list
+         *         has been modified elsewhere.
+         */
+        public void add(Object o)
+        {
+          i.add(o);
+          size++;
+          position++;
+          modCount = backingList.modCount;
+        }
+
+        // Here is the reason why the various modCount fields are mostly
+        // ignored in this wrapper listIterator.
+        // If the backing listIterator is failfast, then the following holds:
+        //   Using any other method on this list will call a corresponding
+        //   method on the backing list *after* the backing listIterator
+        //   is created, which will in turn cause a ConcurrentModException
+        //   when this listIterator comes to use the backing one. So it is
+        //   implicitly failfast.
+        // If the backing listIterator is NOT failfast, then the whole of
+        //   this list isn't failfast, because the modCount field of the
+        //   backing list is not valid. It would still be *possible* to
+        //   make the iterator failfast wrt modifications of the sublist
+        //   only, but somewhat pointless when the list can be changed under
+        //   us.
+        // Either way, no explicit handling of modCount is needed.
+        // However modCount = backingList.modCount must be executed in add
+        // and remove, and size must also be updated in these two methods,
+        // since they do not go through the corresponding methods of the subList.
+      };
+    }
+  } // class SubList
+
+  /**
+   * This class is a RandomAccess version of SubList, as required by
+   * {@link AbstractList#subList(int, int)}.
+   *
+   * @author Eric Blake (ebb9 at email.byu.edu)
+   */
+  private static final class RandomAccessSubList extends SubList
+    implements RandomAccess
+  {
+    /**
+     * Construct the sublist.
+     *
+     * @param backing the list this comes from
+     * @param fromIndex the lower bound, inclusive
+     * @param toIndex the upper bound, exclusive
+     */
+    RandomAccessSubList(AbstractList backing, int fromIndex, int toIndex)
+    {
+      super(backing, fromIndex, toIndex);
+    }
+  } // class RandomAccessSubList
+
+} // class AbstractList

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/AbstractMap.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/AbstractMap.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/AbstractMap.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/AbstractMap.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,749 @@
+/* AbstractMap.java -- Abstract implementation of most of Map
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/**
+ * An abstract implementation of Map to make it easier to create your own
+ * implementations. In order to create an unmodifiable Map, subclass
+ * AbstractMap and implement the <code>entrySet</code> (usually via an
+ * AbstractSet).  To make it modifiable, also implement <code>put</code>,
+ * and have <code>entrySet().iterator()</code> support <code>remove</code>.
+ * <p>
+ *
+ * It is recommended that classes which extend this support at least the
+ * no-argument constructor, and a constructor which accepts another Map.
+ * Further methods in this class may be overridden if you have a more
+ * efficient implementation.
+ *
+ * @author Original author unknown
+ * @author Bryce McKinlay
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Map
+ * @see Collection
+ * @see HashMap
+ * @see LinkedHashMap
+ * @see TreeMap
+ * @see WeakHashMap
+ * @see IdentityHashMap
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public abstract class AbstractMap implements Map
+{
+  /** An "enum" of iterator types. */
+  // Package visible for use by subclasses.
+  static final int KEYS = 0,
+                   VALUES = 1,
+                   ENTRIES = 2;
+
+  /**
+   * The cache for {@link #keySet()}.
+   */
+  // Package visible for use by subclasses.
+  Set keys;
+
+  /**
+   * The cache for {@link #values()}.
+   */
+  // Package visible for use by subclasses.
+  Collection values;
+
+  /**
+   * The main constructor, for use by subclasses.
+   */
+  protected AbstractMap()
+  {
+  }
+
+  /**
+   * Returns a set view of the mappings in this Map.  Each element in the
+   * set must be an implementation of Map.Entry.  The set is backed by
+   * the map, so that changes in one show up in the other.  Modifications
+   * made while an iterator is in progress cause undefined behavior.  If
+   * the set supports removal, these methods must be valid:
+   * <code>Iterator.remove</code>, <code>Set.remove</code>,
+   * <code>removeAll</code>, <code>retainAll</code>, and <code>clear</code>.
+   * Element addition is not supported via this set.
+   *
+   * @return the entry set
+   * @see Map.Entry
+   */
+  public abstract Set entrySet();
+
+  /**
+   * Remove all entries from this Map (optional operation). This default
+   * implementation calls entrySet().clear(). NOTE: If the entry set does
+   * not permit clearing, then this will fail, too. Subclasses often
+   * override this for efficiency.  Your implementation of entrySet() should
+   * not call <code>AbstractMap.clear</code> unless you want an infinite loop.
+   *
+   * @throws UnsupportedOperationException if <code>entrySet().clear()</code>
+   *         does not support clearing.
+   * @see Set#clear()
+   */
+  public void clear()
+  {
+    entrySet().clear();
+  }
+
+  /**
+   * Create a shallow copy of this Map, no keys or values are copied. The
+   * default implementation simply calls <code>super.clone()</code>.
+   *
+   * @return the shallow clone
+   * @throws CloneNotSupportedException if a subclass is not Cloneable
+   * @see Cloneable
+   * @see Object#clone()
+   */
+  protected Object clone() throws CloneNotSupportedException
+  {
+    AbstractMap copy = (AbstractMap) super.clone();
+    // Clear out the caches; they are stale.
+    copy.keys = null;
+    copy.values = null;
+    return copy;
+  }
+
+  /**
+   * Returns true if this contains a mapping for the given key. This
+   * implementation does a linear search, O(n), over the
+   * <code>entrySet()</code>, returning <code>true</code> if a match
+   * is found, <code>false</code> if the iteration ends. Many subclasses
+   * can implement this more efficiently.
+   *
+   * @param key the key to search for
+   * @return true if the map contains the key
+   * @throws NullPointerException if key is <code>null</code> but the map
+   *         does not permit null keys
+   * @see #containsValue(Object)
+   */
+  public boolean containsKey(Object key)
+  {
+    Iterator entries = entrySet().iterator();
+    int pos = size();
+    while (--pos >= 0)
+      if (equals(key, ((Map.Entry) entries.next()).getKey()))
+        return true;
+    return false;
+  }
+
+  /**
+   * Returns true if this contains at least one mapping with the given value.
+   * This implementation does a linear search, O(n), over the
+   * <code>entrySet()</code>, returning <code>true</code> if a match
+   * is found, <code>false</code> if the iteration ends. A match is
+   * defined as a value, v, where <code>(value == null ? v == null :
+   * value.equals(v))</code>.  Subclasses are unlikely to implement
+   * this more efficiently.
+   *
+   * @param value the value to search for
+   * @return true if the map contains the value
+   * @see #containsKey(Object)
+   */
+  public boolean containsValue(Object value)
+  {
+    Iterator entries = entrySet().iterator();
+    int pos = size();
+    while (--pos >= 0)
+      if (equals(value, ((Map.Entry) entries.next()).getValue()))
+        return true;
+    return false;
+  }
+
+  /**
+   * Compares the specified object with this map for equality. Returns
+   * <code>true</code> if the other object is a Map with the same mappings,
+   * that is,<br>
+   * <code>o instanceof Map && entrySet().equals(((Map) o).entrySet();</code>
+   *
+   * @param o the object to be compared
+   * @return true if the object equals this map
+   * @see Set#equals(Object)
+   */
+  public boolean equals(Object o)
+  {
+    return (o == this ||
+            (o instanceof Map &&
+             entrySet().equals(((Map) o).entrySet())));
+  }
+
+  /**
+   * Returns the value mapped by the given key. Returns <code>null</code> if
+   * there is no mapping.  However, in Maps that accept null values, you
+   * must rely on <code>containsKey</code> to determine if a mapping exists.
+   * This iteration takes linear time, searching entrySet().iterator() of
+   * the key.  Many implementations override this method.
+   *
+   * @param key the key to look up
+   * @return the value associated with the key, or null if key not in map
+   * @throws NullPointerException if this map does not accept null keys
+   * @see #containsKey(Object)
+   */
+  public Object get(Object key)
+  {
+    Iterator entries = entrySet().iterator();
+    int pos = size();
+    while (--pos >= 0)
+      {
+        Map.Entry entry = (Map.Entry) entries.next();
+        if (equals(key, entry.getKey()))
+          return entry.getValue();
+      }
+    return null;
+  }
+
+  /**
+   * Returns the hash code for this map. As defined in Map, this is the sum
+   * of all hashcodes for each Map.Entry object in entrySet, or basically
+   * entrySet().hashCode().
+   *
+   * @return the hash code
+   * @see Map.Entry#hashCode()
+   * @see Set#hashCode()
+   */
+  public int hashCode()
+  {
+    return entrySet().hashCode();
+  }
+
+  /**
+   * Returns true if the map contains no mappings. This is implemented by
+   * <code>size() == 0</code>.
+   *
+   * @return true if the map is empty
+   * @see #size()
+   */
+  public boolean isEmpty()
+  {
+    return size() == 0;
+  }
+
+  /**
+   * Returns a set view of this map's keys. The set is backed by the map,
+   * so changes in one show up in the other. Modifications while an iteration
+   * is in progress produce undefined behavior. The set supports removal
+   * if entrySet() does, but does not support element addition.
+   * <p>
+   *
+   * This implementation creates an AbstractSet, where the iterator wraps
+   * the entrySet iterator, size defers to the Map's size, and contains
+   * defers to the Map's containsKey. The set is created on first use, and
+   * returned on subsequent uses, although since no synchronization occurs,
+   * there is a slight possibility of creating two sets.
+   *
+   * @return a Set view of the keys
+   * @see Set#iterator()
+   * @see #size()
+   * @see #containsKey(Object)
+   * @see #values()
+   */
+  public Set keySet()
+  {
+    if (keys == null)
+      keys = new AbstractSet()
+      {
+	/**
+	 * Retrieves the number of keys in the backing map.
+	 *
+	 * @return The number of keys.
+	 */
+        public int size()
+        {
+          return AbstractMap.this.size();
+        }
+
+	/**
+	 * Returns true if the backing map contains the
+	 * supplied key.
+	 *
+	 * @param key The key to search for.
+	 * @return True if the key was found, false otherwise.
+	 */
+        public boolean contains(Object key)
+        {
+          return containsKey(key);
+        }
+
+	/**
+	 * Returns an iterator which iterates over the keys
+	 * in the backing map, using a wrapper around the
+	 * iterator returned by <code>entrySet()</code>.
+	 *
+	 * @return An iterator over the keys.
+	 */
+        public Iterator iterator()
+        {
+          return new Iterator()
+          {
+	    /**
+	     * The iterator returned by <code>entrySet()</code>.
+	     */
+            private final Iterator map_iterator = entrySet().iterator();
+
+	    /**
+	     * Returns true if a call to <code>next()</code> will
+	     * return another key.
+	     *
+	     * @return True if the iterator has not yet reached
+	     *         the last key.
+	     */
+            public boolean hasNext()
+            {
+              return map_iterator.hasNext();
+            }
+
+	    /**
+	     * Returns the key from the next entry retrieved
+	     * by the underlying <code>entrySet()</code> iterator.
+	     *
+	     * @return The next key.
+	     */
+            public Object next()
+            {
+              return ((Map.Entry) map_iterator.next()).getKey();
+            }
+
+	    /**
+	     * Removes the map entry which has a key equal
+	     * to that returned by the last call to
+	     * <code>next()</code>.
+	     *
+	     * @throws UnsupportedOperationException if the
+	     *         map doesn't support removal.
+	     */
+            public void remove()
+            {
+              map_iterator.remove();
+            }
+          };
+        }
+      };
+    return keys;
+  }
+
+  /**
+   * Associates the given key to the given value (optional operation). If the
+   * map already contains the key, its value is replaced. This implementation
+   * simply throws an UnsupportedOperationException. Be aware that in a map
+   * that permits <code>null</code> values, a null return does not always
+   * imply that the mapping was created.
+   *
+   * @param key the key to map
+   * @param value the value to be mapped
+   * @return the previous value of the key, or null if there was no mapping
+   * @throws UnsupportedOperationException if the operation is not supported
+   * @throws ClassCastException if the key or value is of the wrong type
+   * @throws IllegalArgumentException if something about this key or value
+   *         prevents it from existing in this map
+   * @throws NullPointerException if the map forbids null keys or values
+   * @see #containsKey(Object)
+   */
+  public Object put(Object key, Object value)
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Copies all entries of the given map to this one (optional operation). If
+   * the map already contains a key, its value is replaced. This implementation
+   * simply iterates over the map's entrySet(), calling <code>put</code>,
+   * so it is not supported if puts are not.
+   *
+   * @param m the mapping to load into this map
+   * @throws UnsupportedOperationException if the operation is not supported
+   *         by this map.
+   * @throws ClassCastException if a key or value is of the wrong type for
+   *         adding to this map.
+   * @throws IllegalArgumentException if something about a key or value
+   *         prevents it from existing in this map.
+   * @throws NullPointerException if the map forbids null keys or values.
+   * @throws NullPointerException if <code>m</code> is null.
+   * @see #put(Object, Object)
+   */
+  public void putAll(Map m)
+  {
+    Iterator entries = m.entrySet().iterator();
+    int pos = m.size();
+    while (--pos >= 0)
+      {
+        Map.Entry entry = (Map.Entry) entries.next();
+        put(entry.getKey(), entry.getValue());
+      }
+  }
+
+  /**
+   * Removes the mapping for this key if present (optional operation). This
+   * implementation iterates over the entrySet searching for a matching
+   * key, at which point it calls the iterator's <code>remove</code> method.
+   * It returns the result of <code>getValue()</code> on the entry, if found,
+   * or null if no entry is found. Note that maps which permit null values
+   * may also return null if the key was removed.  If the entrySet does not
+   * support removal, this will also fail. This is O(n), so many
+   * implementations override it for efficiency.
+   *
+   * @param key the key to remove
+   * @return the value the key mapped to, or null if not present.
+   *         Null may also be returned if null values are allowed
+   *         in the map and the value of this mapping is null.
+   * @throws UnsupportedOperationException if deletion is unsupported
+   * @see Iterator#remove()
+   */
+  public Object remove(Object key)
+  {
+    Iterator entries = entrySet().iterator();
+    int pos = size();
+    while (--pos >= 0)
+      {
+        Map.Entry entry = (Map.Entry) entries.next();
+        if (equals(key, entry.getKey()))
+          {
+            // Must get the value before we remove it from iterator.
+            Object r = entry.getValue();
+            entries.remove();
+            return r;
+          }
+      }
+    return null;
+  }
+
+  /**
+   * Returns the number of key-value mappings in the map. If there are more
+   * than Integer.MAX_VALUE mappings, return Integer.MAX_VALUE. This is
+   * implemented as <code>entrySet().size()</code>.
+   *
+   * @return the number of mappings
+   * @see Set#size()
+   */
+  public int size()
+  {
+    return entrySet().size();
+  }
+
+  /**
+   * Returns a String representation of this map. This is a listing of the
+   * map entries (which are specified in Map.Entry as being
+   * <code>getKey() + "=" + getValue()</code>), separated by a comma and
+   * space (", "), and surrounded by braces ('{' and '}'). This implementation
+   * uses a StringBuffer and iterates over the entrySet to build the String.
+   * Note that this can fail with an exception if underlying keys or
+   * values complete abruptly in toString().
+   *
+   * @return a String representation
+   * @see Map.Entry#toString()
+   */
+  public String toString()
+  {
+    Iterator entries = entrySet().iterator();
+    StringBuffer r = new StringBuffer("{");
+    for (int pos = size(); pos > 0; pos--)
+      {
+        Map.Entry entry = (Map.Entry) entries.next();
+        r.append(entry.getKey());
+        r.append('=');
+        r.append(entry.getValue());
+        if (pos > 1)
+          r.append(", ");
+      }
+    r.append("}");
+    return r.toString();
+  }
+
+  /**
+   * Returns a collection or bag view of this map's values. The collection
+   * is backed by the map, so changes in one show up in the other.
+   * Modifications while an iteration is in progress produce undefined
+   * behavior. The collection supports removal if entrySet() does, but
+   * does not support element addition.
+   * <p>
+   *
+   * This implementation creates an AbstractCollection, where the iterator
+   * wraps the entrySet iterator, size defers to the Map's size, and contains
+   * defers to the Map's containsValue. The collection is created on first
+   * use, and returned on subsequent uses, although since no synchronization
+   * occurs, there is a slight possibility of creating two collections.
+   *
+   * @return a Collection view of the values
+   * @see Collection#iterator()
+   * @see #size()
+   * @see #containsValue(Object)
+   * @see #keySet()
+   */
+  public Collection values()
+  {
+    if (values == null)
+      values = new AbstractCollection()
+      {
+	/**
+	 * Returns the number of values stored in
+	 * the backing map.
+	 *
+	 * @return The number of values.
+	 */
+        public int size()
+        {
+          return AbstractMap.this.size();
+        }
+
+	/**
+	 * Returns true if the backing map contains
+	 * the supplied value.
+	 *
+	 * @param value The value to search for.
+	 * @return True if the value was found, false otherwise.
+	 */
+        public boolean contains(Object value)
+        {
+          return containsValue(value);
+        }
+
+	/**
+	 * Returns an iterator which iterates over the
+	 * values in the backing map, by using a wrapper
+	 * around the iterator returned by <code>entrySet()</code>.
+	 *
+	 * @return An iterator over the values.
+	 */
+        public Iterator iterator()
+        {
+          return new Iterator()
+          {
+	    /**
+	     * The iterator returned by <code>entrySet()</code>.
+	     */
+            private final Iterator map_iterator = entrySet().iterator();
+
+	    /**
+	     * Returns true if a call to <code>next()</call> will
+	     * return another value.
+	     *
+	     * @return True if the iterator has not yet reached
+	     * the last value.
+	     */
+            public boolean hasNext()
+            {
+              return map_iterator.hasNext();
+            }
+
+	    /**
+	     * Returns the value from the next entry retrieved
+	     * by the underlying <code>entrySet()</code> iterator.
+	     *
+	     * @return The next value.
+	     */
+            public Object next()
+            {
+              return ((Map.Entry) map_iterator.next()).getValue();
+            }
+
+	    /**
+	     * Removes the map entry which has a key equal
+	     * to that returned by the last call to
+	     * <code>next()</code>.
+	     *
+	     * @throws UnsupportedOperationException if the
+	     *         map doesn't support removal.
+	     */
+            public void remove()
+            {
+              map_iterator.remove();
+            }
+          };
+        }
+      };
+    return values;
+  }
+
+  /**
+   * Compare two objects according to Collection semantics.
+   *
+   * @param o1 the first object
+   * @param o2 the second object
+   * @return o1 == o2 || (o1 != null && o1.equals(o2))
+   */
+  // Package visible for use throughout java.util.
+  // It may be inlined since it is final.
+  static final boolean equals(Object o1, Object o2)
+  {
+    return o1 == o2 || (o1 != null && o1.equals(o2));
+  }
+
+  /**
+   * Hash an object according to Collection semantics.
+   *
+   * @param o the object to hash
+   * @return o1 == null ? 0 : o1.hashCode()
+   */
+  // Package visible for use throughout java.util.
+  // It may be inlined since it is final.
+  static final int hashCode(Object o)
+  {
+    return o == null ? 0 : o.hashCode();
+  }
+
+  /**
+   * A class which implements Map.Entry. It is shared by HashMap, TreeMap,
+   * Hashtable, and Collections. It is not specified by the JDK, but makes
+   * life much easier.
+   *
+   * @author Jon Zeppieri
+   * @author Eric Blake (ebb9 at email.byu.edu)
+   */
+  // XXX - FIXME Use fully qualified implements as gcj 3.1 workaround.
+  //       Bug still exists in 3.4.1
+  static class BasicMapEntry implements Map.Entry
+  {
+    /**
+     * The key. Package visible for direct manipulation.
+     */
+    Object key;
+
+    /**
+     * The value. Package visible for direct manipulation.
+     */
+    Object value;
+
+    /**
+     * Basic constructor initializes the fields.
+     * @param newKey the key
+     * @param newValue the value
+     */
+    BasicMapEntry(Object newKey, Object newValue)
+    {
+      key = newKey;
+      value = newValue;
+    }
+
+    /**
+     * Compares the specified object with this entry. Returns true only if
+     * the object is a mapping of identical key and value. In other words,
+     * this must be:<br>
+     * <pre>(o instanceof Map.Entry)
+     *       && (getKey() == null ? ((HashMap) o).getKey() == null
+     *           : getKey().equals(((HashMap) o).getKey()))
+     *       && (getValue() == null ? ((HashMap) o).getValue() == null
+     *           : getValue().equals(((HashMap) o).getValue()))</pre>
+     *
+     * @param o the object to compare
+     * @return <code>true</code> if it is equal
+     */
+    public final boolean equals(Object o)
+    {
+      if (! (o instanceof Map.Entry))
+        return false;
+      // Optimize for our own entries.
+      if (o instanceof BasicMapEntry)
+        {
+          BasicMapEntry e = (BasicMapEntry) o;
+          return (AbstractMap.equals(key, e.key)
+                  && AbstractMap.equals(value, e.value));
+        }
+      Map.Entry e = (Map.Entry) o;
+      return (AbstractMap.equals(key, e.getKey())
+              && AbstractMap.equals(value, e.getValue()));
+    }
+
+    /**
+     * Get the key corresponding to this entry.
+     *
+     * @return the key
+     */
+    public final Object getKey()
+    {
+      return key;
+    }
+
+    /**
+     * Get the value corresponding to this entry. If you already called
+     * Iterator.remove(), the behavior undefined, but in this case it works.
+     *
+     * @return the value
+     */
+    public final Object getValue()
+    {
+      return value;
+    }
+
+    /**
+     * Returns the hash code of the entry.  This is defined as the exclusive-or
+     * of the hashcodes of the key and value (using 0 for null). In other
+     * words, this must be:<br>
+     * <pre>(getKey() == null ? 0 : getKey().hashCode())
+     *       ^ (getValue() == null ? 0 : getValue().hashCode())</pre>
+     *
+     * @return the hash code
+     */
+    public final int hashCode()
+    {
+      return (AbstractMap.hashCode(key) ^ AbstractMap.hashCode(value));
+    }
+
+    /**
+     * Replaces the value with the specified object. This writes through
+     * to the map, unless you have already called Iterator.remove(). It
+     * may be overridden to restrict a null value.
+     *
+     * @param newVal the new value to store
+     * @return the old value
+     * @throws NullPointerException if the map forbids null values.
+     * @throws UnsupportedOperationException if the map doesn't support
+     *          <code>put()</code>.
+     * @throws ClassCastException if the value is of a type unsupported
+     *         by the map.
+     * @throws IllegalArgumentException if something else about this
+     *         value prevents it being stored in the map.
+     */
+    public Object setValue(Object newVal)
+    {
+      Object r = value;
+      value = newVal;
+      return r;
+    }
+
+    /**
+     * This provides a string representation of the entry. It is of the form
+     * "key=value", where string concatenation is used on key and value.
+     *
+     * @return the string representation
+     */
+    public final String toString()
+    {
+      return key + "=" + value;
+    }
+  } // class BasicMapEntry
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/AbstractSequentialList.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/AbstractSequentialList.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/AbstractSequentialList.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/AbstractSequentialList.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,235 @@
+/* AbstractSequentialList.java -- List implementation for sequential access
+   Copyright (C) 1998, 1999, 2000, 2001, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/**
+ * Abstract superclass to make it easier to implement the List interface when
+ * backed by a sequential-access store, such as a linked list. For random
+ * access data, use AbstractList. This class implements the random access
+ * methods (<code>get</code>, <code>set</code>, <code>add</code>, and
+ * <code>remove</code>) atop the list iterator, opposite of AbstractList's
+ * approach of implementing the iterator atop random access.
+ * <p>
+ *
+ * To implement a list, you need an implementation for <code>size()</code>
+ * and <code>listIterator</code>.  With just <code>hasNext</code>,
+ * <code>next</code>, <code>hasPrevious</code>, <code>previous</code>,
+ * <code>nextIndex</code>, and <code>previousIndex</code>, you have an
+ * unmodifiable list. For a modifiable one, add <code>set</code>, and for
+ * a variable-size list, add <code>add</code> and <code>remove</code>.
+ * <p>
+ *
+ * The programmer should provide a no-argument constructor, and one that
+ * accepts another Collection, as recommended by the Collection interface.
+ * Unfortunately, there is no way to enforce this in Java.
+ *
+ * @author Original author unknown
+ * @author Bryce McKinlay
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Collection
+ * @see List
+ * @see AbstractList
+ * @see AbstractCollection
+ * @see ListIterator
+ * @see LinkedList
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public abstract class AbstractSequentialList extends AbstractList
+{
+  /**
+   * The main constructor, for use by subclasses.
+   */
+  protected AbstractSequentialList()
+  {
+  }
+
+  /**
+   * Returns a ListIterator over the list, starting from position index.
+   * Subclasses must provide an implementation of this method.
+   *
+   * @param index the starting position of the list
+   * @return the list iterator
+   * @throws IndexOutOfBoundsException if index < 0 || index > size()
+   */
+  public abstract ListIterator listIterator(int index);
+
+  /**
+   * Insert an element into the list at a given position (optional operation).
+   * This shifts all existing elements from that position to the end one
+   * index to the right. This version of add has no return, since it is
+   * assumed to always succeed if there is no exception. This iteration
+   * uses listIterator(index).add(o).
+   *
+   * @param index the location to insert the item
+   * @param o the object to insert
+   * @throws UnsupportedOperationException if this list does not support the
+   *         add operation
+   * @throws IndexOutOfBoundsException if index < 0 || index > size()
+   * @throws ClassCastException if o cannot be added to this list due to its
+   *         type
+   * @throws IllegalArgumentException if o cannot be added to this list for
+   *         some other reason.
+   * @throws NullPointerException if o is null and the list does not permit
+   *         the addition of null values.
+   */
+  public void add(int index, Object o)
+  {
+    listIterator(index).add(o);
+  }
+
+  /**
+   * Insert the contents of a collection into the list at a given position
+   * (optional operation). Shift all elements at that position to the right
+   * by the number of elements inserted. This operation is undefined if
+   * this list is modified during the operation (for example, if you try
+   * to insert a list into itself).
+   * <p>
+   *
+   * This implementation grabs listIterator(index), then proceeds to use add
+   * for each element returned by c's iterator. Sun's online specs are wrong,
+   * claiming that this also calls next(): listIterator.add() correctly
+   * skips the added element.
+   *
+   * @param index the location to insert the collection
+   * @param c the collection to insert
+   * @return true if the list was modified by this action, that is, if c is
+   *         non-empty
+   * @throws UnsupportedOperationException if this list does not support the
+   *         addAll operation
+   * @throws IndexOutOfBoundsException if index < 0 || index > size()
+   * @throws ClassCastException if some element of c cannot be added to this
+   *         list due to its type
+   * @throws IllegalArgumentException if some element of c cannot be added
+   *         to this list for some other reason
+   * @throws NullPointerException if the specified collection is null
+   * @throws NullPointerException if an object, o, in c is null and the list
+   *         does not permit the addition of null values.
+   * @see #add(int, Object)
+   */
+  public boolean addAll(int index, Collection c)
+  {
+    Iterator ci = c.iterator();
+    int size = c.size();
+    ListIterator i = listIterator(index);
+    for (int pos = size; pos > 0; pos--)
+      i.add(ci.next());
+    return size > 0;
+  }
+
+  /**
+   * Get the element at a given index in this list. This implementation
+   * returns listIterator(index).next().
+   *
+   * @param index the index of the element to be returned
+   * @return the element at index index in this list
+   * @throws IndexOutOfBoundsException if index < 0 || index >= size()
+   */
+  public Object get(int index)
+  {
+    // This is a legal listIterator position, but an illegal get.
+    if (index == size())
+      throw new IndexOutOfBoundsException("Index: " + index + ", Size:"
+                                          + size());
+    return listIterator(index).next();
+  }
+
+  /**
+   * Obtain an Iterator over this list, whose sequence is the list order. This
+   * implementation returns listIterator().
+   *
+   * @return an Iterator over the elements of this list, in order
+   */
+  public Iterator iterator()
+  {
+    return listIterator();
+  }
+
+  /**
+   * Remove the element at a given position in this list (optional operation).
+   * Shifts all remaining elements to the left to fill the gap. This
+   * implementation uses listIterator(index) and ListIterator.remove().
+   *
+   * @param index the position within the list of the object to remove
+   * @return the object that was removed
+   * @throws UnsupportedOperationException if this list does not support the
+   *         remove operation
+   * @throws IndexOutOfBoundsException if index < 0 || index >= size()
+   */
+  public Object remove(int index)
+  {
+    // This is a legal listIterator position, but an illegal remove.
+    if (index == size())
+      throw new IndexOutOfBoundsException("Index: " + index + ", Size:"
+                                          + size());
+    ListIterator i = listIterator(index);
+    Object removed = i.next();
+    i.remove();
+    return removed;
+  }
+
+  /**
+   * Replace an element of this list with another object (optional operation).
+   * This implementation uses listIterator(index) and ListIterator.set(o).
+   *
+   * @param index the position within this list of the element to be replaced
+   * @param o the object to replace it with
+   * @return the object that was replaced
+   * @throws UnsupportedOperationException if this list does not support the
+   *         set operation
+   * @throws IndexOutOfBoundsException if index < 0 || index >= size()
+   * @throws ClassCastException if o cannot be added to this list due to its
+   *         type
+   * @throws IllegalArgumentException if o cannot be added to this list for
+   *         some other reason
+   * @throws NullPointerException if o is null and the list does not allow
+   *         a value to be set to null.
+   */
+  public Object set(int index, Object o)
+  {
+    // This is a legal listIterator position, but an illegal set.
+    if (index == size())
+      throw new IndexOutOfBoundsException("Index: " + index + ", Size:"
+                                          + size());
+    ListIterator i = listIterator(index);
+    Object old = i.next();
+    i.set(o);
+    return old;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/AbstractSet.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/AbstractSet.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/AbstractSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/AbstractSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,139 @@
+/* AbstractSet.java -- Abstract implementation of most of Set
+   Copyright (C) 1998, 2000, 2001, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+/**
+ * An abstract implementation of Set to make it easier to create your own
+ * implementations. In order to create a Set, subclass AbstractSet and
+ * implement the same methods that are required for AbstractCollection
+ * (although these methods must of course meet the requirements that Set puts
+ * on them - specifically, no element may be in the set more than once). This
+ * class simply provides implementations of equals() and hashCode() to fulfil
+ * the requirements placed on them by the Set interface.
+ *
+ * @author Original author unknown
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Collection
+ * @see AbstractCollection
+ * @see Set
+ * @see HashSet
+ * @see TreeSet
+ * @see LinkedHashSet
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public abstract class AbstractSet extends AbstractCollection implements Set
+{
+  /**
+   * The main constructor, for use by subclasses.
+   */
+  protected AbstractSet()
+  {
+  }
+
+  /**
+   * Tests whether the given object is equal to this Set. This implementation
+   * first checks whether this set <em>is</em> the given object, and returns
+   * true if so. Otherwise, if o is a Set and is the same size as this one, it
+   * returns the result of calling containsAll on the given Set. Otherwise, it
+   * returns false.
+   *
+   * @param o the Object to be tested for equality with this Set
+   * @return true if the given object is equal to this Set
+   */
+  public boolean equals(Object o)
+  {
+    return (o == this ||
+            (o instanceof Set && ((Set) o).size() == size()
+             && containsAll((Collection) o)));
+  }
+
+  /**
+   * Returns a hash code for this Set. The hash code of a Set is the sum of the
+   * hash codes of all its elements, except that the hash code of null is
+   * defined to be zero. This implementation obtains an Iterator over the Set,
+   * and sums the results.
+   *
+   * @return a hash code for this Set
+   */
+  public int hashCode()
+  {
+    Iterator itr = iterator();
+    int hash = 0;
+    int pos = size();
+    while (--pos >= 0)
+      hash += hashCode(itr.next());
+    return hash;
+  }
+
+  /**
+   * Removes from this set all elements in the given collection (optional
+   * operation). This implementation uses <code>size()</code> to determine
+   * the smaller collection.  Then, if this set is smaller, it iterates
+   * over the set, calling Iterator.remove if the collection contains
+   * the element.  If this set is larger, it iterates over the collection,
+   * calling Set.remove for all elements in the collection. Note that
+   * this operation will fail if a remove methods is not supported.
+   *
+   * @param c the collection of elements to remove
+   * @return true if the set was modified as a result
+   * @throws UnsupportedOperationException if remove is not supported
+   * @throws NullPointerException if the collection is null
+   * @see AbstractCollection#remove(Object)
+   * @see Collection#contains(Object)
+   * @see Iterator#remove()
+   */
+  public boolean removeAll(Collection c)
+  {
+    int oldsize = size();
+    int count = c.size();
+    Iterator i;
+    if (oldsize < count)
+      {
+	for (i = iterator(), count = oldsize; count > 0; count--)
+          if (c.contains(i.next()))
+            i.remove();
+      }
+    else
+      for (i = c.iterator(); count > 0; count--)
+        remove(i.next());
+    return oldsize != size();
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/ArrayList.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/ArrayList.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/ArrayList.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/ArrayList.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,591 @@
+/* ArrayList.java -- JDK1.2's answer to Vector; this is an array-backed
+   implementation of the List interface
+   Copyright (C) 1998, 1999, 2000, 2001, 2004, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.lang.reflect.Array;
+
+/**
+ * An array-backed implementation of the List interface.  This implements
+ * all optional list operations, and permits null elements, so that it is
+ * better than Vector, which it replaces. Random access is roughly constant
+ * time, and iteration is roughly linear time, so it is nice and fast, with
+ * less overhead than a LinkedList.
+ * <p>
+ *
+ * Each list has a capacity, and as the array reaches that capacity it
+ * is automatically transferred to a larger array. You also have access to
+ * ensureCapacity and trimToSize to control the backing array's size, avoiding
+ * reallocation or wasted memory.
+ * <p>
+ *
+ * ArrayList is not synchronized, so if you need multi-threaded access,
+ * consider using:<br>
+ * <code>List l = Collections.synchronizedList(new ArrayList(...));</code>
+ * <p>
+ *
+ * The iterators are <i>fail-fast</i>, meaning that any structural
+ * modification, except for <code>remove()</code> called on the iterator
+ * itself, cause the iterator to throw a
+ * {@link ConcurrentModificationException} rather than exhibit
+ * non-deterministic behavior.
+ *
+ * @author Jon A. Zeppieri
+ * @author Bryce McKinlay
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Collection
+ * @see List
+ * @see LinkedList
+ * @see Vector
+ * @see Collections#synchronizedList(List)
+ * @see AbstractList
+ * @status updated to 1.4
+ */
+public class ArrayList extends AbstractList
+  implements List, RandomAccess, Cloneable, Serializable
+{
+  /**
+   * Compatible with JDK 1.2
+   */
+  private static final long serialVersionUID = 8683452581122892189L;
+
+  /**
+   * The default capacity for new ArrayLists.
+   */
+  private static final int DEFAULT_CAPACITY = 10;
+
+  /**
+   * The number of elements in this list.
+   * @serial the list size
+   */
+  private int size;
+
+  /**
+   * Where the data is stored.
+   */
+  private transient Object[] data;
+
+  /**
+   * Construct a new ArrayList with the supplied initial capacity.
+   *
+   * @param capacity initial capacity of this ArrayList
+   * @throws IllegalArgumentException if capacity is negative
+   */
+  public ArrayList(int capacity)
+  {
+    // Must explicitly check, to get correct exception.
+    if (capacity < 0)
+      throw new IllegalArgumentException();
+    data = new Object[capacity];
+  }
+
+  /**
+   * Construct a new ArrayList with the default capacity (16).
+   */
+  public ArrayList()
+  {
+    this(DEFAULT_CAPACITY);
+  }
+
+  /**
+   * Construct a new ArrayList, and initialize it with the elements
+   * in the supplied Collection. The initial capacity is 110% of the
+   * Collection's size.
+   *
+   * @param c the collection whose elements will initialize this list
+   * @throws NullPointerException if c is null
+   */
+  public ArrayList(Collection c)
+  {
+    this((int) (c.size() * 1.1f));
+    addAll(c);
+  }
+
+  /**
+   * Trims the capacity of this List to be equal to its size;
+   * a memory saver.
+   */
+  public void trimToSize()
+  {
+    // Not a structural change from the perspective of iterators on this list,
+    // so don't update modCount.
+    if (size != data.length)
+      {
+        Object[] newData = new Object[size];
+        System.arraycopy(data, 0, newData, 0, size);
+        data = newData;
+      }
+  }
+
+  /**
+   * Guarantees that this list will have at least enough capacity to
+   * hold minCapacity elements. This implementation will grow the list to
+   * max(current * 2, minCapacity) if (minCapacity > current). The JCL says
+   * explictly that "this method increases its capacity to minCap", while
+   * the JDK 1.3 online docs specify that the list will grow to at least the
+   * size specified.
+   *
+   * @param minCapacity the minimum guaranteed capacity
+   */
+  public void ensureCapacity(int minCapacity)
+  {
+    int current = data.length;
+
+    if (minCapacity > current)
+      {
+        Object[] newData = new Object[Math.max(current * 2, minCapacity)];
+        System.arraycopy(data, 0, newData, 0, size);
+        data = newData;
+      }
+  }
+
+  /**
+   * Returns the number of elements in this list.
+   *
+   * @return the list size
+   */
+  public int size()
+  {
+    return size;
+  }
+
+  /**
+   * Checks if the list is empty.
+   *
+   * @return true if there are no elements
+   */
+  public boolean isEmpty()
+  {
+    return size == 0;
+  }
+
+  /**
+   * Returns true iff element is in this ArrayList.
+   *
+   * @param e the element whose inclusion in the List is being tested
+   * @return true if the list contains e
+   */
+  public boolean contains(Object e)
+  {
+    return indexOf(e) != -1;
+  }
+
+  /**
+   * Returns the lowest index at which element appears in this List, or
+   * -1 if it does not appear.
+   *
+   * @param e the element whose inclusion in the List is being tested
+   * @return the index where e was found
+   */
+  public int indexOf(Object e)
+  {
+    for (int i = 0; i < size; i++)
+      if (equals(e, data[i]))
+        return i;
+    return -1;
+  }
+
+  /**
+   * Returns the highest index at which element appears in this List, or
+   * -1 if it does not appear.
+   *
+   * @param e the element whose inclusion in the List is being tested
+   * @return the index where e was found
+   */
+  public int lastIndexOf(Object e)
+  {
+    for (int i = size - 1; i >= 0; i--)
+      if (equals(e, data[i]))
+        return i;
+    return -1;
+  }
+
+  /**
+   * Creates a shallow copy of this ArrayList (elements are not cloned).
+   *
+   * @return the cloned object
+   */
+  public Object clone()
+  {
+    ArrayList clone = null;
+    try
+      {
+        clone = (ArrayList) super.clone();
+        clone.data = (Object[]) data.clone();
+      }
+    catch (CloneNotSupportedException e)
+      {
+        // Impossible to get here.
+      }
+    return clone;
+  }
+
+  /**
+   * Returns an Object array containing all of the elements in this ArrayList.
+   * The array is independent of this list.
+   *
+   * @return an array representation of this list
+   */
+  public Object[] toArray()
+  {
+    Object[] array = new Object[size];
+    System.arraycopy(data, 0, array, 0, size);
+    return array;
+  }
+
+  /**
+   * Returns an Array whose component type is the runtime component type of
+   * the passed-in Array.  The returned Array is populated with all of the
+   * elements in this ArrayList.  If the passed-in Array is not large enough
+   * to store all of the elements in this List, a new Array will be created
+   * and returned; if the passed-in Array is <i>larger</i> than the size
+   * of this List, then size() index will be set to null.
+   *
+   * @param a the passed-in Array
+   * @return an array representation of this list
+   * @throws ArrayStoreException if the runtime type of a does not allow
+   *         an element in this list
+   * @throws NullPointerException if a is null
+   */
+  public Object[] toArray(Object[] a)
+  {
+    if (a.length < size)
+      a = (Object[]) Array.newInstance(a.getClass().getComponentType(),
+                                       size);
+    else if (a.length > size)
+      a[size] = null;
+    System.arraycopy(data, 0, a, 0, size);
+    return a;
+  }
+
+  /**
+   * Retrieves the element at the user-supplied index.
+   *
+   * @param index the index of the element we are fetching
+   * @throws IndexOutOfBoundsException if index < 0 || index >= size()
+   */
+  public Object get(int index)
+  {
+    checkBoundExclusive(index);
+    return data[index];
+  }
+
+  /**
+   * Sets the element at the specified index.  The new element, e,
+   * can be an object of any type or null.
+   *
+   * @param index the index at which the element is being set
+   * @param e the element to be set
+   * @return the element previously at the specified index
+   * @throws IndexOutOfBoundsException if index < 0 || index >= 0
+   */
+  public Object set(int index, Object e)
+  {
+    checkBoundExclusive(index);
+    Object result = data[index];
+    data[index] = e;
+    return result;
+  }
+
+  /**
+   * Appends the supplied element to the end of this list.
+   * The element, e, can be an object of any type or null.
+   *
+   * @param e the element to be appended to this list
+   * @return true, the add will always succeed
+   */
+  public boolean add(Object e)
+  {
+    modCount++;
+    if (size == data.length)
+      ensureCapacity(size + 1);
+    data[size++] = e;
+    return true;
+  }
+
+  /**
+   * Adds the supplied element at the specified index, shifting all
+   * elements currently at that index or higher one to the right.
+   * The element, e, can be an object of any type or null.
+   *
+   * @param index the index at which the element is being added
+   * @param e the item being added
+   * @throws IndexOutOfBoundsException if index < 0 || index > size()
+   */
+  public void add(int index, Object e)
+  {
+    checkBoundInclusive(index);
+    modCount++;
+    if (size == data.length)
+      ensureCapacity(size + 1);
+    if (index != size)
+      System.arraycopy(data, index, data, index + 1, size - index);
+    data[index] = e;
+    size++;
+  }
+
+  /**
+   * Removes the element at the user-supplied index.
+   *
+   * @param index the index of the element to be removed
+   * @return the removed Object
+   * @throws IndexOutOfBoundsException if index < 0 || index >= size()
+   */
+  public Object remove(int index)
+  {
+    checkBoundExclusive(index);
+    Object r = data[index];
+    modCount++;
+    if (index != --size)
+      System.arraycopy(data, index + 1, data, index, size - index);
+    // Aid for garbage collection by releasing this pointer.
+    data[size] = null;
+    return r;
+  }
+
+  /**
+   * Removes all elements from this List
+   */
+  public void clear()
+  {
+    if (size > 0)
+      {
+        modCount++;
+        // Allow for garbage collection.
+        Arrays.fill(data, 0, size, null);
+        size = 0;
+      }
+  }
+
+  /**
+   * Add each element in the supplied Collection to this List. It is undefined
+   * what happens if you modify the list while this is taking place; for
+   * example, if the collection contains this list.  c can contain objects
+   * of any type, as well as null values.
+   *
+   * @param c a Collection containing elements to be added to this List
+   * @return true if the list was modified, in other words c is not empty
+   * @throws NullPointerException if c is null
+   */
+  public boolean addAll(Collection c)
+  {
+    return addAll(size, c);
+  }
+
+  /**
+   * Add all elements in the supplied collection, inserting them beginning
+   * at the specified index.  c can contain objects of any type, as well
+   * as null values.
+   *
+   * @param index the index at which the elements will be inserted
+   * @param c the Collection containing the elements to be inserted
+   * @throws IndexOutOfBoundsException if index < 0 || index > 0
+   * @throws NullPointerException if c is null
+   */
+  public boolean addAll(int index, Collection c)
+  {
+    checkBoundInclusive(index);
+    Iterator itr = c.iterator();
+    int csize = c.size();
+
+    modCount++;
+    if (csize + size > data.length)
+      ensureCapacity(size + csize);
+    int end = index + csize;
+    if (size > 0 && index != size)
+      System.arraycopy(data, index, data, end, size - index);
+    size += csize;
+    for ( ; index < end; index++)
+      data[index] = itr.next();
+    return csize > 0;
+  }
+
+  /**
+   * Removes all elements in the half-open interval [fromIndex, toIndex).
+   * Does nothing when toIndex is equal to fromIndex.
+   *
+   * @param fromIndex the first index which will be removed
+   * @param toIndex one greater than the last index which will be removed
+   * @throws IndexOutOfBoundsException if fromIndex > toIndex
+   */
+  protected void removeRange(int fromIndex, int toIndex)
+  {
+    int change = toIndex - fromIndex;
+    if (change > 0)
+      {
+        modCount++;
+        System.arraycopy(data, toIndex, data, fromIndex, size - toIndex);
+        size -= change;
+      }
+    else if (change < 0)
+      throw new IndexOutOfBoundsException();
+  }
+
+  /**
+   * Checks that the index is in the range of possible elements (inclusive).
+   *
+   * @param index the index to check
+   * @throws IndexOutOfBoundsException if index > size
+   */
+  private void checkBoundInclusive(int index)
+  {
+    // Implementation note: we do not check for negative ranges here, since
+    // use of a negative index will cause an ArrayIndexOutOfBoundsException,
+    // a subclass of the required exception, with no effort on our part.
+    if (index > size)
+      throw new IndexOutOfBoundsException("Index: " + index + ", Size: "
+                                          + size);
+  }
+
+  /**
+   * Checks that the index is in the range of existing elements (exclusive).
+   *
+   * @param index the index to check
+   * @throws IndexOutOfBoundsException if index >= size
+   */
+  private void checkBoundExclusive(int index)
+  {
+    // Implementation note: we do not check for negative ranges here, since
+    // use of a negative index will cause an ArrayIndexOutOfBoundsException,
+    // a subclass of the required exception, with no effort on our part.
+    if (index >= size)
+      throw new IndexOutOfBoundsException("Index: " + index + ", Size: "
+                                          + size);
+  }
+
+  /**
+   * Remove from this list all elements contained in the given collection.
+   * This is not public, due to Sun's API, but this performs in linear
+   * time while the default behavior of AbstractList would be quadratic.
+   *
+   * @param c the collection to filter out
+   * @return true if this list changed
+   * @throws NullPointerException if c is null
+   */
+  boolean removeAllInternal(Collection c)
+  {
+    int i;
+    int j;
+    for (i = 0; i < size; i++)
+      if (c.contains(data[i]))
+        break;
+    if (i == size)
+      return false;
+
+    modCount++;
+    for (j = i++; i < size; i++)
+      if (! c.contains(data[i]))
+        data[j++] = data[i];
+    size -= i - j;
+    return true;
+  }
+
+  /**
+   * Retain in this vector only the elements contained in the given collection.
+   * This is not public, due to Sun's API, but this performs in linear
+   * time while the default behavior of AbstractList would be quadratic.
+   *
+   * @param c the collection to filter by
+   * @return true if this vector changed
+   * @throws NullPointerException if c is null
+   * @since 1.2
+   */
+  boolean retainAllInternal(Collection c)
+  {
+    int i;
+    int j;
+    for (i = 0; i < size; i++)
+      if (! c.contains(data[i]))
+        break;
+    if (i == size)
+      return false;
+
+    modCount++;
+    for (j = i++; i < size; i++)
+      if (c.contains(data[i]))
+        data[j++] = data[i];
+    size -= i - j;
+    return true;
+  }
+
+  /**
+   * Serializes this object to the given stream.
+   *
+   * @param s the stream to write to
+   * @throws IOException if the underlying stream fails
+   * @serialData the size field (int), the length of the backing array
+   *             (int), followed by its elements (Objects) in proper order.
+   */
+  private void writeObject(ObjectOutputStream s) throws IOException
+  {
+    // The 'size' field.
+    s.defaultWriteObject();
+    // We serialize unused list entries to preserve capacity.
+    int len = data.length;
+    s.writeInt(len);
+    // it would be more efficient to just write "size" items,
+    // this need readObject read "size" items too.
+    for (int i = 0; i < size; i++)
+      s.writeObject(data[i]);
+  }
+
+  /**
+   * Deserializes this object from the given stream.
+   *
+   * @param s the stream to read from
+   * @throws ClassNotFoundException if the underlying stream fails
+   * @throws IOException if the underlying stream fails
+   * @serialData the size field (int), the length of the backing array
+   *             (int), followed by its elements (Objects) in proper order.
+   */
+  private void readObject(ObjectInputStream s)
+    throws IOException, ClassNotFoundException
+  {
+    // the `size' field.
+    s.defaultReadObject();
+    int capacity = s.readInt();
+    data = new Object[capacity];
+    for (int i = 0; i < size; i++)
+      data[i] = s.readObject();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/Arrays.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/Arrays.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/Arrays.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/Arrays.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,3066 @@
+/* Arrays.java -- Utility class with methods to operate on arrays
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+   Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+import java.io.Serializable;
+import java.lang.reflect.Array;
+
+/**
+ * This class contains various static utility methods performing operations on
+ * arrays, and a method to provide a List "view" of an array to facilitate
+ * using arrays with Collection-based APIs. All methods throw a
+ * {@link NullPointerException} if the parameter array is null.
+ * <p>
+ *
+ * Implementations may use their own algorithms, but must obey the general
+ * properties; for example, the sort must be stable and n*log(n) complexity.
+ * Sun's implementation of sort, and therefore ours, is a tuned quicksort,
+ * adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort
+ * Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265
+ * (November 1993). This algorithm offers n*log(n) performance on many data
+ * sets that cause other quicksorts to degrade to quadratic performance.
+ *
+ * @author Original author unknown
+ * @author Bryce McKinlay
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Comparable
+ * @see Comparator
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public class Arrays
+{
+  /**
+   * This class is non-instantiable.
+   */
+  private Arrays()
+  {
+  }
+
+
+// binarySearch
+  /**
+   * Perform a binary search of a byte array for a key. The array must be
+   * sorted (as by the sort() method) - if it is not, the behaviour of this
+   * method is undefined, and may be an infinite loop. If the array contains
+   * the key more than once, any one of them may be found. Note: although the
+   * specification allows for an infinite loop if the array is unsorted, it
+   * will not happen in this implementation.
+   *
+   * @param a the array to search (must be sorted)
+   * @param key the value to search for
+   * @return the index at which the key was found, or -n-1 if it was not
+   *         found, where n is the index of the first value higher than key or
+   *         a.length if there is no such value.
+   */
+  public static int binarySearch(byte[] a, byte key)
+  {
+    int low = 0;
+    int hi = a.length - 1;
+    int mid = 0;
+    while (low <= hi)
+      {
+        mid = (low + hi) >>> 1;
+        final byte d = a[mid];
+        if (d == key)
+          return mid;
+        else if (d > key)
+          hi = mid - 1;
+        else
+          // This gets the insertion point right on the last loop.
+          low = ++mid;
+      }
+    return -mid - 1;
+  }
+
+  /**
+   * Perform a binary search of a char array for a key. The array must be
+   * sorted (as by the sort() method) - if it is not, the behaviour of this
+   * method is undefined, and may be an infinite loop. If the array contains
+   * the key more than once, any one of them may be found. Note: although the
+   * specification allows for an infinite loop if the array is unsorted, it
+   * will not happen in this implementation.
+   *
+   * @param a the array to search (must be sorted)
+   * @param key the value to search for
+   * @return the index at which the key was found, or -n-1 if it was not
+   *         found, where n is the index of the first value higher than key or
+   *         a.length if there is no such value.
+   */
+  public static int binarySearch(char[] a, char key)
+  {
+    int low = 0;
+    int hi = a.length - 1;
+    int mid = 0;
+    while (low <= hi)
+      {
+        mid = (low + hi) >>> 1;
+        final char d = a[mid];
+        if (d == key)
+          return mid;
+        else if (d > key)
+          hi = mid - 1;
+        else
+          // This gets the insertion point right on the last loop.
+          low = ++mid;
+      }
+    return -mid - 1;
+  }
+
+  /**
+   * Perform a binary search of a short array for a key. The array must be
+   * sorted (as by the sort() method) - if it is not, the behaviour of this
+   * method is undefined, and may be an infinite loop. If the array contains
+   * the key more than once, any one of them may be found. Note: although the
+   * specification allows for an infinite loop if the array is unsorted, it
+   * will not happen in this implementation.
+   *
+   * @param a the array to search (must be sorted)
+   * @param key the value to search for
+   * @return the index at which the key was found, or -n-1 if it was not
+   *         found, where n is the index of the first value higher than key or
+   *         a.length if there is no such value.
+   */
+  public static int binarySearch(short[] a, short key)
+  {
+    int low = 0;
+    int hi = a.length - 1;
+    int mid = 0;
+    while (low <= hi)
+      {
+        mid = (low + hi) >>> 1;
+        final short d = a[mid];
+        if (d == key)
+          return mid;
+        else if (d > key)
+          hi = mid - 1;
+        else
+          // This gets the insertion point right on the last loop.
+          low = ++mid;
+      }
+    return -mid - 1;
+  }
+
+  /**
+   * Perform a binary search of an int array for a key. The array must be
+   * sorted (as by the sort() method) - if it is not, the behaviour of this
+   * method is undefined, and may be an infinite loop. If the array contains
+   * the key more than once, any one of them may be found. Note: although the
+   * specification allows for an infinite loop if the array is unsorted, it
+   * will not happen in this implementation.
+   *
+   * @param a the array to search (must be sorted)
+   * @param key the value to search for
+   * @return the index at which the key was found, or -n-1 if it was not
+   *         found, where n is the index of the first value higher than key or
+   *         a.length if there is no such value.
+   */
+  public static int binarySearch(int[] a, int key)
+  {
+    int low = 0;
+    int hi = a.length - 1;
+    int mid = 0;
+    while (low <= hi)
+      {
+        mid = (low + hi) >>> 1;
+        final int d = a[mid];
+        if (d == key)
+          return mid;
+        else if (d > key)
+          hi = mid - 1;
+        else
+          // This gets the insertion point right on the last loop.
+          low = ++mid;
+      }
+    return -mid - 1;
+  }
+
+  /**
+   * Perform a binary search of a long array for a key. The array must be
+   * sorted (as by the sort() method) - if it is not, the behaviour of this
+   * method is undefined, and may be an infinite loop. If the array contains
+   * the key more than once, any one of them may be found. Note: although the
+   * specification allows for an infinite loop if the array is unsorted, it
+   * will not happen in this implementation.
+   *
+   * @param a the array to search (must be sorted)
+   * @param key the value to search for
+   * @return the index at which the key was found, or -n-1 if it was not
+   *         found, where n is the index of the first value higher than key or
+   *         a.length if there is no such value.
+   */
+  public static int binarySearch(long[] a, long key)
+  {
+    int low = 0;
+    int hi = a.length - 1;
+    int mid = 0;
+    while (low <= hi)
+      {
+        mid = (low + hi) >>> 1;
+        final long d = a[mid];
+        if (d == key)
+          return mid;
+        else if (d > key)
+          hi = mid - 1;
+        else
+          // This gets the insertion point right on the last loop.
+          low = ++mid;
+      }
+    return -mid - 1;
+  }
+
+  /**
+   * Perform a binary search of a float array for a key. The array must be
+   * sorted (as by the sort() method) - if it is not, the behaviour of this
+   * method is undefined, and may be an infinite loop. If the array contains
+   * the key more than once, any one of them may be found. Note: although the
+   * specification allows for an infinite loop if the array is unsorted, it
+   * will not happen in this implementation.
+   *
+   * @param a the array to search (must be sorted)
+   * @param key the value to search for
+   * @return the index at which the key was found, or -n-1 if it was not
+   *         found, where n is the index of the first value higher than key or
+   *         a.length if there is no such value.
+   */
+  public static int binarySearch(float[] a, float key)
+  {
+    // Must use Float.compare to take into account NaN, +-0.
+    int low = 0;
+    int hi = a.length - 1;
+    int mid = 0;
+    while (low <= hi)
+      {
+        mid = (low + hi) >>> 1;
+        final int r = Float.compare(a[mid], key);
+        if (r == 0)
+          return mid;
+        else if (r > 0)
+          hi = mid - 1;
+        else
+          // This gets the insertion point right on the last loop
+          low = ++mid;
+      }
+    return -mid - 1;
+  }
+
+  /**
+   * Perform a binary search of a double array for a key. The array must be
+   * sorted (as by the sort() method) - if it is not, the behaviour of this
+   * method is undefined, and may be an infinite loop. If the array contains
+   * the key more than once, any one of them may be found. Note: although the
+   * specification allows for an infinite loop if the array is unsorted, it
+   * will not happen in this implementation.
+   *
+   * @param a the array to search (must be sorted)
+   * @param key the value to search for
+   * @return the index at which the key was found, or -n-1 if it was not
+   *         found, where n is the index of the first value higher than key or
+   *         a.length if there is no such value.
+   */
+  public static int binarySearch(double[] a, double key)
+  {
+    // Must use Double.compare to take into account NaN, +-0.
+    int low = 0;
+    int hi = a.length - 1;
+    int mid = 0;
+    while (low <= hi)
+      {
+        mid = (low + hi) >>> 1;
+        final int r = Double.compare(a[mid], key);
+        if (r == 0)
+          return mid;
+        else if (r > 0)
+          hi = mid - 1;
+        else
+          // This gets the insertion point right on the last loop
+          low = ++mid;
+      }
+    return -mid - 1;
+  }
+
+  /**
+   * Perform a binary search of an Object array for a key, using the natural
+   * ordering of the elements. The array must be sorted (as by the sort()
+   * method) - if it is not, the behaviour of this method is undefined, and may
+   * be an infinite loop. Further, the key must be comparable with every item
+   * in the array. If the array contains the key more than once, any one of
+   * them may be found. Note: although the specification allows for an infinite
+   * loop if the array is unsorted, it will not happen in this (JCL)
+   * implementation.
+   *
+   * @param a the array to search (must be sorted)
+   * @param key the value to search for
+   * @return the index at which the key was found, or -n-1 if it was not
+   *         found, where n is the index of the first value higher than key or
+   *         a.length if there is no such value.
+   * @throws ClassCastException if key could not be compared with one of the
+   *         elements of a
+   * @throws NullPointerException if a null element in a is compared
+   */
+  public static int binarySearch(Object[] a, Object key)
+  {
+    return binarySearch(a, key, null);
+  }
+
+  /**
+   * Perform a binary search of an Object array for a key, using a supplied
+   * Comparator. The array must be sorted (as by the sort() method with the
+   * same Comparator) - if it is not, the behaviour of this method is
+   * undefined, and may be an infinite loop. Further, the key must be
+   * comparable with every item in the array. If the array contains the key
+   * more than once, any one of them may be found. Note: although the
+   * specification allows for an infinite loop if the array is unsorted, it
+   * will not happen in this (JCL) implementation.
+   *
+   * @param a the array to search (must be sorted)
+   * @param key the value to search for
+   * @param c the comparator by which the array is sorted; or null to
+   *        use the elements' natural order
+   * @return the index at which the key was found, or -n-1 if it was not
+   *         found, where n is the index of the first value higher than key or
+   *         a.length if there is no such value.
+   * @throws ClassCastException if key could not be compared with one of the
+   *         elements of a
+   * @throws NullPointerException if a null element is compared with natural
+   *         ordering (only possible when c is null)
+   */
+  public static int binarySearch(Object[] a, Object key, Comparator c)
+  {
+    int low = 0;
+    int hi = a.length - 1;
+    int mid = 0;
+    while (low <= hi)
+      {
+        mid = (low + hi) >>> 1;
+	// NOTE: Please keep the order of a[mid] and key.  Although
+	// not required by the specs, the RI has it in this order as
+	// well, and real programs (erroneously) depend on it.
+        final int d = Collections.compare(a[mid], key, c);
+        if (d == 0)
+          return mid;
+        else if (d > 0)
+          hi = mid - 1;
+        else
+          // This gets the insertion point right on the last loop
+          low = ++mid;
+      }
+    return -mid - 1;
+  }
+
+
+// equals
+  /**
+   * Compare two boolean arrays for equality.
+   *
+   * @param a1 the first array to compare
+   * @param a2 the second array to compare
+   * @return true if a1 and a2 are both null, or if a2 is of the same length
+   *         as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]
+   */
+  public static boolean equals(boolean[] a1, boolean[] a2)
+  {
+    // Quick test which saves comparing elements of the same array, and also
+    // catches the case that both are null.
+    if (a1 == a2)
+      return true;
+
+    if (null == a1 || null == a2)
+      return false;
+    
+    // If they're the same length, test each element
+    if (a1.length == a2.length)
+      {
+	int i = a1.length;
+	while (--i >= 0)
+	  if (a1[i] != a2[i])
+	    return false;
+	return true;
+      }
+    return false;
+  }
+
+  /**
+   * Compare two byte arrays for equality.
+   *
+   * @param a1 the first array to compare
+   * @param a2 the second array to compare
+   * @return true if a1 and a2 are both null, or if a2 is of the same length
+   *         as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]
+   */
+  public static boolean equals(byte[] a1, byte[] a2)
+  {
+    // Quick test which saves comparing elements of the same array, and also
+    // catches the case that both are null.
+    if (a1 == a2)
+      return true;
+
+    if (null == a1 || null == a2)
+      return false;
+
+    // If they're the same length, test each element
+    if (a1.length == a2.length)
+      {
+	int i = a1.length;
+	while (--i >= 0)
+	  if (a1[i] != a2[i])
+	    return false;
+	return true;
+      }
+    return false;
+  }
+
+  /**
+   * Compare two char arrays for equality.
+   *
+   * @param a1 the first array to compare
+   * @param a2 the second array to compare
+   * @return true if a1 and a2 are both null, or if a2 is of the same length
+   *         as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]
+   */
+  public static boolean equals(char[] a1, char[] a2)
+  {
+    // Quick test which saves comparing elements of the same array, and also
+    // catches the case that both are null.
+    if (a1 == a2)
+      return true;
+
+    if (null == a1 || null == a2)
+      return false;
+    
+    // If they're the same length, test each element
+    if (a1.length == a2.length)
+      {
+	int i = a1.length;
+	while (--i >= 0)
+	  if (a1[i] != a2[i])
+	    return false;
+	return true;
+      }
+    return false;
+  }
+
+  /**
+   * Compare two short arrays for equality.
+   *
+   * @param a1 the first array to compare
+   * @param a2 the second array to compare
+   * @return true if a1 and a2 are both null, or if a2 is of the same length
+   *         as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]
+   */
+  public static boolean equals(short[] a1, short[] a2)
+  {
+    // Quick test which saves comparing elements of the same array, and also
+    // catches the case that both are null.
+    if (a1 == a2)
+      return true;
+
+    if (null == a1 || null == a2)
+      return false;
+
+    // If they're the same length, test each element
+    if (a1.length == a2.length)
+      {
+	int i = a1.length;
+	while (--i >= 0)
+	  if (a1[i] != a2[i])
+	    return false;
+	return true;
+      }
+    return false;
+  }
+
+  /**
+   * Compare two int arrays for equality.
+   *
+   * @param a1 the first array to compare
+   * @param a2 the second array to compare
+   * @return true if a1 and a2 are both null, or if a2 is of the same length
+   *         as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]
+   */
+  public static boolean equals(int[] a1, int[] a2)
+  {
+    // Quick test which saves comparing elements of the same array, and also
+    // catches the case that both are null.
+    if (a1 == a2)
+      return true;
+
+    if (null == a1 || null == a2)
+      return false;
+
+    // If they're the same length, test each element
+    if (a1.length == a2.length)
+      {
+	int i = a1.length;
+	while (--i >= 0)
+	  if (a1[i] != a2[i])
+	    return false;
+	return true;
+      }
+    return false;
+  }
+
+  /**
+   * Compare two long arrays for equality.
+   *
+   * @param a1 the first array to compare
+   * @param a2 the second array to compare
+   * @return true if a1 and a2 are both null, or if a2 is of the same length
+   *         as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]
+   */
+  public static boolean equals(long[] a1, long[] a2)
+  {
+    // Quick test which saves comparing elements of the same array, and also
+    // catches the case that both are null.
+    if (a1 == a2)
+      return true;
+
+    if (null == a1 || null == a2)
+      return false;
+
+    // If they're the same length, test each element
+    if (a1.length == a2.length)
+      {
+	int i = a1.length;
+	while (--i >= 0)
+	  if (a1[i] != a2[i])
+	    return false;
+	return true;
+      }
+    return false;
+  }
+
+  /**
+   * Compare two float arrays for equality.
+   *
+   * @param a1 the first array to compare
+   * @param a2 the second array to compare
+   * @return true if a1 and a2 are both null, or if a2 is of the same length
+   *         as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]
+   */
+  public static boolean equals(float[] a1, float[] a2)
+  {
+    // Quick test which saves comparing elements of the same array, and also
+    // catches the case that both are null.
+    if (a1 == a2)
+      return true;
+
+    if (null == a1 || null == a2)
+      return false;
+
+    // Must use Float.compare to take into account NaN, +-0.
+    // If they're the same length, test each element
+    if (a1.length == a2.length)
+      {
+	int i = a1.length;
+	while (--i >= 0)
+	  if (Float.compare(a1[i], a2[i]) != 0)
+	    return false;
+	return true;
+      }
+    return false;
+  }
+
+  /**
+   * Compare two double arrays for equality.
+   *
+   * @param a1 the first array to compare
+   * @param a2 the second array to compare
+   * @return true if a1 and a2 are both null, or if a2 is of the same length
+   *         as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]
+   */
+  public static boolean equals(double[] a1, double[] a2)
+  {
+    // Quick test which saves comparing elements of the same array, and also
+    // catches the case that both are null.
+    if (a1 == a2)
+      return true;
+
+    if (null == a1 || null == a2)
+      return false;
+    
+    // Must use Double.compare to take into account NaN, +-0.
+    // If they're the same length, test each element
+    if (a1.length == a2.length)
+      {
+	int i = a1.length;
+	while (--i >= 0)
+	  if (Double.compare(a1[i], a2[i]) != 0)
+	    return false;
+	return true;
+      }
+    return false;
+  }
+
+  /**
+   * Compare two Object arrays for equality.
+   *
+   * @param a1 the first array to compare
+   * @param a2 the second array to compare
+   * @return true if a1 and a2 are both null, or if a1 is of the same length
+   *         as a2, and for each 0 <= i < a.length, a1[i] == null ?
+   *         a2[i] == null : a1[i].equals(a2[i]).
+   */
+  public static boolean equals(Object[] a1, Object[] a2)
+  {
+    // Quick test which saves comparing elements of the same array, and also
+    // catches the case that both are null.
+    if (a1 == a2)
+      return true;
+
+    if (null == a1 || null == a2)
+      return false;
+    
+    // If they're the same length, test each element
+    if (a1.length == a2.length)
+      {
+	int i = a1.length;
+	while (--i >= 0)
+	  if (! AbstractCollection.equals(a1[i], a2[i]))
+	    return false;
+	return true;
+      }
+    return false;
+  }
+
+
+// fill
+  /**
+   * Fill an array with a boolean value.
+   *
+   * @param a the array to fill
+   * @param val the value to fill it with
+   */
+  public static void fill(boolean[] a, boolean val)
+  {
+    fill(a, 0, a.length, val);
+  }
+
+  /**
+   * Fill a range of an array with a boolean value.
+   *
+   * @param a the array to fill
+   * @param fromIndex the index to fill from, inclusive
+   * @param toIndex the index to fill to, exclusive
+   * @param val the value to fill with
+   * @throws IllegalArgumentException if fromIndex > toIndex
+   * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
+   *         || toIndex > a.length
+   */
+  public static void fill(boolean[] a, int fromIndex, int toIndex, boolean val)
+  {
+    if (fromIndex > toIndex)
+      throw new IllegalArgumentException();
+    for (int i = fromIndex; i < toIndex; i++)
+      a[i] = val;
+  }
+
+  /**
+   * Fill an array with a byte value.
+   *
+   * @param a the array to fill
+   * @param val the value to fill it with
+   */
+  public static void fill(byte[] a, byte val)
+  {
+    fill(a, 0, a.length, val);
+  }
+
+  /**
+   * Fill a range of an array with a byte value.
+   *
+   * @param a the array to fill
+   * @param fromIndex the index to fill from, inclusive
+   * @param toIndex the index to fill to, exclusive
+   * @param val the value to fill with
+   * @throws IllegalArgumentException if fromIndex > toIndex
+   * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
+   *         || toIndex > a.length
+   */
+  public static void fill(byte[] a, int fromIndex, int toIndex, byte val)
+  {
+    if (fromIndex > toIndex)
+      throw new IllegalArgumentException();
+    for (int i = fromIndex; i < toIndex; i++)
+      a[i] = val;
+  }
+
+  /**
+   * Fill an array with a char value.
+   *
+   * @param a the array to fill
+   * @param val the value to fill it with
+   */
+  public static void fill(char[] a, char val)
+  {
+    fill(a, 0, a.length, val);
+  }
+
+  /**
+   * Fill a range of an array with a char value.
+   *
+   * @param a the array to fill
+   * @param fromIndex the index to fill from, inclusive
+   * @param toIndex the index to fill to, exclusive
+   * @param val the value to fill with
+   * @throws IllegalArgumentException if fromIndex > toIndex
+   * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
+   *         || toIndex > a.length
+   */
+  public static void fill(char[] a, int fromIndex, int toIndex, char val)
+  {
+    if (fromIndex > toIndex)
+      throw new IllegalArgumentException();
+    for (int i = fromIndex; i < toIndex; i++)
+      a[i] = val;
+  }
+
+  /**
+   * Fill an array with a short value.
+   *
+   * @param a the array to fill
+   * @param val the value to fill it with
+   */
+  public static void fill(short[] a, short val)
+  {
+    fill(a, 0, a.length, val);
+  }
+
+  /**
+   * Fill a range of an array with a short value.
+   *
+   * @param a the array to fill
+   * @param fromIndex the index to fill from, inclusive
+   * @param toIndex the index to fill to, exclusive
+   * @param val the value to fill with
+   * @throws IllegalArgumentException if fromIndex > toIndex
+   * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
+   *         || toIndex > a.length
+   */
+  public static void fill(short[] a, int fromIndex, int toIndex, short val)
+  {
+    if (fromIndex > toIndex)
+      throw new IllegalArgumentException();
+    for (int i = fromIndex; i < toIndex; i++)
+      a[i] = val;
+  }
+
+  /**
+   * Fill an array with an int value.
+   *
+   * @param a the array to fill
+   * @param val the value to fill it with
+   */
+  public static void fill(int[] a, int val)
+  {
+    fill(a, 0, a.length, val);
+  }
+
+  /**
+   * Fill a range of an array with an int value.
+   *
+   * @param a the array to fill
+   * @param fromIndex the index to fill from, inclusive
+   * @param toIndex the index to fill to, exclusive
+   * @param val the value to fill with
+   * @throws IllegalArgumentException if fromIndex > toIndex
+   * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
+   *         || toIndex > a.length
+   */
+  public static void fill(int[] a, int fromIndex, int toIndex, int val)
+  {
+    if (fromIndex > toIndex)
+      throw new IllegalArgumentException();
+    for (int i = fromIndex; i < toIndex; i++)
+      a[i] = val;
+  }
+
+  /**
+   * Fill an array with a long value.
+   *
+   * @param a the array to fill
+   * @param val the value to fill it with
+   */
+  public static void fill(long[] a, long val)
+  {
+    fill(a, 0, a.length, val);
+  }
+
+  /**
+   * Fill a range of an array with a long value.
+   *
+   * @param a the array to fill
+   * @param fromIndex the index to fill from, inclusive
+   * @param toIndex the index to fill to, exclusive
+   * @param val the value to fill with
+   * @throws IllegalArgumentException if fromIndex > toIndex
+   * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
+   *         || toIndex > a.length
+   */
+  public static void fill(long[] a, int fromIndex, int toIndex, long val)
+  {
+    if (fromIndex > toIndex)
+      throw new IllegalArgumentException();
+    for (int i = fromIndex; i < toIndex; i++)
+      a[i] = val;
+  }
+
+  /**
+   * Fill an array with a float value.
+   *
+   * @param a the array to fill
+   * @param val the value to fill it with
+   */
+  public static void fill(float[] a, float val)
+  {
+    fill(a, 0, a.length, val);
+  }
+
+  /**
+   * Fill a range of an array with a float value.
+   *
+   * @param a the array to fill
+   * @param fromIndex the index to fill from, inclusive
+   * @param toIndex the index to fill to, exclusive
+   * @param val the value to fill with
+   * @throws IllegalArgumentException if fromIndex > toIndex
+   * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
+   *         || toIndex > a.length
+   */
+  public static void fill(float[] a, int fromIndex, int toIndex, float val)
+  {
+    if (fromIndex > toIndex)
+      throw new IllegalArgumentException();
+    for (int i = fromIndex; i < toIndex; i++)
+      a[i] = val;
+  }
+
+  /**
+   * Fill an array with a double value.
+   *
+   * @param a the array to fill
+   * @param val the value to fill it with
+   */
+  public static void fill(double[] a, double val)
+  {
+    fill(a, 0, a.length, val);
+  }
+
+  /**
+   * Fill a range of an array with a double value.
+   *
+   * @param a the array to fill
+   * @param fromIndex the index to fill from, inclusive
+   * @param toIndex the index to fill to, exclusive
+   * @param val the value to fill with
+   * @throws IllegalArgumentException if fromIndex > toIndex
+   * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
+   *         || toIndex > a.length
+   */
+  public static void fill(double[] a, int fromIndex, int toIndex, double val)
+  {
+    if (fromIndex > toIndex)
+      throw new IllegalArgumentException();
+    for (int i = fromIndex; i < toIndex; i++)
+      a[i] = val;
+  }
+
+  /**
+   * Fill an array with an Object value.
+   *
+   * @param a the array to fill
+   * @param val the value to fill it with
+   * @throws ClassCastException if val is not an instance of the element
+   *         type of a.
+   */
+  public static void fill(Object[] a, Object val)
+  {
+    fill(a, 0, a.length, val);
+  }
+
+  /**
+   * Fill a range of an array with an Object value.
+   *
+   * @param a the array to fill
+   * @param fromIndex the index to fill from, inclusive
+   * @param toIndex the index to fill to, exclusive
+   * @param val the value to fill with
+   * @throws ClassCastException if val is not an instance of the element
+   *         type of a.
+   * @throws IllegalArgumentException if fromIndex > toIndex
+   * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
+   *         || toIndex > a.length
+   */
+  public static void fill(Object[] a, int fromIndex, int toIndex, Object val)
+  {
+    if (fromIndex > toIndex)
+      throw new IllegalArgumentException();
+    for (int i = fromIndex; i < toIndex; i++)
+      a[i] = val;
+  }
+
+
+// sort
+  // Thanks to Paul Fisher (rao at gnu.org) for finding this quicksort algorithm
+  // as specified by Sun and porting it to Java. The algorithm is an optimised
+  // quicksort, as described in Jon L. Bentley and M. Douglas McIlroy's
+  // "Engineering a Sort Function", Software-Practice and Experience, Vol.
+  // 23(11) P. 1249-1265 (November 1993). This algorithm gives n*log(n)
+  // performance on many arrays that would take quadratic time with a standard
+  // quicksort.
+
+  /**
+   * Performs a stable sort on the elements, arranging them according to their
+   * natural order.
+   *
+   * @param a the byte array to sort
+   */
+  public static void sort(byte[] a)
+  {
+    qsort(a, 0, a.length);
+  }
+
+  /**
+   * Performs a stable sort on the elements, arranging them according to their
+   * natural order.
+   *
+   * @param a the byte array to sort
+   * @param fromIndex the first index to sort (inclusive)
+   * @param toIndex the last index to sort (exclusive)
+   * @throws IllegalArgumentException if fromIndex > toIndex
+   * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
+   *         || toIndex > a.length
+   */
+  public static void sort(byte[] a, int fromIndex, int toIndex)
+  {
+    if (fromIndex > toIndex)
+      throw new IllegalArgumentException();
+    if (fromIndex < 0)
+      throw new ArrayIndexOutOfBoundsException();
+    qsort(a, fromIndex, toIndex - fromIndex);
+  }
+
+  /**
+   * Finds the index of the median of three array elements.
+   *
+   * @param a the first index
+   * @param b the second index
+   * @param c the third index
+   * @param d the array
+   * @return the index (a, b, or c) which has the middle value of the three
+   */
+  private static int med3(int a, int b, int c, byte[] d)
+  {
+    return (d[a] < d[b]
+            ? (d[b] < d[c] ? b : d[a] < d[c] ? c : a)
+            : (d[b] > d[c] ? b : d[a] > d[c] ? c : a));
+  }
+
+  /**
+   * Swaps the elements at two locations of an array
+   *
+   * @param i the first index
+   * @param j the second index
+   * @param a the array
+   */
+  private static void swap(int i, int j, byte[] a)
+  {
+    byte c = a[i];
+    a[i] = a[j];
+    a[j] = c;
+  }
+
+  /**
+   * Swaps two ranges of an array.
+   *
+   * @param i the first range start
+   * @param j the second range start
+   * @param n the element count
+   * @param a the array
+   */
+  private static void vecswap(int i, int j, int n, byte[] a)
+  {
+    for ( ; n > 0; i++, j++, n--)
+      swap(i, j, a);
+  }
+
+  /**
+   * Performs a recursive modified quicksort.
+   *
+   * @param array the array to sort
+   * @param from the start index (inclusive)
+   * @param count the number of elements to sort
+   */
+  private static void qsort(byte[] array, int from, int count)
+  {
+    // Use an insertion sort on small arrays.
+    if (count <= 7)
+      {
+        for (int i = from + 1; i < from + count; i++)
+          for (int j = i; j > from && array[j - 1] > array[j]; j--)
+            swap(j, j - 1, array);
+        return;
+      }
+
+    // Determine a good median element.
+    int mid = count / 2;
+    int lo = from;
+    int hi = from + count - 1;
+
+    if (count > 40)
+      { // big arrays, pseudomedian of 9
+        int s = count / 8;
+        lo = med3(lo, lo + s, lo + 2 * s, array);
+        mid = med3(mid - s, mid, mid + s, array);
+        hi = med3(hi - 2 * s, hi - s, hi, array);
+      }
+    mid = med3(lo, mid, hi, array);
+
+    int a, b, c, d;
+    int comp;
+
+    // Pull the median element out of the fray, and use it as a pivot.
+    swap(from, mid, array);
+    a = b = from;
+    c = d = from + count - 1;
+
+    // Repeatedly move b and c to each other, swapping elements so
+    // that all elements before index b are less than the pivot, and all
+    // elements after index c are greater than the pivot. a and b track
+    // the elements equal to the pivot.
+    while (true)
+      {
+        while (b <= c && (comp = array[b] - array[from]) <= 0)
+          {
+            if (comp == 0)
+              {
+                swap(a, b, array);
+                a++;
+              }
+            b++;
+          }
+        while (c >= b && (comp = array[c] - array[from]) >= 0)
+          {
+            if (comp == 0)
+              {
+                swap(c, d, array);
+                d--;
+              }
+            c--;
+          }
+        if (b > c)
+          break;
+        swap(b, c, array);
+        b++;
+        c--;
+      }
+
+    // Swap pivot(s) back in place, the recurse on left and right sections.
+    hi = from + count;
+    int span;
+    span = Math.min(a - from, b - a);
+    vecswap(from, b - span, span, array);
+
+    span = Math.min(d - c, hi - d - 1);
+    vecswap(b, hi - span, span, array);
+
+    span = b - a;
+    if (span > 1)
+      qsort(array, from, span);
+
+    span = d - c;
+    if (span > 1)
+      qsort(array, hi - span, span);
+  }
+
+  /**
+   * Performs a stable sort on the elements, arranging them according to their
+   * natural order.
+   *
+   * @param a the char array to sort
+   */
+  public static void sort(char[] a)
+  {
+    qsort(a, 0, a.length);
+  }
+
+  /**
+   * Performs a stable sort on the elements, arranging them according to their
+   * natural order.
+   *
+   * @param a the char array to sort
+   * @param fromIndex the first index to sort (inclusive)
+   * @param toIndex the last index to sort (exclusive)
+   * @throws IllegalArgumentException if fromIndex > toIndex
+   * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
+   *         || toIndex > a.length
+   */
+  public static void sort(char[] a, int fromIndex, int toIndex)
+  {
+    if (fromIndex > toIndex)
+      throw new IllegalArgumentException();
+    if (fromIndex < 0)
+      throw new ArrayIndexOutOfBoundsException();
+    qsort(a, fromIndex, toIndex - fromIndex);
+  }
+
+  /**
+   * Finds the index of the median of three array elements.
+   *
+   * @param a the first index
+   * @param b the second index
+   * @param c the third index
+   * @param d the array
+   * @return the index (a, b, or c) which has the middle value of the three
+   */
+  private static int med3(int a, int b, int c, char[] d)
+  {
+    return (d[a] < d[b]
+            ? (d[b] < d[c] ? b : d[a] < d[c] ? c : a)
+            : (d[b] > d[c] ? b : d[a] > d[c] ? c : a));
+  }
+
+  /**
+   * Swaps the elements at two locations of an array
+   *
+   * @param i the first index
+   * @param j the second index
+   * @param a the array
+   */
+  private static void swap(int i, int j, char[] a)
+  {
+    char c = a[i];
+    a[i] = a[j];
+    a[j] = c;
+  }
+
+  /**
+   * Swaps two ranges of an array.
+   *
+   * @param i the first range start
+   * @param j the second range start
+   * @param n the element count
+   * @param a the array
+   */
+  private static void vecswap(int i, int j, int n, char[] a)
+  {
+    for ( ; n > 0; i++, j++, n--)
+      swap(i, j, a);
+  }
+
+  /**
+   * Performs a recursive modified quicksort.
+   *
+   * @param array the array to sort
+   * @param from the start index (inclusive)
+   * @param count the number of elements to sort
+   */
+  private static void qsort(char[] array, int from, int count)
+  {
+    // Use an insertion sort on small arrays.
+    if (count <= 7)
+      {
+        for (int i = from + 1; i < from + count; i++)
+          for (int j = i; j > from && array[j - 1] > array[j]; j--)
+            swap(j, j - 1, array);
+        return;
+      }
+
+    // Determine a good median element.
+    int mid = count / 2;
+    int lo = from;
+    int hi = from + count - 1;
+
+    if (count > 40)
+      { // big arrays, pseudomedian of 9
+        int s = count / 8;
+        lo = med3(lo, lo + s, lo + 2 * s, array);
+        mid = med3(mid - s, mid, mid + s, array);
+        hi = med3(hi - 2 * s, hi - s, hi, array);
+      }
+    mid = med3(lo, mid, hi, array);
+
+    int a, b, c, d;
+    int comp;
+
+    // Pull the median element out of the fray, and use it as a pivot.
+    swap(from, mid, array);
+    a = b = from;
+    c = d = from + count - 1;
+
+    // Repeatedly move b and c to each other, swapping elements so
+    // that all elements before index b are less than the pivot, and all
+    // elements after index c are greater than the pivot. a and b track
+    // the elements equal to the pivot.
+    while (true)
+      {
+        while (b <= c && (comp = array[b] - array[from]) <= 0)
+          {
+            if (comp == 0)
+              {
+                swap(a, b, array);
+                a++;
+              }
+            b++;
+          }
+        while (c >= b && (comp = array[c] - array[from]) >= 0)
+          {
+            if (comp == 0)
+              {
+                swap(c, d, array);
+                d--;
+              }
+            c--;
+          }
+        if (b > c)
+          break;
+        swap(b, c, array);
+        b++;
+        c--;
+      }
+
+    // Swap pivot(s) back in place, the recurse on left and right sections.
+    hi = from + count;
+    int span;
+    span = Math.min(a - from, b - a);
+    vecswap(from, b - span, span, array);
+
+    span = Math.min(d - c, hi - d - 1);
+    vecswap(b, hi - span, span, array);
+
+    span = b - a;
+    if (span > 1)
+      qsort(array, from, span);
+
+    span = d - c;
+    if (span > 1)
+      qsort(array, hi - span, span);
+  }
+
+  /**
+   * Performs a stable sort on the elements, arranging them according to their
+   * natural order.
+   *
+   * @param a the short array to sort
+   */
+  public static void sort(short[] a)
+  {
+    qsort(a, 0, a.length);
+  }
+
+  /**
+   * Performs a stable sort on the elements, arranging them according to their
+   * natural order.
+   *
+   * @param a the short array to sort
+   * @param fromIndex the first index to sort (inclusive)
+   * @param toIndex the last index to sort (exclusive)
+   * @throws IllegalArgumentException if fromIndex > toIndex
+   * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
+   *         || toIndex > a.length
+   */
+  public static void sort(short[] a, int fromIndex, int toIndex)
+  {
+    if (fromIndex > toIndex)
+      throw new IllegalArgumentException();
+    if (fromIndex < 0)
+      throw new ArrayIndexOutOfBoundsException();
+    qsort(a, fromIndex, toIndex - fromIndex);
+  }
+
+  /**
+   * Finds the index of the median of three array elements.
+   *
+   * @param a the first index
+   * @param b the second index
+   * @param c the third index
+   * @param d the array
+   * @return the index (a, b, or c) which has the middle value of the three
+   */
+  private static int med3(int a, int b, int c, short[] d)
+  {
+    return (d[a] < d[b]
+            ? (d[b] < d[c] ? b : d[a] < d[c] ? c : a)
+            : (d[b] > d[c] ? b : d[a] > d[c] ? c : a));
+  }
+
+  /**
+   * Swaps the elements at two locations of an array
+   *
+   * @param i the first index
+   * @param j the second index
+   * @param a the array
+   */
+  private static void swap(int i, int j, short[] a)
+  {
+    short c = a[i];
+    a[i] = a[j];
+    a[j] = c;
+  }
+
+  /**
+   * Swaps two ranges of an array.
+   *
+   * @param i the first range start
+   * @param j the second range start
+   * @param n the element count
+   * @param a the array
+   */
+  private static void vecswap(int i, int j, int n, short[] a)
+  {
+    for ( ; n > 0; i++, j++, n--)
+      swap(i, j, a);
+  }
+
+  /**
+   * Performs a recursive modified quicksort.
+   *
+   * @param array the array to sort
+   * @param from the start index (inclusive)
+   * @param count the number of elements to sort
+   */
+  private static void qsort(short[] array, int from, int count)
+  {
+    // Use an insertion sort on small arrays.
+    if (count <= 7)
+      {
+        for (int i = from + 1; i < from + count; i++)
+	  for (int j = i; j > from && array[j - 1] > array[j]; j--)
+	    swap(j, j - 1, array);
+        return;
+      }
+
+    // Determine a good median element.
+    int mid = count / 2;
+    int lo = from;
+    int hi = from + count - 1;
+
+    if (count > 40)
+      { // big arrays, pseudomedian of 9
+        int s = count / 8;
+        lo = med3(lo, lo + s, lo + 2 * s, array);
+        mid = med3(mid - s, mid, mid + s, array);
+        hi = med3(hi - 2 * s, hi - s, hi, array);
+      }
+    mid = med3(lo, mid, hi, array);
+
+    int a, b, c, d;
+    int comp;
+
+    // Pull the median element out of the fray, and use it as a pivot.
+    swap(from, mid, array);
+    a = b = from;
+    c = d = from + count - 1;
+
+    // Repeatedly move b and c to each other, swapping elements so
+    // that all elements before index b are less than the pivot, and all
+    // elements after index c are greater than the pivot. a and b track
+    // the elements equal to the pivot.
+    while (true)
+      {
+        while (b <= c && (comp = array[b] - array[from]) <= 0)
+          {
+            if (comp == 0)
+              {
+                swap(a, b, array);
+                a++;
+              }
+            b++;
+          }
+        while (c >= b && (comp = array[c] - array[from]) >= 0)
+          {
+            if (comp == 0)
+              {
+                swap(c, d, array);
+                d--;
+              }
+            c--;
+          }
+        if (b > c)
+          break;
+        swap(b, c, array);
+        b++;
+        c--;
+      }
+
+    // Swap pivot(s) back in place, the recurse on left and right sections.
+    hi = from + count;
+    int span;
+    span = Math.min(a - from, b - a);
+    vecswap(from, b - span, span, array);
+
+    span = Math.min(d - c, hi - d - 1);
+    vecswap(b, hi - span, span, array);
+
+    span = b - a;
+    if (span > 1)
+      qsort(array, from, span);
+
+    span = d - c;
+    if (span > 1)
+      qsort(array, hi - span, span);
+  }
+
+  /**
+   * Performs a stable sort on the elements, arranging them according to their
+   * natural order.
+   *
+   * @param a the int array to sort
+   */
+  public static void sort(int[] a)
+  {
+    qsort(a, 0, a.length);
+  }
+
+  /**
+   * Performs a stable sort on the elements, arranging them according to their
+   * natural order.
+   *
+   * @param a the int array to sort
+   * @param fromIndex the first index to sort (inclusive)
+   * @param toIndex the last index to sort (exclusive)
+   * @throws IllegalArgumentException if fromIndex > toIndex
+   * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
+   *         || toIndex > a.length
+   */
+  public static void sort(int[] a, int fromIndex, int toIndex)
+  {
+    if (fromIndex > toIndex)
+      throw new IllegalArgumentException();
+    if (fromIndex < 0)
+      throw new ArrayIndexOutOfBoundsException();
+    qsort(a, fromIndex, toIndex - fromIndex);
+  }
+
+  /**
+   * Finds the index of the median of three array elements.
+   *
+   * @param a the first index
+   * @param b the second index
+   * @param c the third index
+   * @param d the array
+   * @return the index (a, b, or c) which has the middle value of the three
+   */
+  private static int med3(int a, int b, int c, int[] d)
+  {
+    return (d[a] < d[b]
+            ? (d[b] < d[c] ? b : d[a] < d[c] ? c : a)
+            : (d[b] > d[c] ? b : d[a] > d[c] ? c : a));
+  }
+
+  /**
+   * Swaps the elements at two locations of an array
+   *
+   * @param i the first index
+   * @param j the second index
+   * @param a the array
+   */
+  private static void swap(int i, int j, int[] a)
+  {
+    int c = a[i];
+    a[i] = a[j];
+    a[j] = c;
+  }
+
+  /**
+   * Swaps two ranges of an array.
+   *
+   * @param i the first range start
+   * @param j the second range start
+   * @param n the element count
+   * @param a the array
+   */
+  private static void vecswap(int i, int j, int n, int[] a)
+  {
+    for ( ; n > 0; i++, j++, n--)
+      swap(i, j, a);
+  }
+
+  /**
+   * Compares two integers in natural order, since a - b is inadequate.
+   *
+   * @param a the first int
+   * @param b the second int
+   * @return < 0, 0, or > 0 accorting to the comparison
+   */
+  private static int compare(int a, int b)
+  {
+    return a < b ? -1 : a == b ? 0 : 1;
+  }
+
+  /**
+   * Performs a recursive modified quicksort.
+   *
+   * @param array the array to sort
+   * @param from the start index (inclusive)
+   * @param count the number of elements to sort
+   */
+  private static void qsort(int[] array, int from, int count)
+  {
+    // Use an insertion sort on small arrays.
+    if (count <= 7)
+      {
+        for (int i = from + 1; i < from + count; i++)
+          for (int j = i; j > from && array[j - 1] > array[j]; j--)
+            swap(j, j - 1, array);
+        return;
+      }
+
+    // Determine a good median element.
+    int mid = count / 2;
+    int lo = from;
+    int hi = from + count - 1;
+
+    if (count > 40)
+      { // big arrays, pseudomedian of 9
+        int s = count / 8;
+        lo = med3(lo, lo + s, lo + 2 * s, array);
+        mid = med3(mid - s, mid, mid + s, array);
+        hi = med3(hi - 2 * s, hi - s, hi, array);
+      }
+    mid = med3(lo, mid, hi, array);
+
+    int a, b, c, d;
+    int comp;
+
+    // Pull the median element out of the fray, and use it as a pivot.
+    swap(from, mid, array);
+    a = b = from;
+    c = d = from + count - 1;
+
+    // Repeatedly move b and c to each other, swapping elements so
+    // that all elements before index b are less than the pivot, and all
+    // elements after index c are greater than the pivot. a and b track
+    // the elements equal to the pivot.
+    while (true)
+      {
+        while (b <= c && (comp = compare(array[b], array[from])) <= 0)
+          {
+            if (comp == 0)
+              {
+                swap(a, b, array);
+                a++;
+              }
+            b++;
+          }
+        while (c >= b && (comp = compare(array[c], array[from])) >= 0)
+          {
+            if (comp == 0)
+              {
+                swap(c, d, array);
+                d--;
+              }
+            c--;
+          }
+        if (b > c)
+          break;
+        swap(b, c, array);
+        b++;
+        c--;
+      }
+
+    // Swap pivot(s) back in place, the recurse on left and right sections.
+    hi = from + count;
+    int span;
+    span = Math.min(a - from, b - a);
+    vecswap(from, b - span, span, array);
+
+    span = Math.min(d - c, hi - d - 1);
+    vecswap(b, hi - span, span, array);
+
+    span = b - a;
+    if (span > 1)
+      qsort(array, from, span);
+
+    span = d - c;
+    if (span > 1)
+      qsort(array, hi - span, span);
+  }
+
+  /**
+   * Performs a stable sort on the elements, arranging them according to their
+   * natural order.
+   *
+   * @param a the long array to sort
+   */
+  public static void sort(long[] a)
+  {
+    qsort(a, 0, a.length);
+  }
+
+  /**
+   * Performs a stable sort on the elements, arranging them according to their
+   * natural order.
+   *
+   * @param a the long array to sort
+   * @param fromIndex the first index to sort (inclusive)
+   * @param toIndex the last index to sort (exclusive)
+   * @throws IllegalArgumentException if fromIndex > toIndex
+   * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
+   *         || toIndex > a.length
+   */
+  public static void sort(long[] a, int fromIndex, int toIndex)
+  {
+    if (fromIndex > toIndex)
+      throw new IllegalArgumentException();
+    if (fromIndex < 0)
+      throw new ArrayIndexOutOfBoundsException();
+    qsort(a, fromIndex, toIndex - fromIndex);
+  }
+
+  /**
+   * Finds the index of the median of three array elements.
+   *
+   * @param a the first index
+   * @param b the second index
+   * @param c the third index
+   * @param d the array
+   * @return the index (a, b, or c) which has the middle value of the three
+   */
+  private static int med3(int a, int b, int c, long[] d)
+  {
+    return (d[a] < d[b]
+            ? (d[b] < d[c] ? b : d[a] < d[c] ? c : a)
+            : (d[b] > d[c] ? b : d[a] > d[c] ? c : a));
+  }
+
+  /**
+   * Swaps the elements at two locations of an array
+   *
+   * @param i the first index
+   * @param j the second index
+   * @param a the array
+   */
+  private static void swap(int i, int j, long[] a)
+  {
+    long c = a[i];
+    a[i] = a[j];
+    a[j] = c;
+  }
+
+  /**
+   * Swaps two ranges of an array.
+   *
+   * @param i the first range start
+   * @param j the second range start
+   * @param n the element count
+   * @param a the array
+   */
+  private static void vecswap(int i, int j, int n, long[] a)
+  {
+    for ( ; n > 0; i++, j++, n--)
+      swap(i, j, a);
+  }
+
+  /**
+   * Compares two longs in natural order, since a - b is inadequate.
+   *
+   * @param a the first long
+   * @param b the second long
+   * @return < 0, 0, or > 0 accorting to the comparison
+   */
+  private static int compare(long a, long b)
+  {
+    return a < b ? -1 : a == b ? 0 : 1;
+  }
+
+  /**
+   * Performs a recursive modified quicksort.
+   *
+   * @param array the array to sort
+   * @param from the start index (inclusive)
+   * @param count the number of elements to sort
+   */
+  private static void qsort(long[] array, int from, int count)
+  {
+    // Use an insertion sort on small arrays.
+    if (count <= 7)
+      {
+        for (int i = from + 1; i < from + count; i++)
+          for (int j = i; j > from && array[j - 1] > array[j]; j--)
+            swap(j, j - 1, array);
+        return;
+      }
+
+    // Determine a good median element.
+    int mid = count / 2;
+    int lo = from;
+    int hi = from + count - 1;
+
+    if (count > 40)
+      { // big arrays, pseudomedian of 9
+        int s = count / 8;
+        lo = med3(lo, lo + s, lo + 2 * s, array);
+        mid = med3(mid - s, mid, mid + s, array);
+        hi = med3(hi - 2 * s, hi - s, hi, array);
+      }
+    mid = med3(lo, mid, hi, array);
+
+    int a, b, c, d;
+    int comp;
+
+    // Pull the median element out of the fray, and use it as a pivot.
+    swap(from, mid, array);
+    a = b = from;
+    c = d = from + count - 1;
+
+    // Repeatedly move b and c to each other, swapping elements so
+    // that all elements before index b are less than the pivot, and all
+    // elements after index c are greater than the pivot. a and b track
+    // the elements equal to the pivot.
+    while (true)
+      {
+        while (b <= c && (comp = compare(array[b], array[from])) <= 0)
+          {
+            if (comp == 0)
+              {
+                swap(a, b, array);
+                a++;
+              }
+            b++;
+          }
+        while (c >= b && (comp = compare(array[c], array[from])) >= 0)
+          {
+            if (comp == 0)
+              {
+                swap(c, d, array);
+                d--;
+              }
+            c--;
+          }
+        if (b > c)
+          break;
+        swap(b, c, array);
+        b++;
+        c--;
+      }
+
+    // Swap pivot(s) back in place, the recurse on left and right sections.
+    hi = from + count;
+    int span;
+    span = Math.min(a - from, b - a);
+    vecswap(from, b - span, span, array);
+
+    span = Math.min(d - c, hi - d - 1);
+    vecswap(b, hi - span, span, array);
+
+    span = b - a;
+    if (span > 1)
+      qsort(array, from, span);
+
+    span = d - c;
+    if (span > 1)
+      qsort(array, hi - span, span);
+  }
+
+  /**
+   * Performs a stable sort on the elements, arranging them according to their
+   * natural order.
+   *
+   * @param a the float array to sort
+   */
+  public static void sort(float[] a)
+  {
+    qsort(a, 0, a.length);
+  }
+
+  /**
+   * Performs a stable sort on the elements, arranging them according to their
+   * natural order.
+   *
+   * @param a the float array to sort
+   * @param fromIndex the first index to sort (inclusive)
+   * @param toIndex the last index to sort (exclusive)
+   * @throws IllegalArgumentException if fromIndex > toIndex
+   * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
+   *         || toIndex > a.length
+   */
+  public static void sort(float[] a, int fromIndex, int toIndex)
+  {
+    if (fromIndex > toIndex)
+      throw new IllegalArgumentException();
+    if (fromIndex < 0)
+      throw new ArrayIndexOutOfBoundsException();
+    qsort(a, fromIndex, toIndex - fromIndex);
+  }
+
+  /**
+   * Finds the index of the median of three array elements.
+   *
+   * @param a the first index
+   * @param b the second index
+   * @param c the third index
+   * @param d the array
+   * @return the index (a, b, or c) which has the middle value of the three
+   */
+  private static int med3(int a, int b, int c, float[] d)
+  {
+    return (Float.compare(d[a], d[b]) < 0
+            ? (Float.compare(d[b], d[c]) < 0 ? b
+               : Float.compare(d[a], d[c]) < 0 ? c : a)
+            : (Float.compare(d[b], d[c]) > 0 ? b
+               : Float.compare(d[a], d[c]) > 0 ? c : a));
+  }
+
+  /**
+   * Swaps the elements at two locations of an array
+   *
+   * @param i the first index
+   * @param j the second index
+   * @param a the array
+   */
+  private static void swap(int i, int j, float[] a)
+  {
+    float c = a[i];
+    a[i] = a[j];
+    a[j] = c;
+  }
+
+  /**
+   * Swaps two ranges of an array.
+   *
+   * @param i the first range start
+   * @param j the second range start
+   * @param n the element count
+   * @param a the array
+   */
+  private static void vecswap(int i, int j, int n, float[] a)
+  {
+    for ( ; n > 0; i++, j++, n--)
+      swap(i, j, a);
+  }
+
+  /**
+   * Performs a recursive modified quicksort.
+   *
+   * @param array the array to sort
+   * @param from the start index (inclusive)
+   * @param count the number of elements to sort
+   */
+  private static void qsort(float[] array, int from, int count)
+  {
+    // Use an insertion sort on small arrays.
+    if (count <= 7)
+      {
+        for (int i = from + 1; i < from + count; i++)
+          for (int j = i;
+               j > from && Float.compare(array[j - 1], array[j]) > 0;
+               j--)
+            {
+              swap(j, j - 1, array);
+            }
+        return;
+      }
+
+    // Determine a good median element.
+    int mid = count / 2;
+    int lo = from;
+    int hi = from + count - 1;
+
+    if (count > 40)
+      { // big arrays, pseudomedian of 9
+        int s = count / 8;
+        lo = med3(lo, lo + s, lo + 2 * s, array);
+        mid = med3(mid - s, mid, mid + s, array);
+        hi = med3(hi - 2 * s, hi - s, hi, array);
+      }
+    mid = med3(lo, mid, hi, array);
+
+    int a, b, c, d;
+    int comp;
+
+    // Pull the median element out of the fray, and use it as a pivot.
+    swap(from, mid, array);
+    a = b = from;
+    c = d = from + count - 1;
+
+    // Repeatedly move b and c to each other, swapping elements so
+    // that all elements before index b are less than the pivot, and all
+    // elements after index c are greater than the pivot. a and b track
+    // the elements equal to the pivot.
+    while (true)
+      {
+        while (b <= c && (comp = Float.compare(array[b], array[from])) <= 0)
+          {
+            if (comp == 0)
+              {
+                swap(a, b, array);
+                a++;
+              }
+            b++;
+          }
+        while (c >= b && (comp = Float.compare(array[c], array[from])) >= 0)
+          {
+            if (comp == 0)
+              {
+                swap(c, d, array);
+                d--;
+              }
+            c--;
+          }
+        if (b > c)
+          break;
+        swap(b, c, array);
+        b++;
+        c--;
+      }
+
+    // Swap pivot(s) back in place, the recurse on left and right sections.
+    hi = from + count;
+    int span;
+    span = Math.min(a - from, b - a);
+    vecswap(from, b - span, span, array);
+
+    span = Math.min(d - c, hi - d - 1);
+    vecswap(b, hi - span, span, array);
+
+    span = b - a;
+    if (span > 1)
+      qsort(array, from, span);
+
+    span = d - c;
+    if (span > 1)
+      qsort(array, hi - span, span);
+  }
+
+  /**
+   * Performs a stable sort on the elements, arranging them according to their
+   * natural order.
+   *
+   * @param a the double array to sort
+   */
+  public static void sort(double[] a)
+  {
+    qsort(a, 0, a.length);
+  }
+
+  /**
+   * Performs a stable sort on the elements, arranging them according to their
+   * natural order.
+   *
+   * @param a the double array to sort
+   * @param fromIndex the first index to sort (inclusive)
+   * @param toIndex the last index to sort (exclusive)
+   * @throws IllegalArgumentException if fromIndex > toIndex
+   * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
+   *         || toIndex > a.length
+   */
+  public static void sort(double[] a, int fromIndex, int toIndex)
+  {
+    if (fromIndex > toIndex)
+      throw new IllegalArgumentException();
+    if (fromIndex < 0)
+      throw new ArrayIndexOutOfBoundsException();
+    qsort(a, fromIndex, toIndex - fromIndex);
+  }
+
+  /**
+   * Finds the index of the median of three array elements.
+   *
+   * @param a the first index
+   * @param b the second index
+   * @param c the third index
+   * @param d the array
+   * @return the index (a, b, or c) which has the middle value of the three
+   */
+  private static int med3(int a, int b, int c, double[] d)
+  {
+    return (Double.compare(d[a], d[b]) < 0
+            ? (Double.compare(d[b], d[c]) < 0 ? b
+               : Double.compare(d[a], d[c]) < 0 ? c : a)
+            : (Double.compare(d[b], d[c]) > 0 ? b
+               : Double.compare(d[a], d[c]) > 0 ? c : a));
+  }
+
+  /**
+   * Swaps the elements at two locations of an array
+   *
+   * @param i the first index
+   * @param j the second index
+   * @param a the array
+   */
+  private static void swap(int i, int j, double[] a)
+  {
+    double c = a[i];
+    a[i] = a[j];
+    a[j] = c;
+  }
+
+  /**
+   * Swaps two ranges of an array.
+   *
+   * @param i the first range start
+   * @param j the second range start
+   * @param n the element count
+   * @param a the array
+   */
+  private static void vecswap(int i, int j, int n, double[] a)
+  {
+    for ( ; n > 0; i++, j++, n--)
+      swap(i, j, a);
+  }
+
+  /**
+   * Performs a recursive modified quicksort.
+   *
+   * @param array the array to sort
+   * @param from the start index (inclusive)
+   * @param count the number of elements to sort
+   */
+  private static void qsort(double[] array, int from, int count)
+  {
+    // Use an insertion sort on small arrays.
+    if (count <= 7)
+      {
+        for (int i = from + 1; i < from + count; i++)
+          for (int j = i;
+               j > from && Double.compare(array[j - 1], array[j]) > 0;
+               j--)
+            {
+              swap(j, j - 1, array);
+            }
+        return;
+      }
+
+    // Determine a good median element.
+    int mid = count / 2;
+    int lo = from;
+    int hi = from + count - 1;
+
+    if (count > 40)
+      { // big arrays, pseudomedian of 9
+        int s = count / 8;
+        lo = med3(lo, lo + s, lo + 2 * s, array);
+        mid = med3(mid - s, mid, mid + s, array);
+        hi = med3(hi - 2 * s, hi - s, hi, array);
+      }
+    mid = med3(lo, mid, hi, array);
+
+    int a, b, c, d;
+    int comp;
+
+    // Pull the median element out of the fray, and use it as a pivot.
+    swap(from, mid, array);
+    a = b = from;
+    c = d = from + count - 1;
+
+    // Repeatedly move b and c to each other, swapping elements so
+    // that all elements before index b are less than the pivot, and all
+    // elements after index c are greater than the pivot. a and b track
+    // the elements equal to the pivot.
+    while (true)
+      {
+        while (b <= c && (comp = Double.compare(array[b], array[from])) <= 0)
+          {
+            if (comp == 0)
+              {
+                swap(a, b, array);
+                a++;
+              }
+            b++;
+          }
+        while (c >= b && (comp = Double.compare(array[c], array[from])) >= 0)
+          {
+            if (comp == 0)
+              {
+                swap(c, d, array);
+                d--;
+              }
+            c--;
+          }
+        if (b > c)
+          break;
+        swap(b, c, array);
+        b++;
+        c--;
+      }
+
+    // Swap pivot(s) back in place, the recurse on left and right sections.
+    hi = from + count;
+    int span;
+    span = Math.min(a - from, b - a);
+    vecswap(from, b - span, span, array);
+
+    span = Math.min(d - c, hi - d - 1);
+    vecswap(b, hi - span, span, array);
+
+    span = b - a;
+    if (span > 1)
+      qsort(array, from, span);
+
+    span = d - c;
+    if (span > 1)
+      qsort(array, hi - span, span);
+  }
+
+  /**
+   * Sort an array of Objects according to their natural ordering. The sort is
+   * guaranteed to be stable, that is, equal elements will not be reordered.
+   * The sort algorithm is a mergesort with the merge omitted if the last
+   * element of one half comes before the first element of the other half. This
+   * algorithm gives guaranteed O(n*log(n)) time, at the expense of making a
+   * copy of the array.
+   *
+   * @param a the array to be sorted
+   * @throws ClassCastException if any two elements are not mutually
+   *         comparable
+   * @throws NullPointerException if an element is null (since
+   *         null.compareTo cannot work)
+   * @see Comparable
+   */
+  public static void sort(Object[] a)
+  {
+    sort(a, 0, a.length, null);
+  }
+
+  /**
+   * Sort an array of Objects according to a Comparator. The sort is
+   * guaranteed to be stable, that is, equal elements will not be reordered.
+   * The sort algorithm is a mergesort with the merge omitted if the last
+   * element of one half comes before the first element of the other half. This
+   * algorithm gives guaranteed O(n*log(n)) time, at the expense of making a
+   * copy of the array.
+   *
+   * @param a the array to be sorted
+   * @param c a Comparator to use in sorting the array; or null to indicate
+   *        the elements' natural order
+   * @throws ClassCastException if any two elements are not mutually
+   *         comparable by the Comparator provided
+   * @throws NullPointerException if a null element is compared with natural
+   *         ordering (only possible when c is null)
+   */
+  public static void sort(Object[] a, Comparator c)
+  {
+    sort(a, 0, a.length, c);
+  }
+
+  /**
+   * Sort an array of Objects according to their natural ordering. The sort is
+   * guaranteed to be stable, that is, equal elements will not be reordered.
+   * The sort algorithm is a mergesort with the merge omitted if the last
+   * element of one half comes before the first element of the other half. This
+   * algorithm gives guaranteed O(n*log(n)) time, at the expense of making a
+   * copy of the array.
+   *
+   * @param a the array to be sorted
+   * @param fromIndex the index of the first element to be sorted
+   * @param toIndex the index of the last element to be sorted plus one
+   * @throws ClassCastException if any two elements are not mutually
+   *         comparable
+   * @throws NullPointerException if an element is null (since
+   *         null.compareTo cannot work)
+   * @throws ArrayIndexOutOfBoundsException if fromIndex and toIndex
+   *         are not in range.
+   * @throws IllegalArgumentException if fromIndex > toIndex
+   */
+  public static void sort(Object[] a, int fromIndex, int toIndex)
+  {
+    sort(a, fromIndex, toIndex, null);
+  }
+
+  /**
+   * Sort an array of Objects according to a Comparator. The sort is
+   * guaranteed to be stable, that is, equal elements will not be reordered.
+   * The sort algorithm is a mergesort with the merge omitted if the last
+   * element of one half comes before the first element of the other half. This
+   * algorithm gives guaranteed O(n*log(n)) time, at the expense of making a
+   * copy of the array.
+   *
+   * @param a the array to be sorted
+   * @param fromIndex the index of the first element to be sorted
+   * @param toIndex the index of the last element to be sorted plus one
+   * @param c a Comparator to use in sorting the array; or null to indicate
+   *        the elements' natural order
+   * @throws ClassCastException if any two elements are not mutually
+   *         comparable by the Comparator provided
+   * @throws ArrayIndexOutOfBoundsException if fromIndex and toIndex
+   *         are not in range.
+   * @throws IllegalArgumentException if fromIndex > toIndex
+   * @throws NullPointerException if a null element is compared with natural
+   *         ordering (only possible when c is null)
+   */
+  public static void sort(Object[] a, int fromIndex, int toIndex, Comparator c)
+  {
+    if (fromIndex > toIndex)
+      throw new IllegalArgumentException("fromIndex " + fromIndex
+                                         + " > toIndex " + toIndex);
+    if (fromIndex < 0)
+      throw new ArrayIndexOutOfBoundsException();
+
+    // In general, the code attempts to be simple rather than fast, the
+    // idea being that a good optimising JIT will be able to optimise it
+    // better than I can, and if I try it will make it more confusing for
+    // the JIT. First presort the array in chunks of length 6 with insertion
+    // sort. A mergesort would give too much overhead for this length.
+    for (int chunk = fromIndex; chunk < toIndex; chunk += 6)
+      {
+        int end = Math.min(chunk + 6, toIndex);
+        for (int i = chunk + 1; i < end; i++)
+          {
+            if (Collections.compare(a[i - 1], a[i], c) > 0)
+              {
+                // not already sorted
+                int j = i;
+                Object elem = a[j];
+                do
+                  {
+                    a[j] = a[j - 1];
+                    j--;
+                  }
+                while (j > chunk
+                       && Collections.compare(a[j - 1], elem, c) > 0);
+                a[j] = elem;
+              }
+          }
+      }
+
+    int len = toIndex - fromIndex;
+    // If length is smaller or equal 6 we are done.
+    if (len <= 6)
+      return;
+
+    Object[] src = a;
+    Object[] dest = new Object[len];
+    Object[] t = null; // t is used for swapping src and dest
+
+    // The difference of the fromIndex of the src and dest array.
+    int srcDestDiff = -fromIndex;
+
+    // The merges are done in this loop
+    for (int size = 6; size < len; size <<= 1)
+      {
+        for (int start = fromIndex; start < toIndex; start += size << 1)
+          {
+            // mid is the start of the second sublist;
+            // end the start of the next sublist (or end of array).
+            int mid = start + size;
+            int end = Math.min(toIndex, mid + size);
+
+            // The second list is empty or the elements are already in
+            // order - no need to merge
+            if (mid >= end
+                || Collections.compare(src[mid - 1], src[mid], c) <= 0)
+              {
+                System.arraycopy(src, start,
+                                 dest, start + srcDestDiff, end - start);
+
+                // The two halves just need swapping - no need to merge
+              }
+            else if (Collections.compare(src[start], src[end - 1], c) > 0)
+              {
+                System.arraycopy(src, start,
+                                 dest, end - size + srcDestDiff, size);
+                System.arraycopy(src, mid,
+                                 dest, start + srcDestDiff, end - mid);
+
+              }
+            else
+              {
+                // Declare a lot of variables to save repeating
+                // calculations.  Hopefully a decent JIT will put these
+                // in registers and make this fast
+                int p1 = start;
+                int p2 = mid;
+                int i = start + srcDestDiff;
+
+                // The main merge loop; terminates as soon as either
+                // half is ended
+                while (p1 < mid && p2 < end)
+                  {
+                    dest[i++] =
+                      src[(Collections.compare(src[p1], src[p2], c) <= 0
+                           ? p1++ : p2++)];
+                  }
+
+                // Finish up by copying the remainder of whichever half
+                // wasn't finished.
+                if (p1 < mid)
+                  System.arraycopy(src, p1, dest, i, mid - p1);
+                else
+                  System.arraycopy(src, p2, dest, i, end - p2);
+              }
+          }
+        // swap src and dest ready for the next merge
+        t = src;
+        src = dest;
+        dest = t;
+        fromIndex += srcDestDiff;
+        toIndex += srcDestDiff;
+        srcDestDiff = -srcDestDiff;
+      }
+
+    // make sure the result ends up back in the right place.  Note
+    // that src and dest may have been swapped above, so src
+    // contains the sorted array.
+    if (src != a)
+      {
+        // Note that fromIndex == 0.
+        System.arraycopy(src, 0, a, srcDestDiff, toIndex);
+      }
+  }
+
+  /**
+   * Returns a list "view" of the specified array. This method is intended to
+   * make it easy to use the Collections API with existing array-based APIs and
+   * programs. Changes in the list or the array show up in both places. The
+   * list does not support element addition or removal, but does permit
+   * value modification. The returned list implements both Serializable and
+   * RandomAccess.
+   *
+   * @param a the array to return a view of (<code>null</code> not permitted)
+   * @return a fixed-size list, changes to which "write through" to the array
+   * 
+   * @throws NullPointerException if <code>a</code> is <code>null</code>.
+   * @see Serializable
+   * @see RandomAccess
+   * @see Arrays.ArrayList
+   */
+  public static List asList(final Object[] a)
+  {
+    return new Arrays.ArrayList(a);
+  }
+
+  /** 
+   * Returns the hashcode of an array of long numbers.  If two arrays
+   * are equal, according to <code>equals()</code>, they should have the
+   * same hashcode.  The hashcode returned by the method is equal to that
+   * obtained by the corresponding <code>List</code> object.  This has the same
+   * data, but represents longs in their wrapper class, <code>Long</code>.
+   * For <code>null</code>, 0 is returned.
+   *
+   * @param v an array of long numbers for which the hash code should be
+   *          computed.
+   * @return the hash code of the array, or 0 if null was given.
+   * @since 1.5 
+   */
+  public static int hashCode(long[] v)
+  {
+    if (v == null)
+      return 0;
+    int result = 1;
+    for (int i = 0; i < v.length; ++i)
+      {
+	int elt = (int) (v[i] ^ (v[i] >>> 32));
+	result = 31 * result + elt;
+      }
+    return result;
+  }
+
+  /** 
+   * Returns the hashcode of an array of integer numbers.  If two arrays
+   * are equal, according to <code>equals()</code>, they should have the
+   * same hashcode.  The hashcode returned by the method is equal to that
+   * obtained by the corresponding <code>List</code> object.  This has the same
+   * data, but represents ints in their wrapper class, <code>Integer</code>.
+   * For <code>null</code>, 0 is returned.
+   *
+   * @param v an array of integer numbers for which the hash code should be
+   *          computed.
+   * @return the hash code of the array, or 0 if null was given.
+   * @since 1.5 
+   */
+  public static int hashCode(int[] v)
+  {
+    if (v == null)
+      return 0;
+    int result = 1;
+    for (int i = 0; i < v.length; ++i)
+      result = 31 * result + v[i];
+    return result;
+  }
+
+  /** 
+   * Returns the hashcode of an array of short numbers.  If two arrays
+   * are equal, according to <code>equals()</code>, they should have the
+   * same hashcode.  The hashcode returned by the method is equal to that
+   * obtained by the corresponding <code>List</code> object.  This has the same
+   * data, but represents shorts in their wrapper class, <code>Short</code>.
+   * For <code>null</code>, 0 is returned.
+   *
+   * @param v an array of short numbers for which the hash code should be
+   *          computed.
+   * @return the hash code of the array, or 0 if null was given.
+   * @since 1.5 
+   */
+  public static int hashCode(short[] v)
+  {
+    if (v == null)
+      return 0;
+    int result = 1;
+    for (int i = 0; i < v.length; ++i)
+      result = 31 * result + v[i];
+    return result;
+  }
+
+  /** 
+   * Returns the hashcode of an array of characters.  If two arrays
+   * are equal, according to <code>equals()</code>, they should have the
+   * same hashcode.  The hashcode returned by the method is equal to that
+   * obtained by the corresponding <code>List</code> object.  This has the same
+   * data, but represents chars in their wrapper class, <code>Character</code>.
+   * For <code>null</code>, 0 is returned.
+   *
+   * @param v an array of characters for which the hash code should be
+   *          computed.
+   * @return the hash code of the array, or 0 if null was given.
+   * @since 1.5 
+   */
+  public static int hashCode(char[] v)
+  {
+    if (v == null)
+      return 0;
+    int result = 1;
+    for (int i = 0; i < v.length; ++i)
+      result = 31 * result + v[i];
+    return result;
+  }
+
+  /** 
+   * Returns the hashcode of an array of bytes.  If two arrays
+   * are equal, according to <code>equals()</code>, they should have the
+   * same hashcode.  The hashcode returned by the method is equal to that
+   * obtained by the corresponding <code>List</code> object.  This has the same
+   * data, but represents bytes in their wrapper class, <code>Byte</code>.
+   * For <code>null</code>, 0 is returned.
+   *
+   * @param v an array of bytes for which the hash code should be
+   *          computed.
+   * @return the hash code of the array, or 0 if null was given.
+   * @since 1.5 
+   */
+  public static int hashCode(byte[] v)
+  {
+    if (v == null)
+      return 0;
+    int result = 1;
+    for (int i = 0; i < v.length; ++i)
+      result = 31 * result + v[i];
+    return result;
+  }
+
+  /** 
+   * Returns the hashcode of an array of booleans.  If two arrays
+   * are equal, according to <code>equals()</code>, they should have the
+   * same hashcode.  The hashcode returned by the method is equal to that
+   * obtained by the corresponding <code>List</code> object.  This has the same
+   * data, but represents booleans in their wrapper class,
+   * <code>Boolean</code>.  For <code>null</code>, 0 is returned.
+   *
+   * @param v an array of booleans for which the hash code should be
+   *          computed.
+   * @return the hash code of the array, or 0 if null was given.
+   * @since 1.5 
+   */
+  public static int hashCode(boolean[] v)
+  {
+    if (v == null)
+      return 0;
+    int result = 1;
+    for (int i = 0; i < v.length; ++i)
+      result = 31 * result + (v[i] ? 1231 : 1237);
+    return result;
+  }
+
+  /** 
+   * Returns the hashcode of an array of floats.  If two arrays
+   * are equal, according to <code>equals()</code>, they should have the
+   * same hashcode.  The hashcode returned by the method is equal to that
+   * obtained by the corresponding <code>List</code> object.  This has the same
+   * data, but represents floats in their wrapper class, <code>Float</code>.
+   * For <code>null</code>, 0 is returned.
+   *
+   * @param v an array of floats for which the hash code should be
+   *          computed.
+   * @return the hash code of the array, or 0 if null was given.
+   * @since 1.5 
+   */
+  public static int hashCode(float[] v)
+  {
+    if (v == null)
+      return 0;
+    int result = 1;
+    for (int i = 0; i < v.length; ++i)
+      result = 31 * result + Float.floatToIntBits(v[i]);
+    return result;
+  }
+
+  /** 
+   * Returns the hashcode of an array of doubles.  If two arrays
+   * are equal, according to <code>equals()</code>, they should have the
+   * same hashcode.  The hashcode returned by the method is equal to that
+   * obtained by the corresponding <code>List</code> object.  This has the same
+   * data, but represents doubles in their wrapper class, <code>Double</code>.
+   * For <code>null</code>, 0 is returned.
+   *
+   * @param v an array of doubles for which the hash code should be
+   *          computed.
+   * @return the hash code of the array, or 0 if null was given.
+   * @since 1.5 
+   */
+  public static int hashCode(double[] v)
+  {
+    if (v == null)
+      return 0;
+    int result = 1;
+    for (int i = 0; i < v.length; ++i)
+      {
+	long l = Double.doubleToLongBits(v[i]);
+	int elt = (int) (l ^ (l >>> 32));
+	result = 31 * result + elt;
+      }
+    return result;
+  }
+
+  /** 
+   * Returns the hashcode of an array of integer numbers.  If two arrays
+   * are equal, according to <code>equals()</code>, they should have the
+   * same hashcode.  The hashcode returned by the method is equal to that
+   * obtained by the corresponding <code>List</code> object.  This has the same
+   * data, but represents ints in their wrapper class, <code>Integer</code>.
+   * For <code>null</code>, 0 is returned.
+   *
+   * @param v an array of integer numbers for which the hash code should be
+   *          computed.
+   * @return the hash code of the array, or 0 if null was given.
+   * @since 1.5 
+   */
+  public static int hashCode(Object[] v)
+  {
+    if (v == null)
+      return 0;
+    int result = 1;
+    for (int i = 0; i < v.length; ++i)
+      {
+	int elt = v[i] == null ? 0 : v[i].hashCode();
+	result = 31 * result + elt;
+      }
+    return result;
+  }
+
+  /** @since 1.5 */
+  public static int deepHashCode(Object[] v)
+  {
+    if (v == null)
+      return 0;
+    int result = 1;
+    for (int i = 0; i < v.length; ++i)
+      {
+	int elt;
+	if (v[i] == null)
+	  elt = 0;
+	else if (v[i] instanceof boolean[])
+	  elt = hashCode((boolean[]) v[i]);
+	else if (v[i] instanceof byte[])
+	  elt = hashCode((byte[]) v[i]);
+	else if (v[i] instanceof char[])
+	  elt = hashCode((char[]) v[i]);
+	else if (v[i] instanceof short[])
+	  elt = hashCode((short[]) v[i]);
+	else if (v[i] instanceof int[])
+	  elt = hashCode((int[]) v[i]);
+	else if (v[i] instanceof long[])
+	  elt = hashCode((long[]) v[i]);
+	else if (v[i] instanceof float[])
+	  elt = hashCode((float[]) v[i]);
+	else if (v[i] instanceof double[])
+	  elt = hashCode((double[]) v[i]);
+	else if (v[i] instanceof Object[])
+	  elt = hashCode((Object[]) v[i]);
+	else
+	  elt = v[i].hashCode();
+	result = 31 * result + elt;
+      }
+    return result;
+  }
+
+  /** @since 1.5 */
+  public static boolean deepEquals(Object[] v1, Object[] v2)
+  {
+    if (v1 == null)
+      return v2 == null;
+    if (v2 == null || v1.length != v2.length)
+      return false;
+
+    for (int i = 0; i < v1.length; ++i)
+      {
+	Object e1 = v1[i];
+	Object e2 = v2[i];
+
+	if (e1 == e2)
+	  continue;
+	if (e1 == null || e2 == null)
+	  return false;
+
+	boolean check;
+	if (e1 instanceof boolean[] && e2 instanceof boolean[])
+	  check = equals((boolean[]) e1, (boolean[]) e2);
+	else if (e1 instanceof byte[] && e2 instanceof byte[])
+	  check = equals((byte[]) e1, (byte[]) e2);
+	else if (e1 instanceof char[] && e2 instanceof char[])
+	  check = equals((char[]) e1, (char[]) e2);
+	else if (e1 instanceof short[] && e2 instanceof short[])
+	  check = equals((short[]) e1, (short[]) e2);
+	else if (e1 instanceof int[] && e2 instanceof int[])
+	  check = equals((int[]) e1, (int[]) e2);
+	else if (e1 instanceof long[] && e2 instanceof long[])
+	  check = equals((long[]) e1, (long[]) e2);
+	else if (e1 instanceof float[] && e2 instanceof float[])
+	  check = equals((float[]) e1, (float[]) e2);
+	else if (e1 instanceof double[] && e2 instanceof double[])
+	  check = equals((double[]) e1, (double[]) e2);
+	else if (e1 instanceof Object[] && e2 instanceof Object[])
+	  check = equals((Object[]) e1, (Object[]) e2);
+	else
+	  check = e1.equals(e2);
+	if (! check)
+	  return false;
+      }
+
+    return true;
+  }
+
+  /**
+   * Returns a String representation of the argument array.  Returns "null"
+   * if <code>a</code> is null.
+   * @param v the array to represent
+   * @return a String representing this array
+   * @since 1.5
+   */
+  public static String toString(boolean[] v)
+  {
+    if (v == null)
+      return "null";
+    StringBuilder b = new StringBuilder("[");
+    for (int i = 0; i < v.length; ++i)
+      {
+	if (i > 0)
+	  b.append(", ");
+	b.append(v[i]);
+      }
+    b.append("]");
+    return b.toString();
+  }
+
+  /**
+   * Returns a String representation of the argument array.  Returns "null"
+   * if <code>a</code> is null.
+   * @param v the array to represent
+   * @return a String representing this array
+   * @since 1.5
+   */
+  public static String toString(byte[] v)
+  {
+    if (v == null)
+      return "null";
+    StringBuilder b = new StringBuilder("[");
+    for (int i = 0; i < v.length; ++i)
+      {
+	if (i > 0)
+	  b.append(", ");
+	b.append(v[i]);
+      }
+    b.append("]");
+    return b.toString();
+  }
+
+  /**
+   * Returns a String representation of the argument array.  Returns "null"
+   * if <code>a</code> is null.
+   * @param v the array to represent
+   * @return a String representing this array
+   * @since 1.5
+   */
+  public static String toString(char[] v)
+  {
+    if (v == null)
+      return "null";
+    StringBuilder b = new StringBuilder("[");
+    for (int i = 0; i < v.length; ++i)
+      {
+	if (i > 0)
+	  b.append(", ");
+	b.append(v[i]);
+      }
+    b.append("]");
+    return b.toString();
+  }
+
+  /**
+   * Returns a String representation of the argument array.  Returns "null"
+   * if <code>a</code> is null.
+   * @param v the array to represent
+   * @return a String representing this array
+   * @since 1.5
+   */
+  public static String toString(short[] v)
+  {
+    if (v == null)
+      return "null";
+    StringBuilder b = new StringBuilder("[");
+    for (int i = 0; i < v.length; ++i)
+      {
+	if (i > 0)
+	  b.append(", ");
+	b.append(v[i]);
+      }
+    b.append("]");
+    return b.toString();
+  }
+
+  /**
+   * Returns a String representation of the argument array.  Returns "null"
+   * if <code>a</code> is null.
+   * @param v the array to represent
+   * @return a String representing this array
+   * @since 1.5
+   */
+  public static String toString(int[] v)
+  {
+    if (v == null)
+      return "null";
+    StringBuilder b = new StringBuilder("[");
+    for (int i = 0; i < v.length; ++i)
+      {
+	if (i > 0)
+	  b.append(", ");
+	b.append(v[i]);
+      }
+    b.append("]");
+    return b.toString();
+  }
+
+  /**
+   * Returns a String representation of the argument array.  Returns "null"
+   * if <code>a</code> is null.
+   * @param v the array to represent
+   * @return a String representing this array
+   * @since 1.5
+   */
+  public static String toString(long[] v)
+  {
+    if (v == null)
+      return "null";
+    StringBuilder b = new StringBuilder("[");
+    for (int i = 0; i < v.length; ++i)
+      {
+	if (i > 0)
+	  b.append(", ");
+	b.append(v[i]);
+      }
+    b.append("]");
+    return b.toString();
+  }
+
+  /**
+   * Returns a String representation of the argument array.  Returns "null"
+   * if <code>a</code> is null.
+   * @param v the array to represent
+   * @return a String representing this array
+   * @since 1.5
+   */
+  public static String toString(float[] v)
+  {
+    if (v == null)
+      return "null";
+    StringBuilder b = new StringBuilder("[");
+    for (int i = 0; i < v.length; ++i)
+      {
+	if (i > 0)
+	  b.append(", ");
+	b.append(v[i]);
+      }
+    b.append("]");
+    return b.toString();
+  }
+
+  /**
+   * Returns a String representation of the argument array.  Returns "null"
+   * if <code>a</code> is null.
+   * @param v the array to represent
+   * @return a String representing this array
+   * @since 1.5
+   */
+  public static String toString(double[] v)
+  {
+    if (v == null)
+      return "null";
+    StringBuilder b = new StringBuilder("[");
+    for (int i = 0; i < v.length; ++i)
+      {
+	if (i > 0)
+	  b.append(", ");
+	b.append(v[i]);
+      }
+    b.append("]");
+    return b.toString();
+  }
+
+  /**
+   * Returns a String representation of the argument array.  Returns "null"
+   * if <code>a</code> is null.
+   * @param v the array to represent
+   * @return a String representing this array
+   * @since 1.5
+   */
+  public static String toString(Object[] v)
+  {
+    if (v == null)
+      return "null";
+    StringBuilder b = new StringBuilder("[");
+    for (int i = 0; i < v.length; ++i)
+      {
+	if (i > 0)
+	  b.append(", ");
+	b.append(v[i]);
+      }
+    b.append("]");
+    return b.toString();
+  }
+
+  private static void deepToString(Object[] v, StringBuilder b, HashSet seen)
+  {
+    b.append("[");
+    for (int i = 0; i < v.length; ++i)
+      {
+	if (i > 0)
+	  b.append(", ");
+	Object elt = v[i];
+	if (elt == null)
+	  b.append("null");
+	else if (elt instanceof boolean[])
+	  b.append(toString((boolean[]) elt));
+	else if (elt instanceof byte[])
+	  b.append(toString((byte[]) elt));
+	else if (elt instanceof char[])
+	  b.append(toString((char[]) elt));
+	else if (elt instanceof short[])
+	  b.append(toString((short[]) elt));
+	else if (elt instanceof int[])
+	  b.append(toString((int[]) elt));
+	else if (elt instanceof long[])
+	  b.append(toString((long[]) elt));
+	else if (elt instanceof float[])
+	  b.append(toString((float[]) elt));
+	else if (elt instanceof double[])
+	  b.append(toString((double[]) elt));
+	else if (elt instanceof Object[])
+	  {
+	    Object[] os = (Object[]) elt;
+	    if (seen.contains(os))
+	      b.append("[...]");
+	    else
+	      {
+		seen.add(os);
+		deepToString(os, b, seen);
+	      }
+	  }
+	else
+	  b.append(elt);
+      }
+    b.append("]");
+  }
+
+  /** @since 1.5 */
+  public static String deepToString(Object[] v)
+  {
+    if (v == null)
+      return "null";
+    HashSet seen = new HashSet();
+    StringBuilder b = new StringBuilder();
+    deepToString(v, b, seen);
+    return b.toString();
+  }
+
+  /**
+   * Inner class used by {@link #asList(Object[])} to provide a list interface
+   * to an array. The name, though it clashes with java.util.ArrayList, is
+   * Sun's choice for Serialization purposes. Element addition and removal
+   * is prohibited, but values can be modified.
+   *
+   * @author Eric Blake (ebb9 at email.byu.edu)
+   * @status updated to 1.4
+   */
+  private static final class ArrayList extends AbstractList
+    implements Serializable, RandomAccess
+  {
+    // We override the necessary methods, plus others which will be much
+    // more efficient with direct iteration rather than relying on iterator().
+
+    /**
+     * Compatible with JDK 1.4.
+     */
+    private static final long serialVersionUID = -2764017481108945198L;
+
+    /**
+     * The array we are viewing.
+     * @serial the array
+     */
+    private final Object[] a;
+
+    /**
+     * Construct a list view of the array.
+     * @param a the array to view
+     * @throws NullPointerException if a is null
+     */
+    ArrayList(Object[] a)
+    {
+      // We have to explicitly check.
+      if (a == null)
+        throw new NullPointerException();
+      this.a = a;
+    }
+
+    /**
+     * Returns the object at the specified index in
+     * the array.
+     *
+     * @param index The index to retrieve an object from.
+     * @return The object at the array index specified.
+     */ 
+    public Object get(int index)
+    {
+      return a[index];
+    }
+
+    /**
+     * Returns the size of the array.
+     *
+     * @return The size.
+     */
+    public int size()
+    {
+      return a.length;
+    }
+
+    /**
+     * Replaces the object at the specified index
+     * with the supplied element.
+     *
+     * @param index The index at which to place the new object.
+     * @param element The new object.
+     * @return The object replaced by this operation.
+     */
+    public Object set(int index, Object element)
+    {
+      Object old = a[index];
+      a[index] = element;
+      return old;
+    }
+
+    /**
+     * Returns true if the array contains the
+     * supplied object.
+     *
+     * @param o The object to look for.
+     * @return True if the object was found.
+     */
+    public boolean contains(Object o)
+    {
+      return lastIndexOf(o) >= 0;
+    }
+
+    /**
+     * Returns the first index at which the
+     * object, o, occurs in the array.
+     *
+     * @param o The object to search for.
+     * @return The first relevant index.
+     */
+    public int indexOf(Object o)
+    {
+      int size = a.length;
+      for (int i = 0; i < size; i++)
+        if (ArrayList.equals(o, a[i]))
+          return i;
+      return -1;
+    }
+
+    /**
+     * Returns the last index at which the
+     * object, o, occurs in the array.
+     *
+     * @param o The object to search for.
+     * @return The last relevant index.
+     */
+    public int lastIndexOf(Object o)
+    {
+      int i = a.length;
+      while (--i >= 0)
+        if (ArrayList.equals(o, a[i]))
+          return i;
+      return -1;
+    }
+
+    /**
+     * Transforms the list into an array of
+     * objects, by simplying cloning the array
+     * wrapped by this list.
+     *
+     * @return A clone of the internal array.
+     */
+    public Object[] toArray()
+    {
+      return (Object[]) a.clone();
+    }
+
+    /**
+     * Copies the objects from this list into
+     * the supplied array.  The supplied array
+     * is shrunk or enlarged to the size of the
+     * internal array, and filled with its objects.
+     *
+     * @param array The array to fill with the objects in this list.
+     * @return The array containing the objects in this list,
+     *         which may or may not be == to array.
+     */
+    public Object[] toArray(Object[] array)
+    {
+      int size = a.length;
+      if (array.length < size)
+        array = (Object[])
+          Array.newInstance(array.getClass().getComponentType(), size);
+      else if (array.length > size)
+        array[size] = null;
+
+      System.arraycopy(a, 0, array, 0, size);
+      return array;
+    }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/BitSet.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/BitSet.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/BitSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/BitSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,744 @@
+/* BitSet.java -- A vector of bits.
+   Copyright (C) 1998, 1999, 2000, 2001, 2004, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.util;
+import java.io.Serializable;
+
+/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
+ * hashCode algorithm taken from JDK 1.2 docs.
+ */
+
+/**
+ * This class can be thought of in two ways.  You can see it as a
+ * vector of bits or as a set of non-negative integers.  The name
+ * <code>BitSet</code> is a bit misleading.
+ *
+ * It is implemented by a bit vector, but its equally possible to see
+ * it as set of non-negative integer; each integer in the set is
+ * represented by a set bit at the corresponding index.  The size of
+ * this structure is determined by the highest integer in the set.
+ *
+ * You can union, intersect and build (symmetric) remainders, by
+ * invoking the logical operations and, or, andNot, resp. xor.
+ *
+ * This implementation is NOT synchronized against concurrent access from
+ * multiple threads. Specifically, if one thread is reading from a bitset
+ * while another thread is simultaneously modifying it, the results are
+ * undefined.
+ *
+ * @author Jochen Hoenicke
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @status updated to 1.4
+ */
+public class BitSet implements Cloneable, Serializable
+{
+  /**
+   * Compatible with JDK 1.0.
+   */
+  private static final long serialVersionUID = 7997698588986878753L;
+
+  /**
+   * A common mask.
+   */
+  private static final int LONG_MASK = 0x3f;
+
+  /**
+   * The actual bits.
+   * @serial the i'th bit is in bits[i/64] at position i%64 (where position
+   *         0 is the least significant).
+   */
+  private long[] bits;
+
+  /**
+   * Create a new empty bit set. All bits are initially false.
+   */
+  public BitSet()
+  {
+    this(64);
+  }
+
+  /**
+   * Create a new empty bit set, with a given size.  This
+   * constructor reserves enough space to represent the integers
+   * from <code>0</code> to <code>nbits-1</code>.
+   *
+   * @param nbits the initial size of the bit set
+   * @throws NegativeArraySizeException if nbits < 0
+   */
+  public BitSet(int nbits)
+  {
+    if (nbits < 0)
+      throw new NegativeArraySizeException();
+    
+    int length = nbits >>> 6;
+    if ((nbits & LONG_MASK) != 0)
+      ++length;
+    bits = new long[length];
+  }
+
+  /**
+   * Performs the logical AND operation on this bit set and the
+   * given <code>set</code>.  This means it builds the intersection
+   * of the two sets.  The result is stored into this bit set.
+   *
+   * @param bs the second bit set
+   * @throws NullPointerException if bs is null
+   */
+  public void and(BitSet bs)
+  {
+    int max = Math.min(bits.length, bs.bits.length);
+    int i;
+    for (i = 0; i < max; ++i)
+      bits[i] &= bs.bits[i];
+    while (i < bits.length)
+      bits[i++] = 0;
+  }
+
+  /**
+   * Performs the logical AND operation on this bit set and the
+   * complement of the given <code>bs</code>.  This means it
+   * selects every element in the first set, that isn't in the
+   * second set.  The result is stored into this bit set and is
+   * effectively the set difference of the two.
+   *
+   * @param bs the second bit set
+   * @throws NullPointerException if bs is null
+   * @since 1.2
+   */
+  public void andNot(BitSet bs)
+  {
+    int i = Math.min(bits.length, bs.bits.length);
+    while (--i >= 0)
+      bits[i] &= ~bs.bits[i];
+  }
+
+  /**
+   * Returns the number of bits set to true.
+   *
+   * @return the number of true bits
+   * @since 1.4
+   */
+  public int cardinality()
+  {
+    int card = 0;
+    for (int i = bits.length - 1; i >= 0; i--)
+      {
+        long a = bits[i];
+        // Take care of common cases.
+        if (a == 0)
+          continue;
+        if (a == -1)
+          {
+            card += 64;
+            continue;
+          }
+
+        // Successively collapse alternating bit groups into a sum.
+        a = ((a >> 1) & 0x5555555555555555L) + (a & 0x5555555555555555L);
+        a = ((a >> 2) & 0x3333333333333333L) + (a & 0x3333333333333333L);
+        int b = (int) ((a >>> 32) + a);
+        b = ((b >> 4) & 0x0f0f0f0f) + (b & 0x0f0f0f0f);
+        b = ((b >> 8) & 0x00ff00ff) + (b & 0x00ff00ff);
+        card += ((b >> 16) & 0x0000ffff) + (b & 0x0000ffff);
+      }
+    return card;
+  }
+
+  /**
+   * Sets all bits in the set to false.
+   *
+   * @since 1.4
+   */
+  public void clear()
+  {
+    Arrays.fill(bits, 0);
+  }
+
+  /**
+   * Removes the integer <code>pos</code> from this set. That is
+   * the corresponding bit is cleared.  If the index is not in the set,
+   * this method does nothing.
+   *
+   * @param pos a non-negative integer
+   * @throws IndexOutOfBoundsException if pos < 0
+   */
+  public void clear(int pos)
+  {
+    int offset = pos >> 6;
+    ensure(offset);
+    // ArrayIndexOutOfBoundsException subclasses IndexOutOfBoundsException,
+    // so we'll just let that be our exception.
+    bits[offset] &= ~(1L << pos);
+  }
+
+  /**
+   * Sets the bits between from (inclusive) and to (exclusive) to false.
+   *
+   * @param from the start range (inclusive)
+   * @param to the end range (exclusive)
+   * @throws IndexOutOfBoundsException if from < 0 || to < 0 ||
+   *         from > to
+   * @since 1.4
+   */
+  public void clear(int from, int to)
+  {
+    if (from < 0 || from > to)
+      throw new IndexOutOfBoundsException();
+    if (from == to)
+      return;
+    int lo_offset = from >>> 6;
+    int hi_offset = to >>> 6;
+    ensure(hi_offset);
+    if (lo_offset == hi_offset)
+      {
+        bits[hi_offset] &= ((1L << from) - 1) | (-1L << to);
+        return;
+      }
+
+    bits[lo_offset] &= (1L << from) - 1;
+    bits[hi_offset] &= -1L << to;
+    for (int i = lo_offset + 1; i < hi_offset; i++)
+      bits[i] = 0;
+  }
+
+  /**
+   * Create a clone of this bit set, that is an instance of the same
+   * class and contains the same elements.  But it doesn't change when
+   * this bit set changes.
+   *
+   * @return the clone of this object.
+   */
+  public Object clone()
+  {
+    try
+      {
+        BitSet bs = (BitSet) super.clone();
+        bs.bits = (long[]) bits.clone();
+        return bs;
+      }
+    catch (CloneNotSupportedException e)
+      {
+        // Impossible to get here.
+        return null;
+      }
+  }
+
+  /**
+   * Returns true if the <code>obj</code> is a bit set that contains
+   * exactly the same elements as this bit set, otherwise false.
+   *
+   * @param obj the object to compare to
+   * @return true if obj equals this bit set
+   */
+  public boolean equals(Object obj)
+  {
+    if (!(obj instanceof BitSet))
+      return false;
+    BitSet bs = (BitSet) obj;
+    int max = Math.min(bits.length, bs.bits.length);
+    int i;
+    for (i = 0; i < max; ++i)
+      if (bits[i] != bs.bits[i])
+        return false;
+    // If one is larger, check to make sure all extra bits are 0.
+    for (int j = i; j < bits.length; ++j)
+      if (bits[j] != 0)
+        return false;
+    for (int j = i; j < bs.bits.length; ++j)
+      if (bs.bits[j] != 0)
+        return false;
+    return true;
+  }
+
+  /**
+   * Sets the bit at the index to the opposite value.
+   *
+   * @param index the index of the bit
+   * @throws IndexOutOfBoundsException if index is negative
+   * @since 1.4
+   */
+  public void flip(int index)
+  {
+    int offset = index >> 6;
+    ensure(offset);
+    // ArrayIndexOutOfBoundsException subclasses IndexOutOfBoundsException,
+    // so we'll just let that be our exception.
+    bits[offset] ^= 1L << index;
+  }
+
+  /**
+   * Sets a range of bits to the opposite value.
+   *
+   * @param from the low index (inclusive)
+   * @param to the high index (exclusive)
+   * @throws IndexOutOfBoundsException if from > to || from < 0 ||
+   *         to < 0
+   * @since 1.4
+   */
+  public void flip(int from, int to)
+  {
+    if (from < 0 || from > to)
+      throw new IndexOutOfBoundsException();
+    if (from == to)
+      return;
+    int lo_offset = from >>> 6;
+    int hi_offset = to >>> 6;
+    ensure(hi_offset);
+    if (lo_offset == hi_offset)
+      {
+        bits[hi_offset] ^= (-1L << from) & ((1L << to) - 1);
+        return;
+      }
+
+    bits[lo_offset] ^= -1L << from;
+    bits[hi_offset] ^= (1L << to) - 1;
+    for (int i = lo_offset + 1; i < hi_offset; i++)
+      bits[i] ^= -1;
+  }
+
+  /**
+   * Returns true if the integer <code>bitIndex</code> is in this bit
+   * set, otherwise false.
+   *
+   * @param pos a non-negative integer
+   * @return the value of the bit at the specified position
+   * @throws IndexOutOfBoundsException if the pos is negative
+   */
+  public boolean get(int pos)
+  {
+    int offset = pos >> 6;
+    if (offset >= bits.length)
+      return false;
+    // ArrayIndexOutOfBoundsException subclasses IndexOutOfBoundsException,
+    // so we'll just let that be our exception.
+    return (bits[offset] & (1L << pos)) != 0;
+  }
+
+  /**
+   * Returns a new <code>BitSet</code> composed of a range of bits from
+   * this one.
+   *
+   * @param from the low index (inclusive)
+   * @param to the high index (exclusive)
+   * @throws IndexOutOfBoundsException if from > to || from < 0 ||
+   *         to < 0
+   * @since 1.4
+   */
+  public BitSet get(int from, int to)
+  {
+    if (from < 0 || from > to)
+      throw new IndexOutOfBoundsException();
+    BitSet bs = new BitSet(to - from);
+    int lo_offset = from >>> 6;
+    if (lo_offset >= bits.length || to == from)
+      return bs;
+
+    int lo_bit = from & LONG_MASK;
+    int hi_offset = to >>> 6;
+    if (lo_bit == 0)
+      {
+        int len = Math.min(hi_offset - lo_offset + 1, bits.length - lo_offset);
+        System.arraycopy(bits, lo_offset, bs.bits, 0, len);
+        if (hi_offset < bits.length)
+          bs.bits[hi_offset - lo_offset] &= (1L << to) - 1;
+        return bs;
+      }
+
+    int len = Math.min(hi_offset, bits.length - 1);
+    int reverse = 64 - lo_bit;
+    int i;
+    for (i = 0; lo_offset < len; lo_offset++, i++)
+      bs.bits[i] = ((bits[lo_offset] >>> lo_bit)
+                    | (bits[lo_offset + 1] << reverse));
+    if ((to & LONG_MASK) > lo_bit)
+      bs.bits[i++] = bits[lo_offset] >>> lo_bit;
+    if (hi_offset < bits.length)
+      bs.bits[i - 1] &= (1L << (to - from)) - 1;
+    return bs;
+  }
+
+  /**
+   * Returns a hash code value for this bit set.  The hash code of
+   * two bit sets containing the same integers is identical.  The algorithm
+   * used to compute it is as follows:
+   *
+   * Suppose the bits in the BitSet were to be stored in an array of
+   * long integers called <code>bits</code>, in such a manner that
+   * bit <code>k</code> is set in the BitSet (for non-negative values
+   * of <code>k</code>) if and only if
+   *
+   * <code>((k/64) < bits.length)
+   * && ((bits[k/64] & (1L << (bit % 64))) != 0)
+   * </code>
+   *
+   * Then the following definition of the hashCode method
+   * would be a correct implementation of the actual algorithm:
+   *
+   * 
+<pre>public int hashCode()
+{
+  long h = 1234;
+  for (int i = bits.length-1; i >= 0; i--)
+  {
+    h ^= bits[i] * (i + 1);
+  }
+
+  return (int)((h >> 32) ^ h);
+}</pre>
+   *
+   * Note that the hash code values changes, if the set is changed.
+   *
+   * @return the hash code value for this bit set.
+   */
+  public int hashCode()
+  {
+    long h = 1234;
+    for (int i = bits.length; i > 0; )
+      h ^= i * bits[--i];
+    return (int) ((h >> 32) ^ h);
+  }
+
+  /**
+   * Returns true if the specified BitSet and this one share at least one
+   * common true bit.
+   *
+   * @param set the set to check for intersection
+   * @return true if the sets intersect
+   * @throws NullPointerException if set is null
+   * @since 1.4
+   */
+  public boolean intersects(BitSet set)
+  {
+    int i = Math.min(bits.length, set.bits.length);
+    while (--i >= 0)
+      if ((bits[i] & set.bits[i]) != 0)
+        return true;
+    return false;
+  }
+
+  /**
+   * Returns true if this set contains no true bits.
+   *
+   * @return true if all bits are false
+   * @since 1.4
+   */
+  public boolean isEmpty()
+  {
+    for (int i = bits.length - 1; i >= 0; i--)
+      if (bits[i] != 0)
+        return false;
+    return true;
+  }
+
+  /**
+   * Returns the logical number of bits actually used by this bit
+   * set.  It returns the index of the highest set bit plus one.
+   * Note that this method doesn't return the number of set bits.
+   *
+   * @return the index of the highest set bit plus one.
+   */
+  public int length()
+  {
+    // Set i to highest index that contains a non-zero value.
+    int i;
+    for (i = bits.length - 1; i >= 0 && bits[i] == 0; --i)
+      ;
+
+    // if i < 0 all bits are cleared.
+    if (i < 0)
+      return 0;
+
+    // Now determine the exact length.
+    long b = bits[i];
+    int len = (i + 1) * 64;
+    // b >= 0 checks if the highest bit is zero.
+    while (b >= 0)
+      {
+        --len;
+        b <<= 1;
+      }
+
+    return len;
+  }
+
+  /**
+   * Returns the index of the next false bit, from the specified bit
+   * (inclusive).
+   *
+   * @param from the start location
+   * @return the first false bit
+   * @throws IndexOutOfBoundsException if from is negative
+   * @since 1.4
+   */
+  public int nextClearBit(int from)
+  {
+    int offset = from >> 6;
+    long mask = 1L << from;
+    while (offset < bits.length)
+      {
+        // ArrayIndexOutOfBoundsException subclasses IndexOutOfBoundsException,
+        // so we'll just let that be our exception.
+        long h = bits[offset];
+        do
+          {
+            if ((h & mask) == 0)
+              return from;
+            mask <<= 1;
+            from++;
+          }
+        while (mask != 0);
+        mask = 1;
+        offset++;
+      }
+    return from;
+  }
+
+  /**
+   * Returns the index of the next true bit, from the specified bit
+   * (inclusive). If there is none, -1 is returned. You can iterate over
+   * all true bits with this loop:<br>
+   * 
+<pre>for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1))
+{
+  // operate on i here
+}</pre>
+   *
+   * @param from the start location
+   * @return the first true bit, or -1
+   * @throws IndexOutOfBoundsException if from is negative
+   * @since 1.4
+   */
+  public int nextSetBit(int from)
+  {
+    int offset = from >> 6;
+    long mask = 1L << from;
+    while (offset < bits.length)
+      {
+        // ArrayIndexOutOfBoundsException subclasses IndexOutOfBoundsException,
+        // so we'll just let that be our exception.
+        long h = bits[offset];
+        do
+          {
+            if ((h & mask) != 0)
+              return from;
+            mask <<= 1;
+            from++;
+          }
+        while (mask != 0);
+        mask = 1;
+        offset++;
+      }
+    return -1;
+  }
+
+  /**
+   * Performs the logical OR operation on this bit set and the
+   * given <code>set</code>.  This means it builds the union
+   * of the two sets.  The result is stored into this bit set, which
+   * grows as necessary.
+   *
+   * @param bs the second bit set
+   * @throws NullPointerException if bs is null
+   */
+  public void or(BitSet bs)
+  {
+    ensure(bs.bits.length - 1);
+    for (int i = bs.bits.length - 1; i >= 0; i--)
+      bits[i] |= bs.bits[i];
+  }
+
+  /**
+   * Add the integer <code>bitIndex</code> to this set.  That is
+   * the corresponding bit is set to true.  If the index was already in
+   * the set, this method does nothing.  The size of this structure
+   * is automatically increased as necessary.
+   *
+   * @param pos a non-negative integer.
+   * @throws IndexOutOfBoundsException if pos is negative
+   */
+  public void set(int pos)
+  {
+    int offset = pos >> 6;
+    ensure(offset);
+    // ArrayIndexOutOfBoundsException subclasses IndexOutOfBoundsException,
+    // so we'll just let that be our exception.
+    bits[offset] |= 1L << pos;
+  }
+
+  /**
+   * Sets the bit at the given index to the specified value. The size of
+   * this structure is automatically increased as necessary.
+   *
+   * @param index the position to set
+   * @param value the value to set it to
+   * @throws IndexOutOfBoundsException if index is negative
+   * @since 1.4
+   */
+  public void set(int index, boolean value)
+  {
+    if (value)
+      set(index);
+    else
+      clear(index);
+  }
+
+  /**
+   * Sets the bits between from (inclusive) and to (exclusive) to true.
+   *
+   * @param from the start range (inclusive)
+   * @param to the end range (exclusive)
+   * @throws IndexOutOfBoundsException if from < 0 || from > to ||
+   *         to < 0
+   * @since 1.4
+   */
+  public void set(int from, int to)
+  {
+    if (from < 0 || from > to)
+      throw new IndexOutOfBoundsException();
+    if (from == to)
+      return;
+    int lo_offset = from >>> 6;
+    int hi_offset = to >>> 6;
+    ensure(hi_offset);
+    if (lo_offset == hi_offset)
+      {
+        bits[hi_offset] |= (-1L << from) & ((1L << to) - 1);
+        return;
+      }
+
+    bits[lo_offset] |= -1L << from;
+    bits[hi_offset] |= (1L << to) - 1;
+    for (int i = lo_offset + 1; i < hi_offset; i++)
+      bits[i] = -1;
+  }
+
+  /**
+   * Sets the bits between from (inclusive) and to (exclusive) to the
+   * specified value.
+   *
+   * @param from the start range (inclusive)
+   * @param to the end range (exclusive)
+   * @param value the value to set it to
+   * @throws IndexOutOfBoundsException if from < 0 || from > to ||
+   *         to < 0
+   * @since 1.4
+   */
+  public void set(int from, int to, boolean value)
+  {
+    if (value)
+      set(from, to);
+    else
+      clear(from, to);
+  }
+
+  /**
+   * Returns the number of bits actually used by this bit set.  Note
+   * that this method doesn't return the number of set bits, and that
+   * future requests for larger bits will make this automatically grow.
+   *
+   * @return the number of bits currently used.
+   */
+  public int size()
+  {
+    return bits.length * 64;
+  }
+
+  /**
+   * Returns the string representation of this bit set.  This
+   * consists of a comma separated list of the integers in this set
+   * surrounded by curly braces.  There is a space after each comma.
+   * A sample string is thus "{1, 3, 53}".
+   * @return the string representation.
+   */
+  public String toString()
+  {
+    StringBuffer r = new StringBuffer("{");
+    boolean first = true;
+    for (int i = 0; i < bits.length; ++i)
+      {
+        long bit = 1;
+        long word = bits[i];
+        if (word == 0)
+          continue;
+        for (int j = 0; j < 64; ++j)
+          {
+            if ((word & bit) != 0)
+              {
+                if (! first)
+                  r.append(", ");
+                r.append(64 * i + j);
+                first = false;
+              }
+            bit <<= 1;
+          }
+      }
+    return r.append("}").toString();
+  }
+
+  /**
+   * Performs the logical XOR operation on this bit set and the
+   * given <code>set</code>.  This means it builds the symmetric
+   * remainder of the two sets (the elements that are in one set,
+   * but not in the other).  The result is stored into this bit set,
+   * which grows as necessary.
+   *
+   * @param bs the second bit set
+   * @throws NullPointerException if bs is null
+   */
+  public void xor(BitSet bs)
+  {
+    ensure(bs.bits.length - 1);
+    for (int i = bs.bits.length - 1; i >= 0; i--)
+      bits[i] ^= bs.bits[i];
+  }
+
+  /**
+   * Make sure the vector is big enough.
+   *
+   * @param lastElt the size needed for the bits array
+   */
+  private void ensure(int lastElt)
+  {
+    if (lastElt >= bits.length)
+      {
+        long[] nd = new long[lastElt + 1];
+        System.arraycopy(bits, 0, nd, 0, bits.length);
+        bits = nd;
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/java/util/Calendar.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/util/Calendar.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/util/Calendar.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/util/Calendar.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,1297 @@
+/* Calendar.java --
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * This class is an abstract base class for Calendars, which can be
+ * used to convert between <code>Date</code> objects and a set of
+ * integer fields which represent <code>YEAR</code>,
+ * <code>MONTH</code>, <code>DAY</code>, etc.  The <code>Date</code>
+ * object represents a time in milliseconds since the Epoch. <br>
+ *
+ * This class is locale sensitive.  To get the Object matching the
+ * current locale you can use <code>getInstance</code>.  You can even provide
+ * a locale or a timezone.  <code>getInstance</code> returns currently
+ * a <code>GregorianCalendar</code> for the current date. <br>
+ *
+ * If you want to convert a date from the Year, Month, Day, DayOfWeek,
+ * etc.  Representation to a <code>Date</code>-Object, you can create
+ * a new Calendar with <code>getInstance()</code>,
+ * <code>clear()</code> all fields, <code>set(int,int)</code> the
+ * fields you need and convert it with <code>getTime()</code>. <br>
+ *
+ * If you want to convert a <code>Date</code>-object to the Calendar
+ * representation, create a new Calendar, assign the
+ * <code>Date</code>-Object with <code>setTime()</code>, and read the
+ * fields with <code>get(int)</code>. <br>
+ *
+ * When computing the date from time fields, it may happen, that there
+ * are either two few fields set, or some fields are inconsistent.  This
+ * cases will handled in a calendar specific way.  Missing fields are
+ * replaced by the fields of the epoch: 1970 January 1 00:00. <br>
+ *
+ * To understand, how the day of year is computed out of the fields
+ * look at the following table.  It is traversed from top to bottom,
+ * and for the first line all fields are set, that line is used to
+ * compute the day. <br>
+ *
+ *
+<pre>month + day_of_month
+month + week_of_month + day_of_week
+month + day_of_week_of_month + day_of_week
+day_of_year
+day_of_week + week_of_year</pre>
+ *
+ * The hour_of_day-field takes precedence over the ampm and
+ * hour_of_ampm fields. <br>
+ *
+ * <STRONG>Note:</STRONG> This can differ for non-Gregorian calendar. <br>
+ *
+ * To convert a calendar to a human readable form and vice versa,  use
+ * the <code>java.text.DateFormat</code> class. <br>
+ *
+ * Other useful things you can do with an calendar, is
+ * <code>roll</code>ing fields (that means increase/decrease a
+ * specific field by one, propagating overflows), or
+ * <code>add</code>ing/substracting a fixed amount to a field.
+ *
+ * @see Date
+ * @see GregorianCalendar
+ * @see TimeZone
+ * @see java.text.DateFormat
+ */
+public abstract class Calendar implements Serializable, Cloneable
+{
+  /**
+   * Constant representing the era time field.
+   */
+  public static final int ERA = 0;
+
+  /**
+   * Constant representing the year time field.
+   */
+  public static final int YEAR = 1;
+
+  /**
+   * Constant representing the month time field.  This field
+   * should contain one of the JANUARY,...,DECEMBER constants below.
+   */
+  public static final int MONTH = 2;
+
+  /**
+   * Constant representing the week of the year field.
+   * @see #setFirstDayOfWeek(int)
+   */
+  public static final int WEEK_OF_YEAR = 3;
+
+  /**
+   * Constant representing the week of the month time field.
+   * @see #setFirstDayOfWeek(int)
+   */
+  public static final int WEEK_OF_MONTH = 4;
+
+  /**
+   * Constant representing the day time field, synonym for DAY_OF_MONTH.
+   */
+  public static final int DATE = 5;
+
+  /**
+   * Constant representing the day time field.
+   */
+  public static final int DAY_OF_MONTH = 5;
+
+  /**
+   * Constant representing the day of year time field.  This is
+   * 1 for the first day in month.
+   */
+  public static final int DAY_OF_YEAR = 6;
+
+  /**
+   * Constant representing the day of week time field.  This field
+   * should contain one of the SUNDAY,...,SATURDAY constants below.
+   */
+  public static final int DAY_OF_WEEK = 7;
+
+  /**
+   * Constant representing the day-of-week-in-month field.  For
+   * instance this field contains 2 for the second thursday in a
+   * month.  If you give a negative number here, the day will count
+   * from the end of the month.
+   */
+  public static final int DAY_OF_WEEK_IN_MONTH = 8;
+
+  /**
+   * Constant representing the part of the day for 12-hour clock.  This
+   * should be one of AM or PM.
+   */
+  public static final int AM_PM = 9;
+
+  /**
+   * Constant representing the hour time field for 12-hour clock.
+   */
+  public static final int HOUR = 10;
+
+  /**
+   * Constant representing the hour of day time field for 24-hour clock.
+   */
+  public static final int HOUR_OF_DAY = 11;
+
+  /**
+   * Constant representing the minute of hour time field.
+   */
+  public static final int MINUTE = 12;
+
+  /**
+   * Constant representing the second time field.
+   */
+  public static final int SECOND = 13;
+
+  /**
+   * Constant representing the millisecond time field.
+   */
+  public static final int MILLISECOND = 14;
+
+  /**
+   * Constant representing the time zone offset time field for the
+   * time given in the other fields.  It is measured in
+   * milliseconds.  The default is the offset of the time zone.
+   */
+  public static final int ZONE_OFFSET = 15;
+
+  /**
+   * Constant representing the daylight saving time offset in
+   * milliseconds.  The default is the value given by the time zone.
+   */
+  public static final int DST_OFFSET = 16;
+
+  /**
+   * Number of time fields.
+   */
+  public static final int FIELD_COUNT = 17;
+
+  /**
+   * Constant representing Sunday.
+   */
+  public static final int SUNDAY = 1;
+
+  /**
+   * Constant representing Monday.
+   */
+  public static final int MONDAY = 2;
+
+  /**
+   * Constant representing Tuesday.
+   */
+  public static final int TUESDAY = 3;
+
+  /**
+   * Constant representing Wednesday.
+   */
+  public static final int WEDNESDAY = 4;
+
+  /**
+   * Constant representing Thursday.
+   */
+  public static final int THURSDAY = 5;
+
+  /**
+   * Constant representing Friday.
+   */
+  public static final int FRIDAY = 6;
+
+  /**
+   * Constant representing Saturday.
+   */
+  public static final int SATURDAY = 7;
+
+  /**
+   * Constant representing January.
+   */
+  public static final int JANUARY = 0;
+
+  /**
+   * Constant representing February.
+   */
+  public static final int FEBRUARY = 1;
+
+  /**
+   * Constant representing March.
+   */
+  public static final int MARCH = 2;
+
+  /**
+   * Constant representing April.
+   */
+  public static final int APRIL = 3;
+
+  /**
+   * Constant representing May.
+   */
+  public static final int MAY = 4;
+
+  /**
+   * Constant representing June.
+   */
+  public static final int JUNE = 5;
+
+  /**
+   * Constant representing July.
+   */
+  public static final int JULY = 6;
+
+  /**
+   * Constant representing August.
+   */
+  public static final int AUGUST = 7;
+
+  /**
+   * Constant representing September.
+   */
+  public static final int SEPTEMBER = 8;
+
+  /**
+   * Constant representing October.
+   */
+  public static final int OCTOBER = 9;
+
+  /**
+   * Constant representing November.
+   */
+  public static final int NOVEMBER = 10;
+
+  /**
+   * Constant representing December.
+   */
+  public static final int DECEMBER = 11;
+
+  /**
+   * Constant representing Undecimber. This is an artificial name useful
+   * for lunar calendars.
+   */
+  public static final int UNDECIMBER = 12;
+
+  /**
+   * Useful constant for 12-hour clock.
+   */
+  public static final int AM = 0;
+
+  /**
+   * Useful constant for 12-hour clock.
+   */
+  public static final int PM = 1;
+
+  /**
+   * The time fields.  The array is indexed by the constants YEAR to
+   * DST_OFFSET.
+   * @serial
+   */
+  protected int[] fields = new int[FIELD_COUNT];
+
+  /**
+   * The flags which tell if the fields above have a value.
+   * @serial
+   */
+  protected boolean[] isSet = new boolean[FIELD_COUNT];
+
+  /**
+   * The time in milliseconds since the epoch.
+   * @serial
+   */
+  protected long time;
+
+  /**
+   * Tells if the above field has a valid value.
+   * @serial
+   */
+  protected boolean isTimeSet;
+
+  /**
+   * Tells if the fields have a valid value.  This superseeds the isSet
+   * array.
+   * @serial
+   */
+  protected boolean areFieldsSet;
+
+  /**
+   * The time zone of this calendar.  Used by sub classes to do UTC / local
+   * time conversion.  Sub classes can access this field with getTimeZone().
+   * @serial
+   */
+  private TimeZone zone;
+
+  /**
+   * This is the default calendar class, that is returned on
+   * java.util.Calendar.getInstance().
+   * XXX - this isn't localized anywhere, is it?
+   * @see java.util.Calendar#getInstance()
+   */
+  private static final String calendarClassName = "java.util.GregorianCalendar";
+
+  /**
+   * Specifies if the date/time interpretation should be lenient.
+   * If the flag is set, a date such as "February 30, 1996" will be
+   * treated as the 29th day after the February 1.  If this flag
+   * is false, such dates will cause an exception.
+   * @serial
+   */
+  private boolean lenient;
+
+  /**
+   * Sets what the first day of week is.  This is used for
+   * WEEK_OF_MONTH and WEEK_OF_YEAR fields.
+   * @serial
+   */
+  private int firstDayOfWeek;
+
+  /**
+   * Sets how many days are required in the first week of the year.
+   * If the first day of the year should be the first week you should
+   * set this value to 1.  If the first week must be a full week, set
+   * it to 7.
+   * @serial
+   */
+  private int minimalDaysInFirstWeek;
+
+  /**
+   * Is set to true if DST_OFFSET is explicitly set. In that case
+   * it's value overrides the value computed from the current
+   * time and the timezone.
+   */
+  private boolean explicitDSTOffset = false;
+
+  /**
+   * The version of the serialized data on the stream.
+   * <dl><dt>0 or not present</dt>
+   * <dd> JDK 1.1.5 or later.</dd>
+   * <dt>1</dt>
+   * <dd>JDK 1.1.6 or later.  This always writes a correct `time' value
+   * on the stream, as well as the other fields, to be compatible with
+   * earlier versions</dd></dl>
+   * @since JDK1.1.6
+   * @serial
+   */
+  private int serialVersionOnStream = 1;
+
+  /**
+   * XXX - I have not checked the compatibility.  The documentation of
+   * the serialized-form is quite hairy...
+   */
+  static final long serialVersionUID = -1807547505821590642L;
+
+  /**
+   * The name of the resource bundle. Used only by getBundle()
+   */
+  private static final String bundleName = "gnu.java.locale.LocaleInformation";
+
+  /**
+   * get resource bundle:
+   * The resources should be loaded via this method only. Iff an application
+   * uses this method, the resourcebundle is required.
+   */
+  private static ResourceBundle getBundle(Locale locale)
+  {
+    return ResourceBundle.getBundle(bundleName, locale,
+                                    ClassLoader.getSystemClassLoader());
+  }
+
+  /**
+   * Constructs a new Calendar with the default time zone and the default
+   * locale.
+   */
+  protected Calendar()
+  {
+    this(TimeZone.getDefault(), Locale.getDefault());
+  }
+
+  /**
+   * Constructs a new Calendar with the given time zone and the given
+   * locale.
+   * @param zone a time zone.
+   * @param locale a locale.
+   */
+  protected Calendar(TimeZone zone, Locale locale)
+  {
+    this.zone = zone;
+    lenient = true;
+    String[] days = { "", "sun", "mon", "tue", "wed", "thu", "fri", "sat" };
+
+    ResourceBundle rb = getBundle(locale);
+    String min = (String) rb.getObject("minNumberOfDaysInFirstWeek");
+    String first = (String) rb.getObject("firstDayOfWeek");
+    try
+      {
+	if (min != null)
+	  minimalDaysInFirstWeek = Integer.parseInt(min);
+      }
+    catch (NumberFormatException ex)
+      {
+	minimalDaysInFirstWeek = 1;
+      }
+
+    firstDayOfWeek = 1;
+    if (first != null)
+      for (int i = 0; i < 8; i++)
+	if (days[i].equals(first))
+	  firstDayOfWeek = i;
+
+    clear();
+  }
+
+  /**
+   * Creates a calendar representing the actual time, using the default
+   * time zone and locale.
+   */
+  public static synchronized Calendar getInstance()
+  {
+    return getInstance(TimeZone.getDefault(), Locale.getDefault());
+  }
+
+  /**
+   * Creates a calendar representing the actual time, using the given
+   * time zone and the default locale.
+   * @param zone a time zone.
+   */
+  public static synchronized Calendar getInstance(TimeZone zone)
+  {
+    return getInstance(zone, Locale.getDefault());
+  }
+
+  /**
+   * Creates a calendar representing the actual time, using the default
+   * time zone and the given locale.
+   * @param locale a locale.
+   */
+  public static synchronized Calendar getInstance(Locale locale)
+  {
+    return getInstance(TimeZone.getDefault(), locale);
+  }
+
+  /**
+   * Cache of locale->calendar-class mappings. This avoids having to do a ResourceBundle
+   * lookup for every getInstance call.
+   */
+  private static HashMap cache = new HashMap();
+
+  /** Preset argument types for calendar-class constructor lookup.  */
+  private static Class[] ctorArgTypes = new Class[]
+                                        {
+                                          TimeZone.class, Locale.class
+                                        };
+
+  /**
+   * Creates a calendar representing the actual time, using the given
+   * time zone and locale.
+   * @param zone a time zone.
+   * @param locale a locale.
+   */
+  public static synchronized Calendar getInstance(TimeZone zone, Locale locale)
+  {
+    Class calendarClass = (Class) cache.get(locale);
+    Throwable exception = null;
+
+    try
+      {
+	if (calendarClass == null)
+	  {
+	    calendarClass = Class.forName(calendarClassName);
+	    if (Calendar.class.isAssignableFrom(calendarClass))
+	      cache.put(locale, calendarClass);
+	  }
+
+	// GregorianCalendar is by far the most common case. Optimize by 
+	// avoiding reflection.
+	if (calendarClass == GregorianCalendar.class)
+	  return new GregorianCalendar(zone, locale);
+
+	if (Calendar.class.isAssignableFrom(calendarClass))
+	  {
+	    Constructor ctor = calendarClass.getConstructor(ctorArgTypes);
+	    return (Calendar) ctor.newInstance(new Object[] { zone, locale });
+	  }
+      }
+    catch (ClassNotFoundException ex)
+      {
+	exception = ex;
+      }
+    catch (IllegalAccessException ex)
+      {
+	exception = ex;
+      }
+    catch (NoSuchMethodException ex)
+      {
+	exception = ex;
+      }
+    catch (InstantiationException ex)
+      {
+	exception = ex;
+      }
+    catch (InvocationTargetException ex)
+      {
+	exception = ex;
+      }
+
+    throw new RuntimeException("Error instantiating calendar for locale "
+                               + locale, exception);
+  }
+
+  /**
+   * Gets the set of locales for which a Calendar is available.
+   * @exception MissingResourceException if locale data couldn't be found.
+   * @return the set of locales.
+   */
+  public static synchronized Locale[] getAvailableLocales()
+  {
+    ResourceBundle rb = getBundle(new Locale("", ""));
+    return (Locale[]) rb.getObject("availableLocales");
+  }
+
+  /**
+   * Converts the time field values (<code>fields</code>) to
+   * milliseconds since the epoch UTC (<code>time</code>).  Override
+   * this method if you write your own Calendar.  */
+  protected abstract void computeTime();
+
+  /**
+   * Converts the milliseconds since the epoch UTC
+   * (<code>time</code>) to time fields
+   * (<code>fields</code>). Override this method if you write your
+   * own Calendar.
+   */
+  protected abstract void computeFields();
+
+  /**
+   * Converts the time represented by this object to a
+   * <code>Date</code>-Object.
+   * @return the Date.
+   */
+  public final Date getTime()
+  {
+    if (! isTimeSet)
+      computeTime();
+    return new Date(time);
+  }
+
+  /**
+   * Sets this Calendar's time to the given Date.  All time fields
+   * are invalidated by this method.
+   */
+  public final void setTime(Date date)
+  {
+    setTimeInMillis(date.getTime());
+  }
+
+  /**
+   * Returns the time represented by this Calendar.
+   * @return the time in milliseconds since the epoch.
+   * @specnote This was made public in 1.4.
+   */
+  public long getTimeInMillis()
+  {
+    if (! isTimeSet)
+      computeTime();
+    return time;
+  }
+
+  /**
+   * Sets this Calendar's time to the given Time.  All time fields
+   * are invalidated by this method.
+   * @param time the time in milliseconds since the epoch
+   * @specnote This was made public in 1.4.
+   */
+  public void setTimeInMillis(long time)
+  {
+    clear();
+    this.time = time;
+    isTimeSet = true;
+    computeFields();
+  }
+
+  /**
+   * Gets the value of the specified field.  They are recomputed
+   * if they are invalid.
+   * @param field the time field. One of the time field constants.
+   * @return the value of the specified field
+   * @throws ArrayIndexOutOfBoundsException if the field is outside
+   *         the valid range.  The value of field must be >= 0 and
+   *         <= <code>FIELD_COUNT</code>.
+   * @specnote Not final since JDK 1.4
+   */
+  public int get(int field)
+  {
+    // If the requested field is invalid, force all fields to be recomputed.
+    if (! isSet[field])
+      areFieldsSet = false;
+    complete();
+    return fields[field];
+  }
+
+  /**
+   * Gets the value of the specified field. This method doesn't
+   * recompute the fields, if they are invalid.
+   * @param field the time field. One of the time field constants.
+   * @return the value of the specified field, undefined if
+   * <code>areFieldsSet</code> or <code>isSet[field]</code> is false.
+   * @throws ArrayIndexOutOfBoundsException if the field is outside
+   *         the valid range.  The value of field must be >= 0 and
+   *         <= <code>FIELD_COUNT</code>.
+   */
+  protected final int internalGet(int field)
+  {
+    return fields[field];
+  }
+
+  /**
+   * Sets the time field with the given value.  This does invalidate
+   * the time in milliseconds.
+   * @param field the time field. One of the time field constants
+   * @param value the value to be set.
+   * @throws ArrayIndexOutOfBoundsException if field is outside
+   *         the valid range.  The value of field must be >= 0 and
+   *         <= <code>FIELD_COUNT</code>.
+   * @specnote Not final since JDK 1.4
+   */
+  public void set(int field, int value)
+  {
+    if (isTimeSet)
+      for (int i = 0; i < FIELD_COUNT; i++)
+	isSet[i] = false;
+    isTimeSet = false;
+    fields[field] = value;
+    isSet[field] = true;
+
+    // The five valid date patterns, in order of priority
+    // 1  YEAR + MONTH + DAY_OF_MONTH
+    // 2  YEAR + MONTH + WEEK_OF_MONTH + DAY_OF_WEEK
+    // 3  YEAR + MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK
+    // 4  YEAR + DAY_OF_YEAR
+    // 5  YEAR + DAY_OF_WEEK + WEEK_OF_YEAR
+    switch (field)
+      {
+      case MONTH: // pattern 1,2 or 3
+	isSet[DAY_OF_YEAR] = false;
+	isSet[WEEK_OF_YEAR] = false;
+	break;
+      case DAY_OF_MONTH: // pattern 1
+	isSet[YEAR] = true;
+	isSet[MONTH] = true;
+	isSet[WEEK_OF_MONTH] = true;
+	isSet[DAY_OF_WEEK] = false;
+	isSet[DAY_OF_WEEK_IN_MONTH] = false;
+	isSet[DAY_OF_YEAR] = false;
+	isSet[WEEK_OF_YEAR] = false;
+	break;
+      case WEEK_OF_MONTH: // pattern 2
+	if (! isSet[DAY_OF_WEEK])
+	  fields[DAY_OF_WEEK] = getFirstDayOfWeek();
+	isSet[YEAR] = true;
+	isSet[MONTH] = true;
+	isSet[DAY_OF_WEEK] = true;
+	isSet[DAY_OF_MONTH] = false;
+	isSet[DAY_OF_WEEK_IN_MONTH] = false;
+	isSet[DAY_OF_YEAR] = false;
+	isSet[WEEK_OF_YEAR] = false;
+	break;
+      case DAY_OF_WEEK_IN_MONTH: // pattern 3
+	if (! isSet[DAY_OF_WEEK])
+	  fields[DAY_OF_WEEK] = getFirstDayOfWeek();
+	isSet[YEAR] = true;
+	isSet[MONTH] = true;
+	isSet[DAY_OF_WEEK] = true;
+	isSet[DAY_OF_YEAR] = false;
+	isSet[DAY_OF_MONTH] = false;
+	isSet[WEEK_OF_MONTH] = false;
+	isSet[WEEK_OF_YEAR] = false;
+	break;
+      case DAY_OF_YEAR: // pattern 4
+	isSet[YEAR] = true;
+	isSet[MONTH] = false;
+	isSet[WEEK_OF_MONTH] = false;
+	isSet[DAY_OF_MONTH] = false;
+	isSet[DAY_OF_WEEK] = false;
+	isSet[WEEK_OF_YEAR] = false;
+	isSet[DAY_OF_WEEK_IN_MONTH] = false;
+	break;
+      case WEEK_OF_YEAR: // pattern 5
+	if (! isSet[DAY_OF_WEEK])
+	  fields[DAY_OF_WEEK] = getFirstDayOfWeek();
+	isSet[YEAR] = true;
+	isSet[DAY_OF_WEEK] = true;
+	isSet[MONTH] = false;
+	isSet[DAY_OF_MONTH] = false;
+	isSet[WEEK_OF_MONTH] = false;
+	isSet[DAY_OF_YEAR] = false;
+	isSet[DAY_OF_WEEK_IN_MONTH] = false;
+	break;
+      case AM_PM:
+	isSet[HOUR] = true;
+	isSet[HOUR_OF_DAY] = false;
+	break;
+      case HOUR_OF_DAY:
+	isSet[AM_PM] = false;
+	isSet[HOUR] = false;
+	break;
+      case HOUR:
+	isSet[AM_PM] = true;
+	isSet[HOUR_OF_DAY] = false;
+	break;
+      case DST_OFFSET:
+	explicitDSTOffset = true;
+      }
+
+    // May have crossed over a DST boundary.
+    if (! explicitDSTOffset && (field != DST_OFFSET && field != ZONE_OFFSET))
+      isSet[DST_OFFSET] = false;
+  }
+
+  /**
+   * Sets the fields for year, month, and date
+   * @param year the year.
+   * @param month the month, one of the constants JANUARY..UNDICEMBER.
+   * @param date the day of the month
+   */
+  public final void set(int year, int month, int date)
+  {
+    isTimeSet = false;
+    fields[YEAR] = year;
+    fields[MONTH] = month;
+    fields[DATE] = date;
+    isSet[YEAR] = isSet[MONTH] = isSet[DATE] = true;
+    isSet[WEEK_OF_YEAR] = false;
+    isSet[DAY_OF_YEAR] = false;
+    isSet[WEEK_OF_MONTH] = false;
+    isSet[DAY_OF_WEEK] = false;
+    isSet[DAY_OF_WEEK_IN_MONTH] = false;
+    isSet[ERA] = false;
+
+    if (! explicitDSTOffset)
+      isSet[DST_OFFSET] = false; // May have crossed a DST boundary.
+  }
+
+  /**
+   * Sets the fields for year, month, date, hour, and minute
+   * @param year the year.
+   * @param month the month, one of the constants JANUARY..UNDICEMBER.
+   * @param date the day of the month
+   * @param hour the hour of day.
+   * @param minute the minute.
+   */
+  public final void set(int year, int month, int date, int hour, int minute)
+  {
+    set(year, month, date);
+    fields[HOUR_OF_DAY] = hour;
+    fields[MINUTE] = minute;
+    isSet[HOUR_OF_DAY] = isSet[MINUTE] = true;
+    isSet[AM_PM] = false;
+    isSet[HOUR] = false;
+  }
+
+  /**
+   * Sets the fields for year, month, date, hour, and minute
+   * @param year the year.
+   * @param month the month, one of the constants JANUARY..UNDICEMBER.
+   * @param date the day of the month
+   * @param hour the hour of day.
+   * @param minute the minute.
+   * @param second the second.
+   */
+  public final void set(int year, int month, int date, int hour, int minute,
+                        int second)
+  {
+    set(year, month, date, hour, minute);
+    fields[SECOND] = second;
+    isSet[SECOND] = true;
+  }
+
+  /**
+   * Clears the values of all the time fields.
+   */
+  public final void clear()
+  {
+    isTimeSet = false;
+    areFieldsSet = false;
+    int zoneOffs = zone.getRawOffset();
+    int[] tempFields = 
+                       {
+                         1, 1970, JANUARY, 1, 1, 1, 1, THURSDAY, 1, AM, 0, 0, 0,
+                         0, 0, zoneOffs, 0
+                       };
+    fields = tempFields;
+    for (int i = 0; i < FIELD_COUNT; i++)
+      isSet[i] = false;
+  }
+
+  /**
+   * Clears the values of the specified time field.
+   * @param field the time field. One of the time field constants.
+   * @throws ArrayIndexOutOfBoundsException if field is outside
+   *         the valid range.  The value of field must be >= 0 and
+   *         <= <code>FIELD_COUNT</code>.
+   */
+  public final void clear(int field)
+  {
+    int[] tempFields = 
+                       {
+                         1, 1970, JANUARY, 1, 1, 1, 1, THURSDAY, 1, AM, 0, 0, 0,
+                         0, 0, zone.getRawOffset(), 0
+                       };
+    complete();
+    isTimeSet = false;
+    areFieldsSet = false;
+    isSet[field] = false;
+    fields[field] = tempFields[field];
+  }
+
+  /**
+   * Determines if the specified field has a valid value.
+   * @return true if the specified field has a value.
+   * @throws ArrayIndexOutOfBoundsException if the field is outside
+   *         the valid range.  The value of field must be >= 0 and
+   *         <= <code>FIELD_COUNT</code>.
+   */
+  public final boolean isSet(int field)
+  {
+    return isSet[field];
+  }
+
+  /**
+   * Fills any unset fields in the time field list
+   */
+  protected void complete()
+  {
+    if (! isTimeSet)
+      computeTime();
+    if (! areFieldsSet)
+      computeFields();
+  }
+
+  /**
+   * Compares the given calendar with this.
+   * @param o the object to that we should compare.
+   * @return true, if the given object is a calendar, that represents
+   * the same time (but doesn't necessary have the same fields).
+   */
+  public boolean equals(Object o)
+  {
+    if (! (o instanceof Calendar))
+      return false;
+    Calendar cal = (Calendar) o;
+    if (getTimeInMillis() == ((Calendar) o).getTimeInMillis()
+        && cal.getFirstDayOfWeek() == getFirstDayOfWeek()
+        && cal.isLenient() == isLenient()
+        && cal.getMinimalDaysInFirstWeek() == getMinimalDaysInFirstWeek())
+      {
+        TimeZone self = getTimeZone();
+        TimeZone oth = cal.getTimeZone();
+        return self == null ? oth == null : self.equals(oth);
+      }
+    return false;
+  }
+
+  /**
+   * Returns a hash code for this calendar.
+   * @return a hash code, which fullfits the general contract of
+   * <code>hashCode()</code>
+   */
+  public int hashCode()
+  {
+    long time = getTimeInMillis();
+    int val = (int) ((time & 0xffffffffL) ^ (time >> 32));
+    val += (getFirstDayOfWeek() + (isLenient() ? 1230 : 1237)
+            + getMinimalDaysInFirstWeek());
+    TimeZone self = getTimeZone();
+    if (self != null)
+      val ^= self.hashCode();
+    return val;
+  }
+
+  /**
+   * Compares the given calendar with this.
+   * @param o the object to that we should compare.
+   * @return true, if the given object is a calendar, and this calendar
+   * represents a smaller time than the calendar o.
+   * @exception ClassCastException if o is not an calendar.
+   * @since JDK1.2 you don't need to override this method
+   */
+  public boolean before(Object o)
+  {
+    return getTimeInMillis() < ((Calendar) o).getTimeInMillis();
+  }
+
+  /**
+   * Compares the given calendar with this.
+   * @param o the object to that we should compare.
+   * @return true, if the given object is a calendar, and this calendar
+   * represents a bigger time than the calendar o.
+   * @exception ClassCastException if o is not an calendar.
+   * @since JDK1.2 you don't need to override this method
+   */
+  public boolean after(Object o)
+  {
+    return getTimeInMillis() > ((Calendar) o).getTimeInMillis();
+  }
+
+  /**
+   * Adds the specified amount of time to the given time field.  The
+   * amount may be negative to subtract the time.  If the field overflows
+   * it does what you expect: Jan, 25 + 10 Days is Feb, 4.
+   * @param field the time field. One of the time field constants.
+   * @param amount the amount of time.
+   * @throws ArrayIndexOutOfBoundsException if the field is outside
+   *         the valid range.  The value of field must be >= 0 and
+   *         <= <code>FIELD_COUNT</code>.
+   */
+  public abstract void add(int field, int amount);
+
+  /**
+   * Rolls the specified time field up or down.  This means add one
+   * to the specified field, but don't change the other fields.  If
+   * the maximum for this field is reached, start over with the
+   * minimum value.  <br>
+   *
+   * <strong>Note:</strong> There may be situation, where the other
+   * fields must be changed, e.g rolling the month on May, 31.
+   * The date June, 31 is automatically converted to July, 1.
+   * @param field the time field. One of the time field constants.
+   * @param up the direction, true for up, false for down.
+   * @throws ArrayIndexOutOfBoundsException if the field is outside
+   *         the valid range.  The value of field must be >= 0 and
+   *         <= <code>FIELD_COUNT</code>.
+   */
+  public abstract void roll(int field, boolean up);
+
+  /**
+   * Rolls up or down the specified time field by the given amount.
+   * A negative amount rolls down.  The default implementation is
+   * call <code>roll(int, boolean)</code> for the specified amount.
+   *
+   * Subclasses should override this method to do more intuitiv things.
+   *
+   * @param field the time field. One of the time field constants.
+   * @param amount the amount to roll by, positive for rolling up,
+   * negative for rolling down.
+   * @throws ArrayIndexOutOfBoundsException if the field is outside
+   *         the valid range.  The value of field must be >= 0 and
+   *         <= <code>FIELD_COUNT</code>.
+   * @since JDK1.2
+   */
+  public void roll(int field, int amount)
+  {
+    while (amount > 0)
+      {
+	roll(field, true);
+	amount--;
+      }
+    while (amount < 0)
+      {
+	roll(field, false);
+	amount++;
+      }
+  }
+
+  /**
+   * Sets the time zone to the specified value.
+   * @param zone the new time zone
+   */
+  public void setTimeZone(TimeZone zone)
+  {
+    this.zone = zone;
+    computeTime();
+    computeFields();
+  }
+
+  /**
+   * Gets the time zone of this calendar
+   * @return the current time zone.
+   */
+  public TimeZone getTimeZone()
+  {
+    return zone;
+  }
+
+  /**
+   * Specifies if the date/time interpretation should be lenient.
+   * If the flag is set, a date such as "February 30, 1996" will be
+   * treated as the 29th day after the February 1.  If this flag
+   * is false, such dates will cause an exception.
+   * @param lenient true, if the date should be interpreted linient,
+   * false if it should be interpreted strict.
+   */
+  public void setLenient(boolean lenient)
+  {
+    this.lenient = lenient;
+  }
+
+  /**
+   * Tells if the date/time interpretation is lenient.
+   * @return true, if the date should be interpreted linient,
+   * false if it should be interpreted strict.
+   */
+  public boolean isLenient()
+  {
+    return lenient;
+  }
+
+  /**
+   * Sets what the first day of week is.  This is used for
+   * WEEK_OF_MONTH and WEEK_OF_YEAR fields.
+   * @param value the first day of week.  One of SUNDAY to SATURDAY.
+   */
+  public void setFirstDayOfWeek(int value)
+  {
+    firstDayOfWeek = value;
+  }
+
+  /**
+   * Gets what the first day of week is.  This is used for
+   * WEEK_OF_MONTH and WEEK_OF_YEAR fields.
+   * @return the first day of week.  One of SUNDAY to SATURDAY.
+   */
+  public int getFirstDayOfWeek()
+  {
+    return firstDayOfWeek;
+  }
+
+  /**
+   * Sets how many days are required in the first week of the year.
+   * If the first day of the year should be the first week you should
+   * set this value to 1.  If the first week must be a full week, set
+   * it to 7.
+   * @param value the minimal days required in the first week.
+   */
+  public void setMinimalDaysInFirstWeek(int value)
+  {
+    minimalDaysInFirstWeek = value;
+  }
+
+  /**
+   * Gets how many days are required in the first week of the year.
+   * @return the minimal days required in the first week.
+   * @see #setMinimalDaysInFirstWeek
+   */
+  public int getMinimalDaysInFirstWeek()
+  {
+    return minimalDaysInFirstWeek;
+  }
+
+  /**
+   * Gets the smallest value that is allowed for the specified field.
+   * @param field the time field. One of the time field constants.
+   * @return the smallest value.
+   */
+  public abstract int getMinimum(int field);
+
+  /**
+   * Gets the biggest value that is allowed for the specified field.
+   * @param field the time field. One of the time field constants.
+   * @return the biggest value.
+   */
+  public abstract int getMaximum(int field);
+
+  /**
+   * Gets the greatest minimum value that is allowed for the specified field.
+   * @param field the time field. One of the time field constants.
+   * @return the greatest minimum value.
+   */
+  public abstract int getGreatestMinimum(int field);
+
+  /**
+   * Gets the smallest maximum value that is allowed for the
+   * specified field.  For example this is 28 for DAY_OF_MONTH.
+   * @param field the time field. One of the time field constants.
+   * @return the least maximum value.
+   */
+  public abstract int getLeastMaximum(int field);
+
+  /**
+   * Gets the actual minimum value that is allowed for the specified field.
+   * This value is dependent on the values of the other fields.
+   * @param field the time field. One of the time field constants.
+   * @return the actual minimum value.
+   * @throws ArrayIndexOutOfBoundsException if the field is outside
+   *         the valid range.  The value of field must be >= 0 and
+   *         <= <code>FIELD_COUNT</code>.
+   * @since jdk1.2
+   */
+  public int getActualMinimum(int field)
+  {
+    Calendar tmp = (Calendar) clone(); // To avoid restoring state
+    int min = tmp.getGreatestMinimum(field);
+    int end = tmp.getMinimum(field);
+    tmp.set(field, min);
+    for (; min > end; min--)
+      {
+	tmp.add(field, -1); // Try to get smaller
+	if (tmp.get(field) != min - 1)
+	  break; // Done if not successful
+      }
+    return min;
+  }
+
+  /**
+   * Gets the actual maximum value that is allowed for the specified field.
+   * This value is dependent on the values of the other fields.
+   * @param field the time field. One of the time field constants.
+   * @return the actual maximum value.
+   * @throws ArrayIndexOutOfBoundsException if the field is outside
+   *         the valid range.  The value of field must be >= 0 and
+   *         <= <code>FIELD_COUNT</code>.
+   * @since jdk1.2
+   */
+  public int getActualMaximum(int field)
+  {
+    Calendar tmp = (Calendar) clone(); // To avoid restoring state
+    int max = tmp.getLeastMaximum(field);
+    int end = tmp.getMaximum(field);
+    tmp.set(field, max);
+    for (; max < end; max++)
+      {
+	tmp.add(field, 1);
+	if (tmp.get(field) != max + 1)
+	  break;
+      }
+    return max;
+  }
+
+  /**
+   * Return a clone of this object.
+   */
+  public Object clone()
+  {
+    try
+      {
+	Calendar cal = (Calendar) super.clone();
+	cal.fields = (int[]) fields.clone();
+	cal.isSet = (boolean[]) isSet.clone();
+	return cal;
+      }
+    catch (CloneNotSupportedException ex)
+      {
+	return null;
+      }
+  }
+
+  private static final String[] fieldNames = 
+                                             {
+                                               ",ERA=", ",YEAR=", ",MONTH=",
+                                               ",WEEK_OF_YEAR=",
+                                               ",WEEK_OF_MONTH=",
+                                               ",DAY_OF_MONTH=",
+                                               ",DAY_OF_YEAR=", ",DAY_OF_WEEK=",
+                                               ",DAY_OF_WEEK_IN_MONTH=",
+                                               ",AM_PM=", ",HOUR=",
+                                               ",HOUR_OF_DAY=", ",MINUTE=",
+                                               ",SECOND=", ",MILLISECOND=",
+                                               ",ZONE_OFFSET=", ",DST_OFFSET="
+                                             };
+
+  /**
+   * Returns a string representation of this object.  It is mainly
+   * for debugging purposes and its content is implementation
+   * specific.
+   */
+  public String toString()
+  {
+    StringBuffer sb = new StringBuffer();
+    sb.append(getClass().getName()).append('[');
+    sb.append("time=");
+    if (isTimeSet)
+      sb.append(time);
+    else
+      sb.append("?");
+    sb.append(",zone=" + zone);
+    sb.append(",areFieldsSet=" + areFieldsSet);
+    for (int i = 0; i < FIELD_COUNT; i++)
+      {
+	sb.append(fieldNames[i]);
+	if (isSet[i])
+	  sb.append(fields[i]);
+	else
+	  sb.append("?");
+      }
+    sb.append(",lenient=").append(lenient);
+    sb.append(",firstDayOfWeek=").append(firstDayOfWeek);
+    sb.append(",minimalDaysInFirstWeek=").append(minimalDaysInFirstWeek);
+    sb.append("]");
+    return sb.toString();
+  }
+
+  /**
+   * Saves the state of the object to the stream.  Ideally we would
+   * only write the time field, but we need to be compatible with
+   * earlier versions. <br>
+   *
+   * This doesn't write the JDK1.1 field nextStamp to the stream, as
+   * I don't know what it is good for, and because the documentation
+   * says, that it could be omitted.  */
+  private void writeObject(ObjectOutputStream stream) throws IOException
+  {
+    if (! isTimeSet)
+      computeTime();
+    stream.defaultWriteObject();
+  }
+
+  /**
+   * Reads the object back from stream (deserialization).
+   */
+  private void readObject(ObjectInputStream stream)
+    throws IOException, ClassNotFoundException
+  {
+    stream.defaultReadObject();
+    if (! isTimeSet)
+      computeTime();
+
+    if (serialVersionOnStream > 1)
+      {
+	// This is my interpretation of the serial number:
+	// Sun wants to remove all fields from the stream someday
+	// and will then increase the serialVersion number again.
+	// We prepare to be compatible.
+	fields = new int[FIELD_COUNT];
+	isSet = new boolean[FIELD_COUNT];
+	areFieldsSet = false;
+      }
+  }
+}





More information about the llvm-commits mailing list