From 7af711a383eb84eabef5681eb3a05ae938ebdb59 Mon Sep 17 00:00:00 2001
From: Yoshito Umaoka May 8, 2009 The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
-at http://www.eclipse.org/legal/epl-v10.html.
-For purposes of the EPL, "Program" will mean the Content. If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party ("Redistributor") and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at http://www.eclipse.org. The Content includes items that have been sourced from third parties as set out below. If you
- did not receive this Content directly from the Eclipse Foundation, the following is provided
- for informational purposes only, and you should look to the Redistributor's license for
- terms and conditions of use. ICU4J 4.2
- Your use of ICU4J is subject to the terms and conditions of the ICU4J license. A copy of the
- license is contained in the file about_files/license.html.
- ICU4J bundles data files imported from the Unicode Character Database and the Locale Data. A copy of the
- Unicode Data and Software license is contained in the file about_files/ucdterms.txt.
- The project information including source code, documentations and demo programs are available on
- the ICU public web site. May 8, 2009 The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
-at http://www.eclipse.org/legal/epl-v10.html.
-For purposes of the EPL, "Program" will mean the Content. If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party ("Redistributor") and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at http://www.eclipse.org. The Content includes items that have been sourced from third parties as set out below. If you
- did not receive this Content directly from the Eclipse Foundation, the following is provided
- for informational purposes only, and you should look to the Redistributor's license for
- terms and conditions of use. ICU4J 4.2
- Your use of ICU4J is subject to the terms and conditions of the ICU4J license. A copy of the
- license is contained in the file about_files/license.html.
- The project information including source code, documentations and demo programs are available on
- the ICU public web site.About This Content
-
-License
-
-Third Party Content
-
- The plug-in includes software ("ICU4J") developed by International Business Machines
- Corporation and others.
-
- ICU4J is:
-
- Copyright (c) 1995-2009 International Business Machines Corporation and others
-
- All rights reserved.
- About This Content
-
-License
-
-Third Party Content
-
- The plug-in includes software ("ICU4J") developed by International Business Machines
- Corporation and others.
-
- ICU4J is:
-
- Copyright (c) 1995-2009 International Business Machines Corporation and others
-
- All rights reserved.
-
- * This class is not subclassable - *
- * @see Collator - * @see RuleBasedCollator - * @stable ICU 2.8 - */ -public final class CollationKey implements Comparable { - /** - * @internal - */ - final java.text.CollationKey key; - - /** - * @internal - */ - CollationKey(java.text.CollationKey delegate) { - this.key = delegate; - } - - /** - * Return the source string that this CollationKey represents. - * @return source string that this CollationKey represents - * @stable ICU 2.8 - */ - public String getSourceString() { - return key.getSourceString(); - } - - /** - *Duplicates and returns the value of this CollationKey as a sequence - * of big-endian bytes terminated by a null.
- * - *If two CollationKeys can be legitimately compared, then one can - * compare the byte arrays of each to obtain the same result, e.g. - *
- * byte key1[] = collationkey1.toByteArray(); - * byte key2[] = collationkey2.toByteArray(); - * int key, targetkey; - * int i = 0; - * do { - * key = key1[i] & 0xFF; - * targetkey = key2[i] & 0xFF; - * if (key < targetkey) { - * System.out.println("String 1 is less than string 2"); - * return; - * } - * if (targetkey < key) { - * System.out.println("String 1 is more than string 2"); - * } - * i ++; - * } while (key != 0 && targetKey != 0); - * - * System.out.println("Strings are equal."); - *- * - * @return CollationKey value in a sequence of big-endian byte bytes - * terminated by a null. - * @stable ICU 2.8 - */ - public byte[] toByteArray() { - return key.toByteArray(); - } - - /** - *
Compare this CollationKey to another CollationKey. The - * collation rules of the Collator that created this key are - * applied.
- * - *Note: Comparison between CollationKeys - * created by different Collators might return incorrect - * results. See class documentation.
- * - * @param target target CollationKey - * @return an integer value. If the value is less than zero this CollationKey - * is less than than target, if the value is zero they are equal, and - * if the value is greater than zero this CollationKey is greater - * than target. - * @exception NullPointerException is thrown if argument is null. - * @see Collator#compare(String, String) - * @stable ICU 2.8 - */ - public int compareTo(CollationKey target) { - return key.compareTo(target.key); - } - - /** - *Compare this CollationKey with the specified Object. The - * collation rules of the Collator that created this key are - * applied.
- * - *See note in compareTo(CollationKey) for warnings about possible - * incorrect results.
- * - * @param obj the Object to be compared to. - * @return Returns a negative integer, zero, or a positive integer - * respectively if this CollationKey is less than, equal to, or - * greater than the given Object. - * @exception ClassCastException is thrown when the argument is not - * a CollationKey. NullPointerException is thrown when the argument - * is null. - * @see #compareTo(CollationKey) - * @stable ICU 2.8 - */ - public int compareTo(Object o) { - return compareTo((CollationKey)o); - } - - /** - *Compare this CollationKey and the specified Object for - * equality. The collation rules of the Collator that created - * this key are applied.
- * - *See note in compareTo(CollationKey) for warnings about - * possible incorrect results.
- * - * @param target the object to compare to. - * @return true if the two keys compare as equal, false otherwise. - * @see #compareTo(CollationKey) - * @exception ClassCastException is thrown when the argument is not - * a CollationKey. NullPointerException is thrown when the argument - * is null. - * @stable ICU 2.8 - */ - public boolean equals(Object target) { - try { - return key.equals(((CollationKey)target).key); - } - catch (Exception e) { - return false; - } - } - - /** - *- * Compare this CollationKey and the argument target CollationKey for - * equality. - * The collation - * rules of the Collator object which created these objects are applied. - *
- *- * See note in compareTo(CollationKey) for warnings of incorrect results - *
- * @param target the CollationKey to compare to. - * @return true if two objects are equal, false otherwise. - * @exception NullPointerException is thrown when the argument is null. - * @stable ICU 2.8 - */ - public boolean equals(CollationKey target) { - return key.equals(target.key); - } - - /** - *Returns a hash code for this CollationKey. The hash value is calculated - * on the key itself, not the String from which the key was created. Thus - * if x and y are CollationKeys, then x.hashCode(x) == y.hashCode() - * if x.equals(y) is true. This allows language-sensitive comparison in a - * hash table. - *
- * @return the hash value. - * @stable ICU 2.8 - */ - public int hashCode() { - return key.hashCode(); - } - - /** - * Return a description of the CollationKey. - * @return a description of the CollationKey, used for debugging - * @stable ICU 3.4.2 - */ - public String toString() { - return key.toString(); - } -} diff --git a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/Collator.java b/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/Collator.java deleted file mode 100644 index 38f680d01e9..00000000000 --- a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/Collator.java +++ /dev/null @@ -1,565 +0,0 @@ -/* - ******************************************************************************* - * Copyright (C) 1996-2008, International Business Machines Corporation and * - * others. All Rights Reserved. * - ******************************************************************************* - */ - -package com.ibm.icu.text; - -import java.util.Comparator; -import java.util.Locale; - -import com.ibm.icu.util.ULocale; - -/** -*Collator performs locale-sensitive string comparison.
-* -*Following the Unicode -* Consortium's specifications for the -* Unicode Collation -* Algorithm (UCA), there are 5 different levels of strength used -* in comparisons: -* -*
For more information about the collation service see the -* users -* guide.
-* -*Examples of use -*
-* // Get the Collator for US English and set its strength to PRIMARY -* Collator usCollator = Collator.getInstance(Locale.US); -* usCollator.setStrength(Collator.PRIMARY); -* if (usCollator.compare("abc", "ABC") == 0) { -* System.out.println("Strings are equivalent"); -* } -* -* The following example shows how to compare two strings using the -* Collator for the default locale. -* -* // Compare two strings in the default locale -* Collator myCollator = Collator.getInstance(); -* myCollator.setDecomposition(NO_DECOMPOSITION); -* if (myCollator.compare("à\u0325", "a\u0325̀") != 0) { -* System.out.println("à\u0325 is not equals to a\u0325̀ without decomposition"); -* myCollator.setDecomposition(CANONICAL_DECOMPOSITION); -* if (myCollator.compare("à\u0325", "a\u0325̀") != 0) { -* System.out.println("Error: à\u0325 should be equals to a\u0325̀ with decomposition"); -* } -* else { -* System.out.println("à\u0325 is equals to a\u0325̀ with decomposition"); -* } -* } -* else { -* System.out.println("Error: à\u0325 should be not equals to a\u0325̀ without decomposition"); -* } -*-* -* @see CollationKey -* @author Syn Wee Quek -* @stable ICU 2.8 -*/ -public class Collator implements Comparator, Cloneable -{ - /** - * @internal - */ - private final java.text.Collator collator; - - /** - * @internal - */ - private Collator(java.text.Collator delegate) { - this.collator = delegate; - } - - /** - * Create a collator with a null delegate. - * For use by possible subclassers. This is present since - * the original Collator is abstract, and so, in theory - * subclassable. All member APIs must be overridden. - */ - protected Collator() { - this.collator = null; - } - - // public data members --------------------------------------------------- - - /** - * Strongest collator strength value. Typically used to denote differences - * between base characters. See class documentation for more explanation. - * @see #setStrength - * @see #getStrength - * @stable ICU 2.8 - */ - public final static int PRIMARY = java.text.Collator.PRIMARY; - - /** - * Second level collator strength value. - * Accents in the characters are considered secondary differences. - * Other differences between letters can also be considered secondary - * differences, depending on the language. - * See class documentation for more explanation. - * @see #setStrength - * @see #getStrength - * @stable ICU 2.8 - */ - public final static int SECONDARY = java.text.Collator.SECONDARY; - - /** - * Third level collator strength value. - * Upper and lower case differences in characters are distinguished at this - * strength level. In addition, a variant of a letter differs from the base - * form on the tertiary level. - * See class documentation for more explanation. - * @see #setStrength - * @see #getStrength - * @stable ICU 2.8 - */ - public final static int TERTIARY = java.text.Collator.TERTIARY; - - /** - * Fourth level collator strength value. - * When punctuation is ignored - * - * (see Ignoring Punctuations in the user guide) at PRIMARY to TERTIARY - * strength, an additional strength level can - * be used to distinguish words with and without punctuation. - * See class documentation for more explanation. - * @see #setStrength - * @see #getStrength - * @stable ICU 2.8 - */ - public final static int QUATERNARY = java.text.Collator.IDENTICAL; - - /** - *
- * Smallest Collator strength value. When all other strengths are equal, - * the IDENTICAL strength is used as a tiebreaker. The Unicode code point - * values of the NFD form of each string are compared, just in case there - * is no difference. - * See class documentation for more explanation. - *
- *- * Note this value is different from JDK's - *
- * @stable ICU 2.8 - */ - public final static int IDENTICAL = java.text.Collator.FULL_DECOMPOSITION; - - /** - * This is for backwards compatibility with Java APIs only. It - * should not be used, IDENTICAL should be used instead. ICU's - * collation does not support Java's FULL_DECOMPOSITION mode. - * @stable ICU 3.4 - * @deprecated Backwards compatibility with Java only. - */ - public final static int FULL_DECOMPOSITION = java.text.Collator.FULL_DECOMPOSITION; - - /** - *Decomposition mode value. With NO_DECOMPOSITION set, Strings - * will not be decomposed for collation. This is the default - * decomposition setting unless otherwise specified by the locale - * used to create the Collator.
- * - *Note this value is different from the JDK's.
- * @see #CANONICAL_DECOMPOSITION - * @see #getDecomposition - * @see #setDecomposition - * @stable ICU 2.8 - */ - public final static int NO_DECOMPOSITION = java.text.Collator.NO_DECOMPOSITION; - - /** - *Decomposition mode value. With CANONICAL_DECOMPOSITION set, - * characters that are canonical variants according to the Unicode standard - * will be decomposed for collation.
- * - *CANONICAL_DECOMPOSITION corresponds to Normalization Form D as - * described in - * Unicode Technical Report #15. - *
- * @see #NO_DECOMPOSITION - * @see #getDecomposition - * @see #setDecomposition - * @stable ICU 2.8 - */ - public final static int CANONICAL_DECOMPOSITION = java.text.Collator.CANONICAL_DECOMPOSITION; - - // public methods -------------------------------------------------------- - - // public setters -------------------------------------------------------- - - /** - *Sets this Collator's strength property. The strength property - * determines the minimum level of difference considered significant - * during comparison.
- * - *The default strength for the Collator is TERTIARY, unless specified - * otherwise by the locale used to create the Collator.
- * - *See the Collator class description for an example of use.
- * @param newStrength the new strength value. - * @see #getStrength - * @see #PRIMARY - * @see #SECONDARY - * @see #TERTIARY - * @see #QUATERNARY - * @see #IDENTICAL - * @exception IllegalArgumentException if the new strength value is not one - * of PRIMARY, SECONDARY, TERTIARY, QUATERNARY or IDENTICAL. - * @stable ICU 2.8 - */ - public void setStrength(int newStrength) { - collator.setStrength(newStrength); - } - - /** - *Set the decomposition mode of this Collator. Setting this - * decomposition property with CANONICAL_DECOMPOSITION allows the - * Collator to handle un-normalized text properly, producing the - * same results as if the text were normalized. If - * NO_DECOMPOSITION is set, it is the user's responsibility to - * insure that all text is already in the appropriate form before - * a comparison or before getting a CollationKey. Adjusting - * decomposition mode allows the user to select between faster and - * more complete collation behavior.
- * - *Since a great many of the world's languages do not require - * text normalization, most locales set NO_DECOMPOSITION as the - * default decomposition mode.
- * - * The default decompositon mode for the Collator is - * NO_DECOMPOSITON, unless specified otherwise by the locale used - * to create the Collator. - * - *See getDecomposition for a description of decomposition - * mode.
- * - * @param decomposition the new decomposition mode - * @see #getDecomposition - * @see #NO_DECOMPOSITION - * @see #CANONICAL_DECOMPOSITION - * @exception IllegalArgumentException If the given value is not a valid - * decomposition mode. - * @stable ICU 2.8 - */ - public void setDecomposition(int decomposition) { - collator.setDecomposition(decomposition); - } - - // public getters -------------------------------------------------------- - - /** - * Gets the Collator for the current default locale. - * The default locale is determined by java.util.Locale.getDefault(). - * @return the Collator for the default locale (for example, en_US) if it - * is created successfully. Otherwise if there is no Collator - * associated with the current locale, the default UCA collator - * will be returned. - * @see java.util.Locale#getDefault() - * @see #getInstance(Locale) - * @stable ICU 2.8 - */ - public static final Collator getInstance() { - return new Collator(java.text.Collator.getInstance()); - } - - /** - * Gets the Collator for the desired locale. - * @param locale the desired locale. - * @return Collator for the desired locale if it is created successfully. - * Otherwise if there is no Collator - * associated with the current locale, a default UCA collator will - * be returned. - * @see java.util.Locale - * @see java.util.ResourceBundle - * @see #getInstance(Locale) - * @see #getInstance() - * @stable ICU 3.4.3 - */ - public static final Collator getInstance(ULocale locale) { - return getInstance(locale.toLocale()); - } - - /** - * Gets the Collator for the desired locale. - * @param locale the desired locale. - * @return Collator for the desired locale if it is created successfully. - * Otherwise if there is no Collator - * associated with the current locale, a default UCA collator will - * be returned. - * @see java.util.Locale - * @see java.util.ResourceBundle - * @see #getInstance(ULocale) - * @see #getInstance() - * @stable ICU 2.8 - */ - public static final Collator getInstance(Locale locale) { - return new Collator(java.text.Collator.getInstance(locale)); - } - - /** - * Get the set of locales, as Locale objects, for which collators - * are installed. Note that Locale objects do not support RFC 3066. - * @return the list of locales in which collators are installed. - * This list includes any that have been registered, in addition to - * those that are installed with ICU4J. - * @stable ICU 2.4 - */ - public static Locale[] getAvailableLocales() { - return java.text.Collator.getAvailableLocales(); - } - - /** - * Get the set of locales, as ULocale objects, for which collators - * are installed. ULocale objects support RFC 3066. - * @return the list of locales in which collators are installed. - * This list includes any that have been registered, in addition to - * those that are installed with ICU4J. - * @stable ICU 3.4.3 - */ - public static final ULocale[] getAvailableULocales() { - Locale[] locales = java.text.Collator.getAvailableLocales(); - ULocale[] ulocales = new ULocale[locales.length]; - for (int i = 0; i < locales.length; ++i) { - ulocales[i] = ULocale.forLocale(locales[i]); - } - return ulocales; - } - - /** - * Return an array of all possible keywords that are relevant to - * collation. At this point, the only recognized keyword for this - * service is "collation". - * @return an array of valid collation keywords. - * @see #getKeywordValues - * @stable ICU 3.0 - */ - public static final String[] getKeywords() { - return new String[0]; - } - - /** - * Given a keyword, return an array of all values for - * that keyword that are currently in use. - * @param keyword one of the keywords returned by getKeywords. - * @see #getKeywords - * @stable ICU 3.0 - */ - public static final String[] getKeywordValues(String keyword) { - return new String[0]; - } - - /** - *Returns this Collator's strength property. The strength property - * determines the minimum level of difference considered significant. - *
- *- * See the Collator class description for more details. - *
- * @return this Collator's current strength property. - * @see #setStrength - * @see #PRIMARY - * @see #SECONDARY - * @see #TERTIARY - * @see #QUATERNARY - * @see #IDENTICAL - * @stable ICU 2.8 - */ - public int getStrength() { - return collator.getStrength(); - } - - /** - *- * Get the decomposition mode of this Collator. Decomposition mode - * determines how Unicode composed characters are handled. - *
- *- * See the Collator class description for more details. - *
- * @return the decomposition mode - * @see #setDecomposition - * @see #NO_DECOMPOSITION - * @see #CANONICAL_DECOMPOSITION - * @stable ICU 2.8 - */ - public int getDecomposition() { - return collator.getDecomposition(); - } - - /** - *- * Compares the source text String to the target text String according to - * this Collator's rules, strength and decomposition mode. - * Returns an integer less than, - * equal to or greater than zero depending on whether the source String is - * less than, equal to or greater than the target String. See the Collator - * class description for an example of use. - *
- * @param source the source String. - * @param target the target String. - * @return Returns an integer value. Value is less than zero if source is - * less than target, value is zero if source and target are equal, - * value is greater than zero if source is greater than target. - * @see CollationKey - * @see #getCollationKey - * @exception NullPointerException thrown if either arguments is null. - * IllegalArgumentException thrown if either source or target is - * not of the class String. - * @stable ICU 2.8 - */ - public int compare(Object source, Object target) { - return collator.compare(source, target); - } - - // public other methods ------------------------------------------------- - - /** - * Convenience method for comparing the equality of two text Strings using - * this Collator's rules, strength and decomposition mode. - * @param source the source string to be compared. - * @param target the target string to be compared. - * @return true if the strings are equal according to the collation - * rules, otherwise false. - * @see #compare - * @exception NullPointerException thrown if either arguments is null. - * @stable ICU 2.8 - */ - public boolean equals(String source, String target) { - return (compare(source, target) == 0); - } - - /** - *- * Compares the source text String to the target text String according to - * this Collator's rules, strength and decomposition mode. - * Returns an integer less than, - * equal to or greater than zero depending on whether the source String is - * less than, equal to or greater than the target String. See the Collator - * class description for an example of use. - *
- * @param source the source String. - * @param target the target String. - * @return Returns an integer value. Value is less than zero if source is - * less than target, value is zero if source and target are equal, - * value is greater than zero if source is greater than target. - * @see CollationKey - * @see #getCollationKey - * @exception NullPointerException thrown if either arguments is null. - * @stable ICU 2.8 - */ - public int compare(String source, String target) { - return collator.compare(source, target); - } - - /** - *- * Transforms the String into a CollationKey suitable for efficient - * repeated comparison. The resulting key depends on the collator's - * rules, strength and decomposition mode. - *
- *See the CollationKey class documentation for more information.
- * @param source the string to be transformed into a CollationKey. - * @return the CollationKey for the given String based on this Collator's - * collation rules. If the source String is null, a null - * CollationKey is returned. - * @see CollationKey - * @see #compare(String, String) - * @stable ICU 2.8 - */ - public CollationKey getCollationKey(String source) { - return new CollationKey(collator.getCollationKey(source)); - } - - /** - * Return a string suitable for debugging. - * @return a string suitable for debugging - * @stable ICU 3.4.3 - */ - public String toString() { - return collator.toString(); - } - - /** - * Clone the collator. - * @return a clone of this collator. - * @stable ICU 2.6 - */ - public Object clone() throws CloneNotSupportedException { - return new Collator((java.text.Collator)collator.clone()); - } - - /** - * Return true if rhs is a Collator and compares the same as this. - * @return true if rhs equals this - * @stable ICU 3.4.3 - */ - public boolean equals(Object rhs) { - try { - return collator.equals(((Collator)rhs).collator); - } - catch (Exception e) { - return false; - } - } - - /** - * Return a hashCode. - * @return a hashCode - * @stable ICU 3.4.3 - */ - public int hashCode() { - return collator.hashCode(); - } -} diff --git a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/DateFormat.java b/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/DateFormat.java deleted file mode 100644 index dce51f10950..00000000000 --- a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/DateFormat.java +++ /dev/null @@ -1,983 +0,0 @@ -/* - ******************************************************************************* - * Copyright (C) 1996-2008, International Business Machines Corporation and * - * others. All Rights Reserved. * - ******************************************************************************* - */ - -package com.ibm.icu.text; - -import java.text.FieldPosition; -import java.text.Format; -import java.text.ParseException; -import java.text.ParsePosition; -import java.util.Date; -import java.util.Locale; - -import com.ibm.icu.util.Calendar; -import com.ibm.icu.util.TimeZone; -import com.ibm.icu.util.ULocale; - -/** - * DateFormat is an abstract class for date/time formatting subclasses which - * formats and parses dates or time in a language-independent manner. - * The date/time formatting subclass, such as SimpleDateFormat, allows for - * formatting (i.e., date -> text), parsing (text -> date), and - * normalization. The date is represented as aDate
object or
- * as the milliseconds since January 1, 1970, 00:00:00 GMT.
- *
- * DateFormat provides many class methods for obtaining default date/time - * formatters based on the default or a given loacle and a number of formatting - * styles. The formatting styles include FULL, LONG, MEDIUM, and SHORT. More - * detail and examples of using these styles are provided in the method - * descriptions. - * - *
DateFormat helps you to format and parse dates for any locale. - * Your code can be completely independent of the locale conventions for - * months, days of the week, or even the calendar format: lunar vs. solar. - * - *
To format a date for the current Locale, use one of the - * static factory methods: - *
- * myString = DateFormat.getDateInstance().format(myDate); - *- *
If you are formatting multiple numbers, it is - * more efficient to get the format and use it multiple times so that - * the system doesn't have to fetch the information about the local - * language and country conventions multiple times. - *
- * DateFormat df = DateFormat.getDateInstance(); - * for (int i = 0; i < a.length; ++i) { - * output.println(df.format(myDate[i]) + "; "); - * } - *- *
To format a number for a different Locale, specify it in the - * call to getDateInstance(). - *
- * DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, Locale.FRANCE); - *- *
You can use a DateFormat to parse also. - *
- * myDate = df.parse(myString); - *- *
Use getDateInstance to get the normal date format for that country. - * There are other static factory methods available. - * Use getTimeInstance to get the time format for that country. - * Use getDateTimeInstance to get a date and time format. You can pass in - * different options to these factory methods to control the length of the - * result; from SHORT to MEDIUM to LONG to FULL. The exact result depends - * on the locale, but generally: - *
You can also set the time zone on the format if you wish. - * If you want even more control over the format or parsing, - * (or want to give your users more control), - * you can try casting the DateFormat you get from the factory methods - * to a SimpleDateFormat. This will work for the majority - * of countries; just remember to put it in a try block in case you - * encounter an unusual one. - * - *
You can also use forms of the parse and format methods with - * ParsePosition and FieldPosition to - * allow you to - *
By default, parsing is lenient: If the input is not in the form used - * by this object's format method but can still be parsed as a date, then - * the parse succeeds. Clients may insist on strict adherence to the - * format by calling setLenient(false). - * - * @see #setLenient(boolean) - * - * @param text The date/time string to be parsed - * - * @param cal The calendar into which parsed data will be stored. - * In general, this should be cleared before calling this - * method. If this parse fails, the calendar may still - * have been modified. - * - * @param pos On input, the position at which to start parsing; on - * output, the position at which parsing terminated, or the - * start position if the parse failed. - * @stable ICU 2.0 - */ - public void parse(String text, Calendar cal, ParsePosition pos) { - Date result = dateFormat.parse(text, pos); - cal.setTime(result); - } - - /** - * Parse a date/time string according to the given parse position. For - * example, a time text "07/10/96 4:5 PM, PDT" will be parsed into a Date - * that is equivalent to Date(837039928046). - * - *
By default, parsing is lenient: If the input is not in the form used
- * by this object's format method but can still be parsed as a date, then
- * the parse succeeds. Clients may insist on strict adherence to the
- * format by calling setLenient(false).
- *
- * @see #setLenient(boolean)
- *
- * @param text The date/time string to be parsed
- *
- * @param pos On input, the position at which to start parsing; on
- * output, the position at which parsing terminated, or the
- * start position if the parse failed.
- *
- * @return A Date, or null if the input could not be parsed
- * @stable ICU 2.0
- */
- public Date parse(String text, ParsePosition pos) {
- return dateFormat.parse(text, pos);
- }
-
- /**
- * Parse a date/time string into an Object. This convenience method simply
- * calls parse(String, ParsePosition).
- *
- * @see #parse(String, ParsePosition)
- * @stable ICU 2.0
- */
- public Object parseObject(String source, ParsePosition pos) {
- return parse(source, pos);
- }
-
- /**
- * Constant for full style pattern.
- * @stable ICU 2.0
- */
- public static final int FULL = 0;
-
- /**
- * Constant for long style pattern.
- * @stable ICU 2.0
- */
- public static final int LONG = 1;
-
- /**
- * Constant for medium style pattern.
- * @stable ICU 2.0
- */
- public static final int MEDIUM = 2;
-
- /**
- * Constant for short style pattern.
- * @stable ICU 2.0
- */
- public static final int SHORT = 3;
-
- /**
- * Constant for default style pattern. Its value is MEDIUM.
- * @stable ICU 2.0
- */
- public static final int DEFAULT = MEDIUM;
-
- /**
- * Gets the time formatter with the default formatting style
- * for the default locale.
- * @return a time formatter.
- * @stable ICU 2.0
- */
- public final static DateFormat getTimeInstance() {
- return new DateFormat(java.text.DateFormat.getTimeInstance());
- }
-
- /**
- * Gets the time formatter with the given formatting style
- * for the default locale.
- * @param style the given formatting style. For example,
- * SHORT for "h:mm a" in the US locale.
- * @return a time formatter.
- * @stable ICU 2.0
- */
- public final static DateFormat getTimeInstance(int style) {
- return new DateFormat(java.text.DateFormat.getTimeInstance(style));
- }
-
- /**
- * Gets the time formatter with the given formatting style
- * for the given locale.
- * @param style the given formatting style. For example,
- * SHORT for "h:mm a" in the US locale.
- * @param aLocale the given locale.
- * @return a time formatter.
- * @stable ICU 2.0
- */
- public final static DateFormat getTimeInstance(int style, Locale aLocale) {
- return new DateFormat(java.text.DateFormat.getTimeInstance(style, aLocale));
- }
-
- /**
- * Gets the time formatter with the given formatting style
- * for the given locale.
- * @param style the given formatting style. For example,
- * SHORT for "h:mm a" in the US locale.
- * @param aLocale the given locale.
- * @return a time formatter.
- * @stable ICU 3.2
- */
- public final static DateFormat getTimeInstance(int style, ULocale aLocale) {
- return new DateFormat(java.text.DateFormat.getTimeInstance(style, aLocale.toLocale()));
- }
-
- /**
- * Gets the date formatter with the default formatting style
- * for the default locale.
- * @return a date formatter.
- * @stable ICU 2.0
- */
- public final static DateFormat getDateInstance() {
- return new DateFormat(java.text.DateFormat.getDateInstance());
- }
-
- /**
- * Gets the date formatter with the given formatting style
- * for the default locale.
- * @param style the given formatting style. For example,
- * SHORT for "M/d/yy" in the US locale.
- * @return a date formatter.
- * @stable ICU 2.0
- */
- public final static DateFormat getDateInstance(int style) {
- return new DateFormat(java.text.DateFormat.getDateInstance(style));
- }
-
- /**
- * Gets the date formatter with the given formatting style
- * for the given locale.
- * @param style the given formatting style. For example,
- * SHORT for "M/d/yy" in the US locale.
- * @param aLocale the given locale.
- * @return a date formatter.
- * @stable ICU 2.0
- */
- public final static DateFormat getDateInstance(int style, Locale aLocale) {
- return new DateFormat(java.text.DateFormat.getDateInstance(style, aLocale));
- }
-
- /**
- * Gets the date formatter with the given formatting style
- * for the given locale.
- * @param style the given formatting style. For example,
- * SHORT for "M/d/yy" in the US locale.
- * @param aLocale the given locale.
- * @return a date formatter.
- * @stable ICU 3.4.3
- */
- public final static DateFormat getDateInstance(int style, ULocale aLocale) {
- return new DateFormat(java.text.DateFormat.getDateInstance(style, aLocale.toLocale()));
- }
-
- /**
- * Gets the date/time formatter with the default formatting style
- * for the default locale.
- * @return a date/time formatter.
- * @stable ICU 2.0
- */
- public final static DateFormat getDateTimeInstance() {
- return new DateFormat(java.text.DateFormat.getDateTimeInstance());
- }
-
- /**
- * Gets the date/time formatter with the given date and time
- * formatting styles for the default locale.
- * @param dateStyle the given date formatting style. For example,
- * SHORT for "M/d/yy" in the US locale.
- * @param timeStyle the given time formatting style. For example,
- * SHORT for "h:mm a" in the US locale.
- * @return a date/time formatter.
- * @stable ICU 2.0
- */
- public final static DateFormat getDateTimeInstance(int dateStyle, int timeStyle) {
- return new DateFormat(java.text.DateFormat.getDateTimeInstance(dateStyle, timeStyle));
- }
-
- /**
- * Gets the date/time formatter with the given formatting styles
- * for the given locale.
- * @param dateStyle the given date formatting style.
- * @param timeStyle the given time formatting style.
- * @param aLocale the given locale.
- * @return a date/time formatter.
- * @stable ICU 2.0
- */
- public final static DateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale aLocale) {
- return new DateFormat(java.text.DateFormat.getDateTimeInstance(dateStyle, timeStyle, aLocale));
- }
-
- /**
- * Gets the date/time formatter with the given formatting styles
- * for the given locale.
- * @param dateStyle the given date formatting style.
- * @param timeStyle the given time formatting style.
- * @param aLocale the given locale.
- * @return a date/time formatter.
- * @stable ICU 3.4.3
- */
- public final static DateFormat getDateTimeInstance(int dateStyle, int timeStyle, ULocale aLocale) {
- return new DateFormat(java.text.DateFormat.getDateTimeInstance(dateStyle, timeStyle, aLocale.toLocale()));
- }
-
- /**
- * Get a default date/time formatter that uses the SHORT style for both the
- * date and the time.
- * @stable ICU 2.0
- */
- public final static DateFormat getInstance() {
- return new DateFormat(java.text.DateFormat.getInstance());
- }
-
- /**
- * Gets the set of locales for which DateFormats are installed.
- * @return the set of locales for which DateFormats are installed.
- * @stable ICU 2.0
- */
- public static Locale[] getAvailableLocales() {
- return java.text.DateFormat.getAvailableLocales();
- }
-
- /**
- * Gets the set of locales for which DateFormats are installed.
- * @return the set of locales for which DateFormats are installed.
- * @stable ICU 3.4.3
- */
- public static ULocale[] getAvailableULocales() {
- Locale[] locales = java.text.DateFormat.getAvailableLocales();
- ULocale[] ulocales = new ULocale[locales.length];
- for (int i = 0; i < locales.length; ++i) {
- ulocales[i] = ULocale.forLocale(locales[i]);
- }
- return ulocales;
- }
-
- /**
- * Set the calendar to be used by this date format. Initially, the default
- * calendar for the specified or default locale is used.
- * @param newCalendar the new Calendar to be used by the date format
- * @stable ICU 2.0
- */
- public void setCalendar(Calendar newCalendar) {
- dateFormat.setCalendar(newCalendar.calendar);
- }
-
- /**
- * Gets the calendar associated with this date/time formatter.
- * @return the calendar associated with this date/time formatter.
- * @stable ICU 2.0
- */
- public Calendar getCalendar() {
- return new Calendar(dateFormat.getCalendar());
- }
-
- /**
- * Allows you to set the number formatter.
- * @param newNumberFormat the given new NumberFormat.
- * @stable ICU 2.0
- */
- public void setNumberFormat(NumberFormat newNumberFormat) {
- dateFormat.setNumberFormat(newNumberFormat.numberFormat);
- }
-
- /**
- * Gets the number formatter which this date/time formatter uses to
- * format and parse a time.
- * @return the number formatter which this date/time formatter uses.
- * @stable ICU 2.0
- */
- public NumberFormat getNumberFormat() {
- return new NumberFormat(dateFormat.getNumberFormat());
- }
-
- /**
- * Sets the time zone for the calendar of this DateFormat object.
- * @param zone the given new time zone.
- * @stable ICU 2.0
- */
- public void setTimeZone(TimeZone zone) {
- dateFormat.setTimeZone(zone.timeZone);
- }
-
- /**
- * Gets the time zone.
- * @return the time zone associated with the calendar of DateFormat.
- * @stable ICU 2.0
- */
- public TimeZone getTimeZone() {
- return new TimeZone(dateFormat.getTimeZone());
- }
-
- /**
- * Specify whether or not date/time parsing is to be lenient. With
- * lenient parsing, the parser may use heuristics to interpret inputs that
- * do not precisely match this object's format. With strict parsing,
- * inputs must match this object's format.
- * @param lenient when true, parsing is lenient
- * @see com.ibm.icu.util.Calendar#setLenient
- * @stable ICU 2.0
- */
- public void setLenient(boolean lenient) {
- dateFormat.setLenient(lenient);
- }
-
- /**
- * Tell whether date/time parsing is to be lenient.
- * @stable ICU 2.0
- */
- public boolean isLenient() {
- return dateFormat.isLenient();
- }
-
- /**
- * Create a {@link DateFormat} object that can be used to format dates in
- * the calendar system specified by cal
.
- *
- * @param cal The calendar system for which a date format is desired.
- *
- * @param dateStyle The type of date format desired. This can be
- * {@link DateFormat#SHORT}, {@link DateFormat#MEDIUM},
- * etc.
- *
- * @param locale The locale for which the date format is desired.
- * @stable ICU 2.0
- */
- static final public DateFormat getDateInstance(Calendar cal, int dateStyle, Locale locale) {
- DateFormat df = getDateInstance(dateStyle, locale);
- df.setCalendar(cal);
- return df;
- }
-
- /**
- * Create a {@link DateFormat} object that can be used to format dates in
- * the calendar system specified by cal
.
- *
- * @param cal The calendar system for which a date format is desired.
- *
- * @param dateStyle The type of date format desired. This can be
- * {@link DateFormat#SHORT}, {@link DateFormat#MEDIUM},
- * etc.
- *
- * @param locale The locale for which the date format is desired.
- * @stable ICU 3.2
- */
- static final public DateFormat getDateInstance(Calendar cal, int dateStyle, ULocale locale) {
- DateFormat df = getDateInstance(dateStyle, locale);
- df.setCalendar(cal);
- return df;
- }
-
- /**
- * Create a {@link DateFormat} object that can be used to format times in
- * the calendar system specified by cal
.
- *
- * Note: When this functionality is moved into the core JDK, this method - * will probably be replaced by a new overload of {@link DateFormat#getInstance}. - *
- * @param cal The calendar system for which a time format is desired.
- *
- * @param timeStyle The type of time format desired. This can be
- * {@link DateFormat#SHORT}, {@link DateFormat#MEDIUM},
- * etc.
- *
- * @param locale The locale for which the time format is desired.
- *
- * @see DateFormat#getTimeInstance
- * @stable ICU 2.0
- */
- static final public DateFormat getTimeInstance(Calendar cal, int timeStyle, Locale locale) {
- DateFormat df = getTimeInstance(timeStyle, locale);
- df.setCalendar(cal);
- return df;
- }
-
- /**
- * Create a {@link DateFormat} object that can be used to format times in
- * the calendar system specified by cal
.
- *
- * Note: When this functionality is moved into the core JDK, this method - * will probably be replaced by a new overload of {@link DateFormat#getInstance}. - *
- * @param cal The calendar system for which a time format is desired.
- *
- * @param timeStyle The type of time format desired. This can be
- * {@link DateFormat#SHORT}, {@link DateFormat#MEDIUM},
- * etc.
- *
- * @param locale The locale for which the time format is desired.
- *
- * @see DateFormat#getTimeInstance
- * @stable ICU 3.2
- */
- static final public DateFormat getTimeInstance(Calendar cal, int timeStyle, ULocale locale) {
- DateFormat df = getTimeInstance(timeStyle, locale);
- df.setCalendar(cal);
- return df;
- }
-
- /**
- * Create a {@link DateFormat} object that can be used to format dates and times in
- * the calendar system specified by cal
.
- *
- * Note: When this functionality is moved into the core JDK, this method - * will probably be replaced by a new overload of {@link DateFormat#getInstance}. - *
- * @param cal The calendar system for which a date/time format is desired.
- *
- * @param dateStyle The type of date format desired. This can be
- * {@link DateFormat#SHORT}, {@link DateFormat#MEDIUM},
- * etc.
- *
- * @param timeStyle The type of time format desired. This can be
- * {@link DateFormat#SHORT}, {@link DateFormat#MEDIUM},
- * etc.
- *
- * @param locale The locale for which the date/time format is desired.
- *
- * @see DateFormat#getDateTimeInstance
- * @stable ICU 2.0
- */
- static final public DateFormat getDateTimeInstance(Calendar cal, int dateStyle,
- int timeStyle, Locale locale) {
- DateFormat df = getDateTimeInstance(dateStyle, timeStyle, locale);
- df.setCalendar(cal);
- return df;
- }
-
- /**
- * Create a {@link DateFormat} object that can be used to format dates and times in
- * the calendar system specified by cal
.
- *
- * Note: When this functionality is moved into the core JDK, this method - * will probably be replaced by a new overload of {@link DateFormat#getInstance}. - *
- * @param cal The calendar system for which a date/time format is desired.
- *
- * @param dateStyle The type of date format desired. This can be
- * {@link DateFormat#SHORT}, {@link DateFormat#MEDIUM},
- * etc.
- *
- * @param timeStyle The type of time format desired. This can be
- * {@link DateFormat#SHORT}, {@link DateFormat#MEDIUM},
- * etc.
- *
- * @param locale The locale for which the date/time format is desired.
- *
- * @see DateFormat#getDateTimeInstance
- * @stable ICU 3.2
- */
- static final public DateFormat getDateTimeInstance(Calendar cal, int dateStyle,
- int timeStyle, ULocale locale) {
- DateFormat df = getDateTimeInstance(dateStyle, timeStyle, locale);
- df.setCalendar(cal);
- return df;
- }
-
- /**
- * Convenience overload
- * @stable ICU 2.0
- */
- static final public DateFormat getInstance(Calendar cal, Locale locale) {
- return getDateTimeInstance(cal, MEDIUM, SHORT, locale);
- }
-
- /**
- * Convenience overload
- * @stable ICU 3.2
- */
- public static final DateFormat getInstance(Calendar cal, ULocale locale) {
- return getDateTimeInstance(cal, MEDIUM, SHORT, locale);
- }
-
- /**
- * Convenience overload
- * @stable ICU 2.0
- */
- public static final DateFormat getInstance(Calendar cal) {
- return getDateTimeInstance(cal, MEDIUM, SHORT, ULocale.getDefault());
- }
-
- /**
- * Convenience overload
- * @stable ICU 2.0
- */
- public static final DateFormat getDateInstance(Calendar cal, int dateStyle) {
- DateFormat df = getDateInstance(dateStyle);
- df.setCalendar(cal);
- return df;
- }
-
- /**
- * Convenience overload
- * @stable ICU 2.0
- */
- static final public DateFormat getTimeInstance(Calendar cal, int timeStyle) {
- DateFormat df = getTimeInstance(timeStyle);
- df.setCalendar(cal);
- return df;
- }
-
- /**
- * Convenience overload
- * @stable ICU 2.0
- */
- static final public DateFormat getDateTimeInstance(Calendar cal, int dateStyle, int timeStyle) {
- DateFormat df = getDateTimeInstance(dateStyle, timeStyle);
- df.setCalendar(cal);
- return df;
- }
-
- /**
- * Return a string suitable for debugging.
- * @return a string suitable for debugging
- * @stable ICU 3.4.3
- */
- public String toString() {
- return dateFormat.toString();
- }
-
- /**
- * Return a clone of this DateFormat.
- * @return a clone of this DateFormat
- * @stable ICU 3.4.3
- */
- public Object clone() {
- return new DateFormat((java.text.DateFormat)dateFormat.clone());
- }
-
- /**
- * Return true if rhs is a DateFormatSymbols and has the same symbols as this.
- * @return true if rhs equals this
- * @stable ICU 3.4.3
- */
- public boolean equals(Object arg0) {
- try {
- return dateFormat.equals(((DateFormat)arg0).dateFormat);
- }
- catch (Exception e) {
- return false;
- }
- }
-
- /**
- * Return a hashCode.
- * @return a hashCode
- * @stable ICU 3.4.3
- */
- public int hashCode() {
- return dateFormat.hashCode();
- }
-}
diff --git a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/DateFormatSymbols.java b/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/DateFormatSymbols.java
deleted file mode 100644
index 76319cd2899..00000000000
--- a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/DateFormatSymbols.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- *******************************************************************************
- * Copyright (C) 1996-2008, International Business Machines Corporation and *
- * others. All Rights Reserved. *
- *******************************************************************************
- */
-
-package com.ibm.icu.text;
-
-import java.io.Serializable;
-import java.util.Locale;
-
-import com.ibm.icu.util.ULocale;
-
-/**
- * DateFormatSymbols
is a public class for encapsulating
- * localizable date-time formatting data, such as the names of the
- * months, the names of the days of the week, and the time zone data.
- * DateFormat
and SimpleDateFormat
both use
- * DateFormatSymbols
to encapsulate this information.
- *
- *
- * Typically you shouldn't use DateFormatSymbols
directly.
- * Rather, you are encouraged to create a date-time formatter with the
- * DateFormat
class's factory methods: getTimeInstance
,
- * getDateInstance
, or getDateTimeInstance
.
- * These methods automatically create a DateFormatSymbols
for
- * the formatter so that you don't have to. After the
- * formatter is created, you may modify its format pattern using the
- * setPattern
method. For more information about
- * creating formatters using DateFormat
's factory methods,
- * see {@link DateFormat}.
- *
- *
- * If you decide to create a date-time formatter with a specific - * format pattern for a specific locale, you can do so with: - *
- *- * - *- * new SimpleDateFormat(aPattern, new DateFormatSymbols(aLocale)). - *- *
- * DateFormatSymbols
objects are clonable. When you obtain
- * a DateFormatSymbols
object, feel free to modify the
- * date-time formatting data. For instance, you can replace the localized
- * date-time format pattern characters with the ones that you feel easy
- * to remember. Or you can change the representative cities
- * to your favorite ones.
- *
- *
- * New DateFormatSymbols
subclasses may be added to support
- * SimpleDateFormat
for date-time formatting for additional locales.
-
- * @see DateFormat
- * @see SimpleDateFormat
- * @see com.ibm.icu.util.SimpleTimeZone
- * @author Chen-Lieh Huang
- * @stable ICU 2.0
- */
-public class DateFormatSymbols implements Serializable, Cloneable {
- private static final long serialVersionUID = 1;
-
- /** @internal */
- public java.text.DateFormatSymbols dfs;
-
- /** @internal */
- public DateFormatSymbols(java.text.DateFormatSymbols delegate) {
- this.dfs = delegate;
- }
-
- /**
- * Construct a DateFormatSymbols object by loading format data from
- * resources for the default locale.
- *
- * @throws java.util.MissingResourceException
- * if the resources for the default locale cannot be
- * found or cannot be loaded.
- * @stable ICU 2.0
- */
- public DateFormatSymbols() {
- this(new java.text.DateFormatSymbols());
- }
-
- /**
- * Construct a DateFormatSymbols object by loading format data from
- * resources for the given locale.
- *
- * @throws java.util.MissingResourceException
- * if the resources for the specified locale cannot be
- * found or cannot be loaded.
- * @stable ICU 2.0
- */
- public DateFormatSymbols(Locale locale) {
- this(new java.text.DateFormatSymbols(locale));
- }
-
- /**
- * Construct a DateFormatSymbols object by loading format data from
- * resources for the given ulocale.
- *
- * @throws java.util.MissingResourceException
- * if the resources for the specified locale cannot be
- * found or cannot be loaded.
- * @stable ICU 3.2
- */
- public DateFormatSymbols(ULocale locale) {
- this(new java.text.DateFormatSymbols(locale.toLocale()));
- }
-
- /**
- * Gets era strings. For example: "AD" and "BC".
- * @return the era strings.
- * @stable ICU 2.0
- */
- public String[] getEras() {
- return dfs.getEras();
- }
-
- /**
- * Sets era strings. For example: "AD" and "BC".
- * @param newEras the new era strings.
- * @stable ICU 2.0
- */
- public void setEras(String[] newEras) {
- dfs.setEras(newEras);
- }
-
- /**
- * Gets month strings. For example: "January", "February", etc.
- * @return the month strings.
- * @stable ICU 2.0
- */
- public String[] getMonths() {
- return dfs.getMonths();
- }
-
- /**
- * Sets month strings. For example: "January", "February", etc.
- * @param newMonths the new month strings.
- * @stable ICU 2.0
- */
- public void setMonths(String[] newMonths) {
- dfs.setMonths(newMonths);
- }
-
- /**
- * Gets short month strings. For example: "Jan", "Feb", etc.
- * @return the short month strings.
- * @stable ICU 2.0
- */
- public String[] getShortMonths() {
- return dfs.getShortMonths();
- }
-
- /**
- * Sets short month strings. For example: "Jan", "Feb", etc.
- * @param newShortMonths the new short month strings.
- * @stable ICU 2.0
- */
- public void setShortMonths(String[] newShortMonths) {
- dfs.setShortMonths(newShortMonths);
- }
-
- /**
- * Gets weekday strings. For example: "Sunday", "Monday", etc.
- * @return the weekday strings. Use Calendar.SUNDAY
,
- * Calendar.MONDAY
, etc. to index the result array.
- * @stable ICU 2.0
- */
- public String[] getWeekdays() {
- return dfs.getWeekdays();
- }
-
- /**
- * Sets weekday strings. For example: "Sunday", "Monday", etc.
- * @param newWeekdays the new weekday strings. The array should
- * be indexed by Calendar.SUNDAY
,
- * Calendar.MONDAY
, etc.
- * @stable ICU 2.0
- */
- public void setWeekdays(String[] newWeekdays) {
- dfs.setWeekdays(newWeekdays);
- }
-
- /**
- * Gets short weekday strings. For example: "Sun", "Mon", etc.
- * @return the short weekday strings. Use Calendar.SUNDAY
,
- * Calendar.MONDAY
, etc. to index the result array.
- * @stable ICU 2.0
- */
- public String[] getShortWeekdays() {
- return dfs.getShortWeekdays();
- }
-
- /**
- * Sets short weekday strings. For example: "Sun", "Mon", etc.
- * @param newShortWeekdays the new short weekday strings. The array should
- * be indexed by Calendar.SUNDAY
,
- * Calendar.MONDAY
, etc.
- * @stable ICU 2.0
- */
- public void setShortWeekdays(String[] newShortWeekdays) {
- dfs.setShortWeekdays(newShortWeekdays);
- }
-
- /**
- * Gets ampm strings. For example: "AM" and "PM".
- * @return the weekday strings.
- * @stable ICU 2.0
- */
- public String[] getAmPmStrings() {
- return dfs.getAmPmStrings();
- }
-
- /**
- * Sets ampm strings. For example: "AM" and "PM".
- * @param newAmpms the new ampm strings.
- * @stable ICU 2.0
- */
- public void setAmPmStrings(String[] newAmpms) {
- dfs.setAmPmStrings(newAmpms);
- }
-
- /**
- * Gets timezone strings.
- * @return the timezone strings.
- * @stable ICU 2.0
- */
- public String[][] getZoneStrings() {
- return dfs.getZoneStrings();
- }
-
- /**
- * Sets timezone strings.
- * @param newZoneStrings the new timezone strings.
- * @stable ICU 2.0
- */
- public void setZoneStrings(String[][] newZoneStrings) {
- dfs.setZoneStrings(newZoneStrings);
- }
-
- /**
- * Gets localized date-time pattern characters. For example: 'u', 't', etc.
- * @return the localized date-time pattern characters.
- * @stable ICU 2.0
- */
- public String getLocalPatternChars() {
- return dfs.getLocalPatternChars();
- }
-
- /**
- * Sets localized date-time pattern characters. For example: 'u', 't', etc.
- * @param newLocalPatternChars the new localized date-time
- * pattern characters.
- * @stable ICU 2.0
- */
- public void setLocalPatternChars(String newLocalPatternChars) {
- dfs.setLocalPatternChars(newLocalPatternChars);
- }
-
- /**
- * Return a string suitable for debugging.
- * @return a string suitable for debugging
- * @stable ICU 3.4.2
- */
- public String toString() {
- return dfs.toString();
- }
-
- /**
- * Return a clone of this DateFormatSymbols.
- * @return a clone of this DateFormatSymbols
- * @stable ICU 3.4.2
- */
- public Object clone() {
- return new DateFormatSymbols((java.text.DateFormatSymbols)dfs.clone());
- }
-
- /**
- * Return true if rhs is a DateFormatSymbols and has the same symbols as this.
- * @return true if rhs equals this
- * @stable ICU 3.4.2
- */
- public boolean equals(Object rhs) {
- try {
- return dfs.equals(((DateFormatSymbols)rhs).dfs);
- }
- catch (Exception e) {
- return false;
- }
- }
-
- /**
- * Return a hashCode.
- * @return a hashCode
- * @stable ICU 3.4.2
- */
- public int hashCode() {
- return dfs.hashCode();
- }
-}
diff --git a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/DecimalFormat.java b/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/DecimalFormat.java
deleted file mode 100644
index 8a4494f5d24..00000000000
--- a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/DecimalFormat.java
+++ /dev/null
@@ -1,903 +0,0 @@
-/*
- *******************************************************************************
- * Copyright (C) 1996-2006, International Business Machines Corporation and *
- * others. All Rights Reserved. *
- *******************************************************************************
- */
-
-package com.ibm.icu.text;
-
-/**
- * DecimalFormat
is a concrete subclass of
- * {@link NumberFormat} that formats decimal numbers.
- *
- *
To obtain a {@link NumberFormat} for a specific locale (including the
- * default locale) call one of NumberFormat
's factory methods such
- * as {@link NumberFormat#getInstance}. Do not call the DecimalFormat
- * constructors directly, unless you know what you are doing, since the
- * {@link NumberFormat} factory methods may return subclasses other than
- * DecimalFormat
. If you need to customize the format object, do
- * something like this:
- *
- *
- * - *- * NumberFormat f = NumberFormat.getInstance(loc); - * if (f instanceof DecimalFormat) { - * ((DecimalFormat) f).setDecimalSeparatorAlwaysShown(true); - * }
Example Usage - * - *
- * - *- * // Print out a number using the localized number, currency, - * // and percent format for each locale - * Locale[] locales = NumberFormat.getAvailableLocales(); - * double myNumber = -1234.56; - * NumberFormat format; - * for (int j=0; j<3; ++j) { - * System.out.println("FORMAT"); - * for (int i = 0; i < locales.length; ++i) { - * if (locales[i].getCountry().length() == 0) { - * // Skip language-only locales - * continue; - * } - * System.out.print(locales[i].getDisplayName()); - * switch (j) { - * case 0: - * format = NumberFormat.getInstance(locales[i]); break; - * case 1: - * format = NumberFormat.getCurrencyInstance(locales[i]); break; - * default: - * format = NumberFormat.getPercentInstance(locales[i]); break; - * } - * try { - * // Assume format is a DecimalFormat - * System.out.print(": " + ((DecimalFormat) format).toPattern() - * + " -> " + form.format(myNumber)); - * } catch (Exception e) {} - * try { - * System.out.println(" -> " + format.parse(form.format(myNumber))); - * } catch (ParseException e) {} - * } - * }
A DecimalFormat
consists of a pattern and a set of
- * symbols. The pattern may be set directly using
- * {@link #applyPattern}, or indirectly using other API methods which
- * manipulate aspects of the pattern, such as the minimum number of integer
- * digits. The symbols are stored in a {@link DecimalFormatSymbols}
- * object. When using the {@link NumberFormat} factory methods, the
- * pattern and symbols are read from ICU's locale data.
- *
- *
Many characters in a pattern are taken literally; they are matched during - * parsing and output unchanged during formatting. Special characters, on the - * other hand, stand for other characters, strings, or classes of characters. - * For example, the '#' character is replaced by a localized digit. Often the - * replacement character is the same as the pattern character; in the U.S. locale, - * the ',' grouping character is replaced by ','. However, the replacement is - * still happening, and if the symbols are modified, the grouping character - * changes. Some special characters affect the behavior of the formatter by - * their presence; for example, if the percent character is seen, then the - * value is multiplied by 100 before being displayed. - * - *
To insert a special character in a pattern as a literal, that is, without - * any special meaning, the character must be quoted. There are some exceptions to - * this which are noted below. - * - *
The characters listed here are used in non-localized patterns. Localized - * patterns use the corresponding characters taken from this formatter's - * {@link DecimalFormatSymbols} object instead, and these characters lose - * their special status. Two exceptions are the currency sign and quote, which - * are not localized. - * - *
- *- * - *- *
- *- * Symbol - * Location - * Localized? - * Meaning - * - * 0
- *Number - * Yes - * Digit - * - * 1-9
- *Number - * Yes - * NEW - * '1' through '9' indicate rounding. - * - * @
- *Number - * No - * NEW - * Significant digit - * - * #
- *Number - * Yes - * Digit, zero shows as absent - * - * .
- *Number - * Yes - * Decimal separator or monetary decimal separator - * - * -
- *Number - * Yes - * Minus sign - * - * ,
- *Number - * Yes - * Grouping separator - * - * E
- *Number - * Yes - * Separates mantissa and exponent in scientific notation. - * Need not be quoted in prefix or suffix. - * - * +
- *Exponent - * Yes - * NEW - * Prefix positive exponents with localized plus sign. - * Need not be quoted in prefix or suffix. - * - * ;
- *Subpattern boundary - * Yes - * Separates positive and negative subpatterns - * - * %
- *Prefix or suffix - * Yes - * Multiply by 100 and show as percentage - * - * \u2030
- *Prefix or suffix - * Yes - * Multiply by 1000 and show as per mille - * - * ¤
(\u00A4
) - *Prefix or suffix - * No - * Currency sign, replaced by currency symbol. If - * doubled, replaced by international currency symbol. - * If present in a pattern, the monetary decimal separator - * is used instead of the decimal separator. - * - * '
- *Prefix or suffix - * No - * Used to quote special characters in a prefix or suffix, - * for example, "'#'#"
formats 123 to - *"#123"
. To create a single quote - * itself, use two in a row:"# o''clock"
. - *- * *
- *Prefix or suffix boundary - * Yes - * NEW - * Pad escape, precedes pad character - *
A DecimalFormat
pattern contains a postive and negative
- * subpattern, for example, "#,##0.00;(#,##0.00)". Each subpattern has a
- * prefix, a numeric part, and a suffix. If there is no explicit negative
- * subpattern, the negative subpattern is the localized minus sign prefixed to the
- * positive subpattern. That is, "0.00" alone is equivalent to "0.00;-0.00". If there
- * is an explicit negative subpattern, it serves only to specify the negative
- * prefix and suffix; the number of digits, minimal digits, and other
- * characteristics are ignored in the negative subpattern. That means that
- * "#,##0.0#;(#)" has precisely the same result as "#,##0.0#;(#,##0.0#)".
- *
- *
The prefixes, suffixes, and various symbols used for infinity, digits, - * thousands separators, decimal separators, etc. may be set to arbitrary - * values, and they will appear properly during formatting. However, care must - * be taken that the symbols and strings do not conflict, or parsing will be - * unreliable. For example, either the positive and negative prefixes or the - * suffixes must be distinct for {@link #parse} to be able - * to distinguish positive from negative values. Another example is that the - * decimal separator and thousands separator should be distinct characters, or - * parsing will be impossible. - * - *
The grouping separator is a character that separates clusters of - * integer digits to make large numbers more legible. It commonly used for - * thousands, but in some locales it separates ten-thousands. The grouping - * size is the number of digits between the grouping separators, such as 3 - * for "100,000,000" or 4 for "1 0000 0000". There are actually two different - * grouping sizes: One used for the least significant integer digits, the - * primary grouping size, and one used for all others, the - * secondary grouping size. In most locales these are the same, but - * sometimes they are different. For example, if the primary grouping interval - * is 3, and the secondary is 2, then this corresponds to the pattern - * "#,##,##0", and the number 123456789 is formatted as "12,34,56,789". If a - * pattern contains multiple grouping separators, the interval between the last - * one and the end of the integer defines the primary grouping size, and the - * interval between the last two defines the secondary grouping size. All others - * are ignored, so "#,##,###,####" == "###,###,####" == "##,#,###,####". - * - *
Illegal patterns, such as "#.#.#" or "#.###,###", will cause
- * DecimalFormat
to throw an {@link IllegalArgumentException}
- * with a message that describes the problem.
- *
- *
- * pattern := subpattern (';' subpattern)? - * subpattern := prefix? number exponent? suffix? - * number := (integer ('.' fraction)?) | sigDigits - * prefix := '\u0000'..'\uFFFD' - specialCharacters - * suffix := '\u0000'..'\uFFFD' - specialCharacters - * integer := '#'* '0'* '0' - * fraction := '0'* '#'* - * sigDigits := '#'* '@' '@'* '#'* - * exponent := 'E' '+'? '0'* '0' - * padSpec := '*' padChar - * padChar := '\u0000'..'\uFFFD' - quote - * - * Notation: - * X* 0 or more instances of X - * X? 0 or 1 instances of X - * X|Y either X or Y - * C..D any character from C up to D, inclusive - * S-T characters in S, except those in T - *- * The first subpattern is for positive numbers. The second (optional) - * subpattern is for negative numbers. - * - *
Not indicated in the BNF syntax above: - * - *
padSpec
may appear before the prefix,
- * after the prefix, before the suffix, after the suffix, or not at all.
- *
- * DecimalFormat
parses all Unicode characters that represent
- * decimal digits, as defined by {@link UCharacter#digit}. In addition,
- * DecimalFormat
also recognizes as digits the ten consecutive
- * characters starting with the localized zero digit defined in the
- * {@link DecimalFormatSymbols} object. During formatting, the
- * {@link DecimalFormatSymbols}-based digits are output.
- *
- *
During parsing, grouping separators are ignored. - * - *
If {@link #parse(String, ParsePosition)} fails to parse
- * a string, it returns null
and leaves the parse position
- * unchanged. The convenience method {@link #parse(String)}
- * indicates parse failure by throwing a {@link java.text.ParseException}.
- *
- *
Formatting is guided by several parameters, all of which can be - * specified either using a pattern or using the API. The following - * description applies to formats that do not use scientific - * notation or significant digits. - * - *
Special Values - * - *
NaN
is represented as a single character, typically
- * \uFFFD
. This character is determined by the
- * {@link DecimalFormatSymbols} object. This is the only value for which
- * the prefixes and suffixes are not used.
- *
- *
Infinity is represented as a single character, typically
- * \u221E
, with the positive or negative prefixes and suffixes
- * applied. The infinity character is determined by the
- * {@link DecimalFormatSymbols} object.
- *
- * Scientific Notation
- *
- *
Numbers in scientific notation are expressed as the product of a mantissa
- * and a power of ten, for example, 1234 can be expressed as 1.234 x 103. The
- * mantissa is typically in the half-open interval [1.0, 10.0) or sometimes [0.0, 1.0),
- * but it need not be. DecimalFormat
supports arbitrary mantissas.
- * DecimalFormat
can be instructed to use scientific
- * notation through the API or through the pattern. In a pattern, the exponent
- * character immediately followed by one or more digit characters indicates
- * scientific notation. Example: "0.###E0" formats the number 1234 as
- * "1.234E3".
- *
- *
DecimalFormat
has two ways of controlling how many
- * digits are shows: (a) significant digits counts, or (b) integer and
- * fraction digit counts. Integer and fraction digit counts are
- * described above. When a formatter is using significant digits
- * counts, the number of integer and fraction digits is not specified
- * directly, and the formatter settings for these counts are ignored.
- * Instead, the formatter uses however many integer and fraction
- * digits are required to display the specified number of significant
- * digits. Examples:
- *
- * - *- * - *- *
- *- * Pattern - * Minimum significant digits - * Maximum significant digits - * Number - * Output of format() - * - * @@@
- *3 - * 3 - * 12345 - * 12300
- *- * @@@
- *3 - * 3 - * 0.12345 - * 0.123
- *- * @@##
- *2 - * 4 - * 3.14159 - * 3.142
- *- * @@##
- *2 - * 4 - * 1.23004 - * 1.23
- *
'@'
and '#'
- * characters. The minimum number of significant digits is the number
- * of '@'
characters. The maximum number of significant
- * digits is the number of '@'
characters plus the number
- * of '#'
characters following on the right. For
- * example, the pattern "@@@"
indicates exactly 3
- * significant digits. The pattern "@##"
indicates from
- * 1 to 3 significant digits. Trailing zero digits to the right of
- * the decimal separator are suppressed after the minimum number of
- * significant digits have been shown. For example, the pattern
- * "@##"
formats the number 0.1203 as
- * "0.12"
.
- *
- * '0'
pattern character.
- * Patterns such as "@00"
or "@.###"
are
- * disallowed.
- *
- * '#'
characters may be prepended to
- * the left of the leftmost '@'
character. These have no
- * effect on the minimum and maximum significant digits counts, but
- * may be used to position grouping separators. For example,
- * "#,#@#"
indicates a minimum of one significant digits,
- * a maximum of two significant digits, and a grouping size of three.
- *
- * '@'
pattern character. Alternatively,
- * call {@link #setSignificantDigitsUsed setSignificantDigitsUsed(true)}.
- *
- * '@'
pattern
- * character. Alternatively, call {@link #setSignificantDigitsUsed
- * setSignificantDigitsUsed(false)}.
- *
- * getMinimumSignificantDigits() - 1
, and a maximum fraction digit
- * count of getMaximumSignificantDigits() - 1
. For example, the
- * pattern "@@###E0"
is equivalent to "0.0###E0"
.
- *
- * DecimalFormat
supports padding the result of
- * {@link #format} to a specific width. Padding may be specified either
- * through the API or through the pattern syntax. In a pattern the pad escape
- * character, followed by a single pad character, causes padding to be parsed
- * and formatted. The pad escape character is '*' in unlocalized patterns, and
- * can be localized using {@link DecimalFormatSymbols#setPadEscape}. For
- * example, "$*x#,##0.00"
formats 123 to "$xx123.00"
,
- * and 1234 to "$1,234.00"
.
- *
- *
"* #0 o''clock"
, the format width is 10.
- *
- * char
s).
- *
- * char
immediately
- * following the pad escape is the pad character. This may be any character,
- * including a special pattern character. That is, the pad escape
- * escapes the following character. If there is no character after
- * the pad escape, then the pattern is illegal.
- *
- * - * NEW - * Rounding - * - *
DecimalFormat
supports rounding to a specific increment. For
- * example, 1230 rounded to the nearest 50 is 1250. 1.234 rounded to the
- * nearest 0.65 is 1.3. The rounding increment may be specified through the API
- * or in a pattern. To specify a rounding increment in a pattern, include the
- * increment in the pattern itself. "#,#50" specifies a rounding increment of
- * 50. "#,##0.05" specifies a rounding increment of 0.05.
- *
- *
DecimalFormat
objects are not synchronized. Multiple
- * threads should not access one formatter concurrently.
- *
- * @see java.text.Format
- * @see NumberFormat
- * @author Mark Davis
- * @author Alan Liu
- * @stable ICU 2.0
- */
-public class DecimalFormat extends NumberFormat {
-
- private static final long serialVersionUID = 1L;
- /**
- * @internal
- * @param delegate the NumberFormat to which to delegate
- */
- public DecimalFormat(java.text.DecimalFormat delegate) {
- super(delegate);
- }
-
- /**
- * Create a DecimalFormat using the default pattern and symbols
- * for the default locale. This is a convenient way to obtain a
- * DecimalFormat when internationalization is not the main concern.
- *
- * To obtain standard formats for a given locale, use the factory methods - * on NumberFormat such as getNumberInstance. These factories will - * return the most appropriate sub-class of NumberFormat for a given - * locale. - * @see NumberFormat#getInstance - * @see NumberFormat#getNumberInstance - * @see NumberFormat#getCurrencyInstance - * @see NumberFormat#getPercentInstance - * @stable ICU 2.0 - */ - public DecimalFormat() { - this(new java.text.DecimalFormat()); - } - - /** - * Create a DecimalFormat from the given pattern and the symbols - * for the default locale. This is a convenient way to obtain a - * DecimalFormat when internationalization is not the main concern. - *
- * To obtain standard formats for a given locale, use the factory methods - * on NumberFormat such as getNumberInstance. These factories will - * return the most appropriate sub-class of NumberFormat for a given - * locale. - * @param pattern A non-localized pattern string. - * @exception IllegalArgumentException if the given pattern is invalid. - * @see NumberFormat#getInstance - * @see NumberFormat#getNumberInstance - * @see NumberFormat#getCurrencyInstance - * @see NumberFormat#getPercentInstance - * @stable ICU 2.0 - */ - public DecimalFormat(String pattern) { - this(new java.text.DecimalFormat(pattern)); - } - - - /** - * Create a DecimalFormat from the given pattern and symbols. - * Use this constructor when you need to completely customize the - * behavior of the format. - *
- * To obtain standard formats for a given - * locale, use the factory methods on NumberFormat such as - * getInstance or getCurrencyInstance. If you need only minor adjustments - * to a standard format, you can modify the format returned by - * a NumberFormat factory method. - * @param pattern a non-localized pattern string - * @param symbols the set of symbols to be used - * @exception IllegalArgumentException if the given pattern is invalid - * @see NumberFormat#getInstance - * @see NumberFormat#getNumberInstance - * @see NumberFormat#getCurrencyInstance - * @see NumberFormat#getPercentInstance - * @see DecimalFormatSymbols - * @stable ICU 2.0 - */ - public DecimalFormat(String pattern, DecimalFormatSymbols symbols) { - this(new java.text.DecimalFormat(pattern, symbols.dfs)); - } - - /** - * Returns a copy of the decimal format symbols used by this format. - * @return desired DecimalFormatSymbols - * @see DecimalFormatSymbols - * @stable ICU 2.0 - */ - public DecimalFormatSymbols getDecimalFormatSymbols() { - return new DecimalFormatSymbols(((java.text.DecimalFormat)numberFormat).getDecimalFormatSymbols()); - } - - /** - * Sets the decimal format symbols used by this format. The - * format uses a copy of the provided symbols. - * @param newSymbols desired DecimalFormatSymbols - * @see DecimalFormatSymbols - * @stable ICU 2.0 - */ - public void setDecimalFormatSymbols(DecimalFormatSymbols newSymbols) { - ((java.text.DecimalFormat)numberFormat).setDecimalFormatSymbols(newSymbols.dfs); - } - - - /** - * Get the positive prefix. - *
Examples: +123, $123, sFr123 - * @stable ICU 2.0 - */ - public String getPositivePrefix() { - return ((java.text.DecimalFormat)numberFormat).getPositivePrefix(); - } - - /** - * Set the positive prefix. - *
Examples: +123, $123, sFr123 - * @stable ICU 2.0 - */ - public void setPositivePrefix(String newValue) { - ((java.text.DecimalFormat)numberFormat).setPositivePrefix(newValue); - } - - /** - * Get the negative prefix. - *
Examples: -123, ($123) (with negative suffix), sFr-123 - * @stable ICU 2.0 - */ - public String getNegativePrefix () { - return ((java.text.DecimalFormat)numberFormat).getNegativePrefix(); - } - - /** - * Set the negative prefix. - *
Examples: -123, ($123) (with negative suffix), sFr-123 - * @stable ICU 2.0 - */ - public void setNegativePrefix (String newValue) { - ((java.text.DecimalFormat)numberFormat).setNegativePrefix(newValue); - } - - /** - * Get the positive suffix. - *
Example: 123% - * @stable ICU 2.0 - */ - public String getPositiveSuffix () { - return ((java.text.DecimalFormat)numberFormat).getPositiveSuffix(); - } - - /** - * Set the positive suffix. - *
Example: 123% - * @stable ICU 2.0 - */ - public void setPositiveSuffix (String newValue) { - ((java.text.DecimalFormat)numberFormat).setPositiveSuffix(newValue); - } - - /** - * Get the negative suffix. - *
Examples: -123%, ($123) (with positive suffixes) - * @stable ICU 2.0 - */ - public String getNegativeSuffix () { - return ((java.text.DecimalFormat)numberFormat).getNegativeSuffix(); - } - - /** - * Set the positive suffix. - *
Examples: 123% - * @stable ICU 2.0 - */ - public void setNegativeSuffix (String newValue) { - ((java.text.DecimalFormat)numberFormat).setNegativeSuffix(newValue); - } - - /** - * Get the multiplier for use in percent, permill, etc. - * For a percentage, set the suffixes to have "%" and the multiplier to be 100. - * (For Arabic, use arabic percent symbol). - * For a permill, set the suffixes to have "\u2031" and the multiplier to be 1000. - *
Examples: with 100, 1.23 -> "123", and "123" -> 1.23 - * @stable ICU 2.0 - */ - public int getMultiplier () { - return ((java.text.DecimalFormat)numberFormat).getMultiplier(); - } - - /** - * Set the multiplier for use in percent, permill, etc. - * For a percentage, set the suffixes to have "%" and the multiplier to be 100. - * (For Arabic, use arabic percent symbol). - * For a permill, set the suffixes to have "\u2031" and the multiplier to be 1000. - *
Examples: with 100, 1.23 -> "123", and "123" -> 1.23 - * @stable ICU 2.0 - */ - public void setMultiplier (int newValue) { - ((java.text.DecimalFormat)numberFormat).setMultiplier(newValue); - } - - /** - * Return the grouping size. Grouping size is the number of digits between - * grouping separators in the integer portion of a number. For example, - * in the number "123,456.78", the grouping size is 3. - * @see #setGroupingSize - * @see NumberFormat#isGroupingUsed - * @see DecimalFormatSymbols#getGroupingSeparator - * @stable ICU 2.0 - */ - public int getGroupingSize () { - return ((java.text.DecimalFormat)numberFormat).getGroupingSize(); - } - - /** - * Set the grouping size. Grouping size is the number of digits between - * grouping separators in the integer portion of a number. For example, - * in the number "123,456.78", the grouping size is 3. - * @see #getGroupingSize - * @see NumberFormat#setGroupingUsed - * @see DecimalFormatSymbols#setGroupingSeparator - * @stable ICU 2.0 - */ - public void setGroupingSize (int newValue) { - ((java.text.DecimalFormat)numberFormat).setGroupingSize(newValue); - } - - /** - * Allows you to get the behavior of the decimal separator with integers. - * (The decimal separator will always appear with decimals.) - *
Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345 - * @stable ICU 2.0 - */ - public boolean isDecimalSeparatorAlwaysShown() { - return ((java.text.DecimalFormat)numberFormat).isDecimalSeparatorAlwaysShown(); - } - - /** - * Allows you to set the behavior of the decimal separator with integers. - * (The decimal separator will always appear with decimals.) - * - *
This only affects formatting, and only where - * there might be no digits after the decimal point, e.g., - * if true, 3456.00 -> "3,456." - * if false, 3456.00 -> "3456" - * This is independent of parsing. If you want parsing to stop at the decimal - * point, use setParseIntegerOnly. - * - *
Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345 - * @stable ICU 2.0 - */ - public void setDecimalSeparatorAlwaysShown(boolean newValue) { - ((java.text.DecimalFormat)numberFormat).setDecimalSeparatorAlwaysShown(newValue); - } - - /** - * Standard override; no change in semantics. - * @stable ICU 2.0 - */ - public Object clone() { - return new DecimalFormatSymbols((java.text.DecimalFormatSymbols)numberFormat.clone()); - } - - /** - * Synthesizes a pattern string that represents the current state - * of this Format object. - * @see #applyPattern - * @stable ICU 2.0 - */ - public String toPattern() { - return ((java.text.DecimalFormat)numberFormat).toPattern(); - } - - /** - * Synthesizes a localized pattern string that represents the current - * state of this Format object. - * @see #applyPattern - * @stable ICU 2.0 - */ - public String toLocalizedPattern() { - return ((java.text.DecimalFormat)numberFormat).toLocalizedPattern(); - } - - - /** - * Apply the given pattern to this Format object. A pattern is a - * short-hand specification for the various formatting properties. - * These properties can also be changed individually through the - * various setter methods. - *
- * There is no limit to integer digits are set - * by this routine, since that is the typical end-user desire; - * use setMaximumInteger if you want to set a real value. - * For negative numbers, use a second pattern, separated by a semicolon - *
Example "#,#00.0#" -> 1,234.56 - *
This means a minimum of 2 integer digits, 1 fraction digit, and - * a maximum of 2 fraction digits. - *
Example: "#,#00.0#;(#,#00.0#)" for negatives in parentheses. - *
In negative patterns, the minimum and maximum counts are ignored; - * these are presumed to be set in the positive pattern. - * @stable ICU 2.0 - */ - public void applyPattern(String pattern) { - ((java.text.DecimalFormat)numberFormat).applyPattern(pattern); - } - - /** - * Apply the given pattern to this Format object. The pattern - * is assumed to be in a localized notation. A pattern is a - * short-hand specification for the various formatting properties. - * These properties can also be changed individually through the - * various setter methods. - *
- * There is no limit to integer digits are set - * by this routine, since that is the typical end-user desire; - * use setMaximumInteger if you want to set a real value. - * For negative numbers, use a second pattern, separated by a semicolon - *
Example "#,#00.0#" -> 1,234.56 - *
This means a minimum of 2 integer digits, 1 fraction digit, and - * a maximum of 2 fraction digits. - *
Example: "#,#00.0#;(#,#00.0#)" for negatives in parentheses. - *
In negative patterns, the minimum and maximum counts are ignored;
- * these are presumed to be set in the positive pattern.
- * @stable ICU 2.0
- */
- public void applyLocalizedPattern(String pattern) {
- ((java.text.DecimalFormat)numberFormat).applyLocalizedPattern(pattern);
- }
-}
diff --git a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/DecimalFormatSymbols.java b/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/DecimalFormatSymbols.java
deleted file mode 100644
index 0ccbe3bbde0..00000000000
--- a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/DecimalFormatSymbols.java
+++ /dev/null
@@ -1,349 +0,0 @@
-/*
- *******************************************************************************
- * Copyright (C) 1996-2008, International Business Machines Corporation and *
- * others. All Rights Reserved. *
- *******************************************************************************
- */
-
-package com.ibm.icu.text;
-
-
-import java.io.Serializable;
-import java.util.Locale;
-
-import com.ibm.icu.util.ULocale;
-
-/**
- * This class represents the set of symbols (such as the decimal separator, the
- * grouping separator, and so on) needed by DecimalFormat
to format
- * numbers. DecimalFormat
creates for itself an instance of
- * DecimalFormatSymbols
from its locale data. If you need to
- * change any of these symbols, you can get the
- * DecimalFormatSymbols
object from your DecimalFormat
- * and modify it.
- *
- *
This is an enhanced version of DecimalFormatSymbols
that
- * is based on the standard version in the JDK. New or changed functionality
- * is labeled
- * NEW.
- *
- * @see java.util.Locale
- * @see DecimalFormat
- * @author Mark Davis
- * @author Alan Liu
- * @stable ICU 2.0
- */
-final public class DecimalFormatSymbols implements Cloneable, Serializable {
- private static final long serialVersionUID =1L;
-
- /**
- * @internal
- */
- public final java.text.DecimalFormatSymbols dfs;
-
- /**
- * @internal
- */
- public DecimalFormatSymbols(java.text.DecimalFormatSymbols delegate) {
- this.dfs = delegate;
- }
-
- /**
- * Create a DecimalFormatSymbols object for the default locale.
- * @stable ICU 2.0
- */
- public DecimalFormatSymbols() {
- this(new java.text.DecimalFormatSymbols());
- }
-
- /**
- * Create a DecimalFormatSymbols object for the given locale.
- * @param locale the locale
- * @stable ICU 2.0
- */
- public DecimalFormatSymbols(Locale locale) {
- this(new java.text.DecimalFormatSymbols(locale));
- }
-
- /**
- * Create a DecimalFormatSymbols object for the given locale.
- * @param locale the locale
- * @stable ICU 3.2
- */
- public DecimalFormatSymbols(ULocale locale) {
- this(new java.text.DecimalFormatSymbols(locale.toLocale()));
- }
-
- /**
- * Return the character used for zero. Different for Arabic, etc.
- * @return the character
- * @stable ICU 2.0
- */
- public char getZeroDigit() {
- return dfs.getZeroDigit();
- }
-
- /**
- * Set the character used for zero.
- * @param zeroDigit the zero character.
- * @stable ICU 2.0
- */
- public void setZeroDigit(char zeroDigit) {
- dfs.setZeroDigit(zeroDigit);
- }
-
- /**
- * Return the character used for thousands separator. Different for French, etc.
- * @return the thousands character
- * @stable ICU 2.0
- */
- public char getGroupingSeparator() {
- return dfs.getGroupingSeparator();
- }
-
- /**
- * Set the character used for thousands separator. Different for French, etc.
- * @param groupingSeparator the thousands character
- * @stable ICU 2.0
- */
- public void setGroupingSeparator(char groupingSeparator) {
- dfs.setGroupingSeparator(groupingSeparator);
- }
-
- /**
- * Return the character used for decimal sign. Different for French, etc.
- * @return the decimal character
- * @stable ICU 2.0
- */
- public char getDecimalSeparator() {
- return dfs.getDecimalSeparator();
- }
-
- /**
- * Set the character used for decimal sign. Different for French, etc.
- * @param decimalSeparator the decimal character
- * @stable ICU 2.0
- */
- public void setDecimalSeparator(char decimalSeparator) {
- dfs.setDecimalSeparator(decimalSeparator);
- }
-
- /**
- * Return the character used for mille percent sign. Different for Arabic, etc.
- * @return the mille percent character
- * @stable ICU 2.0
- */
- public char getPerMill() {
- return dfs.getPerMill();
- }
-
- /**
- * Set the character used for mille percent sign. Different for Arabic, etc.
- * @param perMill the mille percent character
- * @stable ICU 2.0
- */
- public void setPerMill(char perMill) {
- dfs.setPerMill(perMill);
- }
-
- /**
- * Return the character used for percent sign. Different for Arabic, etc.
- * @return the percent character
- * @stable ICU 2.0
- */
- public char getPercent() {
- return dfs.getPercent();
- }
-
- /**
- * Set the character used for percent sign. Different for Arabic, etc.
- * @param percent the percent character
- * @stable ICU 2.0
- */
- public void setPercent(char percent) {
- dfs.setPercent(percent);
- }
-
- /**
- * Return the character used for a digit in a pattern.
- * @return the digit pattern character
- * @stable ICU 2.0
- */
- public char getDigit() {
- return dfs.getDigit();
- }
-
- /**
- * Set the character used for a digit in a pattern.
- * @param digit the digit pattern character
- * @stable ICU 2.0
- */
- public void setDigit(char digit) {
- dfs.setDigit(digit);
- }
-
- /**
- * Return the character used to separate positive and negative subpatterns
- * in a pattern.
- * @return the pattern separator character
- * @stable ICU 2.0
- */
- public char getPatternSeparator() {
- return dfs.getPatternSeparator();
- }
-
- /**
- * Set the character used to separate positive and negative subpatterns
- * in a pattern.
- * @param patternSeparator the pattern separator character
- * @stable ICU 2.0
- */
- public void setPatternSeparator(char patternSeparator) {
- dfs.setPatternSeparator(patternSeparator);
- }
-
- /**
- * Return the String used to represent infinity. Almost always left
- * unchanged.
- * @return the Infinity string
- * @stable ICU 2.0
- */
- public String getInfinity() {
- return dfs.getInfinity();
- }
-
- /**
- * Set the String used to represent infinity. Almost always left
- * unchanged.
- * @param infinity the Infinity String
- * @stable ICU 2.0
- */
- public void setInfinity(String infinity) {
- dfs.setInfinity(infinity);
- }
-
- /**
- * Return the String used to represent NaN. Almost always left
- * unchanged.
- * @return the NaN String
- * @stable ICU 2.0
- */
- public String getNaN() {
- return dfs.getNaN();
- }
-
- /**
- * Set the String used to represent NaN. Almost always left
- * unchanged.
- * @param NaN the NaN String
- * @stable ICU 2.0
- */
- public void setNaN(String NaN) {
- dfs.setNaN(NaN);
- }
-
- /**
- * Return the character used to represent minus sign. If no explicit
- * negative format is specified, one is formed by prefixing
- * minusSign to the positive format.
- * @return the minus sign character
- * @stable ICU 2.0
- */
- public char getMinusSign() {
- return dfs.getMinusSign();
- }
-
- /**
- * Set the character used to represent minus sign. If no explicit
- * negative format is specified, one is formed by prefixing
- * minusSign to the positive format.
- * @param minusSign the minus sign character
- * @stable ICU 2.0
- */
- public void setMinusSign(char minusSign) {
- dfs.setMinusSign(minusSign);
- }
-
- /**
- * Return the string denoting the local currency.
- * @return the local currency String.
- * @stable ICU 2.0
- */
- public String getCurrencySymbol() {
- return dfs.getCurrencySymbol();
- }
-
- /**
- * Set the string denoting the local currency.
- * @param currency the local currency String.
- * @stable ICU 2.0
- */
- public void setCurrencySymbol(String currency) {
- dfs.setCurrencySymbol(currency);
- }
-
- /**
- * Return the international string denoting the local currency.
- * @return the international string denoting the local currency
- * @stable ICU 2.0
- */
- public String getInternationalCurrencySymbol() {
- return dfs.getInternationalCurrencySymbol();
- }
-
- /**
- * Set the international string denoting the local currency.
- * @param currency the international string denoting the local currency.
- * @stable ICU 2.0
- */
- public void setInternationalCurrencySymbol(String currency) {
- dfs.setInternationalCurrencySymbol(currency);
- }
-
- /**
- * Return the monetary decimal separator.
- * @return the monetary decimal separator character
- * @stable ICU 2.0
- */
- public char getMonetaryDecimalSeparator() {
- return dfs.getMonetaryDecimalSeparator();
- }
-
- /**
- * Set the monetary decimal separator.
- * @param sep the monetary decimal separator character
- * @stable ICU 2.0
- */
- public void setMonetaryDecimalSeparator(char sep) {
- dfs.setMonetaryDecimalSeparator(sep);
- }
-
- /**
- * Standard override.
- * @stable ICU 2.0
- */
- public Object clone() {
- return new DecimalFormatSymbols((java.text.DecimalFormatSymbols)dfs.clone());
- }
-
- /**
- * Override equals.
- * @stable ICU 2.0
- */
- public boolean equals(Object obj) {
- try {
- return dfs.equals(((DecimalFormatSymbols)obj).dfs);
- }
- catch (Exception e) {
- return false;
- }
- }
-
- /**
- * Override hashCode
- * @stable ICU 2.0
- */
- public int hashCode() {
- return dfs.hashCode();
- }
-}
diff --git a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/MessageFormat.java b/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/MessageFormat.java
deleted file mode 100644
index 67e6300e8d4..00000000000
--- a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/MessageFormat.java
+++ /dev/null
@@ -1,1042 +0,0 @@
-/*
- *******************************************************************************
- * Copyright (C) 2004-2008, International Business Machines Corporation and *
- * others. All Rights Reserved. *
- *******************************************************************************
- */
-package com.ibm.icu.text;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.text.FieldPosition;
-import java.text.Format;
-import java.text.ParseException;
-import java.text.ParsePosition;
-import java.util.Locale;
-
-import com.ibm.icu.util.ULocale;
-
-/**
- * MessageFormat
provides a means to produce concatenated
- * messages in language-neutral way. Use this to construct messages
- * displayed for end users.
- *
- *
- * MessageFormat
takes a set of objects, formats them, then
- * inserts the formatted strings into the pattern at the appropriate places.
- *
- *
- * Note:
- * MessageFormat
differs from the other Format
- * classes in that you create a MessageFormat
object with one
- * of its constructors (not with a getInstance
style factory
- * method). The factory methods aren't necessary because MessageFormat
- * itself doesn't implement locale specific behavior. Any locale specific
- * behavior is defined by the pattern that you provide as well as the
- * subformats used for inserted arguments.
- *
- *
MessageFormat
uses patterns of the following form:
- * - * - *- * MessageFormatPattern: - * String - * MessageFormatPattern FormatElement String - * - * FormatElement: - * { ArgumentIndex } - * { ArgumentIndex , FormatType } - * { ArgumentIndex , FormatType , FormatStyle } - * - * FormatType: one of - * number date time choice - * - * FormatStyle: - * short - * medium - * long - * full - * integer - * currency - * percent - * SubformatPattern - * - * String: - * StringPartopt - * String StringPart - * - * StringPart: - * '' - * ' QuotedString ' - * UnquotedString - * - * SubformatPattern: - * SubformatPatternPartopt - * SubformatPattern SubformatPatternPart - * - * SubFormatPatternPart: - * ' QuotedPattern ' - * UnquotedPattern - *
- * Within a String, "''"
represents a single
- * quote. A QuotedString can contain arbitrary characters
- * except single quotes; the surrounding single quotes are removed.
- * An UnquotedString can contain arbitrary characters
- * except single quotes and left curly brackets. Thus, a string that
- * should result in the formatted message "'{0}'" can be written as
- * "'''{'0}''"
or "'''{0}'''"
.
- *
- * Within a SubformatPattern, different rules apply.
- * A QuotedPattern can contain arbitrary characters
- * except single quotes; but the surrounding single quotes are
- * not removed, so they may be interpreted by the
- * subformat. For example, "{1,number,$'#',##}"
will
- * produce a number format with the pound-sign quoted, with a result
- * such as: "$#31,45".
- * An UnquotedPattern can contain arbitrary characters
- * except single quotes, but curly braces within it must be balanced.
- * For example, "ab {0} de"
and "ab '}' de"
- * are valid subformat patterns, but "ab {0'}' de"
and
- * "ab } de"
are not.
- *
- *
- * The ArgumentIndex value is a non-negative integer written
- * using the digits '0' through '9', and represents an index into the
- * arguments
array passed to the format
methods
- * or the result array returned by the parse
methods.
- *
- * The FormatType and FormatStyle values are used to create
- * a Format
instance for the format element. The following
- * table shows how the values map to Format instances. Combinations not
- * shown in the table are illegal. A SubformatPattern must
- * be a valid pattern string for the Format subclass used.
- *
- *
Format Type - * | Format Style - * | Subformat Created - * | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
(none) - * | null
- * | ||||||||||||||||
number
- * | (none) - * | NumberFormat.getInstance(getLocale())
- * | |||||||||||||||
integer
- * | NumberFormat.getIntegerInstance(getLocale())
- * | ||||||||||||||||
currency
- * | NumberFormat.getCurrencyInstance(getLocale())
- * | ||||||||||||||||
percent
- * | NumberFormat.getPercentInstance(getLocale())
- * | ||||||||||||||||
SubformatPattern - * | new DecimalFormat(subformatPattern, new DecimalFormatSymbols(getLocale()))
- * | ||||||||||||||||
date
- * | (none) - * | DateFormat.getDateInstance(DateFormat.DEFAULT, getLocale())
- * | |||||||||||||||
short
- * | DateFormat.getDateInstance(DateFormat.SHORT, getLocale())
- * | ||||||||||||||||
medium
- * | DateFormat.getDateInstance(DateFormat.DEFAULT, getLocale())
- * | ||||||||||||||||
long
- * | DateFormat.getDateInstance(DateFormat.LONG, getLocale())
- * | ||||||||||||||||
full
- * | DateFormat.getDateInstance(DateFormat.FULL, getLocale())
- * | ||||||||||||||||
SubformatPattern - * | new SimpleDateFormat(subformatPattern, getLocale())
- * |
- * - *
- * Here are some examples of usage: - *
- *- * Typically, the message format will come from resources, and the - * arguments will be dynamically set at runtime. - * - *- * Object[] arguments = { - * new Integer(7), - * new Date(System.currentTimeMillis()), - * "a disturbance in the Force" - * }; - * - * String result = MessageFormat.format( - * "At {1,time} on {1,date}, there was {2} on planet {0,number,integer}.", - * arguments); - * - * output: At 12:30 PM on Jul 3, 2053, there was a disturbance - * in the Force on planet 7. - * - *- *
- * Example 2: - *
- *- * - *- * Object[] testArgs = {new Long(3), "MyDisk"}; - * - * MessageFormat form = new MessageFormat( - * "The disk \"{1}\" contains {0} file(s)."); - * - * System.out.println(form.format(testArgs)); - * - * // output, with different testArgs - * output: The disk "MyDisk" contains 0 file(s). - * output: The disk "MyDisk" contains 1 file(s). - * output: The disk "MyDisk" contains 1,273 file(s). - *- *
- * For more sophisticated patterns, you can use a ChoiceFormat
to get
- * output such as:
- *
- *- * You can either do this programmatically, as in the above example, - * or by using a pattern (see - * {@link ChoiceFormat} - * for more information) as in: - *- * MessageFormat form = new MessageFormat("The disk \"{1}\" contains {0}."); - * double[] filelimits = {0,1,2}; - * String[] filepart = {"no files","one file","{0,number} files"}; - * ChoiceFormat fileform = new ChoiceFormat(filelimits, filepart); - * form.setFormatByArgumentIndex(0, fileform); - * - * Object[] testArgs = {new Long(12373), "MyDisk"}; - * - * System.out.println(form.format(testArgs)); - * - * // output, with different testArgs - * output: The disk "MyDisk" contains no files. - * output: The disk "MyDisk" contains one file. - * output: The disk "MyDisk" contains 1,273 files. - *- *
- *- *- * form.applyPattern( - * "There {0,choice,0#are no files|1#is one file|1<are {0,number,integer} files}."); - *- *
- * Note: As we see above, the string produced
- * by a ChoiceFormat
in MessageFormat
is treated specially;
- * occurances of '{' are used to indicated subformats, and cause recursion.
- * If you create both a MessageFormat
and ChoiceFormat
- * programmatically (instead of using the string patterns), then be careful not to
- * produce a format that recurses on itself, which will cause an infinite loop.
- *
- * When a single argument is parsed more than once in the string, the last match - * will be the final result of the parsing. For example, - *
- * MessageFormat mf = new MessageFormat("{0,number,#.##}, {0,number,#.#}"); - * Object[] objs = {new Double(3.1415)}; - * String result = mf.format( objs ); - * // result now equals "3.14, 3.1" - * objs = null; - * objs = mf.parse(result, new ParsePosition(0)); - * // objs now equals {new Double(3.1)} - *- *
- * Likewise, parsing with a MessageFormat object using patterns containing - * multiple occurances of the same argument would return the last match. For - * example, - *
- * MessageFormat mf = new MessageFormat("{0}, {0}, {0}"); - * String forParsing = "x, y, z"; - * Object[] objs = mf.parse(forParsing, new ParsePosition(0)); - * // result now equals {new String("z")} - *- * - *
- * Message formats are not synchronized.
- * It is recommended to create separate format instances for each thread.
- * If multiple threads access a format concurrently, it must be synchronized
- * externally.
- *
- * @see java.util.Locale
- * @see Format
- * @see NumberFormat
- * @see DecimalFormat
- * @see ChoiceFormat
- * @author Mark Davis
- * @stable ICU 3.0
- */
-public class MessageFormat extends Format {
- static final long serialVersionUID = 1L;
-
- /**
- * @internal
- */
- public final java.text.MessageFormat messageFormat;
-
- /**
- * @internal
- * @param delegate the DateFormat to which to delegate
- */
- public MessageFormat(java.text.MessageFormat delegate) {
- this.messageFormat = delegate;
- }
-
- /**
- * Constructs a MessageFormat for the default locale and the
- * specified pattern.
- * The constructor first sets the locale, then parses the pattern and
- * creates a list of subformats for the format elements contained in it.
- * Patterns and their interpretation are specified in the
- * class description.
- *
- * @param pattern the pattern for this message format
- * @exception IllegalArgumentException if the pattern is invalid
- * @stable ICU 3.0
- */
- public MessageFormat(String pattern) {
- this(new java.text.MessageFormat(pattern));
- }
-
- /**
- * Constructs a MessageFormat for the specified locale and
- * pattern.
- * The constructor first sets the locale, then parses the pattern and
- * creates a list of subformats for the format elements contained in it.
- * Patterns and their interpretation are specified in the
- * class description.
- *
- * @param pattern the pattern for this message format
- * @param locale the locale for this message format
- * @exception IllegalArgumentException if the pattern is invalid
- * @stable ICU 3.0
- */
- public MessageFormat(String pattern, Locale locale) {
- // locale is ignored
- this(new java.text.MessageFormat(pattern));
- }
-
- /**
- * Constructs a MessageFormat for the specified locale and
- * pattern.
- * The constructor first sets the locale, then parses the pattern and
- * creates a list of subformats for the format elements contained in it.
- * Patterns and their interpretation are specified in the
- * class description.
- *
- * @param pattern the pattern for this message format
- * @param locale the locale for this message format
- * @exception IllegalArgumentException if the pattern is invalid
- * @stable ICU 3.2
- */
- public MessageFormat(String pattern, ULocale locale) {
- // locale is ignored
- this(pattern);
- }
-
- /**
- * Sets the locale to be used when creating or comparing subformats.
- * This affects subsequent calls to the {@link #applyPattern applyPattern}
- * and {@link #toPattern toPattern} methods as well as to the
- * format
and
- * {@link #formatToCharacterIterator formatToCharacterIterator} methods.
- *
- * @param locale the locale to be used when creating or comparing subformats
- * @stable ICU 3.0
- */
- public void setLocale(Locale locale) {
- messageFormat.setLocale(locale);
- }
-
- /**
- * Sets the locale to be used when creating or comparing subformats.
- * This affects subsequent calls to the {@link #applyPattern applyPattern}
- * and {@link #toPattern toPattern} methods as well as to the
- * format
and
- * {@link #formatToCharacterIterator formatToCharacterIterator} methods.
- *
- * @param locale the locale to be used when creating or comparing subformats
- * @stable ICU 3.2
- */
- public void setLocale(ULocale locale) {
- messageFormat.setLocale(locale.toLocale());
- }
-
- /**
- * Gets the locale that's used when creating or comparing subformats.
- *
- * @return the locale used when creating or comparing subformats
- * @stable ICU 3.0
- */
- public Locale getLocale() {
- return messageFormat.getLocale();
- }
-
- /**
- * Gets the locale that's used when creating or comparing subformats.
- *
- * @return the locale used when creating or comparing subformats
- * @stable ICU 3.2
- */
- public ULocale getULocale() {
- return ULocale.forLocale(messageFormat.getLocale());
- }
-
- /**
- * Sets the pattern used by this message format.
- * The method parses the pattern and creates a list of subformats
- * for the format elements contained in it.
- * Patterns and their interpretation are specified in the
- * class description.
- *
- * @param pattern the pattern for this message format
- * @exception IllegalArgumentException if the pattern is invalid
- * @stable ICU 3.0
- */
- public void applyPattern(String pattern) {
- messageFormat.applyPattern(pattern);
- }
-
- /**
- * Returns a pattern representing the current state of the message format.
- * The string is constructed from internal information and therefore
- * does not necessarily equal the previously applied pattern.
- *
- * @return a pattern representing the current state of the message format
- * @stable ICU 3.0
- */
- public String toPattern() {
- return messageFormat.toPattern();
- }
-
- /**
- * Sets the formats to use for the values passed into
- * format
methods or returned from parse
- * methods. The indices of elements in newFormats
- * correspond to the argument indices used in the previously set
- * pattern string.
- * The order of formats in newFormats
thus corresponds to
- * the order of elements in the arguments
array passed
- * to the format
methods or the result array returned
- * by the parse
methods.
- *
- * If an argument index is used for more than one format element
- * in the pattern string, then the corresponding new format is used
- * for all such format elements. If an argument index is not used
- * for any format element in the pattern string, then the
- * corresponding new format is ignored. If fewer formats are provided
- * than needed, then only the formats for argument indices less
- * than newFormats.length
are replaced.
- *
- * @param newFormats the new formats to use
- * @exception NullPointerException if newFormats
is null
- * @stable ICU 3.0
- * @throws UnsupportedOperationException if the underlying JVM does not
- * support this method.
- */
- public void setFormatsByArgumentIndex(Format[] newFormats) {
- if (sfsbai == null) {
- synchronized (missing) {
- try {
- Class[] params = { Format[].class };
- sfsbai = java.text.MessageFormat.class.getMethod("setFormatsByArgumentIndex", params);
- }
- catch (NoSuchMethodException e) {
- sfsbai = missing;
- }
- }
- }
- if (sfsbai != missing) {
- try {
- Format[] unwrapped = new Format[newFormats.length];
- for (int i = 0; i < newFormats.length; ++i) {
- unwrapped[i] = unwrap(newFormats[i]);
- }
- Object[] args = { unwrapped };
- ((Method)sfsbai).invoke(messageFormat, args);
- return;
- }
- catch (IllegalAccessException e) {
- // can't happen
- }
- catch (InvocationTargetException e) {
- // can't happen
- }
- }
- throw new UnsupportedOperationException();
- }
- private static Object sfsbai;
-
- /**
- * Sets the formats to use for the format elements in the
- * previously set pattern string.
- * The order of formats in newFormats
corresponds to
- * the order of format elements in the pattern string.
- *
- * If more formats are provided than needed by the pattern string,
- * the remaining ones are ignored. If fewer formats are provided
- * than needed, then only the first newFormats.length
- * formats are replaced.
- *
- * Since the order of format elements in a pattern string often
- * changes during localization, it is generally better to use the
- * {@link #setFormatsByArgumentIndex setFormatsByArgumentIndex}
- * method, which assumes an order of formats corresponding to the
- * order of elements in the arguments
array passed to
- * the format
methods or the result array returned by
- * the parse
methods.
- *
- * @param newFormats the new formats to use
- * @exception NullPointerException if newFormats
is null
- * @stable ICU 3.0
- */
- public void setFormats(Format[] newFormats) {
- messageFormat.setFormats(newFormats);
- }
-
- /**
- * Sets the format to use for the format elements within the
- * previously set pattern string that use the given argument
- * index.
- * The argument index is part of the format element definition and
- * represents an index into the arguments
array passed
- * to the format
methods or the result array returned
- * by the parse
methods.
- *
- * If the argument index is used for more than one format element - * in the pattern string, then the new format is used for all such - * format elements. If the argument index is not used for any format - * element in the pattern string, then the new format is ignored. - * - * @param argumentIndex the argument index for which to use the new format - * @param newFormat the new format to use - * @stable ICU 3.0 - * @throws UnsupportedOperationException if the underlying JVM does not - * support this method. - */ - public void setFormatByArgumentIndex(int argumentIndex, Format newFormat) { - if (sfbai == null) { - synchronized (missing) { - try { - Class[] params = { Integer.TYPE, Format.class }; - sfbai = java.text.MessageFormat.class.getMethod("setFormatByArgumentIndex", params); - } - catch (NoSuchMethodException e) { - sfbai = missing; - } - } - } - if (sfbai != missing) { - try { - Object[] args = { new Integer(argumentIndex), newFormat }; - ((Method)sfbai).invoke(messageFormat, args); - return; - } - catch (IllegalAccessException e) { - // can't happen - } - catch (InvocationTargetException e) { - // can't happen - } - } - throw new UnsupportedOperationException(); - } - private static Object sfbai; - - /** - * Sets the format to use for the format element with the given - * format element index within the previously set pattern string. - * The format element index is the zero-based number of the format - * element counting from the start of the pattern string. - *
- * Since the order of format elements in a pattern string often
- * changes during localization, it is generally better to use the
- * {@link #setFormatByArgumentIndex setFormatByArgumentIndex}
- * method, which accesses format elements based on the argument
- * index they specify.
- *
- * @param formatElementIndex the index of a format element within the pattern
- * @param newFormat the format to use for the specified format element
- * @exception ArrayIndexOutOfBoundsException if formatElementIndex is equal to or
- * larger than the number of format elements in the pattern string
- * @stable ICU 3.0
- */
- public void setFormat(int formatElementIndex, Format newFormat) {
- messageFormat.setFormat(formatElementIndex, unwrap(newFormat));
- }
-
- /**
- * Gets the formats used for the values passed into
- * format
methods or returned from parse
- * methods. The indices of elements in the returned array
- * correspond to the argument indices used in the previously set
- * pattern string.
- * The order of formats in the returned array thus corresponds to
- * the order of elements in the arguments
array passed
- * to the format
methods or the result array returned
- * by the parse
methods.
- *
- * If an argument index is used for more than one format element - * in the pattern string, then the format used for the last such - * format element is returned in the array. If an argument index - * is not used for any format element in the pattern string, then - * null is returned in the array. - * - * @return the formats used for the arguments within the pattern - * @stable ICU 3.0 - * @throws UnsupportedOperationException if the underlying JVM does not - * support this method. - */ - public Format[] getFormatsByArgumentIndex() { - if (gfbai == null) { - synchronized (missing) { - try { - gfbai = java.text.MessageFormat.class.getMethod("getFormatsByArgumentIndex", null); - } - catch (NoSuchMethodException e) { - gfbai = missing; - } - } - } - if (gfbai != missing) { - try { - Format[] result = (Format[])((Method)gfbai).invoke(messageFormat, null); - for (int i = 0; i < result.length; ++i) { - result[i] = wrap(result[i]); - } - return result; - } - catch (IllegalAccessException e) { - // can't happen - } - catch (InvocationTargetException e) { - // can't happen - } - } - throw new UnsupportedOperationException(); - } - private static Object gfbai; - private static final Object missing = new Object(); - - /** - * Gets the formats used for the format elements in the - * previously set pattern string. - * The order of formats in the returned array corresponds to - * the order of format elements in the pattern string. - *
- * Since the order of format elements in a pattern string often
- * changes during localization, it's generally better to use the
- * {@link #getFormatsByArgumentIndex getFormatsByArgumentIndex}
- * method, which assumes an order of formats corresponding to the
- * order of elements in the arguments
array passed to
- * the format
methods or the result array returned by
- * the parse
methods.
- *
- * @return the formats used for the format elements in the pattern
- * @stable ICU 3.0
- */
- public Format[] getFormats() {
- Format[] result = messageFormat.getFormats();
- for (int i = 0; i < result.length; ++i) {
- result[i] = wrap(result[i]);
- }
- return result;
- }
-
- /**
- * Formats an array of objects and appends the MessageFormat
's
- * pattern, with format elements replaced by the formatted objects, to the
- * provided StringBuffer
.
- *
- * The text substituted for the individual format elements is derived from
- * the current subformat of the format element and the
- * arguments
element at the format element's argument index
- * as indicated by the first matching line of the following table. An
- * argument is unavailable if arguments
is
- * null
or has fewer than argumentIndex+1 elements.
- *
- *
Subformat - * | Argument - * | Formatted Text - * |
---|---|---|
any - * | unavailable - * | "{" + argumentIndex + "}"
- * |
any - * | null
- * | "null"
- * |
instanceof ChoiceFormat
- * | any - * | subformat.format(argument).indexOf('{') >= 0 ?
- * |
!= null
- * | any - * | subformat.format(argument)
- * |
null
- * | instanceof Number
- * | NumberFormat.getInstance(getLocale()).format(argument)
- * |
null
- * | instanceof Date
- * | DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, getLocale()).format(argument)
- * |
null
- * | instanceof String
- * | argument
- * |
null
- * | any - * | argument.toString()
- * |
- * If pos
is non-null, and refers to
- * Field.ARGUMENT
, the location of the first formatted
- * string will be returned.
- *
- * @param arguments an array of objects to be formatted and substituted.
- * @param result where text is appended.
- * @param pos On input: an alignment field, if desired.
- * On output: the offsets of the alignment field.
- * @exception IllegalArgumentException if an argument in the
- * arguments
array is not of the type
- * expected by the format element(s) that use it.
- * @stable ICU 3.0
- */
- public final StringBuffer format(Object[] arguments, StringBuffer result,
- FieldPosition pos)
- {
- return messageFormat.format(arguments, result, pos);
- }
-
- /**
- * Creates a MessageFormat with the given pattern and uses it
- * to format the given arguments. This is equivalent to
- *
- * (new {@link #MessageFormat(String) MessageFormat}(pattern)).{@link #format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition) format}(arguments, new StringBuffer(), null).toString()
- *
- *
- * @exception IllegalArgumentException if the pattern is invalid,
- * or if an argument in the arguments
array
- * is not of the type expected by the format element(s)
- * that use it.
- * @stable ICU 3.0
- */
- public static String format(String pattern, Object[] arguments) {
- return java.text.MessageFormat.format(pattern, arguments);
- }
-
- // Overrides
- /**
- * Formats an array of objects and appends the MessageFormat
's
- * pattern, with format elements replaced by the formatted objects, to the
- * provided StringBuffer
.
- * This is equivalent to
- *
- * {@link #format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition) format}((Object[]) arguments, result, pos)
- *
- *
- * @param arguments an array of objects to be formatted and substituted.
- * @param result where text is appended.
- * @param pos On input: an alignment field, if desired.
- * On output: the offsets of the alignment field.
- * @exception IllegalArgumentException if an argument in the
- * arguments
array is not of the type
- * expected by the format element(s) that use it.
- * @stable ICU 3.0
- */
- public final StringBuffer format(Object arguments, StringBuffer result,
- FieldPosition pos)
- {
- return messageFormat.format(arguments, result, pos);
- }
-
-
- /**
- * Parses the string.
- *
- * Caveats: The parse may fail in a number of circumstances. - * For example: - *
- * See the {@link #parse(String, ParsePosition)} method for more information
- * on message parsing.
- *
- * @param source A String
whose beginning should be parsed.
- * @return An Object
array parsed from the string.
- * @exception ParseException if the beginning of the specified string
- * cannot be parsed.
- * @stable ICU 3.0
- */
- public Object[] parse(String source) throws ParseException {
- return messageFormat.parse(source);
- }
-
- /**
- * Parses text from a string to produce an object array.
- *
- * The method attempts to parse text starting at the index given by
- * pos
.
- * If parsing succeeds, then the index of pos
is updated
- * to the index after the last character used (parsing does not necessarily
- * use all characters up to the end of the string), and the parsed
- * object array is returned. The updated pos
can be used to
- * indicate the starting point for the next call to this method.
- * If an error occurs, then the index of pos
is not
- * changed, the error index of pos
is set to the index of
- * the character where the error occurred, and null is returned.
- *
- * See the {@link #parse(String, ParsePosition)} method for more information
- * on message parsing.
- *
- * @param source A String
, part of which should be parsed.
- * @param pos A ParsePosition
object with index and error
- * index information as described above.
- * @return An Object
array parsed from the string. In case of
- * error, returns null.
- * @exception NullPointerException if pos
is null.
- * @stable ICU 3.0
- */
- public Object parseObject(String source, ParsePosition pos) {
- return messageFormat.parse(source, pos);
- }
-
- /**
- * Convert an 'apostrophe-friendly' pattern into a standard
- * pattern. Standard patterns treat all apostrophes as
- * quotes, which is problematic in some languages, e.g.
- * French, where apostrophe is commonly used. This utility
- * assumes that only an unpaired apostrophe immediately before
- * a brace is a true quote. Other unpaired apostrophes are paired,
- * and the resulting standard pattern string is returned.
- *
- *
Note it is not guaranteed that the returned pattern
- * is indeed a valid pattern. The only effect is to convert
- * between patterns having different quoting semantics.
- *
- * @param pattern the 'apostrophe-friendly' patttern to convert
- * @return the standard equivalent of the original pattern
- * @stable ICU 3.4
- */
- public static String autoQuoteApostrophe(String pattern) {
- StringBuffer buf = new StringBuffer(pattern.length()*2);
- int state = STATE_INITIAL;
- int braceCount = 0;
- for (int i = 0, j = pattern.length(); i < j; ++i) {
- char c = pattern.charAt(i);
- switch (state) {
- case STATE_INITIAL:
- switch (c) {
- case SINGLE_QUOTE:
- state = STATE_SINGLE_QUOTE;
- break;
- case CURLY_BRACE_LEFT:
- state = STATE_MSG_ELEMENT;
- ++braceCount;
- break;
- }
- break;
- case STATE_SINGLE_QUOTE:
- switch (c) {
- case SINGLE_QUOTE:
- state = STATE_INITIAL;
- break;
- case CURLY_BRACE_LEFT:
- case CURLY_BRACE_RIGHT:
- state = STATE_IN_QUOTE;
- break;
- default:
- buf.append(SINGLE_QUOTE);
- state = STATE_INITIAL;
- break;
- }
- break;
- case STATE_IN_QUOTE:
- switch (c) {
- case SINGLE_QUOTE:
- state = STATE_INITIAL;
- break;
- }
- break;
- case STATE_MSG_ELEMENT:
- switch (c) {
- case CURLY_BRACE_LEFT:
- ++braceCount;
- break;
- case CURLY_BRACE_RIGHT:
- if (--braceCount == 0) {
- state = STATE_INITIAL;
- }
- break;
- }
- break;
- default: // Never happens.
- break;
- }
- buf.append(c);
- }
- // End of scan
- if (state == STATE_SINGLE_QUOTE || state == STATE_IN_QUOTE) {
- buf.append(SINGLE_QUOTE);
- }
- return new String(buf);
- }
-
- /**
- * Creates and returns a copy of this object.
- *
- * @return a clone of this instance.
- * @stable ICU 3.0
- */
- public Object clone() {
- return new MessageFormat((java.text.MessageFormat)messageFormat.clone());
- }
-
- /**
- * Equality comparison between two message format objects
- * @stable ICU 3.0
- */
- public boolean equals(Object obj) {
- try {
- return messageFormat.equals(((MessageFormat)obj).messageFormat);
- }
- catch (Exception e) {
- return false;
- }
- }
-
- /**
- * Generates a hash code for the message format object.
- * @stable ICU 3.0
- */
- public int hashCode() {
- return messageFormat.hashCode();
- }
-
- /**
- * Return a string suitable for debugging.
- * @return a string suitable for debugging
- * @stable ICU 3.4.2
- */
- public String toString() {
- return messageFormat.toPattern();
- }
-
- private static Format unwrap(Format f) {
- if (f instanceof DateFormat) {
- return ((DateFormat)f).dateFormat;
- } else if (f instanceof NumberFormat) {
- return ((NumberFormat)f).numberFormat;
- } else if (f instanceof MessageFormat) {
- return ((MessageFormat)f).messageFormat;
- } else {
- return f;
- }
- }
-
- private static Format wrap(Format f) {
- if (f instanceof java.text.DateFormat) {
- return new DateFormat((java.text.DateFormat)f);
- } else if (f instanceof java.text.DecimalFormat) {
- return new DecimalFormat((java.text.DecimalFormat)f);
- } else if (f instanceof java.text.MessageFormat) {
- return new MessageFormat((java.text.MessageFormat)f);
- } else {
- return f;
- }
- }
-
- private static final char SINGLE_QUOTE = '\'';
- private static final char CURLY_BRACE_LEFT = '{';
- private static final char CURLY_BRACE_RIGHT = '}';
-
- private static final int STATE_INITIAL = 0;
- private static final int STATE_SINGLE_QUOTE = 1;
- private static final int STATE_IN_QUOTE = 2;
- private static final int STATE_MSG_ELEMENT = 3;
-}
diff --git a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/NumberFormat.java b/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/NumberFormat.java
deleted file mode 100644
index f825a943b76..00000000000
--- a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/NumberFormat.java
+++ /dev/null
@@ -1,778 +0,0 @@
-/*
- *******************************************************************************
- * Copyright (C) 1996-2008, International Business Machines Corporation and *
- * others. All Rights Reserved. *
- *******************************************************************************
- */
-
-
-package com.ibm.icu.text;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.math.BigInteger;
-import java.text.DecimalFormatSymbols;
-import java.text.FieldPosition;
-import java.text.Format;
-import java.text.ParseException;
-import java.text.ParsePosition;
-import java.util.Locale;
-
-import com.ibm.icu.util.ULocale;
-
-/**
- * NumberFormat
is the abstract base class for all number
- * formats. This class provides the interface for formatting and parsing
- * numbers. NumberFormat
also provides methods for determining
- * which locales have number formats, and what their names are.
- *
- *
This is an enhanced version of NumberFormat
that
- * is based on the standard version in the JDK. New or changed functionality
- * is labeled
- * NEW or
- * CHANGED.
- *
- *
- * NumberFormat
helps you to format and parse numbers for any locale.
- * Your code can be completely independent of the locale conventions for
- * decimal points, thousands-separators, or even the particular decimal
- * digits used, or whether the number format is even decimal.
- *
- *
- * To format a number for the current Locale, use one of the factory - * class methods: - *
- *- * If you are formatting multiple numbers, it is - * more efficient to get the format and use it multiple times so that - * the system doesn't have to fetch the information about the local - * language and country conventions multiple times. - *- * myString = NumberFormat.getInstance().format(myNumber); - *- *
- *- * To format a number for a different Locale, specify it in the - * call to- * NumberFormat nf = NumberFormat.getInstance(); - * for (int i = 0; i < a.length; ++i) { - * output.println(nf.format(myNumber[i]) + "; "); - * } - *- *
getInstance
.
- * - *- * You can also use a- * NumberFormat nf = NumberFormat.getInstance(Locale.FRENCH); - *- *
NumberFormat
to parse numbers:
- * - *- * Use- * myNumber = nf.parse(myString); - *- *
getInstance
or getNumberInstance
to get the
- * normal number format. Use getIntegerInstance
to get an
- * integer number format. Use getCurrencyInstance
to get the
- * currency number format. And use getPercentInstance
to get a
- * format for displaying percentages. With this format, a fraction like
- * 0.53 is displayed as 53%.
- *
- *
- * You can also control the display of numbers with such methods as
- * setMinimumFractionDigits
.
- * If you want even more control over the format or parsing,
- * or want to give your users more control,
- * you can try casting the NumberFormat
you get from the factory methods
- * to a DecimalFormat
. This will work for the vast majority
- * of locales; just remember to put it in a try
block in case you
- * encounter an unusual one.
- *
- *
- * NumberFormat is designed such that some controls - * work for formatting and others work for parsing. The following is - * the detailed description for each these control methods, - *
- * setParseIntegerOnly : only affects parsing, e.g. - * if true, "3456.78" -> 3456 (and leaves the parse position just after '6') - * if false, "3456.78" -> 3456.78 (and leaves the parse position just after '8') - * This is independent of formatting. If you want to not show a decimal point - * where there might be no digits after the decimal point, use - * setDecimalSeparatorAlwaysShown on DecimalFormat. - *
- * You can also use forms of the parse
and format
- * methods with ParsePosition
and FieldPosition
to
- * allow you to:
- *
FieldPosition
in your format call, with
- * field
= INTEGER_FIELD
. On output,
- * getEndIndex
will be set to the offset between the
- * last character of the integer and the decimal. Add
- * (desiredSpaceCount - getEndIndex) spaces at the front of the string.
- *
- * getEndIndex
.
- * Then move the pen by
- * (desiredPixelWidth - widthToAlignmentPoint) before drawing the text.
- * It also works where there is no decimal, but possibly additional
- * characters at the end, e.g., with parentheses in negative
- * numbers: "(12)" for -12.
- * - * Number formats are generally not synchronized. It is recommended to create - * separate format instances for each thread. If multiple threads access a format - * concurrently, it must be synchronized externally. - *
- * - *
DecimalFormat is the concrete implementation of NumberFormat, and the - * NumberFormat API is essentially an abstraction from DecimalFormat's API. - * Refer to DecimalFormat for more information about this API.
- * - * see DecimalFormat - * see java.text.ChoiceFormat - * @author Mark Davis - * @author Helena Shih - * @author Alan Liu - * @stable ICU 2.0 - */ -public class NumberFormat extends Format { - private static final long serialVersionUID = 1; - - /** - * @internal - */ - public final java.text.NumberFormat numberFormat; - - /** - * @internal - * @param delegate the NumberFormat to which to delegate - */ - public NumberFormat(java.text.NumberFormat delegate) { - this.numberFormat = delegate; - } - - /** - * Default constructor to mirror Java's default public - * constructor. Java's is not callable as a public API, since - * their NumberFormat is abstract, so this is only useful to - * subclasses. In general, subclasses will not work unless - * they manipulate the delegate. - */ - public NumberFormat() { - this.numberFormat = java.text.NumberFormat.getInstance(); - } - - /** - * Field constant used to construct a FieldPosition object. Signifies that - * the position of the integer part of a formatted number should be returned. - * @see java.text.FieldPosition - * @stable ICU 2.0 - */ - public static final int INTEGER_FIELD = 0; - - /** - * Field constant used to construct a FieldPosition object. Signifies that - * the position of the fraction part of a formatted number should be returned. - * @see java.text.FieldPosition - * @stable ICU 2.0 - */ - public static final int FRACTION_FIELD = 1; - - /** - * CHANGED - * Format an object. Change: recognizesBigInteger
- * and BigDecimal
objects.
- * @stable ICU 2.0
- */
- public StringBuffer format(Object number, StringBuffer toAppendTo, FieldPosition pos) {
- return numberFormat.format(number, toAppendTo, pos);
- }
-
- /**
- * @stable ICU 2.0
- */
- public final Object parseObject(String source, ParsePosition parsePosition) {
- return numberFormat.parse(source, parsePosition);
- }
-
- /**
- * Specialization of format.
- * @see java.text.Format#format(Object)
- * @stable ICU 2.0
- */
- public final String format(double number) {
- return numberFormat.format(number);
- }
-
- /**
- * Specialization of format.
- * @see java.text.Format#format(Object)
- * @stable ICU 2.0
- */
- public final String format(long number) {
- return numberFormat.format(number);
- }
-
- /**
- * NEW
- * Convenience method to format a BigInteger.
- * @stable ICU 2.0
- */
- public final String format(BigInteger number) {
- return numberFormat.format(number);
- }
-
- /**
- * Specialization of format.
- * @see java.text.Format#format(Object, StringBuffer, FieldPosition)
- * @stable ICU 2.0
- */
- public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
- return numberFormat.format(number, toAppendTo, pos);
- }
-
- /**
- * Specialization of format.
- * @see java.text.Format#format(Object, StringBuffer, FieldPosition)
- * @stable ICU 2.0
- */
- public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) {
- return numberFormat.format(number, toAppendTo, pos);
- }
-
- /**
- * NEW
- * Format a BigInteger.
- * @see java.text.Format#format(Object, StringBuffer, FieldPosition)
- * @stable ICU 2.0
- */
- public StringBuffer format(BigInteger number, StringBuffer toAppendTo, FieldPosition pos) {
- return numberFormat.format(number, toAppendTo, pos);
- }
- /**
- * Returns a Long if possible (e.g., within the range [Long.MIN_VALUE,
- * Long.MAX_VALUE] and with no decimals), otherwise a Double.
- * If IntegerOnly is set, will stop at a decimal
- * point (or equivalent; e.g., for rational numbers "1 2/3", will stop
- * after the 1).
- * Does not throw an exception; if no object can be parsed, index is
- * unchanged!
- * @see #isParseIntegerOnly
- * @see java.text.Format#parseObject(String, ParsePosition)
- * @stable ICU 2.0
- */
- public Number parse(String text, ParsePosition parsePosition) {
- return numberFormat.parse(text, parsePosition);
- }
-
- /**
- * Parses text from the beginning of the given string to produce a number.
- * The method might not use the entire text of the given string.
- *
- * @param text A String whose beginning should be parsed.
- * @return A Number parsed from the string.
- * @exception ParseException if the beginning of the specified string
- * cannot be parsed.
- * @see #format
- * @stable ICU 2.0
- */
- public Number parse(String text) throws ParseException {
- return numberFormat.parse(text);
- }
- /**
- * Returns true if this format will parse numbers as integers only.
- * For example in the English locale, with ParseIntegerOnly true, the
- * string "1234." would be parsed as the integer value 1234 and parsing
- * would stop at the "." character. The decimal separator accepted
- * by the parse operation is locale-dependent and determined by the
- * subclass.
- * @return true if this will parse integers only
- * @stable ICU 2.0
- */
- public boolean isParseIntegerOnly() {
- return numberFormat.isParseIntegerOnly();
- }
-
- /**
- * Sets whether or not numbers should be parsed as integers only.
- * @param value true if this should parse integers only
- * @see #isParseIntegerOnly
- * @stable ICU 2.0
- */
- public void setParseIntegerOnly(boolean value) {
- numberFormat.setParseIntegerOnly(value);
- }
-
- //============== Locale Stuff =====================
-
- /**
- * Returns the default number format for the current default locale.
- * The default format is one of the styles provided by the other
- * factory methods: getNumberInstance, getIntegerInstance,
- * getCurrencyInstance or getPercentInstance.
- * Exactly which one is locale-dependent.
- * @stable ICU 2.0
- */
- public final static NumberFormat getInstance() {
- return getInstance(ULocale.getDefault(), NUMBERSTYLE);
- }
-
- /**
- * Returns the default number format for the specified locale.
- * The default format is one of the styles provided by the other
- * factory methods: getNumberInstance, getCurrencyInstance or getPercentInstance.
- * Exactly which one is locale-dependent.
- * @stable ICU 2.0
- */
- public static NumberFormat getInstance(Locale inLocale) {
- return getInstance(ULocale.forLocale(inLocale), NUMBERSTYLE);
- }
-
- /**
- * Returns the default number format for the specified locale.
- * The default format is one of the styles provided by the other
- * factory methods: getNumberInstance, getCurrencyInstance or getPercentInstance.
- * Exactly which one is locale-dependent.
- * @stable ICU 3.2
- */
- public static NumberFormat getInstance(ULocale inLocale) {
- return getInstance(inLocale, NUMBERSTYLE);
- }
-
- /**
- * Returns a general-purpose number format for the current default locale.
- * @stable ICU 2.0
- */
- public final static NumberFormat getNumberInstance() {
- return getInstance(ULocale.getDefault(), NUMBERSTYLE);
- }
-
- /**
- * Returns a general-purpose number format for the specified locale.
- * @stable ICU 2.0
- */
- public static NumberFormat getNumberInstance(Locale inLocale) {
- return getInstance(ULocale.forLocale(inLocale), NUMBERSTYLE);
- }
-
- /**
- * Returns a general-purpose number format for the specified locale.
- * @stable ICU 3.2
- */
- public static NumberFormat getNumberInstance(ULocale inLocale) {
- return getInstance(inLocale, NUMBERSTYLE);
- }
-
- /**
- * Returns an integer number format for the current default locale. The
- * returned number format is configured to round floating point numbers
- * to the nearest integer using IEEE half-even rounding (see {@link
- * com.ibm.icu.math.BigDecimal#ROUND_HALF_EVEN ROUND_HALF_EVEN}) for formatting,
- * and to parse only the integer part of an input string (see {@link
- * #isParseIntegerOnly isParseIntegerOnly}).
- *
- * @return a number format for integer values
- * @stable ICU 2.0
- */
- public final static NumberFormat getIntegerInstance() {
- return getInstance(ULocale.getDefault(), INTEGERSTYLE);
- }
-
- /**
- * Returns an integer number format for the specified locale. The
- * returned number format is configured to round floating point numbers
- * to the nearest integer using IEEE half-even rounding (see {@link
- * com.ibm.icu.math.BigDecimal#ROUND_HALF_EVEN ROUND_HALF_EVEN}) for formatting,
- * and to parse only the integer part of an input string (see {@link
- * #isParseIntegerOnly isParseIntegerOnly}).
- *
- * @param inLocale the locale for which a number format is needed
- * @return a number format for integer values
- * @stable ICU 2.0
- */
- public static NumberFormat getIntegerInstance(Locale inLocale) {
- return getInstance(ULocale.forLocale(inLocale), INTEGERSTYLE);
- }
-
- /**
- * Returns an integer number format for the specified locale. The
- * returned number format is configured to round floating point numbers
- * to the nearest integer using IEEE half-even rounding (see {@link
- * com.ibm.icu.math.BigDecimal#ROUND_HALF_EVEN ROUND_HALF_EVEN}) for formatting,
- * and to parse only the integer part of an input string (see {@link
- * #isParseIntegerOnly isParseIntegerOnly}).
- *
- * @param inLocale the locale for which a number format is needed
- * @return a number format for integer values
- * @stable ICU 3.2
- */
- public static NumberFormat getIntegerInstance(ULocale inLocale) {
- return getInstance(inLocale, INTEGERSTYLE);
- }
-
- /**
- * Returns a currency format for the current default locale.
- * @return a number format for currency
- * @stable ICU 2.0
- */
- public final static NumberFormat getCurrencyInstance() {
- return getInstance(ULocale.getDefault(), CURRENCYSTYLE);
- }
-
- /**
- * Returns a currency format for the specified locale.
- * @return a number format for currency
- * @stable ICU 2.0
- */
- public static NumberFormat getCurrencyInstance(Locale inLocale) {
- return getInstance(ULocale.forLocale(inLocale), CURRENCYSTYLE);
- }
-
- /**
- * Returns a currency format for the specified locale.
- * @return a number format for currency
- * @stable ICU 3.2
- */
- public static NumberFormat getCurrencyInstance(ULocale inLocale) {
- return getInstance(inLocale, CURRENCYSTYLE);
- }
-
- /**
- * Returns a percentage format for the current default locale.
- * @return a number format for percents
- * @stable ICU 2.0
- */
- public final static NumberFormat getPercentInstance() {
- return getInstance(ULocale.getDefault(), PERCENTSTYLE);
- }
-
- /**
- * Returns a percentage format for the specified locale.
- * @return a number format for percents
- * @stable ICU 2.0
- */
- public static NumberFormat getPercentInstance(Locale inLocale) {
- return getInstance(ULocale.forLocale(inLocale), PERCENTSTYLE);
- }
-
- /**
- * Returns a percentage format for the specified locale.
- * @return a number format for percents
- * @stable ICU 3.2
- */
- public static NumberFormat getPercentInstance(ULocale inLocale) {
- return getInstance(inLocale, PERCENTSTYLE);
- }
-
- /**
- * NEW
- * Returns a scientific format for the current default locale.
- * @return a scientific number format
- * @stable ICU 2.0
- */
- public final static NumberFormat getScientificInstance() {
- return getInstance(ULocale.getDefault(), SCIENTIFICSTYLE);
- }
-
- /**
- * NEW
- * Returns a scientific format for the specified locale.
- * @return a scientific number format
- * @stable ICU 2.0
- */
- public static NumberFormat getScientificInstance(Locale inLocale) {
- return getInstance(ULocale.forLocale(inLocale), SCIENTIFICSTYLE);
- }
-
- /**
- * NEW
- * Returns a scientific format for the specified locale.
- * @return a scientific number format
- * @stable ICU 3.2
- */
- public static NumberFormat getScientificInstance(ULocale inLocale) {
- return getInstance(inLocale, SCIENTIFICSTYLE);
- }
-
- /**
- * Get the list of Locales for which NumberFormats are available.
- * @return the available locales
- * @stable ICU 2.0
- */
- public static Locale[] getAvailableLocales() {
- return java.text.NumberFormat.getAvailableLocales();
- }
-
- /**
- * Get the list of Locales for which NumberFormats are available.
- * @return the available locales
- * @draft ICU 3.2 (retain)
- */
- public static ULocale[] getAvailableULocales() {
- if (availableULocales == null) {
- Locale[] locales = java.text.NumberFormat.getAvailableLocales();
- ULocale[] ulocales = new ULocale[locales.length];
- for (int i = 0; i < locales.length; ++i) {
- ulocales[i] = ULocale.forLocale(locales[i]);
- }
- availableULocales = ulocales;
- }
- return (ULocale[])availableULocales.clone();
- }
- private static ULocale[] availableULocales;
-
-
- /**
- * Returns true if grouping is used in this format. For example, in the
- * en_US locale, with grouping on, the number 1234567 will be formatted
- * as "1,234,567". The grouping separator as well as the size of each group
- * is locale-dependent and is determined by subclasses of NumberFormat.
- * Grouping affects both parsing and formatting.
- * @return true if grouping is used
- * @see #setGroupingUsed
- * @stable ICU 2.0
- */
- public boolean isGroupingUsed() {
- return numberFormat.isGroupingUsed();
- }
-
- /**
- * Sets whether or not grouping will be used in this format. Grouping
- * affects both parsing and formatting.
- * @see #isGroupingUsed
- * @param newValue true to use grouping.
- * @stable ICU 2.0
- */
- public void setGroupingUsed(boolean newValue) {
- numberFormat.setGroupingUsed(newValue);
- }
-
- /**
- * Returns the maximum number of digits allowed in the integer portion of a
- * number. The default value is 40, which subclasses can override.
- * When formatting, the exact behavior when this value is exceeded is
- * subclass-specific. When parsing, this has no effect.
- * @return the maximum number of integer digits
- * @see #setMaximumIntegerDigits
- * @stable ICU 2.0
- */
- public int getMaximumIntegerDigits() {
- return numberFormat.getMaximumIntegerDigits();
- }
-
- /**
- * Sets the maximum number of digits allowed in the integer portion of a
- * number. This must be >= minimumIntegerDigits. If the
- * new value for maximumIntegerDigits is less than the current value
- * of minimumIntegerDigits, then minimumIntegerDigits will also be set to
- * the new value.
- * @param newValue the maximum number of integer digits to be shown; if
- * less than zero, then zero is used. Subclasses might enforce an
- * upper limit to this value appropriate to the numeric type being formatted.
- * @see #getMaximumIntegerDigits
- * @stable ICU 2.0
- */
- public void setMaximumIntegerDigits(int newValue) {
- numberFormat.setMaximumIntegerDigits(newValue);
- }
-
- /**
- * Returns the minimum number of digits allowed in the integer portion of a
- * number. The default value is 1, which subclasses can override.
- * When formatting, if this value is not reached, numbers are padded on the
- * left with the locale-specific '0' character to ensure at least this
- * number of integer digits. When parsing, this has no effect.
- * @return the minimum number of integer digits
- * @see #setMinimumIntegerDigits
- * @stable ICU 2.0
- */
- public int getMinimumIntegerDigits() {
- return numberFormat.getMinimumIntegerDigits();
- }
-
- /**
- * Sets the minimum number of digits allowed in the integer portion of a
- * number. This must be <= maximumIntegerDigits. If the
- * new value for minimumIntegerDigits is more than the current value
- * of maximumIntegerDigits, then maximumIntegerDigits will also be set to
- * the new value.
- * @param newValue the minimum number of integer digits to be shown; if
- * less than zero, then zero is used. Subclasses might enforce an
- * upper limit to this value appropriate to the numeric type being formatted.
- * @see #getMinimumIntegerDigits
- * @stable ICU 2.0
- */
- public void setMinimumIntegerDigits(int newValue) {
- numberFormat.setMinimumIntegerDigits(newValue);
- }
-
- /**
- * Returns the maximum number of digits allowed in the fraction
- * portion of a number. The default value is 3, which subclasses
- * can override. When formatting, the exact behavior when this
- * value is exceeded is subclass-specific. When parsing, this has
- * no effect.
- * @return the maximum number of fraction digits
- * @see #setMaximumFractionDigits
- * @stable ICU 2.0
- */
- public int getMaximumFractionDigits() {
- return numberFormat.getMaximumFractionDigits();
- }
-
- /**
- * Sets the maximum number of digits allowed in the fraction portion of a
- * number. This must be >= minimumFractionDigits. If the
- * new value for maximumFractionDigits is less than the current value
- * of minimumFractionDigits, then minimumFractionDigits will also be set to
- * the new value.
- * @param newValue the maximum number of fraction digits to be shown; if
- * less than zero, then zero is used. The concrete subclass may enforce an
- * upper limit to this value appropriate to the numeric type being formatted.
- * @see #getMaximumFractionDigits
- * @stable ICU 2.0
- */
- public void setMaximumFractionDigits(int newValue) {
- numberFormat.setMaximumFractionDigits(newValue);
- }
-
- /**
- * Returns the minimum number of digits allowed in the fraction portion of a
- * number. The default value is 0, which subclasses can override.
- * When formatting, if this value is not reached, numbers are padded on
- * the right with the locale-specific '0' character to ensure at least
- * this number of fraction digits. When parsing, this has no effect.
- * @return the minimum number of fraction digits
- * @see #setMinimumFractionDigits
- * @stable ICU 2.0
- */
- public int getMinimumFractionDigits() {
- return numberFormat.getMinimumFractionDigits();
- }
-
- /**
- * Sets the minimum number of digits allowed in the fraction portion of a
- * number. This must be <= maximumFractionDigits. If the
- * new value for minimumFractionDigits exceeds the current value
- * of maximumFractionDigits, then maximumFractionDigits will also be set to
- * the new value.
- * @param newValue the minimum number of fraction digits to be shown; if
- * less than zero, then zero is used. Subclasses might enforce an
- * upper limit to this value appropriate to the numeric type being formatted.
- * @see #getMinimumFractionDigits
- * @stable ICU 2.0
- */
- public void setMinimumFractionDigits(int newValue) {
- numberFormat.setMinimumFractionDigits(newValue);
- }
-
- /**
- * Return a string suitable for debugging.
- * @return a string suitable for debugging
- * @stable ICU 3.4.2
- */
- public String toString() {
- return numberFormat.toString();
- }
-
- /**
- * Overrides Cloneable.
- * @stable ICU 2.0
- */
- public Object clone() {
- return new NumberFormat((java.text.NumberFormat)numberFormat.clone());
- }
-
- /**
- * Overrides equals. Two NumberFormats are equal if they are of the same class
- * and the settings (groupingUsed, parseIntegerOnly, maximumIntegerDigits, etc.
- * are equal.
- * @param obj the object to compare against
- * @return true if the object is equal to this.
- * @stable ICU 2.0
- */
- public boolean equals(Object obj) {
- try {
- return numberFormat.equals(((NumberFormat)obj).numberFormat);
- }
- catch (Exception e) {
- return false;
- }
- }
-
- /**
- * Overrides hashCode
- * @stable ICU 2.0
- */
- public int hashCode() {
- return numberFormat.hashCode();
- }
-
- // =======================privates===============================
-
- private static NumberFormat getInstance(ULocale desiredLocale, int choice) {
- Locale locale = desiredLocale.toLocale();
- java.text.NumberFormat nf = null;
- switch (choice) {
- case NUMBERSTYLE: nf = java.text.NumberFormat.getInstance(locale); break;
- case CURRENCYSTYLE: nf = java.text.NumberFormat.getCurrencyInstance(locale); break;
- case PERCENTSTYLE: nf = java.text.NumberFormat.getPercentInstance(locale); break;
- case SCIENTIFICSTYLE: nf = new java.text.DecimalFormat("#E0", new DecimalFormatSymbols(locale));
- nf.setMaximumFractionDigits(10);
- break;
- case INTEGERSTYLE:
- if (unchecked) {
- unchecked = false;
- try {
- Class[] args = { java.util.Locale.class };
- integer14API = java.text.NumberFormat.class.getMethod("getIntegerInstance", args);
- }
- catch (Exception e) {
- }
- }
- if (integer14API != null) {
- try {
- Object[] args = { locale };
- nf = (java.text.NumberFormat)integer14API.invoke(null, args);
- }
- catch (IllegalAccessException e) {
- integer14API = null;
- }
- catch (InvocationTargetException e) {
- integer14API = null;
- }
- catch (Exception e) {
- // shouldn't happen, but locale might be null, for example
- // and we don't want to throw away our method because someone
- // called us with a bad parameter
- }
- }
- if (nf == null) {
- nf = java.text.NumberFormat.getNumberInstance(locale);
- nf.setMaximumFractionDigits(0);
- nf.setParseIntegerOnly(true);
- }
- break;
- }
- return new NumberFormat(nf);
- }
-
- private static boolean unchecked = true;
- private static Method integer14API;
-
- private static final int NUMBERSTYLE = 0;
- private static final int CURRENCYSTYLE = 1;
- private static final int PERCENTSTYLE = 2;
- private static final int SCIENTIFICSTYLE = 3;
- private static final int INTEGERSTYLE = 4;
-}
diff --git a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/SimpleDateFormat.java b/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/SimpleDateFormat.java
deleted file mode 100644
index ddf03001420..00000000000
--- a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/SimpleDateFormat.java
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- *******************************************************************************
- * Copyright (C) 1996-2008, International Business Machines Corporation and *
- * others. All Rights Reserved. *
- *******************************************************************************
- */
-
-package com.ibm.icu.text;
-
-import java.text.FieldPosition;
-import java.text.ParsePosition;
-import java.util.Date;
-import java.util.Locale;
-
-import com.ibm.icu.util.Calendar;
-import com.ibm.icu.util.ULocale;
-
-/**
- * SimpleDateFormat
is a concrete class for formatting and
- * parsing dates in a locale-sensitive manner. It allows for formatting
- * (date -> text), parsing (text -> date), and normalization.
- *
- *
- * SimpleDateFormat
allows you to start by choosing
- * any user-defined patterns for date-time formatting. However, you
- * are encouraged to create a date-time formatter with either
- * getTimeInstance
, getDateInstance
, or
- * getDateTimeInstance
in DateFormat
. Each
- * of these class methods can return a date/time formatter initialized
- * with a default format pattern. You may modify the format pattern
- * using the applyPattern
methods as desired.
- * For more information on using these methods, see
- * {@link DateFormat}.
- *
- *
- * Time Format Syntax: - *
- * To specify the time format use a time pattern string. - * In this pattern, all ASCII letters are reserved as pattern letters, - * which are defined as the following: - *
- *- * * These items are not supported by Java's SimpleDateFormat.- * Symbol Meaning Presentation Example - * ------ ------- ------------ ------- - * G era designator (Text) AD - * y† year (Number) 1996 - * Y* year (week of year) (Number) 1997 - * u* extended year (Number) 4601 - * M month in year (Text & Number) July & 07 - * d day in month (Number) 10 - * h hour in am/pm (1~12) (Number) 12 - * H hour in day (0~23) (Number) 0 - * m minute in hour (Number) 30 - * s second in minute (Number) 55 - * S fractional second (Number) 978 - * E day of week (Text) Tuesday - * e* day of week (local 1~7) (Number) 2 - * D day in year (Number) 189 - * F day of week in month (Number) 2 (2nd Wed in July) - * w week in year (Number) 27 - * W week in month (Number) 2 - * a am/pm marker (Text) PM - * k hour in day (1~24) (Number) 24 - * K hour in am/pm (0~11) (Number) 0 - * z time zone (Text) Pacific Standard Time - * Z time zone (RFC 822) (Number) -0800 - * v time zone (generic) (Text) Pacific Time - * g* Julian day (Number) 2451334 - * A* milliseconds in day (Number) 69540000 - * ' escape for text (Delimiter) 'Date=' - * '' single quote (Literal) 'o''clock' - *- *
- * The count of pattern letters determine the format. - *
- * (Text): 4 or more pattern letters--use full form, - * < 4--use short or abbreviated form if one exists. - *
- * (Number): the minimum number of digits. Shorter - * numbers are zero-padded to this amount. Year is handled specially; - * that is, if the count of 'y' is 2, the Year will be truncated to 2 digits. - * (e.g., if "yyyy" produces "1997", "yy" produces "97".) - * Unlike other fields, fractional seconds are padded on the right with zero. - *
- * (Text & Number): 3 or over, use text, otherwise use number. - *
- * Any characters in the pattern that are not in the ranges of ['a'..'z'] - * and ['A'..'Z'] will be treated as quoted text. For instance, characters - * like ':', '.', ' ', '#' and '@' will appear in the resulting time text - * even they are not embraced within single quotes. - *
- * A pattern containing any invalid pattern letter will result in a thrown - * exception during formatting or parsing. - * - *
- * Examples Using the US Locale: - *
- *- * Code Sample: - *- * Format Pattern Result - * -------------- ------- - * "yyyy.MM.dd G 'at' HH:mm:ss vvvv" ->> 1996.07.10 AD at 15:08:56 Pacific Time - * "EEE, MMM d, ''yy" ->> Wed, July 10, '96 - * "h:mm a" ->> 12:08 PM - * "hh 'o''clock' a, zzzz" ->> 12 o'clock PM, Pacific Daylight Time - * "K:mm a, vvv" ->> 0:00 PM, PT - * "yyyyy.MMMMM.dd GGG hh:mm aaa" ->> 01996.July.10 AD 12:08 PM - *- *
- *- * In the example, the time value- * SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, "PST"); - * pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2*60*60*1000); - * pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2*60*60*1000); - *- *
- * // Format the current time. - * SimpleDateFormat formatter - * = new SimpleDateFormat ("yyyy.MM.dd G 'at' hh:mm:ss a zzz"); - * Date currentTime_1 = new Date(); - * String dateString = formatter.format(currentTime_1); - *
- * // Parse the previous string back into a Date. - * ParsePosition pos = new ParsePosition(0); - * Date currentTime_2 = formatter.parse(dateString, pos); - *
currentTime_2
obtained from
- * parsing will be equal to currentTime_1
. However, they may not be
- * equal if the am/pm marker 'a' is left out from the format pattern while
- * the "hour in am/pm" pattern symbol is used. This information loss can
- * happen when formatting the time in PM.
- *
- * - * When parsing a date string using the abbreviated year pattern ("yy"), - * SimpleDateFormat must interpret the abbreviated year - * relative to some century. It does this by adjusting dates to be - * within 80 years before and 20 years after the time the SimpleDateFormat - * instance is created. For example, using a pattern of "MM/dd/yy" and a - * SimpleDateFormat instance created on Jan 1, 1997, the string - * "01/11/12" would be interpreted as Jan 11, 2012 while the string "05/04/64" - * would be interpreted as May 4, 1964. - * During parsing, only strings consisting of exactly two digits, as defined by - * {@link java.lang.Character#isDigit(char)}, will be parsed into the default - * century. - * Any other numeric string, such as a one digit string, a three or more digit - * string, or a two digit string that isn't all digits (for example, "-1"), is - * interpreted literally. So "01/02/3" or "01/02/003" are parsed, using the - * same pattern, as Jan 2, 3 AD. Likewise, "01/02/-3" is parsed as Jan 2, 4 BC. - * - *
- * If the year pattern does not have exactly two 'y' characters, the year is - * interpreted literally, regardless of the number of digits. So using the - * pattern "MM/dd/yyyy", "01/11/12" parses to Jan 11, 12 A.D. - * - *
- * When numeric fields abut one another directly, with no intervening delimiter - * characters, they constitute a run of abutting numeric fields. Such runs are - * parsed specially. For example, the format "HHmmss" parses the input text - * "123456" to 12:34:56, parses the input text "12345" to 1:23:45, and fails to - * parse "1234". In other words, the leftmost field of the run is flexible, - * while the others keep a fixed width. If the parse fails anywhere in the run, - * then the leftmost field is shortened by one character, and the entire run is - * parsed again. This is repeated until either the parse succeeds or the - * leftmost field is one character in length. If the parse still fails at that - * point, the parse of the run fails. - * - *
- * For time zones that have no names, use strings GMT+hours:minutes or - * GMT-hours:minutes. - * - *
- * The calendar defines what is the first day of the week, the first week - * of the year, whether hours are zero based or not (0 vs 12 or 24), and the - * time zone. There is one common decimal format to handle all the numbers; - * the digit count is handled programmatically according to the pattern. - * - *
startDate
to startDate + 100 years
.
- * @stable ICU 2.0
- */
- public void set2DigitYearStart(Date startDate) {
- ((java.text.SimpleDateFormat)dateFormat).set2DigitYearStart(startDate);
- }
-
- /**
- * Returns the beginning date of the 100-year period 2-digit years are interpreted
- * as being within.
- * @return the start of the 100-year period into which two digit years are
- * parsed
- * @stable ICU 2.0
- */
- public Date get2DigitYearStart() {
- return ((java.text.SimpleDateFormat)dateFormat).get2DigitYearStart();
- }
-
- /**
- * Overrides DateFormat.
- * Formats a date or time, which is the standard millis - * since January 1, 1970, 00:00:00 GMT. - *
Example: using the US locale:
- * "yyyy.MM.dd G 'at' HH:mm:ss zzz" ->> 1996.07.10 AD at 15:08:56 PDT
- * @param cal the calendar whose date-time value is to be formatted into a date-time string
- * @param toAppendTo where the new date-time text is to be appended
- * @param pos the formatting position. On input: an alignment field,
- * if desired. On output: the offsets of the alignment field.
- * @return the formatted date-time string.
- * @see DateFormat
- * @stable ICU 2.0
- */
- public StringBuffer format(Calendar cal, StringBuffer toAppendTo, FieldPosition pos) {
- StringBuffer result;
- synchronized(dateFormat) {
- java.util.Calendar oldCal = dateFormat.getCalendar();
- dateFormat.setCalendar(cal.calendar);
- result = dateFormat.format(cal.getTime(), toAppendTo, pos);
- dateFormat.setCalendar(oldCal);
- }
- return result;
- }
-
- /**
- * Overrides DateFormat
- * @see DateFormat
- * @stable ICU 2.0
- */
- public void parse(String text, Calendar cal, ParsePosition parsePos) {
- // TODO: cannot set the parsed timezone, document?
- cal.setTime(dateFormat.parse(text, parsePos));
- }
-
- /**
- * Return a pattern string describing this date format.
- * @stable ICU 2.0
- */
- public String toPattern() {
- return ((java.text.SimpleDateFormat)dateFormat).toPattern();
- }
-
- /**
- * Return a localized pattern string describing this date format.
- * @stable ICU 2.0
- */
- public String toLocalizedPattern() {
- return ((java.text.SimpleDateFormat)dateFormat).toLocalizedPattern();
- }
-
- /**
- * Apply the given unlocalized pattern string to this date format.
- * @stable ICU 2.0
- */
- public void applyPattern(String pattern) {
- ((java.text.SimpleDateFormat)dateFormat).applyPattern(pattern);
- }
-
- /**
- * Apply the given localized pattern string to this date format.
- * @stable ICU 2.0
- */
- public void applyLocalizedPattern(String pattern) {
- ((java.text.SimpleDateFormat)dateFormat).applyLocalizedPattern(pattern);
- }
-
- /**
- * Gets the date/time formatting data.
- * @return a copy of the date-time formatting data associated
- * with this date-time formatter.
- * @stable ICU 2.0
- */
- public DateFormatSymbols getDateFormatSymbols() {
- return new DateFormatSymbols(((java.text.SimpleDateFormat)dateFormat).getDateFormatSymbols());
- }
-
- /**
- * Allows you to set the date/time formatting data.
- * @param newFormatSymbols the new symbols
- * @stable ICU 2.0
- */
- public void setDateFormatSymbols(DateFormatSymbols newFormatSymbols) {
- ((java.text.SimpleDateFormat)dateFormat).setDateFormatSymbols(newFormatSymbols.dfs);
- }
-
- /**
- * Overrides Cloneable
- * @stable ICU 2.0
- */
- public Object clone() {
- return new SimpleDateFormat((java.text.SimpleDateFormat)dateFormat.clone());
- }
-
- /**
- * For clone to use
- * @param sdf
- */
- private SimpleDateFormat(java.text.SimpleDateFormat sdf) {
- super(sdf);
- }
-
- // hashCode, equals, clone use DateFormat implementation.
-}
diff --git a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/util/Calendar.java b/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/util/Calendar.java
deleted file mode 100644
index 18d4e02598a..00000000000
--- a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/util/Calendar.java
+++ /dev/null
@@ -1,2118 +0,0 @@
-/*
- *******************************************************************************
- * Copyright (C) 1996-2008, International Business Machines Corporation and *
- * others. All Rights Reserved. *
- *******************************************************************************
- */
-
-
-package com.ibm.icu.util;
-
-import java.io.Serializable;
-import java.util.Date;
-import java.util.Locale;
-
-import com.ibm.icu.text.DateFormat;
-
-/**
- * Calendar
is an abstract base class for converting between
- * a Date
object and a set of integer fields such as
- * YEAR
, MONTH
, DAY
, HOUR
,
- * and so on. (A Date
object represents a specific instant in
- * time with millisecond precision. See
- * {@link Date}
- * for information about the Date
class.)
- *
- *
Note: This class is similar, but not identical, to the class
- * java.util.Calendar
. Changes are detailed below.
- *
- *
- * Subclasses of Calendar
interpret a Date
- * according to the rules of a specific calendar system. ICU4J contains
- * several subclasses implementing different international calendar systems.
- *
- *
- * Like other locale-sensitive classes, Calendar
provides a
- * class method, getInstance
, for getting a generally useful
- * object of this type. Calendar
's getInstance
method
- * returns a calendar of a type appropriate to the locale, whose
- * time fields have been initialized with the current date and time:
- *
- *- * - *Calendar rightNow = Calendar.getInstance()- *
When a ULocale
is used by getInstance
, its
- * 'calendar
' tag and value are retrieved if present. If a recognized
- * value is supplied, a calendar is provided and configured as appropriate.
- * Currently recognized tags are "buddhist", "chinese", "coptic", "ethiopic",
- * "gregorian", "hebrew", "islamic", "islamic-civil", and "japanese". For
- * example:
- *will return an instance of JapaneseCalendar (using en_US conventions for - * minimum days in first week, start day of week, et cetera). - * - *Calendar cal = Calendar.getInstance(new ULocale("en_US@calendar=japanese"));- *
A Calendar
object can produce all the time field values
- * needed to implement the date-time formatting for a particular language and
- * calendar style (for example, Japanese-Gregorian, Japanese-Traditional).
- * Calendar
defines the range of values returned by certain fields,
- * as well as their meaning. For example, the first month of the year has value
- * MONTH
== JANUARY
for all calendars. Other values
- * are defined by the concrete subclass, such as ERA
and
- * YEAR
. See individual field documentation and subclass
- * documentation for details.
- *
- *
When a Calendar
is lenient, it accepts a wider range
- * of field values than it produces. For example, a lenient
- * GregorianCalendar
interprets MONTH
==
- * JANUARY
, DAY_OF_MONTH
== 32 as February 1. A
- * non-lenient GregorianCalendar
throws an exception when given
- * out-of-range field settings. When calendars recompute field values for
- * return by get()
, they normalize them. For example, a
- * GregorianCalendar
always produces DAY_OF_MONTH
- * values between 1 and the length of the month.
- *
- *
Calendar
defines a locale-specific seven day week using two
- * parameters: the first day of the week and the minimal days in first week
- * (from 1 to 7). These numbers are taken from the locale resource data when a
- * Calendar
is constructed. They may also be specified explicitly
- * through the API.
- *
- *
When setting or getting the WEEK_OF_MONTH
or
- * WEEK_OF_YEAR
fields, Calendar
must determine the
- * first week of the month or year as a reference point. The first week of a
- * month or year is defined as the earliest seven day period beginning on
- * getFirstDayOfWeek()
and containing at least
- * getMinimalDaysInFirstWeek()
days of that month or year. Weeks
- * numbered ..., -1, 0 precede the first week; weeks numbered 2, 3,... follow
- * it. Note that the normalized numbering returned by get()
may be
- * different. For example, a specific Calendar
subclass may
- * designate the week before week 1 of a year as week n of the previous
- * year.
- *
- *
When computing a Date
from time fields, two special
- * circumstances may arise: there may be insufficient information to compute the
- * Date
(such as only year and month but no day in the month), or
- * there may be inconsistent information (such as "Tuesday, July 15, 1996" --
- * July 15, 1996 is actually a Monday).
- *
- *
- * Insufficient information. The calendar will use default - * information to specify the missing fields. This may vary by calendar; for - * the Gregorian calendar, the default for a field is the same as that of the - * start of the epoch: i.e., YEAR = 1970, MONTH = JANUARY, DATE = 1, etc. - * - *
- * Inconsistent information. If fields conflict, the calendar - * will give preference to fields set more recently. For example, when - * determining the day, the calendar will look for one of the following - * combinations of fields. The most recent combination, as determined by the - * most recently set single field, will be used. - * - *
- *- * - * For the time of day: - * - *- * MONTH + DAY_OF_MONTH - * MONTH + WEEK_OF_MONTH + DAY_OF_WEEK - * MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK - * DAY_OF_YEAR - * DAY_OF_WEEK + WEEK_OF_YEAR- *
- *- * - *- * HOUR_OF_DAY - * AM_PM + HOUR- *
- * Note: for some non-Gregorian calendars, different - * fields may be necessary for complete disambiguation. For example, a full - * specification of the historial Arabic astronomical calendar requires year, - * month, day-of-month and day-of-week in some cases. - * - *
- * Note: There are certain possible ambiguities in - * interpretation of certain singular times, which are resolved in the - * following ways: - *
- * The date or time format strings are not part of the definition of a - * calendar, as those must be modifiable or overridable by the user at - * runtime. Use {@link DateFormat} - * to format dates. - * - *
Field manipulation methods
- * - *Calendar
fields can be changed using three methods:
- * set()
, add()
, and roll()
.
set(f, value)
changes field
- * f
to value
. In addition, it sets an
- * internal member variable to indicate that field f
has
- * been changed. Although field f
is changed immediately,
- * the calendar's milliseconds is not recomputed until the next call to
- * get()
, getTime()
, or
- * getTimeInMillis()
is made. Thus, multiple calls to
- * set()
do not trigger multiple, unnecessary
- * computations. As a result of changing a field using
- * set()
, other fields may also change, depending on the
- * field, the field value, and the calendar system. In addition,
- * get(f)
will not necessarily return value
- * after the fields have been recomputed. The specifics are determined by
- * the concrete calendar class.
Example: Consider a GregorianCalendar
- * originally set to August 31, 1999. Calling set(Calendar.MONTH,
- * Calendar.SEPTEMBER)
sets the calendar to September 31,
- * 1999. This is a temporary internal representation that resolves to
- * October 1, 1999 if getTime()
is then called. However, a
- * call to set(Calendar.DAY_OF_MONTH, 30)
before the call to
- * getTime()
sets the calendar to September 30, 1999, since
- * no recomputation occurs after set()
itself.
add(f, delta)
adds delta
- * to field f
. This is equivalent to calling set(f,
- * get(f) + delta)
with two adjustments:
- *- * - *Add rule 1. The value of field
- * - *f
- * after the call minus the value of fieldf
before the - * call isdelta
, modulo any overflow that has occurred in - * fieldf
. Overflow occurs when a field value exceeds its - * range and, as a result, the next larger field is incremented or - * decremented and the field value is adjusted back into its range.Add rule 2. If a smaller field is expected to be - * invariant, but it is impossible for it to be equal to its - * prior value because of changes in its minimum or maximum after field - *
- *f
is changed, then its value is adjusted to be as close - * as possible to its expected value. A smaller field represents a - * smaller unit of time.HOUR
is a smaller field than - *DAY_OF_MONTH
. No adjustment is made to smaller fields - * that are not expected to be invariant. The calendar system - * determines what fields are expected to be invariant.
In addition, unlike set()
, add()
forces
- * an immediate recomputation of the calendar's milliseconds and all
- * fields.
Example: Consider a GregorianCalendar
- * originally set to August 31, 1999. Calling add(Calendar.MONTH,
- * 13)
sets the calendar to September 30, 2000. Add rule
- * 1 sets the MONTH
field to September, since
- * adding 13 months to August gives September of the next year. Since
- * DAY_OF_MONTH
cannot be 31 in September in a
- * GregorianCalendar
, add rule 2 sets the
- * DAY_OF_MONTH
to 30, the closest possible value. Although
- * it is a smaller field, DAY_OF_WEEK
is not adjusted by
- * rule 2, since it is expected to change when the month changes in a
- * GregorianCalendar
.
roll(f, delta)
adds
- * delta
to field f
without changing larger
- * fields. This is equivalent to calling add(f, delta)
with
- * the following adjustment:
- *- * - *Roll rule. Larger fields are unchanged after the - * call. A larger field represents a larger unit of - * time.
- *DAY_OF_MONTH
is a larger field than - *HOUR
.
Example: Consider a GregorianCalendar
- * originally set to August 31, 1999. Calling roll(Calendar.MONTH,
- * 8)
sets the calendar to April 30, 1999. Add
- * rule 1 sets the MONTH
field to April. Using a
- * GregorianCalendar
, the DAY_OF_MONTH
cannot
- * be 31 in the month April. Add rule 2 sets it to the closest possible
- * value, 30. Finally, the roll rule maintains the
- * YEAR
field value of 1999.
Example: Consider a GregorianCalendar
- * originally set to Sunday June 6, 1999. Calling
- * roll(Calendar.WEEK_OF_MONTH, -1)
sets the calendar to
- * Tuesday June 1, 1999, whereas calling
- * add(Calendar.WEEK_OF_MONTH, -1)
sets the calendar to
- * Sunday May 30, 1999. This is because the roll rule imposes an
- * additional constraint: The MONTH
must not change when the
- * WEEK_OF_MONTH
is rolled. Taken together with add rule 1,
- * the resultant date must be between Tuesday June 1 and Saturday June
- * 5. According to add rule 2, the DAY_OF_WEEK
, an invariant
- * when changing the WEEK_OF_MONTH
, is set to Tuesday, the
- * closest possible value to Sunday (where Sunday is the first day of the
- * week).
Usage model. To motivate the behavior of
- * add()
and roll()
, consider a user interface
- * component with increment and decrement buttons for the month, day, and
- * year, and an underlying GregorianCalendar
. If the
- * interface reads January 31, 1999 and the user presses the month
- * increment button, what should it read? If the underlying
- * implementation uses set()
, it might read March 3, 1999. A
- * better result would be February 28, 1999. Furthermore, if the user
- * presses the month increment button again, it should read March 31,
- * 1999, not March 28, 1999. By saving the original date and using either
- * add()
or roll()
, depending on whether larger
- * fields should be affected, the user interface can behave as most users
- * will intuitively expect.
Note: You should always use {@link #roll roll} and {@link #add add} rather - * than attempting to perform arithmetic operations directly on the fields - * of a Calendar. It is quite possible for Calendar subclasses - * to have fields with non-linear behavior, for example missing months - * or days during non-leap years. The subclasses' add and roll - * methods will take this into account, while simple arithmetic manipulations - * may give invalid results. - * - *
Calendar Architecture in ICU4J
- * - *Recently the implementation of Calendar
has changed
- * significantly in order to better support subclassing. The original
- * Calendar
class was designed to support subclassing, but
- * it had only one implemented subclass, GregorianCalendar
.
- * With the implementation of several new calendar subclasses, including
- * the BuddhistCalendar
, ChineseCalendar
,
- * HebrewCalendar
, IslamicCalendar
, and
- * JapaneseCalendar
, the subclassing API has been reworked
- * thoroughly. This section details the new subclassing API and other
- * ways in which com.ibm.icu.util.Calendar
differs from
- * java.util.Calendar
.
- *
Changes
- * - *Overview of changes between the classic Calendar
- * architecture and the new architecture.
- *
- *
fields[]
array is private
now
- * instead of protected
. Subclasses must access it
- * using the methods {@link #internalSet} and
- * {@link #internalGet}. Motivation: Subclasses should
- * not directly access data members.time
long word is private
now
- * instead of protected
. Subclasses may access it using
- * the method {@link #internalGetTimeInMillis}, which does not
- * provoke an update. Motivation: Subclasses should not
- * directly access data members.Calendar
base class. As a result, it is much easier
- * to subclass Calendar
. Motivation: Subclasses
- * should not have to reimplement common code. Certain behaviors are
- * common across calendar systems: The definition and behavior of
- * week-related fields and time fields, the arithmetic
- * ({@link #add(int, int) add} and {@link #roll(int, int) roll}) behavior of many
- * fields, and the field validation system.Calendar
base class contains some Gregorian
- * calendar algorithmic support that subclasses can use (specifically
- * in {@link #handleComputeFields}). Subclasses can use the
- * methods getGregorianXxx()
to obtain precomputed
- * values. Motivation: This is required by all
- * Calendar
subclasses in order to implement consistent
- * time zone behavior, and Gregorian-derived systems can use the
- * already computed data.FIELD_COUNT
constant has been removed. Use
- * {@link #getFieldCount}. In addition, framework API has been
- * added to allow subclasses to define additional fields.
- * Motivation: The number of fields is not constant across
- * calendar systems.Date(Long.MIN_VALUE)
or
- * Date(Long.MAX_VALUE)
. Instead, the
- * Calendar
constants {@link #MIN_DATE},
- * {@link #MAX_DATE}, {@link #MIN_MILLIS},
- * {@link #MAX_MILLIS}, {@link #MIN_JULIAN}, and
- * {@link #MAX_JULIAN} should be used. Motivation: With
- * the addition of the {@link #JULIAN_DAY} field, Julian day
- * numbers must be restricted to a 32-bit int
. This
- * restricts the overall supported range. Furthermore, restricting
- * the supported range simplifies the computations by removing
- * special case code that was used to accomodate arithmetic overflow
- * at millis near Long.MIN_VALUE
and
- * Long.MAX_VALUE
.Calendar
.DateFormat
.Subclass API
- * - *The original Calendar
API was based on the experience
- * of implementing a only a single subclass,
- * GregorianCalendar
. As a result, all of the subclassing
- * kinks had not been worked out. The new subclassing API has been
- * refined based on several implemented subclasses. This includes methods
- * that must be overridden and methods for subclasses to call. Subclasses
- * no longer have direct access to fields
and
- * stamp
. Instead, they have new API to access
- * these. Subclasses are able to allocate the fields
array
- * through a protected framework method; this allows subclasses to
- * specify additional fields.
More functionality has been moved into the base class. The base - * class now contains much of the computational machinery to support the - * Gregorian calendar. This is based on two things: (1) Many calendars - * are based on the Gregorian calendar (such as the Buddhist and Japanese - * imperial calendars). (2) All calendars require basic - * Gregorian support in order to handle timezone computations.
- * - *Common computations have been moved into
- * Calendar
. Subclasses no longer compute the week related
- * fields and the time related fields. These are commonly handled for all
- * calendars by the base class.
Subclass computation of time => fields - * - *
The {@link #ERA}, {@link #YEAR},
- * {@link #EXTENDED_YEAR}, {@link #MONTH},
- * {@link #DAY_OF_MONTH}, and {@link #DAY_OF_YEAR} fields are
- * computed by the subclass, based on the Julian day. All other fields
- * are computed by Calendar
.
- *
- *
Calendar
,
- * they must also be computed. These are the only fields that the
- * subclass should compute. All other fields are computed by the base
- * class, so time and week fields behave in a consistent way across
- * all calendars. The default version of this method in
- * Calendar
implements a proleptic Gregorian
- * calendar. Within this method, subclasses may call
- * getGregorianXxx()
to obtain the Gregorian calendar
- * month, day of month, and extended year for the given date.Subclass computation of fields => time - * - *
The interpretation of most field values is handled entirely by
- * Calendar
. Calendar
determines which fields
- * are set, which are not, which are set more recently, and so on. In
- * addition, Calendar
handles the computation of the time
- * from the time fields and handles the week-related fields. The only
- * thing the subclass must do is determine the extended year, based on
- * the year fields, and then, given an extended year and a month, it must
- * return a Julian day number.
- *
- *
Other methods - * - *
limitType
. This method only needs to handle the
- * fields {@link #ERA}, {@link #YEAR}, {@link #MONTH},
- * {@link #WEEK_OF_YEAR}, {@link #WEEK_OF_MONTH},
- * {@link #DAY_OF_MONTH}, {@link #DAY_OF_YEAR},
- * {@link #DAY_OF_WEEK_IN_MONTH}, {@link #YEAR_WOY}, and
- * {@link #EXTENDED_YEAR}. Other fields are invariant (with
- * respect to calendar system) and are handled by the base
- * class.IllegalArgumentException
. The method may call
- * super.validateField(field)
to handle fields in a
- * generic way, that is, to compare them to the range
- * getMinimum(field)
..getMaximum(field)
.int[]
- * array large enough to hold the calendar's fields. This is only
- * necessary if the calendar defines additional fields beyond those
- * defined by Calendar
. The length of the result must be
- * at least {@link #BASE_FIELD_COUNT} and no more than
- * {@link #MAX_FIELD_COUNT}.DateFormat
appropriate to this calendar. This is only
- * required if a calendar subclass redefines the use of a field (for
- * example, changes the {@link #ERA} field from a symbolic field
- * to a numeric one) or defines an additional field.Normalized behavior - * - *
The behavior of certain fields has been made consistent across all
- * calendar systems and implemented in Calendar
.
- *
- *
Calendar
and to maintain basic correpsondences
- * between calendar systems. Affected fields: {@link #AM_PM},
- * {@link #HOUR}, {@link #HOUR_OF_DAY}, {@link #MINUTE},
- * {@link #SECOND}, {@link #MILLISECOND},
- * {@link #ZONE_OFFSET}, and {@link #DST_OFFSET}.GregorianCalendar
fields: the
- * {@link #YEAR}, {@link #MONTH}, and
- * {@link #DAY_OF_MONTH}. As a result, Calendar
- * always computes these fields, even for non-Gregorian calendar
- * systems. These fields are available to subclasses.WEEK_OF_YEAR,
- * WEEK_OF_MONTH
, {@link #DAY_OF_WEEK_IN_MONTH},
- * {@link #DOW_LOCAL}, {@link #YEAR_WOY} are all computed in
- * a consistent way in the base class, based on the
- * {@link #EXTENDED_YEAR}, {@link #DAY_OF_YEAR},
- * {@link #MONTH}, and {@link #DAY_OF_MONTH}, which are
- * computed by the subclass.Supported range - * - *
The allowable range of Calendar
has been
- * narrowed. GregorianCalendar
used to attempt to support
- * the range of dates with millisecond values from
- * Long.MIN_VALUE
to Long.MAX_VALUE
. This
- * introduced awkward constructions (hacks) which slowed down
- * performance. It also introduced non-uniform behavior at the
- * boundaries. The new Calendar
protocol specifies the
- * maximum range of supportable dates as those having Julian day numbers
- * of -0x7F000000
to +0x7F000000
. This
- * corresponds to years from ~5,000,000 BCE to ~5,000,000 CE. Programmers
- * should use the constants {@link #MIN_DATE} (or
- * {@link #MIN_MILLIS} or {@link #MIN_JULIAN}) and
- * {@link #MAX_DATE} (or {@link #MAX_MILLIS} or
- * {@link #MAX_JULIAN}) in Calendar
to specify an
- * extremely early or extremely late date.
General notes - * - *
GregorianCalendar
class supports
- * dates before the historical onset of the calendar by extending the
- * calendar system backward in time. Similarly, the
- * HebrewCalendar
extends backward before the start of
- * its epoch into zero and negative years. Subclasses do not throw
- * exceptions because a date precedes the historical start of a
- * calendar system. Instead, they implement
- * {@link #handleGetLimit} to return appropriate limits on
- * {@link #YEAR}, {@link #ERA}, etc. fields. Then, if the
- * calendar is set to not be lenient, out-of-range field values will
- * trigger an exception.ERA==AD ? YEAR : 1-YEAR
. Another example is the Mayan
- * long count, which has years (KUN
) and nested cycles
- * of years (KATUN
and BAKTUN
). The Mayan
- * {@link #EXTENDED_YEAR} is computed as TUN + 20 * (KATUN
- * + 20 * BAKTUN)
. The Calendar
base class uses
- * the {@link #EXTENDED_YEAR} field to compute the week-related
- * fields.get
and set
indicating the
- * era, e.g., AD or BC in the Julian calendar. This is a calendar-specific
- * value; see subclass documentation.
- * @see GregorianCalendar#AD
- * @see GregorianCalendar#BC
- * @stable ICU 2.0
- */
- public final static int ERA = 0;
-
- /**
- * Field number for get
and set
indicating the
- * year. This is a calendar-specific value; see subclass documentation.
- * @stable ICU 2.0
- */
- public final static int YEAR = 1;
-
- /**
- * Field number for get
and set
indicating the
- * month. This is a calendar-specific value. The first month of the year is
- * JANUARY
; the last depends on the number of months in a year.
- * @see #JANUARY
- * @see #FEBRUARY
- * @see #MARCH
- * @see #APRIL
- * @see #MAY
- * @see #JUNE
- * @see #JULY
- * @see #AUGUST
- * @see #SEPTEMBER
- * @see #OCTOBER
- * @see #NOVEMBER
- * @see #DECEMBER
- * @see #UNDECIMBER
- * @stable ICU 2.0
- */
- public final static int MONTH = 2;
-
- /**
- * Field number for get
and set
indicating the
- * week number within the current year. The first week of the year, as
- * defined by getFirstDayOfWeek()
and
- * getMinimalDaysInFirstWeek()
, has value 1. Subclasses define
- * the value of WEEK_OF_YEAR
for days before the first week of
- * the year.
- * @see #getFirstDayOfWeek
- * @see #getMinimalDaysInFirstWeek
- * @stable ICU 2.0
- */
- public final static int WEEK_OF_YEAR = 3;
-
- /**
- * Field number for get
and set
indicating the
- * week number within the current month. The first week of the month, as
- * defined by getFirstDayOfWeek()
and
- * getMinimalDaysInFirstWeek()
, has value 1. Subclasses define
- * the value of WEEK_OF_MONTH
for days before the first week of
- * the month.
- * @see #getFirstDayOfWeek
- * @see #getMinimalDaysInFirstWeek
- * @stable ICU 2.0
- */
- public final static int WEEK_OF_MONTH = 4;
-
- /**
- * Field number for get
and set
indicating the
- * day of the month. This is a synonym for DAY_OF_MONTH
.
- * The first day of the month has value 1.
- * @see #DAY_OF_MONTH
- * @stable ICU 2.0
- */
- public final static int DATE = 5;
-
- /**
- * Field number for get
and set
indicating the
- * day of the month. This is a synonym for DATE
.
- * The first day of the month has value 1.
- * @see #DATE
- * @stable ICU 2.0
- */
- public final static int DAY_OF_MONTH = 5;
-
- /**
- * Field number for get
and set
indicating the day
- * number within the current year. The first day of the year has value 1.
- * @stable ICU 2.0
- */
- public final static int DAY_OF_YEAR = 6;
-
- /**
- * Field number for get
and set
indicating the day
- * of the week. This field takes values SUNDAY
,
- * MONDAY
, TUESDAY
, WEDNESDAY
,
- * THURSDAY
, FRIDAY
, and SATURDAY
.
- * @see #SUNDAY
- * @see #MONDAY
- * @see #TUESDAY
- * @see #WEDNESDAY
- * @see #THURSDAY
- * @see #FRIDAY
- * @see #SATURDAY
- * @stable ICU 2.0
- */
- public final static int DAY_OF_WEEK = 7;
-
- /**
- * Field number for get
and set
indicating the
- * ordinal number of the day of the week within the current month. Together
- * with the DAY_OF_WEEK
field, this uniquely specifies a day
- * within a month. Unlike WEEK_OF_MONTH
and
- * WEEK_OF_YEAR
, this field's value does not depend on
- * getFirstDayOfWeek()
or
- * getMinimalDaysInFirstWeek()
. DAY_OF_MONTH 1
- * through 7
always correspond to DAY_OF_WEEK_IN_MONTH
- * 1
; 8
through 15
correspond to
- * DAY_OF_WEEK_IN_MONTH 2
, and so on.
- * DAY_OF_WEEK_IN_MONTH 0
indicates the week before
- * DAY_OF_WEEK_IN_MONTH 1
. Negative values count back from the
- * end of the month, so the last Sunday of a month is specified as
- * DAY_OF_WEEK = SUNDAY, DAY_OF_WEEK_IN_MONTH = -1
. Because
- * negative values count backward they will usually be aligned differently
- * within the month than positive values. For example, if a month has 31
- * days, DAY_OF_WEEK_IN_MONTH -1
will overlap
- * DAY_OF_WEEK_IN_MONTH 5
and the end of 4
.
- * @see #DAY_OF_WEEK
- * @see #WEEK_OF_MONTH
- * @stable ICU 2.0
- */
- public final static int DAY_OF_WEEK_IN_MONTH = 8;
-
- /**
- * Field number for get
and set
indicating
- * whether the HOUR
is before or after noon.
- * E.g., at 10:04:15.250 PM the AM_PM
is PM
.
- * @see #AM
- * @see #PM
- * @see #HOUR
- * @stable ICU 2.0
- */
- public final static int AM_PM = 9;
-
- /**
- * Field number for get
and set
indicating the
- * hour of the morning or afternoon. HOUR
is used for the 12-hour
- * clock.
- * E.g., at 10:04:15.250 PM the HOUR
is 10.
- * @see #AM_PM
- * @see #HOUR_OF_DAY
- * @stable ICU 2.0
- */
- public final static int HOUR = 10;
-
- /**
- * Field number for get
and set
indicating the
- * hour of the day. HOUR_OF_DAY
is used for the 24-hour clock.
- * E.g., at 10:04:15.250 PM the HOUR_OF_DAY
is 22.
- * @see #HOUR
- * @stable ICU 2.0
- */
- public final static int HOUR_OF_DAY = 11;
-
- /**
- * Field number for get
and set
indicating the
- * minute within the hour.
- * E.g., at 10:04:15.250 PM the MINUTE
is 4.
- * @stable ICU 2.0
- */
- public final static int MINUTE = 12;
-
- /**
- * Field number for get
and set
indicating the
- * second within the minute.
- * E.g., at 10:04:15.250 PM the SECOND
is 15.
- * @stable ICU 2.0
- */
- public final static int SECOND = 13;
-
- /**
- * Field number for get
and set
indicating the
- * millisecond within the second.
- * E.g., at 10:04:15.250 PM the MILLISECOND
is 250.
- * @stable ICU 2.0
- */
- public final static int MILLISECOND = 14;
-
- /**
- * Field number for get
and set
indicating the
- * raw offset from GMT in milliseconds.
- * @stable ICU 2.0
- */
- public final static int ZONE_OFFSET = 15;
-
- /**
- * Field number for get
and set
indicating the
- * daylight savings offset in milliseconds.
- * @stable ICU 2.0
- */
- public final static int DST_OFFSET = 16;
-
- /**
- * Field number for get()
and set()
- * indicating the extended year corresponding to the
- * WEEK_OF_YEAR
field. This may be one greater or less
- * than the value of EXTENDED_YEAR
.
- * @stable ICU 2.0
- */
- public static final int YEAR_WOY = 17;
-
- /**
- * Field number for get()
and set()
- * indicating the localized day of week. This will be a value from 1
- * to 7 inclusive, with 1 being the localized first day of the week.
- * @stable ICU 2.0
- */
- public static final int DOW_LOCAL = 18;
-
- /**
- * Field number for get()
and set()
- * indicating the extended year. This is a single number designating
- * the year of this calendar system, encompassing all supra-year
- * fields. For example, for the Julian calendar system, year numbers
- * are positive, with an era of BCE or CE. An extended year value for
- * the Julian calendar system assigns positive values to CE years and
- * negative values to BCE years, with 1 BCE being year 0.
- * @stable ICU 2.0
- */
- public static final int EXTENDED_YEAR = 19;
-
- /**
- * Field number for get()
and set()
- * indicating the modified Julian day number. This is different from
- * the conventional Julian day number in two regards. First, it
- * demarcates days at local zone midnight, rather than noon GMT.
- * Second, it is a local number; that is, it depends on the local time
- * zone. It can be thought of as a single number that encompasses all
- * the date-related fields.
- * @stable ICU 2.0
- */
- public static final int JULIAN_DAY = 20;
-
- /**
- * Field number for get()
and set()
- * indicating the milliseconds in the day. This ranges from 0 to
- * 23:59:59.999 (regardless of DST). This field behaves
- * exactly like a composite of all time-related fields, not
- * including the zone fields. As such, it also reflects
- * discontinuities of those fields on DST transition days. On a day of
- * DST onset, it will jump forward. On a day of DST cessation, it will
- * jump backward. This reflects the fact that is must be combined with
- * the DST_OFFSET field to obtain a unique local time value.
- * @stable ICU 2.0
- */
- public static final int MILLISECONDS_IN_DAY = 21;
-
- /**
- * The number of fields defined by this class. Subclasses may define
- * addition fields starting with this number.
- * @stable ICU 2.0
- */
- protected static final int BASE_FIELD_COUNT = 22;
-
- /**
- * The maximum number of fields possible. Subclasses must not define
- * more total fields than this number.
- * @stable ICU 2.0
- */
- protected static final int MAX_FIELD_COUNT = 32;
-
- /**
- * Value of the DAY_OF_WEEK
field indicating
- * Sunday.
- * @stable ICU 2.0
- */
- public final static int SUNDAY = 1;
-
- /**
- * Value of the DAY_OF_WEEK
field indicating
- * Monday.
- * @stable ICU 2.0
- */
- public final static int MONDAY = 2;
-
- /**
- * Value of the DAY_OF_WEEK
field indicating
- * Tuesday.
- * @stable ICU 2.0
- */
- public final static int TUESDAY = 3;
-
- /**
- * Value of the DAY_OF_WEEK
field indicating
- * Wednesday.
- * @stable ICU 2.0
- */
- public final static int WEDNESDAY = 4;
-
- /**
- * Value of the DAY_OF_WEEK
field indicating
- * Thursday.
- * @stable ICU 2.0
- */
- public final static int THURSDAY = 5;
-
- /**
- * Value of the DAY_OF_WEEK
field indicating
- * Friday.
- * @stable ICU 2.0
- */
- public final static int FRIDAY = 6;
-
- /**
- * Value of the DAY_OF_WEEK
field indicating
- * Saturday.
- * @stable ICU 2.0
- */
- public final static int SATURDAY = 7;
-
- /**
- * Value of the MONTH
field indicating the
- * first month of the year.
- * @stable ICU 2.0
- */
- public final static int JANUARY = 0;
-
- /**
- * Value of the MONTH
field indicating the
- * second month of the year.
- * @stable ICU 2.0
- */
- public final static int FEBRUARY = 1;
-
- /**
- * Value of the MONTH
field indicating the
- * third month of the year.
- * @stable ICU 2.0
- */
- public final static int MARCH = 2;
-
- /**
- * Value of the MONTH
field indicating the
- * fourth month of the year.
- * @stable ICU 2.0
- */
- public final static int APRIL = 3;
-
- /**
- * Value of the MONTH
field indicating the
- * fifth month of the year.
- * @stable ICU 2.0
- */
- public final static int MAY = 4;
-
- /**
- * Value of the MONTH
field indicating the
- * sixth month of the year.
- * @stable ICU 2.0
- */
- public final static int JUNE = 5;
-
- /**
- * Value of the MONTH
field indicating the
- * seventh month of the year.
- * @stable ICU 2.0
- */
- public final static int JULY = 6;
-
- /**
- * Value of the MONTH
field indicating the
- * eighth month of the year.
- * @stable ICU 2.0
- */
- public final static int AUGUST = 7;
-
- /**
- * Value of the MONTH
field indicating the
- * ninth month of the year.
- * @stable ICU 2.0
- */
- public final static int SEPTEMBER = 8;
-
- /**
- * Value of the MONTH
field indicating the
- * tenth month of the year.
- * @stable ICU 2.0
- */
- public final static int OCTOBER = 9;
-
- /**
- * Value of the MONTH
field indicating the
- * eleventh month of the year.
- * @stable ICU 2.0
- */
- public final static int NOVEMBER = 10;
-
- /**
- * Value of the MONTH
field indicating the
- * twelfth month of the year.
- * @stable ICU 2.0
- */
- public final static int DECEMBER = 11;
-
- /**
- * Value of the MONTH
field indicating the
- * thirteenth month of the year. Although GregorianCalendar
- * does not use this value, lunar calendars do.
- * @stable ICU 2.0
- */
- public final static int UNDECIMBER = 12;
-
- /**
- * Value of the AM_PM
field indicating the
- * period of the day from midnight to just before noon.
- * @stable ICU 2.0
- */
- public final static int AM = 0;
-
- /**
- * Value of the AM_PM
field indicating the
- * period of the day from noon to just before midnight.
- * @stable ICU 2.0
- */
- public final static int PM = 1;
-
- /**
- * Value returned by getDayOfWeekType(int dayOfWeek) to indicate a
- * weekday.
- * @see #WEEKEND
- * @see #WEEKEND_ONSET
- * @see #WEEKEND_CEASE
- * @see #getDayOfWeekType
- * @stable ICU 2.0
- */
- public static final int WEEKDAY = 0;
-
- /**
- * Value returned by getDayOfWeekType(int dayOfWeek) to indicate a
- * weekend day.
- * @see #WEEKDAY
- * @see #WEEKEND_ONSET
- * @see #WEEKEND_CEASE
- * @see #getDayOfWeekType
- * @stable ICU 2.0
- */
- public static final int WEEKEND = 1;
-
- /**
- * Value returned by getDayOfWeekType(int dayOfWeek) to indicate a
- * day that starts as a weekday and transitions to the weekend.
- * Call getWeekendTransition() to get the point of transition.
- * @see #WEEKDAY
- * @see #WEEKEND
- * @see #WEEKEND_CEASE
- * @see #getDayOfWeekType
- * @stable ICU 2.0
- */
- public static final int WEEKEND_ONSET = 2;
-
- /**
- * Value returned by getDayOfWeekType(int dayOfWeek) to indicate a
- * day that starts as the weekend and transitions to a weekday.
- * Call getWeekendTransition() to get the point of transition.
- * @see #WEEKDAY
- * @see #WEEKEND
- * @see #WEEKEND_ONSET
- * @see #getDayOfWeekType
- * @stable ICU 2.0
- */
- public static final int WEEKEND_CEASE = 3;
- /**
- * Gets a calendar using the default time zone and locale.
- * @return a Calendar.
- * @stable ICU 2.0
- */
- public static synchronized Calendar getInstance() {
- return new Calendar(java.util.Calendar.getInstance());
- }
-
- /**
- * Gets a calendar using the specified time zone and default locale.
- * @param zone the time zone to use
- * @return a Calendar.
- * @stable ICU 2.0
- */
- public static synchronized Calendar getInstance(TimeZone zone) {
- return new Calendar(java.util.Calendar.getInstance(zone.timeZone));
- }
-
- /**
- * Gets a calendar using the default time zone and specified locale.
- * @param aLocale the locale for the week data
- * @return a Calendar.
- * @stable ICU 2.0
- */
- public static synchronized Calendar getInstance(Locale aLocale) {
- return new Calendar(java.util.Calendar.getInstance(aLocale));
- }
-
- /**
- * Gets a calendar using the default time zone and specified locale.
- * @param locale the ulocale for the week data
- * @return a Calendar.
- * @stable ICU 3.2
- */
- public static synchronized Calendar getInstance(ULocale locale) {
- return new Calendar(java.util.Calendar.getInstance(locale.toLocale()));
- }
-
- /**
- * Gets a calendar with the specified time zone and locale.
- * @param zone the time zone to use
- * @param aLocale the locale for the week data
- * @return a Calendar.
- * @stable ICU 2.0
- */
- public static synchronized Calendar getInstance(TimeZone zone, Locale aLocale) {
- return new Calendar(java.util.Calendar.getInstance(zone.timeZone, aLocale));
- }
-
- /**
- * Gets a calendar with the specified time zone and locale.
- * @param zone the time zone to use
- * @param locale the ulocale for the week data
- * @return a Calendar.
- * @stable ICU 3.2
- */
- public static synchronized Calendar getInstance(TimeZone zone, ULocale locale) {
- return new Calendar(java.util.Calendar.getInstance(zone.timeZone, locale.toLocale()));
- }
-
- /**
- * Gets the list of locales for which Calendars are installed.
- * @return the list of locales for which Calendars are installed.
- * @stable ICU 2.0
- */
- public static Locale[] getAvailableLocales() {
- return java.util.Calendar.getAvailableLocales();
- }
-
- /**
- * Gets the list of locales for which Calendars are installed.
- * @return the list of locales for which Calendars are installed.
- * @draft ICU 3.2 (retain)
- */
- public static ULocale[] getAvailableULocales() {
- if (availableULocales == null) {
- Locale[] locales = java.util.Calendar.getAvailableLocales();
- ULocale[] ulocales = new ULocale[locales.length];
- for (int i = 0; i < locales.length; ++i) {
- ulocales[i] = ULocale.forLocale(locales[i]);
- }
- availableULocales = ulocales;
- }
- return (ULocale[])availableULocales.clone();
- }
- private static ULocale[] availableULocales;
-
- /**
- * Gets this Calendar's current time.
- * @return the current time.
- * @stable ICU 2.0
- */
- public final Date getTime() {
- return calendar.getTime();
- }
-
- /**
- * Sets this Calendar's current time with the given Date.
- *
- * Note: Calling setTime()
with
- * Date(Long.MAX_VALUE)
or Date(Long.MIN_VALUE)
- * may yield incorrect field values from get()
.
- * @param date the given Date.
- * @stable ICU 2.0
- */
- public final void setTime(Date date) {
- calendar.setTime(date);
- }
-
- /**
- * Gets this Calendar's current time as a long.
- * @return the current time as UTC milliseconds from the epoch.
- * @stable ICU 2.0
- */
- public long getTimeInMillis() {
- return calendar.getTime().getTime();
- }
-
- /**
- * Sets this Calendar's current time from the given long value.
- * @param millis the new time in UTC milliseconds from the epoch.
- * @stable ICU 2.0
- */
- public void setTimeInMillis(long millis) {
- calendar.setTime(new Date(millis));
- }
-
- /**
- * Gets the value for a given time field.
- * @param field the given time field.
- * @return the value for the given time field.
- * @stable ICU 2.0
- */
- public final int get(int field) {
- return calendar.get(field);
- }
-
- /**
- * Sets the time field with the given value.
- * @param field the given time field.
- * @param value the value to be set for the given time field.
- * @stable ICU 2.0
- */
- public final void set(int field, int value) {
- calendar.set(field, value);
- }
-
- /**
- * Sets the values for the fields year, month, and date.
- * Previous values of other fields are retained. If this is not desired,
- * call clear
first.
- * @param year the value used to set the YEAR time field.
- * @param month the value used to set the MONTH time field.
- * Month value is 0-based. e.g., 0 for January.
- * @param date the value used to set the DATE time field.
- * @stable ICU 2.0
- */
- public final void set(int year, int month, int date) {
- calendar.set(year, month, date);
- }
-
- /**
- * Sets the values for the fields year, month, date, hour, and minute.
- * Previous values of other fields are retained. If this is not desired,
- * call clear
first.
- * @param year the value used to set the YEAR time field.
- * @param month the value used to set the MONTH time field.
- * Month value is 0-based. e.g., 0 for January.
- * @param date the value used to set the DATE time field.
- * @param hour the value used to set the HOUR_OF_DAY time field.
- * @param minute the value used to set the MINUTE time field.
- * @stable ICU 2.0
- */
- public final void set(int year, int month, int date, int hour, int minute) {
- calendar.set(year, month, date, hour, minute);
- }
-
- /**
- * Sets the values for the fields year, month, date, hour, minute, and second.
- * Previous values of other fields are retained. If this is not desired,
- * call clear
first.
- * @param year the value used to set the YEAR time field.
- * @param month the value used to set the MONTH time field.
- * Month value is 0-based. e.g., 0 for January.
- * @param date the value used to set the DATE time field.
- * @param hour the value used to set the HOUR_OF_DAY time field.
- * @param minute the value used to set the MINUTE time field.
- * @param second the value used to set the SECOND time field.
- * @stable ICU 2.0
- */
- public final void set(int year, int month, int date, int hour, int minute, int second) {
- calendar.set(year, month, date, hour, minute, second);
- }
-
- /**
- * Clears the values of all the time fields.
- * @stable ICU 2.0
- */
- public final void clear() {
- calendar.clear();
- }
-
- /**
- * Clears the value in the given time field.
- * @param field the time field to be cleared.
- * @stable ICU 2.0
- */
- public final void clear(int field) {
- calendar.clear(field);
- }
-
- /**
- * Determines if the given time field has a value set.
- * @return true if the given time field has a value set; false otherwise.
- * @stable ICU 2.0
- */
- public final boolean isSet(int field) {
- return calendar.isSet(field);
- }
-
- /**
- * Compares this calendar to the specified object.
- * The result is true
if and only if the argument is
- * not null
and is a Calendar
object that
- * represents the same calendar as this object.
- * @param obj the object to compare with.
- * @return true
if the objects are the same;
- * false
otherwise.
- * @stable ICU 2.0
- */
- public boolean equals(Object obj) {
- try {
- return calendar.equals(((Calendar)obj).calendar);
- }
- catch (Exception e) {
- return false;
- }
- }
-
- /**
- * Returns true if the given Calendar object is equivalent to this
- * one. An equivalent Calendar will behave exactly as this one
- * does, but it may be set to a different time. By contrast, for
- * the equals() method to return true, the other Calendar must
- * be set to the same time.
- *
- * @param other the Calendar to be compared with this Calendar
- * @stable ICU 2.4
- */
- public boolean isEquivalentTo(Calendar other) {
- return this.getClass() == other.getClass() &&
- isLenient() == other.isLenient() &&
- getFirstDayOfWeek() == other.getFirstDayOfWeek() &&
- getMinimalDaysInFirstWeek() == other.getMinimalDaysInFirstWeek() &&
- getTimeZone().equals(other.getTimeZone());
- }
-
- /**
- * Returns a hash code for this calendar.
- * @return a hash code value for this object.
- * @stable ICU 2.0
- */
- public int hashCode() {
- return calendar.hashCode();
- }
-
- /**
- * Return the difference in milliseconds between the moment this
- * calendar is set to and the moment the given calendar or Date object
- * is set to.
- */
- private long compare(Object that) {
- long thatMs;
- if (that instanceof Calendar) {
- thatMs = ((Calendar)that).getTimeInMillis();
- } else if (that instanceof Date) {
- thatMs = ((Date)that).getTime();
- } else {
- throw new IllegalArgumentException(that + "is not a Calendar or Date");
- }
- return getTimeInMillis() - thatMs;
- }
-
- /**
- * Compares the time field records.
- * Equivalent to comparing result of conversion to UTC.
- * @param when the Calendar to be compared with this Calendar.
- * @return true if the current time of this Calendar is before
- * the time of Calendar when; false otherwise.
- * @stable ICU 2.0
- */
- public boolean before(Object when) {
- return compare(when) < 0;
- }
-
- /**
- * Compares the time field records.
- * Equivalent to comparing result of conversion to UTC.
- * @param when the Calendar to be compared with this Calendar.
- * @return true if the current time of this Calendar is after
- * the time of Calendar when; false otherwise.
- * @stable ICU 2.0
- */
- public boolean after(Object when) {
- return compare(when) > 0;
- }
-
- /**
- * Return the maximum value that this field could have, given the
- * current date. For example, with the Gregorian date February 3, 1997
- * and the {@link #DAY_OF_MONTH DAY_OF_MONTH} field, the actual maximum
- * is 28; for February 3, 1996 it is 29.
- *
- *
The actual maximum computation ignores smaller fields and the - * current value of like-sized fields. For example, the actual maximum - * of the DAY_OF_YEAR or MONTH depends only on the year and supra-year - * fields. The actual maximum of the DAY_OF_MONTH depends, in - * addition, on the MONTH field and any other fields at that - * granularity (such as ChineseCalendar.IS_LEAP_MONTH). The - * DAY_OF_WEEK_IN_MONTH field does not depend on the current - * DAY_OF_WEEK; it returns the maximum for any day of week in the - * current month. Likewise for the WEEK_OF_MONTH and WEEK_OF_YEAR - * fields. - * - * @param field the field whose maximum is desired - * @return the maximum of the given field for the current date of this calendar - * @see #getMaximum - * @see #getLeastMaximum - * @stable ICU 2.0 - */ - public int getActualMaximum(int field) { - return calendar.getActualMaximum(field); - } - - /** - * Return the minimum value that this field could have, given the current date. - * For most fields, this is the same as {@link #getMinimum getMinimum} - * and {@link #getGreatestMinimum getGreatestMinimum}. However, some fields, - * especially those related to week number, are more complicated. - *
- * For example, assume {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek}
- * returns 4 and {@link #getFirstDayOfWeek getFirstDayOfWeek} returns SUNDAY.
- * If the first day of the month is Sunday, Monday, Tuesday, or Wednesday
- * there will be four or more days in the first week, so it will be week number 1,
- * and getActualMinimum(WEEK_OF_MONTH)
will return 1. However,
- * if the first of the month is a Thursday, Friday, or Saturday, there are
- * not four days in that week, so it is week number 0, and
- * getActualMinimum(WEEK_OF_MONTH)
will return 0.
- *
- * @param field the field whose actual minimum value is desired. - * @return the minimum of the given field for the current date of this calendar - * - * @see #getMinimum - * @see #getGreatestMinimum - * @stable ICU 2.0 - */ - public int getActualMinimum(int field) { - return calendar.getActualMinimum(field); - } - - - /** - * Rolls (up/down) a single unit of time on the given field. If the - * field is rolled past its maximum allowable value, it will "wrap" back - * to its minimum and continue rolling. For - * example, to roll the current date up by one day, you can call: - *
- * roll({@link #DATE}, true)
- *
- * When rolling on the {@link #YEAR} field, it will roll the year - * value in the range between 1 and the value returned by calling - * {@link #getMaximum getMaximum}({@link #YEAR}). - *
- * When rolling on certain fields, the values of other fields may conflict and
- * need to be changed. For example, when rolling the MONTH
field
- * for the Gregorian date 1/31/96 upward, the DAY_OF_MONTH
field
- * must be adjusted so that the result is 2/29/96 rather than the invalid
- * 2/31/96.
- *
- * Note: Calling roll(field, true) N times is not - * necessarily equivalent to calling roll(field, N). For example, - * imagine that you start with the date Gregorian date January 31, 1995. If you call - * roll(Calendar.MONTH, 2), the result will be March 31, 1995. - * But if you call roll(Calendar.MONTH, true), the result will be - * February 28, 1995. Calling it one more time will give March 28, 1995, which - * is usually not the desired result. - *
- * Note: You should always use roll and add rather - * than attempting to perform arithmetic operations directly on the fields - * of a Calendar. It is quite possible for Calendar subclasses - * to have fields with non-linear behavior, for example missing months - * or days during non-leap years. The subclasses' add and roll - * methods will take this into account, while simple arithmetic manipulations - * may give invalid results. - *
- * @param field the calendar field to roll.
- *
- * @param up indicates if the value of the specified time field is to be
- * rolled up or rolled down. Use true
if rolling up,
- * false
otherwise.
- *
- * @exception IllegalArgumentException if the field is invalid or refers
- * to a field that cannot be handled by this method.
- * @see #roll(int, int)
- * @see #add
- * @stable ICU 2.0
- */
- public final void roll(int field, boolean up) {
- calendar.roll(field, up);
- }
-
- /**
- * Rolls (up/down) a specified amount time on the given field. For
- * example, to roll the current date up by three days, you can call
- * roll(Calendar.DATE, 3)
. If the
- * field is rolled past its maximum allowable value, it will "wrap" back
- * to its minimum and continue rolling.
- * For example, calling roll(Calendar.DATE, 10)
- * on a Gregorian calendar set to 4/25/96 will result in the date 4/5/96.
- *
- * When rolling on certain fields, the values of other fields may conflict and - * need to be changed. For example, when rolling the {@link #MONTH MONTH} field - * for the Gregorian date 1/31/96 by +1, the {@link #DAY_OF_MONTH DAY_OF_MONTH} field - * must be adjusted so that the result is 2/29/96 rather than the invalid - * 2/31/96. - *
- * The com.ibm.icu.util.Calendar
implementation of this method is able to roll
- * all fields except for {@link #ERA ERA}, {@link #DST_OFFSET DST_OFFSET},
- * and {@link #ZONE_OFFSET ZONE_OFFSET}. Subclasses may, of course, add support for
- * additional fields in their overrides of roll
.
- *
- * Note: You should always use roll and add rather - * than attempting to perform arithmetic operations directly on the fields - * of a Calendar. It is quite possible for Calendar subclasses - * to have fields with non-linear behavior, for example missing months - * or days during non-leap years. The subclasses' add and roll - * methods will take this into account, while simple arithmetic manipulations - * may give invalid results. - *
- * Subclassing:
- * This implementation of roll
assumes that the behavior of the
- * field is continuous between its minimum and maximum, which are found by
- * calling {@link #getActualMinimum getActualMinimum} and {@link #getActualMaximum getActualMaximum}.
- * For most such fields, simple addition, subtraction, and modulus operations
- * are sufficient to perform the roll. For week-related fields,
- * the results of {@link #getFirstDayOfWeek getFirstDayOfWeek} and
- * {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek} are also necessary.
- * Subclasses can override these two methods if their values differ from the defaults.
- *
- * Subclasses that have fields for which the assumption of continuity breaks
- * down must overide roll
to handle those fields specially.
- * For example, in the Hebrew calendar the month "Adar I"
- * only occurs in leap years; in other years the calendar jumps from
- * Shevat (month #4) to Adar (month #6). The
- * {@link HebrewCalendar#roll HebrewCalendar.roll} method takes this into account,
- * so that rolling the month of Shevat by one gives the proper result (Adar) in a
- * non-leap year.
- *
- * @param field the calendar field to roll.
- * @param amount the amount by which the field should be rolled.
- *
- * @exception IllegalArgumentException if the field is invalid or refers
- * to a field that cannot be handled by this method.
- * @see #roll(int, boolean)
- * @see #add
- * @stable ICU 2.0
- */
- public void roll(int field, int amount) {
- calendar.roll(field, amount);
- }
-
- /**
- * Add a signed amount to a specified field, using this calendar's rules.
- * For example, to add three days to the current date, you can call
- * add(Calendar.DATE, 3)
.
- *
- * When adding to certain fields, the values of other fields may conflict and - * need to be changed. For example, when adding one to the {@link #MONTH MONTH} field - * for the Gregorian date 1/31/96, the {@link #DAY_OF_MONTH DAY_OF_MONTH} field - * must be adjusted so that the result is 2/29/96 rather than the invalid - * 2/31/96. - *
- * The com.ibm.icu.util.Calendar
implementation of this method is able to add to
- * all fields except for {@link #ERA ERA}, {@link #DST_OFFSET DST_OFFSET},
- * and {@link #ZONE_OFFSET ZONE_OFFSET}. Subclasses may, of course, add support for
- * additional fields in their overrides of add
.
- *
- * Note: You should always use roll and add rather - * than attempting to perform arithmetic operations directly on the fields - * of a Calendar. It is quite possible for Calendar subclasses - * to have fields with non-linear behavior, for example missing months - * or days during non-leap years. The subclasses' add and roll - * methods will take this into account, while simple arithmetic manipulations - * may give invalid results. - *
- * Subclassing:
- * This implementation of add
assumes that the behavior of the
- * field is continuous between its minimum and maximum, which are found by
- * calling {@link #getActualMinimum getActualMinimum} and
- * {@link #getActualMaximum getActualMaximum}.
- * For such fields, simple arithmetic operations are sufficient to
- * perform the add.
- *
- * Subclasses that have fields for which this assumption of continuity breaks
- * down must overide add
to handle those fields specially.
- * For example, in the Hebrew calendar the month "Adar I"
- * only occurs in leap years; in other years the calendar jumps from
- * Shevat (month #4) to Adar (month #6). The
- * {@link HebrewCalendar#add HebrewCalendar.add} method takes this into account,
- * so that adding one month
- * to a date in Shevat gives the proper result (Adar) in a non-leap year.
- *
- * @param field the time field.
- * @param amount the amount to add to the field.
- *
- * @exception IllegalArgumentException if the field is invalid or refers
- * to a field that cannot be handled by this method.
- * @see #roll(int, int)
- * @stable ICU 2.0
- */
- public void add(int field, int amount) {
- calendar.add(field, amount);
- }
-
- /**
- * Return the name of this calendar in the language of the given locale.
- * @stable ICU 2.0
- */
- public String getDisplayName(Locale loc) {
- return "Calendar";
- }
-
- /**
- * Return the name of this calendar in the language of the given locale.
- * @stable ICU 3.2
- */
- public String getDisplayName(ULocale loc) {
- return "Calendar";
- }
-
- /**
- * Compares the times (in millis) represented by two
- * Calendar
objects.
- *
- * @param that the Calendar
to compare to this.
- * @return 0
if the time represented by
- * this Calendar
is equal to the time represented
- * by that Calendar
, a value less than
- * 0
if the time represented by this is before
- * the time represented by that, and a value greater than
- * 0
if the time represented by this
- * is after the time represented by that.
- * @throws NullPointerException if that
- * Calendar
is null.
- * @throws IllegalArgumentException if the time of that
- * Calendar
can't be obtained because of invalid
- * calendar values.
- * @stable ICU 3.4
- */
- public int compareTo(Calendar that) {
- long v = getTimeInMillis() - that.getTimeInMillis();
- return v < 0 ? -1 : (v > 0 ? 1 : 0);
- }
-
- /**
- * Implement comparable API as a convenience override of
- * {@link #compareTo(Calendar)}.
- * @stable ICU 3.4
- */
- public int compareTo(Object that) {
- return compareTo((Calendar)that);
- }
-
- //-------------------------------------------------------------------------
- // Interface for creating custon DateFormats for different types of Calendars
- //-------------------------------------------------------------------------
-
- /**
- * Return a DateFormat
appropriate to this calendar.
- * @stable ICU 2.0
- */
- public DateFormat getDateTimeFormat(int dateStyle, int timeStyle, Locale loc) {
- return formatHelper(this, loc, dateStyle, timeStyle);
- }
-
- /**
- * Return a DateFormat
appropriate to this calendar.
- * @stable ICU 3.2
- */
- public DateFormat getDateTimeFormat(int dateStyle, int timeStyle, ULocale loc) {
- return formatHelper(this, loc.toLocale(), dateStyle, timeStyle);
- }
-
- /*
- * Utility for formatting.
- */
- private static DateFormat formatHelper(Calendar cal, Locale loc, int dateStyle, int timeStyle) {
- // Assume there is only one kind of calendar. In Java 6 there will also be Japanese
- // calendars, but we'll worry about that when it happens.
- DateFormat df = DateFormat.getDateTimeInstance(dateStyle, timeStyle, loc);
- df.setCalendar(cal);
- return df;
- }
-
- //-------------------------------------------------------------------------
- // Constants
- //-------------------------------------------------------------------------
-
- /**
- * [NEW]
- * Return the difference between the given time and the time this
- * calendar object is set to. If this calendar is set
- * before the given time, the returned value will be
- * positive. If this calendar is set after the given
- * time, the returned value will be negative. The
- * field
parameter specifies the units of the return
- * value. For example, if fieldDifference(when,
- * Calendar.MONTH)
returns 3, then this calendar is set to
- * 3 months before when
, and possibly some additional
- * time less than one month.
- *
- *
As a side effect of this call, this calendar is advanced
- * toward when
by the given amount. That is, calling
- * this method has the side effect of calling add(field,
- * n)
, where n
is the return value.
- *
- *
Usage: To use this method, call it first with the largest - * field of interest, then with progressively smaller fields. For - * example: - * - *
- * int y = cal.fieldDifference(when, Calendar.YEAR); - * int m = cal.fieldDifference(when, Calendar.MONTH); - * int d = cal.fieldDifference(when, Calendar.DATE);- * - * computes the difference between
cal
and
- * when
in years, months, and days.
- *
- * Note: fieldDifference()
is
- * asymmetrical. That is, in the following code:
- *
- *
- * cal.setTime(date1); - * int m1 = cal.fieldDifference(date2, Calendar.MONTH); - * int d1 = cal.fieldDifference(date2, Calendar.DATE); - * cal.setTime(date2); - * int m2 = cal.fieldDifference(date1, Calendar.MONTH); - * int d2 = cal.fieldDifference(date1, Calendar.DATE);- * - * one might expect that
m1 == -m2 && d1 == -d2
.
- * However, this is not generally the case, because of
- * irregularities in the underlying calendar system (e.g., the
- * Gregorian calendar has a varying number of days per month).
- *
- * @param when the date to compare this calendar's time to
- * @param field the field in which to compute the result
- * @return the difference, either positive or negative, between
- * this calendar's time and when
, in terms of
- * field
.
- * @stable ICU 2.0
- */
- public int fieldDifference(Date when, int field) {
- int min = 0;
- long startMs = getTimeInMillis();
- long targetMs = when.getTime();
- // Always add from the start millis. This accomodates
- // operations like adding years from February 29, 2000 up to
- // February 29, 2004. If 1, 1, 1, 1 is added to the year
- // field, the DOM gets pinned to 28 and stays there, giving an
- // incorrect DOM difference of 1. We have to add 1, reset, 2,
- // reset, 3, reset, 4.
- if (startMs < targetMs) {
- int max = 1;
- // Find a value that is too large
- for (;;) {
- setTimeInMillis(startMs);
- add(field, max);
- long ms = getTimeInMillis();
- if (ms == targetMs) {
- return max;
- } else if (ms > targetMs) {
- break;
- } else {
- max <<= 1;
- if (max < 0) {
- // Field difference too large to fit into int
- throw new RuntimeException();
- }
- }
- }
- // Do a binary search
- while ((max - min) > 1) {
- int t = (min + max) / 2;
- setTimeInMillis(startMs);
- add(field, t);
- long ms = getTimeInMillis();
- if (ms == targetMs) {
- return t;
- } else if (ms > targetMs) {
- max = t;
- } else {
- min = t;
- }
- }
- } else if (startMs > targetMs) {
- if (false) {
- // This works, and makes the code smaller, but costs
- // an extra object creation and an extra couple cycles
- // of calendar computation.
- setTimeInMillis(targetMs);
- min = -fieldDifference(new Date(startMs), field);
- }
- int max = -1;
- // Find a value that is too small
- for (;;) {
- setTimeInMillis(startMs);
- add(field, max);
- long ms = getTimeInMillis();
- if (ms == targetMs) {
- return max;
- } else if (ms < targetMs) {
- break;
- } else {
- max <<= 1;
- if (max == 0) {
- // Field difference too large to fit into int
- throw new RuntimeException();
- }
- }
- }
- // Do a binary search
- while ((min - max) > 1) {
- int t = (min + max) / 2;
- setTimeInMillis(startMs);
- add(field, t);
- long ms = getTimeInMillis();
- if (ms == targetMs) {
- return t;
- } else if (ms < targetMs) {
- max = t;
- } else {
- min = t;
- }
- }
- }
- // Set calendar to end point
- setTimeInMillis(startMs);
- add(field, min);
- return min;
- }
-
- /**
- * Sets the time zone with the given time zone value.
- * @param value the given time zone.
- * @stable ICU 2.0
- */
- public void setTimeZone(TimeZone value) {
- calendar.setTimeZone(value.timeZone);
- }
-
- /**
- * Gets the time zone.
- * @return the time zone object associated with this calendar.
- * @stable ICU 2.0
- */
- public TimeZone getTimeZone() {
- return new TimeZone(calendar.getTimeZone());
- }
-
- /**
- * Specify whether or not date/time interpretation is to be lenient. With
- * lenient interpretation, a date such as "February 942, 1996" will be
- * treated as being equivalent to the 941st day after February 1, 1996.
- * With strict interpretation, such dates will cause an exception to be
- * thrown.
- *
- * @see DateFormat#setLenient
- * @stable ICU 2.0
- */
- public void setLenient(boolean lenient) {
- calendar.setLenient(lenient);
- }
-
- /**
- * Tell whether date/time interpretation is to be lenient.
- * @stable ICU 2.0
- */
- public boolean isLenient() {
- return calendar.isLenient();
- }
-
- /**
- * Sets what the first day of the week is; e.g., Sunday in US,
- * Monday in France.
- * @param value the given first day of the week.
- * @stable ICU 2.0
- */
- public void setFirstDayOfWeek(int value) {
- calendar.setFirstDayOfWeek(value);
- }
-
- /**
- * Gets what the first day of the week is; e.g., Sunday in US,
- * Monday in France.
- * @return the first day of the week.
- * @stable ICU 2.0
- */
- public int getFirstDayOfWeek() {
- return calendar.getFirstDayOfWeek();
- }
-
- /**
- * Sets what the minimal days required in the first week of the year are.
- * For example, if the first week is defined as one that contains the first
- * day of the first month of a year, call the method with value 1. If it
- * must be a full week, use value 7.
- * @param value the given minimal days required in the first week
- * of the year.
- * @stable ICU 2.0
- */
- public void setMinimalDaysInFirstWeek(int value) {
- calendar.setMinimalDaysInFirstWeek(value);
- }
-
- /**
- * Gets what the minimal days required in the first week of the year are;
- * e.g., if the first week is defined as one that contains the first day
- * of the first month of a year, getMinimalDaysInFirstWeek returns 1. If
- * the minimal days required must be a full week, getMinimalDaysInFirstWeek
- * returns 7.
- * @return the minimal days required in the first week of the year.
- * @stable ICU 2.0
- */
- public int getMinimalDaysInFirstWeek() {
- return calendar.getMinimalDaysInFirstWeek();
- }
-
- /**
- * Gets the minimum value for the given time field.
- * e.g., for Gregorian DAY_OF_MONTH, 1.
- * @param field the given time field.
- * @return the minimum value for the given time field.
- * @stable ICU 2.0
- */
- public final int getMinimum(int field) {
- return calendar.getMinimum(field);
- }
-
- /**
- * Gets the maximum value for the given time field.
- * e.g. for Gregorian DAY_OF_MONTH, 31.
- * @param field the given time field.
- * @return the maximum value for the given time field.
- * @stable ICU 2.0
- */
- public final int getMaximum(int field) {
- return calendar.getMaximum(field);
- }
-
- /**
- * Gets the highest minimum value for the given field if varies.
- * Otherwise same as getMinimum(). For Gregorian, no difference.
- * @param field the given time field.
- * @return the highest minimum value for the given time field.
- * @stable ICU 2.0
- */
- public final int getGreatestMinimum(int field) {
- return calendar.getGreatestMinimum(field);
- }
-
- /**
- * Gets the lowest maximum value for the given field if varies.
- * Otherwise same as getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28.
- * @param field the given time field.
- * @return the lowest maximum value for the given time field.
- * @stable ICU 2.0
- */
- public final int getLeastMaximum(int field) {
- return calendar.getLeastMaximum(field);
- }
-
- //-------------------------------------------------------------------------
- // Weekend support -- determining which days of the week are the weekend
- // in a given locale
- //-------------------------------------------------------------------------
-
- /**
- * Return whether the given day of the week is a weekday, a
- * weekend day, or a day that transitions from one to the other,
- * in this calendar system. If a transition occurs at midnight,
- * then the days before and after the transition will have the
- * type WEEKDAY or WEEKEND. If a transition occurs at a time
- * other than midnight, then the day of the transition will have
- * the type WEEKEND_ONSET or WEEKEND_CEASE. In this case, the
- * method getWeekendTransition() will return the point of
- * transition.
- * @param dayOfWeek either SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
- * THURSDAY, FRIDAY, or SATURDAY
- * @return either WEEKDAY, WEEKEND, WEEKEND_ONSET, or
- * WEEKEND_CEASE
- * @exception IllegalArgumentException if dayOfWeek is not
- * between SUNDAY and SATURDAY, inclusive
- * @see #WEEKDAY
- * @see #WEEKEND
- * @see #WEEKEND_ONSET
- * @see #WEEKEND_CEASE
- * @see #getWeekendTransition
- * @see #isWeekend(Date)
- * @see #isWeekend()
- * @stable ICU 2.0
- */
- public int getDayOfWeekType(int dayOfWeek) {
- // weekend always full saturday and sunday
- if (dayOfWeek < 1 || dayOfWeek > 7) {
- throw new IllegalArgumentException("illegal day of week: " + dayOfWeek);
- }
- return dayOfWeek >= SATURDAY ? WEEKEND : WEEKDAY;
- }
-
- /**
- * Return the time during the day at which the weekend begins or end in
- * this calendar system. If getDayOfWeekType(dayOfWeek) ==
- * WEEKEND_ONSET return the time at which the weekend begins. If
- * getDayOfWeekType(dayOfWeek) == WEEKEND_CEASE return the time at
- * which the weekend ends. If getDayOfWeekType(dayOfWeek) has some
- * other value, then throw an exception.
- * @param dayOfWeek either SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
- * THURSDAY, FRIDAY, or SATURDAY
- * @return the milliseconds after midnight at which the
- * weekend begins or ends
- * @exception IllegalArgumentException if dayOfWeek is not
- * WEEKEND_ONSET or WEEKEND_CEASE
- * @see #getDayOfWeekType
- * @see #isWeekend(Date)
- * @see #isWeekend()
- * @stable ICU 2.0
- */
- public int getWeekendTransition(int dayOfWeek) {
- throw new IllegalArgumentException("Not weekend transition day");
- }
-
- /**
- * Return true if the given date and time is in the weekend in
- * this calendar system. Equivalent to calling setTime() followed
- * by isWeekend(). Note: This method changes the time this
- * calendar is set to.
- * @param date the date and time
- * @return true if the given date and time is part of the
- * weekend
- * @see #getDayOfWeekType
- * @see #getWeekendTransition
- * @see #isWeekend()
- * @stable ICU 2.0
- */
- public boolean isWeekend(Date date) {
- calendar.setTime(date);
- return isWeekend();
- }
-
- /**
- * Return true if this Calendar's current date and time is in the
- * weekend in this calendar system.
- * @return true if the given date and time is part of the
- * weekend
- * @see #getDayOfWeekType
- * @see #getWeekendTransition
- * @see #isWeekend(Date)
- * @stable ICU 2.0
- */
- public boolean isWeekend() {
- return calendar.get(Calendar.DAY_OF_WEEK) >= SATURDAY;
- }
-
- //-------------------------------------------------------------------------
- // End of weekend support
- //-------------------------------------------------------------------------
-
- /**
- * Overrides Cloneable
- * @stable ICU 2.0
- */
- public Object clone() {
- return new Calendar((java.util.Calendar)calendar.clone());
- }
-
- /**
- * Return a string representation of this calendar. This method
- * is intended to be used only for debugging purposes, and the
- * format of the returned string may vary between implementations.
- * The returned string may be empty but may not be null
.
- *
- * @return a string representation of this calendar.
- * @stable ICU 2.0
- */
- public String toString() {
- return calendar.toString();
- }
-
- /**
- * Return the current Calendar type.
- * Note, in 3.0 this function will return 'gregorian' in Calendar to emulate legacy behavior
- * @return type of calendar (gregorian, etc)
- * @internal ICU 3.0
- */
- public String getType() {
- return "gregorian";
- }
-}
-
diff --git a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/util/TimeZone.java b/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/util/TimeZone.java
deleted file mode 100644
index 878afeb88a9..00000000000
--- a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/util/TimeZone.java
+++ /dev/null
@@ -1,432 +0,0 @@
-/*
- *******************************************************************************
- * Copyright (C) 1996-2008, International Business Machines Corporation and *
- * others. All Rights Reserved. *
- *******************************************************************************
- */
-
-package com.ibm.icu.util;
-
-import java.io.Serializable;
-import java.util.Date;
-import java.util.Locale;
-
-/**
- * TimeZone
represents a time zone offset, and also figures out daylight
- * savings.
- *
- *
- * Typically, you get a TimeZone
using getDefault
- * which creates a TimeZone
based on the time zone where the program
- * is running. For example, for a program running in Japan, getDefault
- * creates a TimeZone
object based on Japanese Standard Time.
- *
- *
- * You can also get a TimeZone
using getTimeZone
- * along with a time zone ID. For instance, the time zone ID for the
- * U.S. Pacific Time zone is "America/Los_Angeles". So, you can get a
- * U.S. Pacific Time TimeZone
object with:
- *
- *- * You can use- * TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles"); - *- *
getAvailableIDs
method to iterate through
- * all the supported time zone IDs. You can then choose a
- * supported ID to get a TimeZone
.
- * If the time zone you want is not represented by one of the
- * supported IDs, then you can create a custom time zone ID with
- * the following syntax:
- *
- * - *- * - * For example, you might specify GMT+14:00 as a custom - * time zone ID. The- * GMT[+|-]hh[[:]mm] - *- *
TimeZone
that is returned
- * when you specify a custom time zone ID does not include
- * daylight savings time.
- *
- * For compatibility with JDK 1.1.x, some other three-letter time zone IDs
- * (such as "PST", "CTT", "AST") are also supported. However, their
- * use is deprecated because the same abbreviation is often used
- * for multiple time zones (for example, "CST" could be U.S. "Central Standard
- * Time" and "China Standard Time"), and the Java platform can then only
- * recognize one of them.
- *
- * @see Calendar
- * @see GregorianCalendar
- * @see SimpleTimeZone
- * @author Mark Davis, David Goldsmith, Chen-Lieh Huang, Alan Liu
- * @stable ICU 2.0
- */
-public class TimeZone implements Serializable, Cloneable {
- private static final long serialVersionUID = 1;
-
- /**
- * @internal
- */
- public final java.util.TimeZone timeZone;
-
- /**
- * @internal
- * @param delegate the TimeZone to which to delegate
- */
- public TimeZone(java.util.TimeZone delegate) {
- this.timeZone = delegate;
- }
-
- /**
- * Default constructor to mirror Java's public
- * constructor. Java's is not callable as a public API, since
- * their TimeZone is abstract, so this is only useful to
- * subclasses. In general, subclasses will not work unless
- * they manipulate the delegate.
- */
- public TimeZone() {
- this.timeZone = java.util.TimeZone.getDefault();
- }
-
- /**
- * A style specifier for getDisplayName()
indicating
- * a short name, such as "PST."
- * @see #LONG
- * @stable ICU 2.0
- */
- public static final int SHORT = 0;
-
- /**
- * A style specifier for getDisplayName()
indicating
- * a long name, such as "Pacific Standard Time."
- * @see #SHORT
- * @stable ICU 2.0
- */
- public static final int LONG = 1;
-
- /**
- * Gets the time zone offset, for current date, modified in case of
- * daylight savings. This is the offset to add *to* UTC to get local time.
- * @param era the era of the given date.
- * @param year the year in the given date.
- * @param month the month in the given date.
- * Month is 0-based. e.g., 0 for January.
- * @param day the day-in-month of the given date.
- * @param dayOfWeek the day-of-week of the given date.
- * @param milliseconds the millis in day in standard local time.
- * @return the offset to add *to* GMT to get local time.
- * @stable ICU 2.0
- */
- public int getOffset(int era, int year, int month, int day,
- int dayOfWeek, int milliseconds) {
- return timeZone.getOffset(era, year, month, day, dayOfWeek, milliseconds);
- }
-
- /**
- * Returns the offset of this time zone from UTC at the specified
- * date. If Daylight Saving Time is in effect at the specified
- * date, the offset value is adjusted with the amount of daylight
- * saving.
- *
- * @param date the date represented in milliseconds since January 1, 1970 00:00:00 GMT
- * @return the amount of time in milliseconds to add to UTC to get local time.
- *
- * @see Calendar#ZONE_OFFSET
- * @see Calendar#DST_OFFSET
- * @see #getOffset(long, boolean, int[])
- * @stable ICU 2.8
- */
- public int getOffset(long date) {
- if (inDaylightTime(new Date(date))) {
- return getRawOffset() + getDSTSavings();
- }
- return getRawOffset();
- }
-
- /**
- * Sets the base time zone offset to GMT.
- * This is the offset to add *to* UTC to get local time.
- * @param offsetMillis the given base time zone offset to GMT.
- * @stable ICU 2.0
- */
- public void setRawOffset(int offsetMillis) {
- timeZone.setRawOffset(offsetMillis);
- }
-
- /**
- * Gets unmodified offset, NOT modified in case of daylight savings.
- * This is the offset to add *to* UTC to get local time.
- * @return the unmodified offset to add *to* UTC to get local time.
- * @stable ICU 2.0
- */
- public int getRawOffset() {
- return timeZone.getRawOffset();
- }
-
- /**
- * Gets the ID of this time zone.
- * @return the ID of this time zone.
- * @stable ICU 2.0
- */
- public String getID() {
- return timeZone.getID();
- }
-
- /**
- * Sets the time zone ID. This does not change any other data in
- * the time zone object.
- * @param ID the new time zone ID.
- * @stable ICU 2.0
- */
- public void setID(String ID) {
- timeZone.setID(ID);
- }
-
- /**
- * Returns a name of this time zone suitable for presentation to the user
- * in the default locale.
- * This method returns the long generic name.
- * If the display name is not available for the locale,
- * a fallback based on the country, city, or time zone id will be used.
- * @return the human-readable name of this time zone in the default locale.
- * @stable ICU 2.0
- */
- public final String getDisplayName() {
- return timeZone.getDisplayName();
- }
-
- /**
- * Returns a name of this time zone suitable for presentation to the user
- * in the specified locale.
- * This method returns the long generic name.
- * If the display name is not available for the locale,
- * a fallback based on the country, city, or time zone id will be used.
- * @param locale the locale in which to supply the display name.
- * @return the human-readable name of this time zone in the given locale
- * or in the default locale if the given locale is not recognized.
- * @stable ICU 2.0
- */
- public final String getDisplayName(Locale locale) {
- return timeZone.getDisplayName(locale);
- }
-
- /**
- * Returns a name of this time zone suitable for presentation to the user
- * in the specified locale.
- * This method returns the long name, not including daylight savings.
- * If the display name is not available for the locale,
- * a fallback based on the country, city, or time zone id will be used.
- * @param locale the ulocale in which to supply the display name.
- * @return the human-readable name of this time zone in the given locale
- * or in the default ulocale if the given ulocale is not recognized.
- * @stable ICU 3.2
- */
- public final String getDisplayName(ULocale locale) {
- return timeZone.getDisplayName(locale.toLocale());
- }
-
- /**
- * Returns a name of this time zone suitable for presentation to the user
- * in the default locale.
- * If the display name is not available for the locale,
- * then this method returns a string in the format
- * GMT[+-]hh:mm
.
- * @param daylight if true, return the daylight savings name.
- * @param style either LONG
or SHORT
- * @return the human-readable name of this time zone in the default locale.
- * @stable ICU 2.0
- */
- public final String getDisplayName(boolean daylight, int style) {
- return timeZone.getDisplayName(daylight, style);
- }
-
- /**
- * Returns a name of this time zone suitable for presentation to the user
- * in the specified locale.
- * If the display name is not available for the locale,
- * then this method returns a string in the format
- * GMT[+-]hh:mm
.
- * @param daylight if true, return the daylight savings name.
- * @param style either LONG
or SHORT
- * @param locale the locale in which to supply the display name.
- * @return the human-readable name of this time zone in the given locale
- * or in the default locale if the given locale is not recognized.
- * @exception IllegalArgumentException style is invalid.
- * @stable ICU 2.0
- */
- public String getDisplayName(boolean daylight, int style, Locale locale) {
- return timeZone.getDisplayName(daylight, style, locale);
- }
-
- /**
- * Returns a name of this time zone suitable for presentation to the user
- * in the specified locale.
- * If the display name is not available for the locale,
- * then this method returns a string in the format
- * GMT[+-]hh:mm
.
- * @param daylight if true, return the daylight savings name.
- * @param style either LONG
or SHORT
- * @param locale the locale in which to supply the display name.
- * @return the human-readable name of this time zone in the given locale
- * or in the default locale if the given locale is not recognized.
- * @exception IllegalArgumentException style is invalid.
- * @stable ICU 3.2
- */
- public String getDisplayName(boolean daylight, int style, ULocale locale) {
- return timeZone.getDisplayName(daylight, style, locale.toLocale());
- }
-
- /**
- * Returns the amount of time to be added to local standard time
- * to get local wall clock time.
- *
- * The default implementation always returns 3600000 milliseconds - * (i.e., one hour) if this time zone observes Daylight Saving - * Time. Otherwise, 0 (zero) is returned. - *
- * If an underlying TimeZone implementation subclass supports
- * historical Daylight Saving Time changes, this method returns
- * the known latest daylight saving value.
- *
- * @return the amount of saving time in milliseconds
- * @stable ICU 2.8
- */
- public int getDSTSavings() {
- if (useDaylightTime()) {
- return 3600000;
- }
- return 0;
- }
-
- /**
- * Queries if this time zone uses daylight savings time.
- * @return true if this time zone uses daylight savings time,
- * false, otherwise.
- * @stable ICU 2.0
- */
- public boolean useDaylightTime() {
- return timeZone.useDaylightTime();
- }
-
- /**
- * Queries if the given date is in daylight savings time in
- * this time zone.
- * @param date the given Date.
- * @return true if the given date is in daylight savings time,
- * false, otherwise.
- * @stable ICU 2.0
- */
- public boolean inDaylightTime(Date date) {
- return timeZone.inDaylightTime(date);
- }
-
- /**
- * Gets the TimeZone
for the given ID.
- *
- * @param ID the ID for a TimeZone
, either an abbreviation
- * such as "PST", a full name such as "America/Los_Angeles", or a custom
- * ID such as "GMT-8:00". Note that the support of abbreviations is
- * for JDK 1.1.x compatibility only and full names should be used.
- *
- * @return the specified TimeZone
, or the GMT zone if the given ID
- * cannot be understood.
- * @stable ICU 2.0
- */
- public static TimeZone getTimeZone(String ID) {
- return new TimeZone(java.util.TimeZone.getTimeZone(ID));
- }
-
- /**
- * Return a new String array containing all system TimeZone IDs
- * with the given raw offset from GMT. These IDs may be passed to
- * get()
to construct the corresponding TimeZone
- * object.
- * @param rawOffset the offset in milliseconds from GMT
- * @return an array of IDs for system TimeZones with the given
- * raw offset. If there are none, return a zero-length array.
- * @stable ICU 2.0
- */
- public static String[] getAvailableIDs(int rawOffset) {
- return java.util.TimeZone.getAvailableIDs(rawOffset);
- }
-
- /**
- * Return a new String array containing all system TimeZone IDs.
- * These IDs (and only these IDs) may be passed to
- * get()
to construct the corresponding TimeZone
- * object.
- * @return an array of all system TimeZone IDs
- * @stable ICU 2.0
- */
- public static String[] getAvailableIDs() {
- return java.util.TimeZone.getAvailableIDs();
- }
-
- /**
- * Gets the default TimeZone
for this host.
- * The source of the default TimeZone
- * may vary with implementation.
- * @return a default TimeZone
.
- * @stable ICU 2.0
- */
- public static TimeZone getDefault() {
- return new TimeZone(java.util.TimeZone.getDefault());
- }
-
- /**
- * Sets the TimeZone
that is
- * returned by the getDefault
method. If zone
- * is null, reset the default to the value it had originally when the
- * VM first started.
- * @param tz the new default time zone
- * @stable ICU 2.0
- */
- public static void setDefault(TimeZone tz) {
- java.util.TimeZone.setDefault(tz.timeZone);
- }
-
- /**
- * Returns true if this zone has the same rule and offset as another zone.
- * That is, if this zone differs only in ID, if at all. Returns false
- * if the other zone is null.
- * @param other the TimeZone
object to be compared with
- * @return true if the other zone is not null and is the same as this one,
- * with the possible exception of the ID
- * @stable ICU 2.0
- */
- public boolean hasSameRules(TimeZone other) {
- return timeZone.hasSameRules(other.timeZone);
- }
-
- /**
- * Overrides Cloneable
- * @stable ICU 2.0
- */
- public Object clone() {
- return new TimeZone((java.util.TimeZone)timeZone.clone());
- }
-
- /**
- * Return true if rhs is a TimeZone and has the same time rules as this.
- * @return true if rhs equals this
- * @stable ICU 3.4.2
- */
- public boolean equals(Object rhs){
- try {
- return timeZone.equals(((TimeZone)rhs).timeZone);
- }
- catch (Exception e) {
- return false;
- }
- }
-
- /**
- * Return a hashCode.
- * @return a hashCode
- * @stable ICU 3.4.2
- */
- public int hashCode(){
- return timeZone.hashCode();
- }
-}
diff --git a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/util/ULocale.java b/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/util/ULocale.java
deleted file mode 100644
index ea9a603ab3f..00000000000
--- a/icu4j/icu-eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/util/ULocale.java
+++ /dev/null
@@ -1,3822 +0,0 @@
-/*
-******************************************************************************
-* Copyright (C) 2003-2008, International Business Machines Corporation and *
-* others. All Rights Reserved. *
-******************************************************************************
-*/
-
-package com.ibm.icu.util;
-
-import java.io.Serializable;
-import java.lang.ref.SoftReference;
-import java.text.ParseException;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.TreeMap;
-
-//import com.ibm.icu.impl.SimpleCache;
-//import com.ibm.icu.impl.ICUResourceBundle;
-//import com.ibm.icu.impl.LocaleUtility;
-
-/**
- * A class analogous to {@link java.util.Locale} that provides additional
- * support for ICU protocol. In ICU 3.0 this class is enhanced to support
- * RFC 3066 language identifiers.
- *
- *
Many classes and services in ICU follow a factory idiom, in - * which a factory method or object responds to a client request with - * an object. The request includes a locale (the requested - * locale), and the returned object is constructed using data for that - * locale. The system may lack data for the requested locale, in - * which case the locale fallback mechanism will be invoked until a - * populated locale is found (the valid locale). Furthermore, - * even when a populated locale is found (the valid locale), - * further fallback may be required to reach a locale containing the - * specific data required by the service (the actual locale). - * - *
ULocale performs 'normalization' and 'canonicalization' of locale ids. - * Normalization 'cleans up' ICU locale ids as follows: - *
canonicalize
can be called to convert the id
- * to canonical form, or the canonicalInstance
factory method
- * can be called.
- *
- * This class provides selectors {@link #VALID_LOCALE} and {@link - * #ACTUAL_LOCALE} intended for use in methods named - * getLocale(). These methods exist in several ICU classes, - * including {@link com.ibm.icu.util.Calendar}, {@link - * com.ibm.icu.util.Currency}, {@link com.ibm.icu.text.UFormat}, - * {@link com.ibm.icu.text.BreakIterator}, {@link - * com.ibm.icu.text.Collator}, {@link - * com.ibm.icu.text.DateFormatSymbols}, and {@link - * com.ibm.icu.text.DecimalFormatSymbols} and their subclasses, if - * any. Once an object of one of these classes has been created, - * getLocale() may be called on it to determine the valid and - * actual locale arrived at during the object's construction. - * - *
Note: The getLocale() method will be implemented in ICU
- * 3.0; ICU 2.8 contains a partial preview implementation. The
- * actual locale is returned correctly, but the valid
- * locale is not, in most cases.
- *
- * @see java.util.Locale
- * @author weiv
- * @author Alan Liu
- * @author Ram Viswanadha
- * @stable ICU 2.8
- */
-public final class ULocale implements Serializable {
- // using serialver from jdk1.4.2_05
- private static final long serialVersionUID = 3715177670352309217L;
-
- /**
- * Useful constant for language.
- * @stable ICU 3.0
- */
- public static final ULocale ENGLISH = new ULocale("en", Locale.ENGLISH);
-
- /**
- * Useful constant for language.
- * @stable ICU 3.0
- */
- public static final ULocale FRENCH = new ULocale("fr", Locale.FRENCH);
-
- /**
- * Useful constant for language.
- * @stable ICU 3.0
- */
- public static final ULocale GERMAN = new ULocale("de", Locale.GERMAN);
-
- /**
- * Useful constant for language.
- * @stable ICU 3.0
- */
- public static final ULocale ITALIAN = new ULocale("it", Locale.ITALIAN);
-
- /**
- * Useful constant for language.
- * @stable ICU 3.0
- */
- public static final ULocale JAPANESE = new ULocale("ja", Locale.JAPANESE);
-
- /**
- * Useful constant for language.
- * @stable ICU 3.0
- */
- public static final ULocale KOREAN = new ULocale("ko", Locale.KOREAN);
-
- /**
- * Useful constant for language.
- * @stable ICU 3.0
- */
- public static final ULocale CHINESE = new ULocale("zh", Locale.CHINESE);
-
- /**
- * Useful constant for language.
- * @stable ICU 3.0
- */
- public static final ULocale SIMPLIFIED_CHINESE = new ULocale("zh_Hans", Locale.CHINESE);
-
- /**
- * Useful constant for language.
- * @stable ICU 3.0
- */
- public static final ULocale TRADITIONAL_CHINESE = new ULocale("zh_Hant", Locale.CHINESE);
-
- /**
- * Useful constant for country/region.
- * @stable ICU 3.0
- */
- public static final ULocale FRANCE = new ULocale("fr_FR", Locale.FRANCE);
-
- /**
- * Useful constant for country/region.
- * @stable ICU 3.0
- */
- public static final ULocale GERMANY = new ULocale("de_DE", Locale.GERMANY);
-
- /**
- * Useful constant for country/region.
- * @stable ICU 3.0
- */
- public static final ULocale ITALY = new ULocale("it_IT", Locale.ITALY);
-
- /**
- * Useful constant for country/region.
- * @stable ICU 3.0
- */
- public static final ULocale JAPAN = new ULocale("ja_JP", Locale.JAPAN);
-
- /**
- * Useful constant for country/region.
- * @stable ICU 3.0
- */
- public static final ULocale KOREA = new ULocale("ko_KR", Locale.KOREA);
-
- /**
- * Useful constant for country/region.
- * @stable ICU 3.0
- */
- public static final ULocale CHINA = new ULocale("zh_Hans_CN", Locale.CHINA);
-
- /**
- * Useful constant for country/region.
- * @stable ICU 3.0
- */
- public static final ULocale PRC = CHINA;
-
- /**
- * Useful constant for country/region.
- * @stable ICU 3.0
- */
- public static final ULocale TAIWAN = new ULocale("zh_Hant_TW", Locale.TAIWAN);
-
- /**
- * Useful constant for country/region.
- * @stable ICU 3.0
- */
- public static final ULocale UK = new ULocale("en_GB", Locale.UK);
-
- /**
- * Useful constant for country/region.
- * @stable ICU 3.0
- */
- public static final ULocale US = new ULocale("en_US", Locale.US);
-
- /**
- * Useful constant for country/region.
- * @stable ICU 3.0
- */
- public static final ULocale CANADA = new ULocale("en_CA", Locale.CANADA);
-
- /**
- * Useful constant for country/region.
- * @stable ICU 3.0
- */
- public static final ULocale CANADA_FRENCH = new ULocale("fr_CA", Locale.CANADA_FRENCH);
-
- /**
- * Handy constant.
- */
- private static final String EMPTY_STRING = "";
-
- // Used in both ULocale and IDParser, so moved up here.
- private static final char UNDERSCORE = '_';
-
- // default empty locale
- private static final Locale EMPTY_LOCALE = new Locale("", "");
-
- /**
- * The root ULocale.
- * @stable ICU 2.8
- */
- public static final ULocale ROOT = new ULocale("root", EMPTY_LOCALE);
-
-// private static final SimpleCache CACHE = new SimpleCache();
- private static final HashMap CACHE = new HashMap(20);
-
- /**
- * Cache the locale.
- */
- private transient Locale locale;
-
- /**
- * The raw localeID that we were passed in.
- */
- private String localeID;
-
- /**
- * Tables used in normalizing portions of the id.
- */
- /* tables updated per http://lcweb.loc.gov/standards/iso639-2/
- to include the revisions up to 2001/7/27 *CWB*/
- /* The 3 character codes are the terminology codes like RFC 3066.
- This is compatible with prior ICU codes */
- /* "in" "iw" "ji" "jw" & "sh" have been withdrawn but are still in
- the table but now at the end of the table because
- 3 character codes are duplicates. This avoids bad searches
- going from 3 to 2 character codes.*/
- /* The range qaa-qtz is reserved for local use. */
-
- private static String[] _languages;
- private static String[] _replacementLanguages;
- private static String[] _obsoleteLanguages;
- private static String[] _languages3;
- private static String[] _obsoleteLanguages3;
-
- // Avoid initializing languages tables unless we have to.
- private static void initLanguageTables() {
- if (_languages == null) {
-
- /* This list MUST be in sorted order, and MUST contain the two-letter codes
- if one exists otherwise use the three letter code */
- String[] tempLanguages = {
- "aa", "ab", "ace", "ach", "ada", "ady", "ae", "af", "afa",
- "afh", "ak", "akk", "ale", "alg", "am", "an", "ang", "apa",
- "ar", "arc", "arn", "arp", "art", "arw", "as", "ast",
- "ath", "aus", "av", "awa", "ay", "az", "ba", "bad",
- "bai", "bal", "ban", "bas", "bat", "be", "bej",
- "bem", "ber", "bg", "bh", "bho", "bi", "bik", "bin",
- "bla", "bm", "bn", "bnt", "bo", "br", "bra", "bs",
- "btk", "bua", "bug", "byn", "ca", "cad", "cai", "car", "cau",
- "ce", "ceb", "cel", "ch", "chb", "chg", "chk", "chm",
- "chn", "cho", "chp", "chr", "chy", "cmc", "co", "cop",
- "cpe", "cpf", "cpp", "cr", "crh", "crp", "cs", "csb", "cu", "cus",
- "cv", "cy", "da", "dak", "dar", "day", "de", "del", "den",
- "dgr", "din", "doi", "dra", "dsb", "dua", "dum", "dv", "dyu",
- "dz", "ee", "efi", "egy", "eka", "el", "elx", "en",
- "enm", "eo", "es", "et", "eu", "ewo", "fa",
- "fan", "fat", "ff", "fi", "fiu", "fj", "fo", "fon",
- "fr", "frm", "fro", "fur", "fy", "ga", "gaa", "gay",
- "gba", "gd", "gem", "gez", "gil", "gl", "gmh", "gn",
- "goh", "gon", "gor", "got", "grb", "grc", "gu", "gv",
- "gwi", "ha", "hai", "haw", "he", "hi", "hil", "him",
- "hit", "hmn", "ho", "hr", "hsb", "ht", "hu", "hup", "hy", "hz",
- "ia", "iba", "id", "ie", "ig", "ii", "ijo", "ik",
- "ilo", "inc", "ine", "inh", "io", "ira", "iro", "is", "it",
- "iu", "ja", "jbo", "jpr", "jrb", "jv", "ka", "kaa", "kab",
- "kac", "kam", "kar", "kaw", "kbd", "kg", "kha", "khi",
- "kho", "ki", "kj", "kk", "kl", "km", "kmb", "kn",
- "ko", "kok", "kos", "kpe", "kr", "krc", "kro", "kru", "ks",
- "ku", "kum", "kut", "kv", "kw", "ky", "la", "lad",
- "lah", "lam", "lb", "lez", "lg", "li", "ln", "lo", "lol",
- "loz", "lt", "lu", "lua", "lui", "lun", "luo", "lus",
- "lv", "mad", "mag", "mai", "mak", "man", "map", "mas",
- "mdf", "mdr", "men", "mg", "mga", "mh", "mi", "mic", "min",
- "mis", "mk", "mkh", "ml", "mn", "mnc", "mni", "mno",
- "mo", "moh", "mos", "mr", "ms", "mt", "mul", "mun",
- "mus", "mwr", "my", "myn", "myv", "na", "nah", "nai", "nap",
- "nb", "nd", "nds", "ne", "new", "ng", "nia", "nic",
- "niu", "nl", "nn", "no", "nog", "non", "nr", "nso", "nub",
- "nv", "nwc", "ny", "nym", "nyn", "nyo", "nzi", "oc", "oj",
- "om", "or", "os", "osa", "ota", "oto", "pa", "paa",
- "pag", "pal", "pam", "pap", "pau", "peo", "phi", "phn",
- "pi", "pl", "pon", "pra", "pro", "ps", "pt", "qu",
- "raj", "rap", "rar", "rm", "rn", "ro", "roa", "rom",
- "ru", "rup", "rw", "sa", "sad", "sah", "sai", "sal", "sam",
- "sas", "sat", "sc", "sco", "sd", "se", "sel", "sem",
- "sg", "sga", "sgn", "shn", "si", "sid", "sio", "sit",
- "sk", "sl", "sla", "sm", "sma", "smi", "smj", "smn",
- "sms", "sn", "snk", "so", "sog", "son", "sq", "sr",
- "srr", "ss", "ssa", "st", "su", "suk", "sus", "sux",
- "sv", "sw", "syr", "ta", "tai", "te", "tem", "ter",
- "tet", "tg", "th", "ti", "tig", "tiv", "tk", "tkl",
- "tl", "tlh", "tli", "tmh", "tn", "to", "tog", "tpi", "tr",
- "ts", "tsi", "tt", "tum", "tup", "tut", "tvl", "tw",
- "ty", "tyv", "udm", "ug", "uga", "uk", "umb", "und", "ur",
- "uz", "vai", "ve", "vi", "vo", "vot", "wa", "wak",
- "wal", "war", "was", "wen", "wo", "xal", "xh", "yao", "yap",
- "yi", "yo", "ypk", "za", "zap", "zen", "zh", "znd",
- "zu", "zun",
- };
-
- String[] tempReplacementLanguages = {
- "id", "he", "yi", "jv", "sr", "nb",/* replacement language codes */
- };
-
- String[] tempObsoleteLanguages = {
- "in", "iw", "ji", "jw", "sh", "no", /* obsolete language codes */
- };
-
- /* This list MUST contain a three-letter code for every two-letter code in the
- list above, and they MUST ne in the same order (i.e., the same language must
- be in the same place in both lists)! */
- String[] tempLanguages3 = {
- /*"aa", "ab", "ace", "ach", "ada", "ady", "ae", "af", "afa", */
- "aar", "abk", "ace", "ach", "ada", "ady", "ave", "afr", "afa",
- /*"afh", "ak", "akk", "ale", "alg", "am", "an", "ang", "apa", */
- "afh", "aka", "akk", "ale", "alg", "amh", "arg", "ang", "apa",
- /*"ar", "arc", "arn", "arp", "art", "arw", "as", "ast", */
- "ara", "arc", "arn", "arp", "art", "arw", "asm", "ast",
- /*"ath", "aus", "av", "awa", "ay", "az", "ba", "bad", */
- "ath", "aus", "ava", "awa", "aym", "aze", "bak", "bad",
- /*"bai", "bal", "ban", "bas", "bat", "be", "bej", */
- "bai", "bal", "ban", "bas", "bat", "bel", "bej",
- /*"bem", "ber", "bg", "bh", "bho", "bi", "bik", "bin", */
- "bem", "ber", "bul", "bih", "bho", "bis", "bik", "bin",
- /*"bla", "bm", "bn", "bnt", "bo", "br", "bra", "bs", */
- "bla", "bam", "ben", "bnt", "bod", "bre", "bra", "bos",
- /*"btk", "bua", "bug", "byn", "ca", "cad", "cai", "car", "cau", */
- "btk", "bua", "bug", "byn", "cat", "cad", "cai", "car", "cau",
- /*"ce", "ceb", "cel", "ch", "chb", "chg", "chk", "chm", */
- "che", "ceb", "cel", "cha", "chb", "chg", "chk", "chm",
- /*"chn", "cho", "chp", "chr", "chy", "cmc", "co", "cop", */
- "chn", "cho", "chp", "chr", "chy", "cmc", "cos", "cop",
- /*"cpe", "cpf", "cpp", "cr", "crh", "crp", "cs", "csb", "cu", "cus", */
- "cpe", "cpf", "cpp", "cre", "crh", "crp", "ces", "csb", "chu", "cus",
- /*"cv", "cy", "da", "dak", "dar", "day", "de", "del", "den", */
- "chv", "cym", "dan", "dak", "dar", "day", "deu", "del", "den",
- /*"dgr", "din", "doi", "dra", "dsb", "dua", "dum", "dv", "dyu", */
- "dgr", "din", "doi", "dra", "dsb", "dua", "dum", "div", "dyu",
- /*"dz", "ee", "efi", "egy", "eka", "el", "elx", "en", */
- "dzo", "ewe", "efi", "egy", "eka", "ell", "elx", "eng",
- /*"enm", "eo", "es", "et", "eu", "ewo", "fa", */
- "enm", "epo", "spa", "est", "eus", "ewo", "fas",
- /*"fan", "fat", "ff", "fi", "fiu", "fj", "fo", "fon", */
- "fan", "fat", "ful", "fin", "fiu", "fij", "fao", "fon",
- /*"fr", "frm", "fro", "fur", "fy", "ga", "gaa", "gay", */
- "fra", "frm", "fro", "fur", "fry", "gle", "gaa", "gay",
- /*"gba", "gd", "gem", "gez", "gil", "gl", "gmh", "gn", */
- "gba", "gla", "gem", "gez", "gil", "glg", "gmh", "grn",
- /*"goh", "gon", "gor", "got", "grb", "grc", "gu", "gv", */
- "goh", "gon", "gor", "got", "grb", "grc", "guj", "glv",
- /*"gwi", "ha", "hai", "haw", "he", "hi", "hil", "him", */
- "gwi", "hau", "hai", "haw", "heb", "hin", "hil", "him",
- /*"hit", "hmn", "ho", "hr", "hsb", "ht", "hu", "hup", "hy", "hz", */
- "hit", "hmn", "hmo", "hrv", "hsb", "hat", "hun", "hup", "hye", "her",
- /*"ia", "iba", "id", "ie", "ig", "ii", "ijo", "ik", */
- "ina", "iba", "ind", "ile", "ibo", "iii", "ijo", "ipk",
- /*"ilo", "inc", "ine", "inh", "io", "ira", "iro", "is", "it", */
- "ilo", "inc", "ine", "inh", "ido", "ira", "iro", "isl", "ita",
- /*"iu", "ja", "jbo", "jpr", "jrb", "jv", "ka", "kaa", "kab", */
- "iku", "jpn", "jbo", "jpr", "jrb", "jaw", "kat", "kaa", "kab",
- /*"kac", "kam", "kar", "kaw", "kbd", "kg", "kha", "khi", */
- "kac", "kam", "kar", "kaw", "kbd", "kon", "kha", "khi",
- /*"kho", "ki", "kj", "kk", "kl", "km", "kmb", "kn", */
- "kho", "kik", "kua", "kaz", "kal", "khm", "kmb", "kan",
- /*"ko", "kok", "kos", "kpe", "kr", "krc", "kro", "kru", "ks", */
- "kor", "kok", "kos", "kpe", "kau", "krc", "kro", "kru", "kas",
- /*"ku", "kum", "kut", "kv", "kw", "ky", "la", "lad", */
- "kur", "kum", "kut", "kom", "cor", "kir", "lat", "lad",
- /*"lah", "lam", "lb", "lez", "lg", "li", "ln", "lo", "lol", */
- "lah", "lam", "ltz", "lez", "lug", "lim", "lin", "lao", "lol",
- /*"loz", "lt", "lu", "lua", "lui", "lun", "luo", "lus", */
- "loz", "lit", "lub", "lua", "lui", "lun", "luo", "lus",
- /*"lv", "mad", "mag", "mai", "mak", "man", "map", "mas", */
- "lav", "mad", "mag", "mai", "mak", "man", "map", "mas",
- /*"mdf", "mdr", "men", "mg", "mga", "mh", "mi", "mic", "min", */
- "mdf", "mdr", "men", "mlg", "mga", "mah", "mri", "mic", "min",
- /*"mis", "mk", "mkh", "ml", "mn", "mnc", "mni", "mno", */
- "mis", "mkd", "mkh", "mal", "mon", "mnc", "mni", "mno",
- /*"mo", "moh", "mos", "mr", "ms", "mt", "mul", "mun", */
- "mol", "moh", "mos", "mar", "msa", "mlt", "mul", "mun",
- /*"mus", "mwr", "my", "myn", "myv", "na", "nah", "nai", "nap", */
- "mus", "mwr", "mya", "myn", "myv", "nau", "nah", "nai", "nap",
- /*"nb", "nd", "nds", "ne", "new", "ng", "nia", "nic", */
- "nob", "nde", "nds", "nep", "new", "ndo", "nia", "nic",
- /*"niu", "nl", "nn", "no", "nog", "non", "nr", "nso", "nub", */
- "niu", "nld", "nno", "nor", "nog", "non", "nbl", "nso", "nub",
- /*"nv", "nwc", "ny", "nym", "nyn", "nyo", "nzi", "oc", "oj", */
- "nav", "nwc", "nya", "nym", "nyn", "nyo", "nzi", "oci", "oji",
- /*"om", "or", "os", "osa", "ota", "oto", "pa", "paa", */
- "orm", "ori", "oss", "osa", "ota", "oto", "pan", "paa",
- /*"pag", "pal", "pam", "pap", "pau", "peo", "phi", "phn", */
- "pag", "pal", "pam", "pap", "pau", "peo", "phi", "phn",
- /*"pi", "pl", "pon", "pra", "pro", "ps", "pt", "qu", */
- "pli", "pol", "pon", "pra", "pro", "pus", "por", "que",
- /*"raj", "rap", "rar", "rm", "rn", "ro", "roa", "rom", */
- "raj", "rap", "rar", "roh", "run", "ron", "roa", "rom",
- /*"ru", "rup", "rw", "sa", "sad", "sah", "sai", "sal", "sam", */
- "rus", "rup", "kin", "san", "sad", "sah", "sai", "sal", "sam",
- /*"sas", "sat", "sc", "sco", "sd", "se", "sel", "sem", */
- "sas", "sat", "srd", "sco", "snd", "sme", "sel", "sem",
- /*"sg", "sga", "sgn", "shn", "si", "sid", "sio", "sit", */
- "sag", "sga", "sgn", "shn", "sin", "sid", "sio", "sit",
- /*"sk", "sl", "sla", "sm", "sma", "smi", "smj", "smn", */
- "slk", "slv", "sla", "smo", "sma", "smi", "smj", "smn",
- /*"sms", "sn", "snk", "so", "sog", "son", "sq", "sr", */
- "sms", "sna", "snk", "som", "sog", "son", "sqi", "srp",
- /*"srr", "ss", "ssa", "st", "su", "suk", "sus", "sux", */
- "srr", "ssw", "ssa", "sot", "sun", "suk", "sus", "sux",
- /*"sv", "sw", "syr", "ta", "tai", "te", "tem", "ter", */
- "swe", "swa", "syr", "tam", "tai", "tel", "tem", "ter",
- /*"tet", "tg", "th", "ti", "tig", "tiv", "tk", "tkl", */
- "tet", "tgk", "tha", "tir", "tig", "tiv", "tuk", "tkl",
- /*"tl", "tlh", "tli", "tmh", "tn", "to", "tog", "tpi", "tr", */
- "tgl", "tlh", "tli", "tmh", "tsn", "ton", "tog", "tpi", "tur",
- /*"ts", "tsi", "tt", "tum", "tup", "tut", "tvl", "tw", */
- "tso", "tsi", "tat", "tum", "tup", "tut", "tvl", "twi",
- /*"ty", "tyv", "udm", "ug", "uga", "uk", "umb", "und", "ur", */
- "tah", "tyv", "udm", "uig", "uga", "ukr", "umb", "und", "urd",
- /*"uz", "vai", "ve", "vi", "vo", "vot", "wa", "wak", */
- "uzb", "vai", "ven", "vie", "vol", "vot", "wln", "wak",
- /*"wal", "war", "was", "wen", "wo", "xal", "xh", "yao", "yap", */
- "wal", "war", "was", "wen", "wol", "xal", "xho", "yao", "yap",
- /*"yi", "yo", "ypk", "za", "zap", "zen", "zh", "znd", */
- "yid", "yor", "ypk", "zha", "zap", "zen", "zho", "znd",
- /*"zu", "zun", */
- "zul", "zun",
- };
-
- String[] tempObsoleteLanguages3 = {
- /* "in", "iw", "ji", "jw", "sh", */
- "ind", "heb", "yid", "jaw", "srp",
- };
-
- synchronized (ULocale.class) {
- if (_languages == null) {
- _languages = tempLanguages;
- _replacementLanguages = tempReplacementLanguages;
- _obsoleteLanguages = tempObsoleteLanguages;
- _languages3 = tempLanguages3;
- _obsoleteLanguages3 = tempObsoleteLanguages3;
- }
- }
- }
- }
-
- private static String[] _countries;
- private static String[] _deprecatedCountries;
- private static String[] _replacementCountries;
- private static String[] _obsoleteCountries;
- private static String[] _countries3;
- private static String[] _obsoleteCountries3;
-
- // Avoid initializing country tables unless we have to.
- private static void initCountryTables() {
- if (_countries == null) {
- /* ZR(ZAR) is now CD(COD) and FX(FXX) is PS(PSE) as per
- http://www.evertype.com/standards/iso3166/iso3166-1-en.html
- added new codes keeping the old ones for compatibility
- updated to include 1999/12/03 revisions *CWB*/
-
- /* RO(ROM) is now RO(ROU) according to
- http://www.iso.org/iso/en/prods-services/iso3166ma/03updates-on-iso-3166/nlv3e-rou.html
- */
-
- /* This list MUST be in sorted order, and MUST contain only two-letter codes! */
- String[] tempCountries = {
- "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN",
- "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ",
- "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI",
- "BJ", "BL", "BM", "BN", "BO", "BR", "BS", "BT", "BV",
- "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG",
- "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR",
- "CU", "CV", "CX", "CY", "CZ", "DE", "DJ", "DK",
- "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER",
- "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR",
- "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL",
- "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU",
- "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU",
- "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS",
- "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI",
- "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA",
- "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU",
- "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK",
- "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS",
- "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA",
- "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP",
- "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG",
- "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT",
- "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA",
- "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ",
- "SK", "SL", "SM", "SN", "SO", "SR", "ST", "SV",
- "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ",
- "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV",
- "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ",
- "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF",
- "WS", "YE", "YT", "ZA", "ZM", "ZW",
- };
-
- /* this table is used for 3 letter codes */
- String[] tempObsoleteCountries = {
- "FX", "CS", "RO", "TP", "YU", "ZR", /* obsolete country codes */
- };
-
- String[] tempDeprecatedCountries = {
- "BU", "CS", "DY", "FX", "HV", "NH", "RH", "TP", "YU", "ZR" /* deprecated country list */
- };
- String[] tempReplacementCountries = {
- /* "BU", "CS", "DY", "FX", "HV", "NH", "RH", "TP", "YU", "ZR" */
- "MM", "RS", "BJ", "FR", "BF", "VU", "ZW", "TL", "RS", "CD", /* replacement country codes */
- };
-
- /* This list MUST contain a three-letter code for every two-letter code in
- the above list, and they MUST be listed in the same order! */
- String[] tempCountries3 = {
- /* "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN", */
- "AND", "ARE", "AFG", "ATG", "AIA", "ALB", "ARM", "ANT",
- /* "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", */
- "AGO", "ATA", "ARG", "ASM", "AUT", "AUS", "ABW", "ALA", "AZE",
- /* "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", */
- "BIH", "BRB", "BGD", "BEL", "BFA", "BGR", "BHR", "BDI",
- /* "BJ", "BL", "BM", "BN", "BO", "BR", "BS", "BT", "BV", */
- "BEN", "BLM", "BMU", "BRN", "BOL", "BRA", "BHS", "BTN", "BVT",
- /* "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", */
- "BWA", "BLR", "BLZ", "CAN", "CCK", "COD", "CAF", "COG",
- /* "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", */
- "CHE", "CIV", "COK", "CHL", "CMR", "CHN", "COL", "CRI",
- /* "CU", "CV", "CX", "CY", "CZ", "DE", "DJ", "DK", */
- "CUB", "CPV", "CXR", "CYP", "CZE", "DEU", "DJI", "DNK",
- /* "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER", */
- "DMA", "DOM", "DZA", "ECU", "EST", "EGY", "ESH", "ERI",
- /* "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", */
- "ESP", "ETH", "FIN", "FJI", "FLK", "FSM", "FRO", "FRA",
- /* "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", */
- "GAB", "GBR", "GRD", "GEO", "GUF", "GGY", "GHA", "GIB", "GRL",
- /* "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", */
- "GMB", "GIN", "GLP", "GNQ", "GRC", "SGS", "GTM", "GUM",
- /* "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", */
- "GNB", "GUY", "HKG", "HMD", "HND", "HRV", "HTI", "HUN",
- /* "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS" */
- "IDN", "IRL", "ISR", "IMN", "IND", "IOT", "IRQ", "IRN", "ISL",
- /* "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", */
- "ITA", "JEY", "JAM", "JOR", "JPN", "KEN", "KGZ", "KHM", "KIR",
- /* "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", */
- "COM", "KNA", "PRK", "KOR", "KWT", "CYM", "KAZ", "LAO",
- /* "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", */
- "LBN", "LCA", "LIE", "LKA", "LBR", "LSO", "LTU", "LUX",
- /* "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", */
- "LVA", "LBY", "MAR", "MCO", "MDA", "MNE", "MAF", "MDG", "MHL", "MKD",
- /* "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", */
- "MLI", "MMR", "MNG", "MAC", "MNP", "MTQ", "MRT", "MSR",
- /* "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", */
- "MLT", "MUS", "MDV", "MWI", "MEX", "MYS", "MOZ", "NAM",
- /* "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", */
- "NCL", "NER", "NFK", "NGA", "NIC", "NLD", "NOR", "NPL",
- /* "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", */
- "NRU", "NIU", "NZL", "OMN", "PAN", "PER", "PYF", "PNG",
- /* "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", */
- "PHL", "PAK", "POL", "SPM", "PCN", "PRI", "PSE", "PRT",
- /* "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", */
- "PLW", "PRY", "QAT", "REU", "ROU", "SRB", "RUS", "RWA", "SAU",
- /* "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", */
- "SLB", "SYC", "SDN", "SWE", "SGP", "SHN", "SVN", "SJM",
- /* "SK", "SL", "SM", "SN", "SO", "SR", "ST", "SV", */
- "SVK", "SLE", "SMR", "SEN", "SOM", "SUR", "STP", "SLV",
- /* "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", */
- "SYR", "SWZ", "TCA", "TCD", "ATF", "TGO", "THA", "TJK",
- /* "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", */
- "TKL", "TLS", "TKM", "TUN", "TON", "TUR", "TTO", "TUV",
- /* "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", */
- "TWN", "TZA", "UKR", "UGA", "UMI", "USA", "URY", "UZB",
- /* "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", */
- "VAT", "VCT", "VEN", "VGB", "VIR", "VNM", "VUT", "WLF",
- /* "WS", "YE", "YT", "ZA", "ZM", "ZW" */
- "WSM", "YEM", "MYT", "ZAF", "ZMB", "ZWE",
- };
-
- String[] tempObsoleteCountries3 = {
- /*"FX", "CS", "RO", "TP", "YU", "ZR", */
- "FXX", "SCG", "ROM", "TMP", "YUG", "ZAR",
- };
-
- synchronized (ULocale.class) {
- if (_countries == null) {
- _countries = tempCountries;
- _deprecatedCountries = tempDeprecatedCountries;
- _replacementCountries = tempReplacementCountries;
- _obsoleteCountries = tempObsoleteCountries;
- _countries3 = tempCountries3;
- _obsoleteCountries3 = tempObsoleteCountries3;
- }
- }
- }
- }
-
- private static String[][] CANONICALIZE_MAP;
- private static String[][] variantsToKeywords;
-
- private static void initCANONICALIZE_MAP() {
- if (CANONICALIZE_MAP == null) {
- /**
- * This table lists pairs of locale ids for canonicalization. The
- * The 1st item is the normalized id. The 2nd item is the
- * canonicalized id. The 3rd is the keyword. The 4th is the keyword value.
- */
- String[][] tempCANONICALIZE_MAP = {
-// { EMPTY_STRING, "en_US_POSIX", null, null }, /* .NET name */
- { "C", "en_US_POSIX", null, null }, /* POSIX name */
- { "art_LOJBAN", "jbo", null, null }, /* registered name */
- { "az_AZ_CYRL", "az_Cyrl_AZ", null, null }, /* .NET name */
- { "az_AZ_LATN", "az_Latn_AZ", null, null }, /* .NET name */
- { "ca_ES_PREEURO", "ca_ES", "currency", "ESP" },
- { "cel_GAULISH", "cel__GAULISH", null, null }, /* registered name */
- { "de_1901", "de__1901", null, null }, /* registered name */
- { "de_1906", "de__1906", null, null }, /* registered name */
- { "de__PHONEBOOK", "de", "collation", "phonebook" }, /* Old ICU name */
- { "de_AT_PREEURO", "de_AT", "currency", "ATS" },
- { "de_DE_PREEURO", "de_DE", "currency", "DEM" },
- { "de_LU_PREEURO", "de_LU", "currency", "EUR" },
- { "el_GR_PREEURO", "el_GR", "currency", "GRD" },
- { "en_BOONT", "en__BOONT", null, null }, /* registered name */
- { "en_SCOUSE", "en__SCOUSE", null, null }, /* registered name */
- { "en_BE_PREEURO", "en_BE", "currency", "BEF" },
- { "en_IE_PREEURO", "en_IE", "currency", "IEP" },
- { "es__TRADITIONAL", "es", "collation", "traditional" }, /* Old ICU name */
- { "es_ES_PREEURO", "es_ES", "currency", "ESP" },
- { "eu_ES_PREEURO", "eu_ES", "currency", "ESP" },
- { "fi_FI_PREEURO", "fi_FI", "currency", "FIM" },
- { "fr_BE_PREEURO", "fr_BE", "currency", "BEF" },
- { "fr_FR_PREEURO", "fr_FR", "currency", "FRF" },
- { "fr_LU_PREEURO", "fr_LU", "currency", "LUF" },
- { "ga_IE_PREEURO", "ga_IE", "currency", "IEP" },
- { "gl_ES_PREEURO", "gl_ES", "currency", "ESP" },
- { "hi__DIRECT", "hi", "collation", "direct" }, /* Old ICU name */
- { "it_IT_PREEURO", "it_IT", "currency", "ITL" },
- { "ja_JP_TRADITIONAL", "ja_JP", "calendar", "japanese" },
-// { "nb_NO_NY", "nn_NO", null, null },
- { "nl_BE_PREEURO", "nl_BE", "currency", "BEF" },
- { "nl_NL_PREEURO", "nl_NL", "currency", "NLG" },
- { "pt_PT_PREEURO", "pt_PT", "currency", "PTE" },
- { "sl_ROZAJ", "sl__ROZAJ", null, null }, /* registered name */
- { "sr_SP_CYRL", "sr_Cyrl_RS", null, null }, /* .NET name */
- { "sr_SP_LATN", "sr_Latn_RS", null, null }, /* .NET name */
- { "sr_YU_CYRILLIC", "sr_Cyrl_RS", null, null }, /* Linux name */
- { "th_TH_TRADITIONAL", "th_TH", "calendar", "buddhist" }, /* Old ICU name */
- { "uz_UZ_CYRILLIC", "uz_Cyrl_UZ", null, null }, /* Linux name */
- { "uz_UZ_CYRL", "uz_Cyrl_UZ", null, null }, /* .NET name */
- { "uz_UZ_LATN", "uz_Latn_UZ", null, null }, /* .NET name */
- { "zh_CHS", "zh_Hans", null, null }, /* .NET name */
- { "zh_CHT", "zh_Hant", null, null }, /* .NET name */
- { "zh_GAN", "zh__GAN", null, null }, /* registered name */
- { "zh_GUOYU", "zh", null, null }, /* registered name */
- { "zh_HAKKA", "zh__HAKKA", null, null }, /* registered name */
- { "zh_MIN", "zh__MIN", null, null }, /* registered name */
- { "zh_MIN_NAN", "zh__MINNAN", null, null }, /* registered name */
- { "zh_WUU", "zh__WUU", null, null }, /* registered name */
- { "zh_XIANG", "zh__XIANG", null, null }, /* registered name */
- { "zh_YUE", "zh__YUE", null, null } /* registered name */
- };
-
- synchronized (ULocale.class) {
- if (CANONICALIZE_MAP == null) {
- CANONICALIZE_MAP = tempCANONICALIZE_MAP;
- }
- }
- }
- if (variantsToKeywords == null) {
- /**
- * This table lists pairs of locale ids for canonicalization. The
- * The first item is the normalized variant id.
- */
- String[][] tempVariantsToKeywords = {
- { "EURO", "currency", "EUR" },
- { "PINYIN", "collation", "pinyin" }, /* Solaris variant */
- { "STROKE", "collation", "stroke" } /* Solaris variant */
- };
-
- synchronized (ULocale.class) {
- if (variantsToKeywords == null) {
- variantsToKeywords = tempVariantsToKeywords;
- }
- }
- }
- }
-
- /*
- * This table is used for mapping between ICU and special Java
- * locales. When an ICU locale matches
- * This constructor does not canonicalize the localeID. So, for
- * example, "zh__pinyin" remains unchanged instead of converting
- * to "zh@collation=pinyin". By default ICU only recognizes the
- * latter as specifying pinyin collation. Use {@link #createCanonical}
- * or {@link #canonicalize} if you need to canonicalize the localeID.
- *
- * @param localeID string representation of the locale, e.g:
- * "en_US", "sy_Cyrl_YU", "zh__pinyin", "es_ES@currency=EUR;collation=traditional"
- * @stable ICU 2.8
- */
- public ULocale(String localeID) {
- this.localeID = getName(localeID);
- }
-
- /**
- * Convenience overload of ULocale(String, String, String) for
- * compatibility with java.util.Locale.
- * @see #ULocale(String, String, String)
- * @stable ICU 3.4
- */
- public ULocale(String a, String b) {
- this(a, b, null);
- }
-
- /**
- * Construct a ULocale from a localeID constructed from the three 'fields' a, b, and c. These
- * fields are concatenated using underscores to form a localeID of
- * the form a_b_c, which is then handled like the localeID passed
- * to Java locale strings consisting of language, country, and
- * variant will be handled by this form, since the country code
- * (being shorter than four letters long) will not be interpreted
- * as a script code. If a script code is present, the final
- * argument ('c') will be interpreted as the country code. It is
- * recommended that this constructor only be used to ease porting,
- * and that clients instead use the single-argument constructor
- * when constructing a ULocale from a localeID.
- * @param a first component of the locale id
- * @param b second component of the locale id
- * @param c third component of the locale id
- * @see #ULocale(String)
- * @stable ICU 3.0
- */
- public ULocale(String a, String b, String c) {
- localeID = getName(lscvToID(a, b, c, EMPTY_STRING));
- }
-
- /**
- * Create a ULocale from the id by first canonicalizing the id.
- * @param nonCanonicalID the locale id to canonicalize
- * @return the locale created from the canonical version of the ID.
- * @stable ICU 3.0
- */
- public static ULocale createCanonical(String nonCanonicalID) {
- return new ULocale(canonicalize(nonCanonicalID), (Locale)null);
- }
-
- private static String lscvToID(String lang, String script, String country, String variant) {
- StringBuffer buf = new StringBuffer();
-
- if (lang != null && lang.length() > 0) {
- buf.append(lang);
- }
- if (script != null && script.length() > 0) {
- buf.append(UNDERSCORE);
- buf.append(script);
- }
- if (country != null && country.length() > 0) {
- buf.append(UNDERSCORE);
- buf.append(country);
- }
- if (variant != null && variant.length() > 0) {
- if (country == null || country.length() == 0) {
- buf.append(UNDERSCORE);
- }
- buf.append(UNDERSCORE);
- buf.append(variant);
- }
- return buf.toString();
- }
-
- /**
- * Convert this ULocale object to a {@link java.util.Locale}.
- * @return a JDK locale that either exactly represents this object
- * or is the closest approximation.
- * @stable ICU 2.8
- */
- public Locale toLocale() {
- if (locale == null) {
- IDParser p = new IDParser(localeID);
- String base = p.getBaseName();
- for (int i = 0; i < _javaLocaleMap.length; i++) {
- if (base.equals(_javaLocaleMap[i][1]) || base.equals(_javaLocaleMap[i][4])) {
- if (_javaLocaleMap[i][2] != null) {
- String val = p.getKeywordValue(_javaLocaleMap[i][2]);
- if (val != null && val.equals(_javaLocaleMap[i][3])) {
- p = new IDParser(_javaLocaleMap[i][0]);
- break;
- }
- } else {
- p = new IDParser(_javaLocaleMap[i][0]);
- break;
- }
- }
- }
- String[] names = p.getLanguageScriptCountryVariant();
- locale = new Locale(names[0], names[2], names[3]);
- }
- return locale;
- }
-
- private static Locale toLocale(String localeID) {
- IDParser p = new IDParser(localeID);
- String base = p.getBaseName();
- for (int i = 0; i < _javaLocaleMap.length; i++) {
- if (base.equals(_javaLocaleMap[i][1]) || base.equals(_javaLocaleMap[i][4])) {
- if (_javaLocaleMap[i][2] != null) {
- String val = p.getKeywordValue(_javaLocaleMap[i][2]);
- if (val != null && val.equals(_javaLocaleMap[i][3])) {
- p = new IDParser(_javaLocaleMap[i][0]);
- break;
- }
- } else {
- p = new IDParser(_javaLocaleMap[i][0]);
- break;
- }
- }
- }
- String[] names = p.getLanguageScriptCountryVariant();
- return new Locale(names[0], names[2], names[3]);
- }
-
-
- private static SoftReference nameCacheRef = new SoftReference(Collections.synchronizedMap(new HashMap()));
- /**
- * Keep our own default ULocale.
- */
- private static Locale defaultLocale = Locale.getDefault();
- private static ULocale defaultULocale = new ULocale(defaultLocale);
-
- /**
- * Returns the current default ULocale.
- * @stable ICU 2.8
- */
- public static ULocale getDefault() {
- synchronized (ULocale.class) {
- Locale currentDefault = Locale.getDefault();
- if (defaultLocale != currentDefault) {
- defaultLocale = currentDefault;
- defaultULocale = new ULocale(defaultLocale);
- }
- return defaultULocale;
- }
- }
-
- /**
- * Sets the default ULocale. This also sets the default Locale.
- * If the caller does not have write permission to the
- * user.language property, a security exception will be thrown,
- * and the default ULocale will remain unchanged.
- * @param newLocale the new default locale
- * @throws SecurityException
- * if a security manager exists and its
- * Note: The valid locale will be returned correctly in ICU
- * 3.0 or later. In ICU 2.8, it is not returned correctly.
- * @draft ICU 2.8 (retain)
- * @provisional This API might change or be removed in a future release.
- */
- public static Type VALID_LOCALE = new Type();
-
- /**
- * Opaque selector enum for getLocale().
- * @see com.ibm.icu.util.ULocale
- * @see com.ibm.icu.util.ULocale#ACTUAL_LOCALE
- * @see com.ibm.icu.util.ULocale#VALID_LOCALE
- * @draft ICU 2.8 (retainAll)
- * @provisional This API might change or be removed in a future release.
- */
- public static final class Type {
- private Type() {}
- }
-
- /**
- * Based on a HTTP formatted list of acceptable locales, determine an available locale for the user.
- * NullPointerException is thrown if acceptLanguageList or availableLocales is
- * null. If fallback is non-null, it will contain true if a fallback locale (one
- * not in the acceptLanguageList) was returned. The value on entry is ignored.
- * ULocale will be one of the locales in availableLocales, or the ROOT ULocale if
- * if a ROOT locale was used as a fallback (because nothing else in
- * availableLocales matched). No ULocale array element should be null; behavior
- * is undefined if this is the case.
- * @param acceptLanguageList list in HTTP "Accept-Language:" format of acceptable locales
- * @param availableLocales list of available locales. One of these will be returned.
- * @param fallback if non-null, a 1-element array containing a boolean to be set with the fallback status
- * @return one of the locales from the availableLocales list, or null if none match
- * @stable ICU 3.4
- */
-
- public static ULocale acceptLanguage(String acceptLanguageList, ULocale[] availableLocales,
- boolean[] fallback) {
- if (acceptLanguageList == null) {
- throw new NullPointerException();
- }
- ULocale acceptList[] = null;
- try {
- acceptList = parseAcceptLanguage(acceptLanguageList, true);
- } catch (ParseException pe) {
- acceptList = null;
- }
- if (acceptList == null) {
- return null;
- }
- return acceptLanguage(acceptList, availableLocales, fallback);
- }
-
- /**
- * Based on a list of acceptable locales, determine an available locale for the user.
- * NullPointerException is thrown if acceptLanguageList or availableLocales is
- * null. If fallback is non-null, it will contain true if a fallback locale (one
- * not in the acceptLanguageList) was returned. The value on entry is ignored.
- * ULocale will be one of the locales in availableLocales, or the ROOT ULocale if
- * if a ROOT locale was used as a fallback (because nothing else in
- * availableLocales matched). No ULocale array element should be null; behavior
- * is undefined if this is the case.
- * @param acceptLanguageList list of acceptable locales
- * @param availableLocales list of available locales. One of these will be returned.
- * @param fallback if non-null, a 1-element array containing a boolean to be set with the fallback status
- * @return one of the locales from the availableLocales list, or null if none match
- * @stable ICU 3.4
- */
-
- public static ULocale acceptLanguage(ULocale[] acceptLanguageList, ULocale[]
- availableLocales, boolean[] fallback) {
- // fallbacklist
- int i,j;
- if(fallback != null) {
- fallback[0]=true;
- }
- for(i=0;iULocale(String localeID)
.
- *
- * checkPermission
method doesn't allow the operation.
- * @throws NullPointerException if newLocale
is null
- * @see SecurityManager#checkPermission(java.security.Permission)
- * @see java.util.PropertyPermission
- * @stable ICU 3.0
- */
- public static synchronized void setDefault(ULocale newLocale){
- Locale.setDefault(newLocale.toLocale());
- defaultULocale = newLocale;
- }
-
- /**
- * This is for compatibility with Locale-- in actuality, since ULocale is
- * immutable, there is no reason to clone it, so this API returns 'this'.
- * @stable ICU 3.0
- */
- public Object clone() {
- return this;
- }
-
- /**
- * Returns the hashCode.
- * @stable ICU 3.0
- */
- public int hashCode() {
- return localeID.hashCode();
- }
-
- /**
- * Returns true if the other object is another ULocale with the
- * same full name, or is a String localeID that matches the full name.
- * Note that since names are not canonicalized, two ULocales that
- * function identically might not compare equal.
- *
- * @return true if this Locale is equal to the specified object.
- * @stable ICU 3.0
- */
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof String) {
- return localeID.equals((String)obj);
- }
- if (obj instanceof ULocale) {
- return localeID.equals(((ULocale)obj).localeID);
- }
- return false;
- }
-
- private static ULocale[] ulocales;
-
- /**
- * Returns a list of all installed locales.
- * @stable ICU 3.0
- */
- public static ULocale[] getAvailableLocales() {
-// return ICUResourceBundle.getAvailableULocales();
- if (ulocales == null) {
- Locale[] locales = Locale.getAvailableLocales();
- ULocale[] ul = new ULocale[locales.length];
- for (int i = 0; i < locales.length; ++i) {
- ul[i] = ULocale.forLocale(locales[i]);
- }
- ulocales = ul;
- }
- return (ULocale[])ulocales.clone();
- }
-
- /**
- * Returns a list of all 2-letter country codes defined in ISO 3166.
- * Can be used to create Locales.
- * @stable ICU 3.0
- */
- public static String[] getISOCountries() {
- initCountryTables();
- return (String[])_countries.clone();
- }
-
- /**
- * Returns a list of all 2-letter language codes defined in ISO 639.
- * Can be used to create Locales.
- * [NOTE: ISO 639 is not a stable standard-- some languages' codes have changed.
- * The list this function returns includes both the new and the old codes for the
- * languages whose codes have changed.]
- * @stable ICU 3.0
- */
- public static String[] getISOLanguages() {
- initLanguageTables();
- return (String[])_languages.clone();
- }
-
- /**
- * Returns the language code for this locale, which will either be the empty string
- * or a lowercase ISO 639 code.
- * @see #getDisplayLanguage()
- * @see #getDisplayLanguage(ULocale)
- * @stable ICU 3.0
- */
- public String getLanguage() {
- return getLanguage(localeID);
- }
-
- /**
- * Returns the language code for the locale ID,
- * which will either be the empty string
- * or a lowercase ISO 639 code.
- * @see #getDisplayLanguage()
- * @see #getDisplayLanguage(ULocale)
- * @stable ICU 3.0
- */
- public static String getLanguage(String localeID) {
- return new IDParser(localeID).getLanguage();
- }
-
- /**
- * Returns the script code for this locale, which might be the empty string.
- * @see #getDisplayScript()
- * @see #getDisplayScript(ULocale)
- * @stable ICU 3.0
- */
- public String getScript() {
- return getScript(localeID);
- }
-
- /**
- * Returns the script code for the specified locale, which might be the empty string.
- * @see #getDisplayScript()
- * @see #getDisplayScript(ULocale)
- * @stable ICU 3.0
- */
- public static String getScript(String localeID) {
- return new IDParser(localeID).getScript();
- }
-
- /**
- * Returns the country/region code for this locale, which will either be the empty string
- * or an uppercase ISO 3166 2-letter code.
- * @see #getDisplayCountry()
- * @see #getDisplayCountry(ULocale)
- * @stable ICU 3.0
- */
- public String getCountry() {
- return getCountry(localeID);
- }
-
- /**
- * Returns the country/region code for this locale, which will either be the empty string
- * or an uppercase ISO 3166 2-letter code.
- * @param localeID
- * @see #getDisplayCountry()
- * @see #getDisplayCountry(ULocale)
- * @stable ICU 3.0
- */
- public static String getCountry(String localeID) {
- return new IDParser(localeID).getCountry();
- }
-
- /**
- * Returns the variant code for this locale, which might be the empty string.
- * @see #getDisplayVariant()
- * @see #getDisplayVariant(ULocale)
- * @stable ICU 3.0
- */
- public String getVariant() {
- return getVariant(localeID);
- }
-
- /**
- * Returns the variant code for the specified locale, which might be the empty string.
- * @see #getDisplayVariant()
- * @see #getDisplayVariant(ULocale)
- * @stable ICU 3.0
- */
- public static String getVariant(String localeID) {
- return new IDParser(localeID).getVariant();
- }
-
- /**
- * Returns the fallback locale for the specified locale, which might be the empty string.
- * @stable ICU 3.2
- */
- public static String getFallback(String localeID) {
- return getFallbackString(getName(localeID));
- }
-
- /**
- * Returns the fallback locale for this locale. If this locale is root, returns null.
- * @stable ICU 3.2
- */
- public ULocale getFallback() {
- if (localeID.length() == 0 || localeID.charAt(0) == '@') {
- return null;
- }
- return new ULocale(getFallbackString(localeID), (Locale)null);
- }
-
- /**
- * Return the given (canonical) locale id minus the last part before the tags.
- */
- private static String getFallbackString(String fallback) {
- int limit = fallback.indexOf('@');
- if (limit == -1) {
- limit = fallback.length();
- }
- int start = fallback.lastIndexOf('_', limit);
- if (start == -1) {
- start = 0;
- }
- return fallback.substring(0, start) + fallback.substring(limit);
- }
-
- /**
- * Returns the (normalized) base name for this locale.
- * @return the base name as a String.
- * @stable ICU 3.0
- */
- public String getBaseName() {
- return getBaseName(localeID);
- }
-
- /**
- * Returns the (normalized) base name for the specified locale.
- * @param localeID the locale ID as a string
- * @return the base name as a String.
- * @stable ICU 3.0
- */
- public static String getBaseName(String localeID){
- if (localeID.indexOf('@') == -1) {
- return localeID;
- }
- return new IDParser(localeID).getBaseName();
- }
-
- /**
- * Returns the (normalized) full name for this locale.
- *
- * @return String the full name of the localeID
- * @stable ICU 3.0
- */
- public String getName() {
- return localeID; // always normalized
- }
-
- /**
- * Returns the (normalized) full name for the specified locale.
- *
- * @param localeID the localeID as a string
- * @return String the full name of the localeID
- * @stable ICU 3.0
- */
- public static String getName(String localeID){
- Map cache = (Map)nameCacheRef.get();
- if (cache == null) {
- cache = Collections.synchronizedMap(new HashMap());
- nameCacheRef = new SoftReference(cache);
- }
- String name = (String)cache.get(localeID);
- if (name == null) {
- name = new IDParser(localeID).getName();
- cache.put(localeID, name);
- }
- return name;
- }
-
- /**
- * Returns a string representation of this object.
- * @stable ICU 3.0
- */
- public String toString() {
- return localeID;
- }
-
- /**
- * Returns an iterator over keywords for this locale. If there
- * are no keywords, returns null.
- * @return iterator over keywords, or null if there are no keywords.
- * @stable ICU 3.0
- */
- public Iterator getKeywords() {
- return getKeywords(localeID);
- }
-
- /**
- * Returns an iterator over keywords for the specified locale. If there
- * are no keywords, returns null.
- * @return an iterator over the keywords in the specified locale, or null
- * if there are no keywords.
- * @stable ICU 3.0
- */
- public static Iterator getKeywords(String localeID){
- return new IDParser(localeID).getKeywords();
- }
-
- /**
- * Returns the value for a keyword in this locale. If the keyword is not defined, returns null.
- * @param keywordName name of the keyword whose value is desired. Case insensitive.
- * @return the value of the keyword, or null.
- * @stable ICU 3.0
- */
- public String getKeywordValue(String keywordName){
- return getKeywordValue(localeID, keywordName);
- }
-
- /**
- * Returns the value for a keyword in the specified locale. If the keyword is not defined, returns null.
- * The locale name does not need to be normalized.
- * @param keywordName name of the keyword whose value is desired. Case insensitive.
- * @return String the value of the keyword as a string
- * @stable ICU 3.0
- */
- public static String getKeywordValue(String localeID, String keywordName) {
- return new IDParser(localeID).getKeywordValue(keywordName);
- }
-
- /**
- * Utility class to parse and normalize locale ids (including POSIX style)
- */
- private static final class IDParser {
- private char[] id;
- private int index;
- private char[] buffer;
- private int blen;
- // um, don't handle POSIX ids unless we request it. why not? well... because.
- private boolean canonicalize;
- private boolean hadCountry;
-
- // used when canonicalizing
- Map keywords;
- String baseName;
-
- /**
- * Parsing constants.
- */
- private static final char KEYWORD_SEPARATOR = '@';
- private static final char HYPHEN = '-';
- private static final char KEYWORD_ASSIGN = '=';
- private static final char COMMA = ',';
- private static final char ITEM_SEPARATOR = ';';
- private static final char DOT = '.';
-
- private IDParser(String localeID) {
- this(localeID, false);
- }
-
- private IDParser(String localeID, boolean canonicalize) {
- id = localeID.toCharArray();
- index = 0;
- buffer = new char[id.length + 5];
- blen = 0;
- this.canonicalize = canonicalize;
- }
-
- private void reset() {
- index = blen = 0;
- }
-
- // utilities for working on text in the buffer
-
- /**
- * Append c to the buffer.
- */
- private void append(char c) {
- try {
- buffer[blen] = c;
- }
- catch (IndexOutOfBoundsException e) {
- if (buffer.length > 512) {
- // something is seriously wrong, let this go
- throw e;
- }
- char[] nbuffer = new char[buffer.length * 2];
- System.arraycopy(buffer, 0, nbuffer, 0, buffer.length);
- nbuffer[blen] = c;
- buffer = nbuffer;
- }
- ++blen;
- }
-
- private void addSeparator() {
- append(UNDERSCORE);
- }
-
- /**
- * Returns the text in the buffer from start to blen as a String.
- */
- private String getString(int start) {
- if (start == blen) {
- return EMPTY_STRING;
- }
- return new String(buffer, start, blen-start);
- }
-
- /**
- * Set the length of the buffer to pos, then append the string.
- */
- private void set(int pos, String s) {
- this.blen = pos; // no safety
- append(s);
- }
-
- /**
- * Append the string to the buffer.
- */
- private void append(String s) {
- for (int i = 0; i < s.length(); ++i) {
- append(s.charAt(i));
- }
- }
-
- // utilities for parsing text out of the id
-
- /**
- * Character to indicate no more text is available in the id.
- */
- private static final char DONE = '\uffff';
-
- /**
- * Returns the character at index in the id, and advance index. The returned character
- * is DONE if index was at the limit of the buffer. The index is advanced regardless
- * so that decrementing the index will always 'unget' the last character returned.
- */
- private char next() {
- if (index == id.length) {
- index++;
- return DONE;
- }
-
- return id[index++];
- }
-
- /**
- * Advance index until the next terminator or id separator, and leave it there.
- */
- private void skipUntilTerminatorOrIDSeparator() {
- while (!isTerminatorOrIDSeparator(next())) {
- }
- --index;
- }
-
- /**
- * Returns true if the character at index in the id is a terminator.
- */
- private boolean atTerminator() {
- return index >= id.length || isTerminator(id[index]);
- }
-
- /*
- * Returns true if the character is an id separator (underscore or hyphen).
- */
-/* private boolean isIDSeparator(char c) {
- return c == UNDERSCORE || c == HYPHEN;
- }*/
-
- /**
- * Returns true if the character is a terminator (keyword separator, dot, or DONE).
- * Dot is a terminator because of the POSIX form, where dot precedes the codepage.
- */
- private boolean isTerminator(char c) {
- // always terminate at DOT, even if not handling POSIX. It's an error...
- return c == KEYWORD_SEPARATOR || c == DONE || c == DOT;
- }
-
- /**
- * Returns true if the character is a terminator or id separator.
- */
- private boolean isTerminatorOrIDSeparator(char c) {
- return c == KEYWORD_SEPARATOR || c == UNDERSCORE || c == HYPHEN ||
- c == DONE || c == DOT;
- }
-
- /**
- * Returns true if the start of the buffer has an experimental or private language
- * prefix, the pattern '[ixIX][-_].' shows the syntax checked.
- */
- private boolean haveExperimentalLanguagePrefix() {
- if (id.length > 2) {
- char c = id[1];
- if (c == HYPHEN || c == UNDERSCORE) {
- c = id[0];
- return c == 'x' || c == 'X' || c == 'i' || c == 'I';
- }
- }
- return false;
- }
-
- /**
- * Returns true if a value separator occurs at or after index.
- */
- private boolean haveKeywordAssign() {
- // assume it is safe to start from index
- for (int i = index; i < id.length; ++i) {
- if (id[i] == KEYWORD_ASSIGN) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Advance index past language, and accumulate normalized language code in buffer.
- * Index must be at 0 when this is called. Index is left at a terminator or id
- * separator. Returns the start of the language code in the buffer.
- */
- private int parseLanguage() {
- if (haveExperimentalLanguagePrefix()) {
- append(Character.toLowerCase(id[0]));
- append(HYPHEN);
- index = 2;
- }
-
- char c;
- while(!isTerminatorOrIDSeparator(c = next())) {
- append(Character.toLowerCase(c));
- }
- --index; // unget
-
- if (blen == 3) {
- initLanguageTables();
-
- /* convert 3 character code to 2 character code if possible *CWB*/
- String lang = getString(0);
- int offset = findIndex(_languages3, lang);
- if (offset >= 0) {
- set(0, _languages[offset]);
- } else {
- offset = findIndex(_obsoleteLanguages3, lang);
- if (offset >= 0) {
- set(0, _obsoleteLanguages[offset]);
- }
- }
- }
-
- return 0;
- }
-
- /**
- * Advance index past language. Index must be at 0 when this is called. Index
- * is left at a terminator or id separator.
- */
- private void skipLanguage() {
- if (haveExperimentalLanguagePrefix()) {
- index = 2;
- }
- skipUntilTerminatorOrIDSeparator();
- }
-
- /**
- * Advance index past script, and accumulate normalized script in buffer.
- * Index must be immediately after the language.
- * If the item at this position is not a script (is not four characters
- * long) leave index and buffer unchanged. Otherwise index is left at
- * a terminator or id separator. Returns the start of the script code
- * in the buffer (this may be equal to the buffer length, if there is no
- * script).
- */
- private int parseScript() {
- if (!atTerminator()) {
- int oldIndex = index; // save original index
- ++index;
-
- int oldBlen = blen; // get before append hyphen, if we truncate everything is undone
- char c;
- while(!isTerminatorOrIDSeparator(c = next())) {
- if (blen == oldBlen) { // first pass
- addSeparator();
- append(Character.toUpperCase(c));
- } else {
- append(Character.toLowerCase(c));
- }
- }
- --index; // unget
-
- /* If it's not exactly 4 characters long, then it's not a script. */
- if (index - oldIndex != 5) { // +1 to account for separator
- index = oldIndex;
- blen = oldBlen;
- } else {
- oldBlen++; // index past hyphen, for clients who want to extract just the script
- }
-
- return oldBlen;
- }
- return blen;
- }
-
- /**
- * Advance index past script.
- * Index must be immediately after the language and IDSeparator.
- * If the item at this position is not a script (is not four characters
- * long) leave index. Otherwise index is left at a terminator or
- * id separator.
- */
- private void skipScript() {
- if (!atTerminator()) {
- int oldIndex = index;
- ++index;
-
- skipUntilTerminatorOrIDSeparator();
- if (index - oldIndex != 5) { // +1 to account for separator
- index = oldIndex;
- }
- }
- }
-
- /**
- * Advance index past country, and accumulate normalized country in buffer.
- * Index must be immediately after the script (if there is one, else language)
- * and IDSeparator. Return the start of the country code in the buffer.
- */
- private int parseCountry() {
- if (!atTerminator()) {
- int oldIndex = index;
- ++index;
-
- int oldBlen = blen;
- char c;
- while (!isTerminatorOrIDSeparator(c = next())) {
- if (oldBlen == blen) { // first, add hyphen
- hadCountry = true; // we have a country, let variant parsing know
- addSeparator();
- ++oldBlen; // increment past hyphen
- }
- append(Character.toUpperCase(c));
- }
- --index; // unget
-
- int charsAppended = blen - oldBlen;
-
- if (charsAppended == 0) {
- // Do nothing.
- }
- else if (charsAppended < 2 || charsAppended > 3) {
- // It's not a country, so return index and blen to
- // their previous values.
- index = oldIndex;
- --oldBlen;
- blen = oldBlen;
- hadCountry = false;
- }
- else if (charsAppended == 3) {
- initCountryTables();
-
- /* convert 3 character code to 2 character code if possible *CWB*/
- int offset = findIndex(_countries3, getString(oldBlen));
- if (offset >= 0) {
- set(oldBlen, _countries[offset]);
- } else {
- offset = findIndex(_obsoleteCountries3, getString(oldBlen));
- if (offset >= 0) {
- set(oldBlen, _obsoleteCountries[offset]);
- }
- }
- }
-
- return oldBlen;
- }
-
- return blen;
- }
-
- /**
- * Advance index past country.
- * Index must be immediately after the script (if there is one, else language)
- * and IDSeparator.
- */
- private void skipCountry() {
- if (!atTerminator()) {
- ++index;
- /*
- * Save the index point after the separator, since the format
- * requires two separators if the country is not present.
- */
- int oldIndex = index;
-
- skipUntilTerminatorOrIDSeparator();
- int charsSkipped = index - oldIndex;
- if (charsSkipped < 2 || charsSkipped > 3) {
- index = oldIndex;
- }
- }
- }
-
- /**
- * Advance index past variant, and accumulate normalized variant in buffer. This ignores
- * the codepage information from POSIX ids. Index must be immediately after the country
- * or script. Index is left at the keyword separator or at the end of the text. Return
- * the start of the variant code in the buffer.
- *
- * In standard form, we can have the following forms:
- * ll__VVVV
- * ll_CC_VVVV
- * ll_Ssss_VVVV
- * ll_Ssss_CC_VVVV
- *
- * This also handles POSIX ids, which can have the following forms (pppp is code page id):
- * ll_CC.pppp --> ll_CC
- * ll_CC.pppp@VVVV --> ll_CC_VVVV
- * ll_CC@VVVV --> ll_CC_VVVV
- *
- * We identify this use of '@' in POSIX ids by looking for an '=' following
- * the '@'. If there is one, we consider '@' to start a keyword list, instead of
- * being part of a POSIX id.
- *
- * Note: since it was decided that we want an option to not handle POSIX ids, this
- * becomes a bit more complex.
- */
- private int parseVariant() {
- int oldBlen = blen;
-
- boolean start = true;
- boolean needSeparator = true;
- boolean skipping = false;
- char c;
- while ((c = next()) != DONE) {
- if (c == DOT) {
- start = false;
- skipping = true;
- } else if (c == KEYWORD_SEPARATOR) {
- if (haveKeywordAssign()) {
- break;
- }
- skipping = false;
- start = false;
- needSeparator = true; // add another underscore if we have more text
- } else if (start) {
- start = false;
- } else if (!skipping) {
- if (needSeparator) {
- boolean incOldBlen = blen == oldBlen; // need to skip separators
- needSeparator = false;
- if (incOldBlen && !hadCountry) { // no country, we'll need two
- addSeparator();
- ++oldBlen; // for sure
- }
- addSeparator();
- if (incOldBlen) { // only for the first separator
- ++oldBlen;
- }
- }
- c = Character.toUpperCase(c);
- if (c == HYPHEN || c == COMMA) {
- c = UNDERSCORE;
- }
- append(c);
- }
- }
- --index; // unget
-
- return oldBlen;
- }
-
- // no need for skipvariant, to get the keywords we'll just scan directly for
- // the keyword separator
-
- /**
- * Returns the normalized language id, or the empty string.
- */
- public String getLanguage() {
- reset();
- return getString(parseLanguage());
- }
-
- /**
- * Returns the normalized script id, or the empty string.
- */
- public String getScript() {
- reset();
- skipLanguage();
- return getString(parseScript());
- }
-
- /**
- * return the normalized country id, or the empty string.
- */
- public String getCountry() {
- reset();
- skipLanguage();
- skipScript();
- return getString(parseCountry());
- }
-
- /**
- * Returns the normalized variant id, or the empty string.
- */
- public String getVariant() {
- reset();
- skipLanguage();
- skipScript();
- skipCountry();
- return getString(parseVariant());
- }
-
- /**
- * Returns the language, script, country, and variant as separate strings.
- */
- public String[] getLanguageScriptCountryVariant() {
- reset();
- return new String[] {
- getString(parseLanguage()),
- getString(parseScript()),
- getString(parseCountry()),
- getString(parseVariant())
- };
- }
-
- public void setBaseName(String baseName) {
- this.baseName = baseName;
- }
-
- public void parseBaseName() {
- if (baseName != null) {
- set(0, baseName);
- } else {
- reset();
- parseLanguage();
- parseScript();
- parseCountry();
- parseVariant();
-
- // catch unwanted trailing underscore after country if there was no variant
- if (blen > 1 && buffer[blen-1] == UNDERSCORE) {
- --blen;
- }
- }
- }
-
- /**
- * Returns the normalized base form of the locale id. The base
- * form does not include keywords.
- */
- public String getBaseName() {
- if (baseName != null) {
- return baseName;
- }
- parseBaseName();
- return getString(0);
- }
-
- /**
- * Returns the normalized full form of the locale id. The full
- * form includes keywords if they are present.
- */
- public String getName() {
- parseBaseName();
- parseKeywords();
- return getString(0);
- }
-
- // keyword utilities
-
- /**
- * If we have keywords, advance index to the start of the keywords and return true,
- * otherwise return false.
- */
- private boolean setToKeywordStart() {
- for (int i = index; i < id.length; ++i) {
- if (id[i] == KEYWORD_SEPARATOR) {
- if (canonicalize) {
- for (int j = ++i; j < id.length; ++j) { // increment i past separator for return
- if (id[j] == KEYWORD_ASSIGN) {
- index = i;
- return true;
- }
- }
- } else {
- if (++i < id.length) {
- index = i;
- return true;
- }
- }
- break;
- }
- }
- return false;
- }
-
- private static boolean isDoneOrKeywordAssign(char c) {
- return c == DONE || c == KEYWORD_ASSIGN;
- }
-
- private static boolean isDoneOrItemSeparator(char c) {
- return c == DONE || c == ITEM_SEPARATOR;
- }
-
- private String getKeyword() {
- int start = index;
- while (!isDoneOrKeywordAssign(next())) {
- }
- --index;
- return new String(id, start, index-start).trim().toLowerCase();
- }
-
- private String getValue() {
- int start = index;
- while (!isDoneOrItemSeparator(next())) {
- }
- --index;
- return new String(id, start, index-start).trim(); // leave case alone
- }
-
- private Comparator getKeyComparator() {
- final Comparator comp = new Comparator() {
- public int compare(Object lhs, Object rhs) {
- return ((String)lhs).compareTo((String)rhs);
- }
- };
- return comp;
- }
-
- /**
- * Returns a map of the keywords and values, or null if there are none.
- */
- private Map getKeywordMap() {
- if (keywords == null) {
- TreeMap m = null;
- if (setToKeywordStart()) {
- // trim spaces and convert to lower case, both keywords and values.
- do {
- String key = getKeyword();
- if (key.length() == 0) {
- break;
- }
- char c = next();
- if (c != KEYWORD_ASSIGN) {
- // throw new IllegalArgumentException("key '" + key + "' missing a value.");
- if (c == DONE) {
- break;
- } else {
- continue;
- }
- }
- String value = getValue();
- if (value.length() == 0) {
- // throw new IllegalArgumentException("key '" + key + "' missing a value.");
- continue;
- }
- if (m == null) {
- m = new TreeMap(getKeyComparator());
- } else if (m.containsKey(key)) {
- // throw new IllegalArgumentException("key '" + key + "' already has a value.");
- continue;
- }
- m.put(key, value);
- } while (next() == ITEM_SEPARATOR);
- }
- keywords = m != null ? m : Collections.EMPTY_MAP;
- }
-
- return keywords;
- }
-
- /**
- * Parse the keywords and return start of the string in the buffer.
- */
- private int parseKeywords() {
- int oldBlen = blen;
- Map m = getKeywordMap();
- if (!m.isEmpty()) {
- Iterator iter = m.entrySet().iterator();
- boolean first = true;
- while (iter.hasNext()) {
- append(first ? KEYWORD_SEPARATOR : ITEM_SEPARATOR);
- first = false;
- Map.Entry e = (Map.Entry)iter.next();
- append((String)e.getKey());
- append(KEYWORD_ASSIGN);
- append((String)e.getValue());
- }
- if (blen != oldBlen) {
- ++oldBlen;
- }
- }
- return oldBlen;
- }
-
- /**
- * Returns an iterator over the keywords, or null if we have an empty map.
- */
- public Iterator getKeywords() {
- Map m = getKeywordMap();
- return m.isEmpty() ? null : m.keySet().iterator();
- }
-
- /**
- * Returns the value for the named keyword, or null if the keyword is not
- * present.
- */
- public String getKeywordValue(String keywordName) {
- Map m = getKeywordMap();
- return m.isEmpty() ? null : (String)m.get(keywordName.trim().toLowerCase());
- }
-
- /**
- * Set the keyword value only if it is not already set to something else.
- */
- public void defaultKeywordValue(String keywordName, String value) {
- setKeywordValue(keywordName, value, false);
- }
-
- /**
- * Set the value for the named keyword, or unset it if value is null. If
- * keywordName itself is null, unset all keywords. If keywordName is not null,
- * value must not be null.
- */
- public void setKeywordValue(String keywordName, String value) {
- setKeywordValue(keywordName, value, true);
- }
-
- /**
- * Set the value for the named keyword, or unset it if value is null. If
- * keywordName itself is null, unset all keywords. If keywordName is not null,
- * value must not be null. If reset is true, ignore any previous value for
- * the keyword, otherwise do not change the keyword (including removal of
- * one or all keywords).
- */
- private void setKeywordValue(String keywordName, String value, boolean reset) {
- if (keywordName == null) {
- if (reset) {
- // force new map, ignore value
- keywords = Collections.EMPTY_MAP;
- }
- } else {
- keywordName = keywordName.trim().toLowerCase();
- if (keywordName.length() == 0) {
- throw new IllegalArgumentException("keyword must not be empty");
- }
- if (value != null) {
- value = value.trim();
- if (value.length() == 0) {
- throw new IllegalArgumentException("value must not be empty");
- }
- }
- Map m = getKeywordMap();
- if (m.isEmpty()) { // it is EMPTY_MAP
- if (value != null) {
- // force new map
- keywords = new TreeMap(getKeyComparator());
- keywords.put(keywordName, value.trim());
- }
- } else {
- if (reset || !m.containsKey(keywordName)) {
- if (value != null) {
- m.put(keywordName, value);
- } else {
- m.remove(keywordName);
- if (m.isEmpty()) {
- // force new map
- keywords = Collections.EMPTY_MAP;
- }
- }
- }
- }
- }
- }
- }
-
- /**
- * linear search of the string array. the arrays are unfortunately ordered by the
- * two-letter target code, not the three-letter search code, which seems backwards.
- */
- private static int findIndex(String[] array, String target){
- for (int i = 0; i < array.length; i++) {
- if (target.equals(array[i])) {
- return i;
- }
- }
- return -1;
- }
-
- /**
- * Returns the canonical name for the specified locale ID. This is used to convert POSIX
- * and other grandfathered IDs to standard ICU form.
- * @param localeID the locale id
- * @return the canonicalized id
- * @stable ICU 3.0
- */
- public static String canonicalize(String localeID){
- IDParser parser = new IDParser(localeID, true);
- String baseName = parser.getBaseName();
- boolean foundVariant = false;
-
- // formerly, we always set to en_US_POSIX if the basename was empty, but
- // now we require that the entire id be empty, so that "@foo=bar"
- // will pass through unchanged.
- // {dlf} I'd rather keep "" unchanged.
- if (localeID.equals("")) {
- return "";
-// return "en_US_POSIX";
- }
-
- // we have an ID in the form xx_Yyyy_ZZ_KKKKK
-
- initCANONICALIZE_MAP();
-
- /* convert the variants to appropriate ID */
- for (int i = 0; i < variantsToKeywords.length; i++) {
- String[] vals = variantsToKeywords[i];
- int idx = baseName.lastIndexOf("_" + vals[0]);
- if (idx > -1) {
- foundVariant = true;
-
- baseName = baseName.substring(0, idx);
- if (baseName.endsWith("_")) {
- baseName = baseName.substring(0, --idx);
- }
- parser.setBaseName(baseName);
- parser.defaultKeywordValue(vals[1], vals[2]);
- break;
- }
- }
-
- /* See if this is an already known locale */
- for (int i = 0; i < CANONICALIZE_MAP.length; i++) {
- if (CANONICALIZE_MAP[i][0].equals(baseName)) {
- foundVariant = true;
-
- String[] vals = CANONICALIZE_MAP[i];
- parser.setBaseName(vals[1]);
- if (vals[2] != null) {
- parser.defaultKeywordValue(vals[2], vals[3]);
- }
- break;
- }
- }
-
- /* total mondo hack for Norwegian, fortunately the main NY case is handled earlier */
- if (!foundVariant) {
- if (parser.getLanguage().equals("nb") && parser.getVariant().equals("NY")) {
- parser.setBaseName(lscvToID("nn", parser.getScript(), parser.getCountry(), null));
- }
- }
-
- return parser.getName();
- }
-
- /**
- * Given a keyword and a value, return a new locale with an updated
- * keyword and value. If keyword is null, this removes all keywords from the locale id.
- * Otherwise, if the value is null, this removes the value for this keyword from the
- * locale id. Otherwise, this adds/replaces the value for this keyword in the locale id.
- * The keyword and value must not be empty.
- * @param keyword the keyword to add/remove, or null to remove all keywords.
- * @param value the value to add/set, or null to remove this particular keyword.
- * @return the updated locale
- * @stable ICU 3.2
- */
- public ULocale setKeywordValue(String keyword, String value) {
- return new ULocale(setKeywordValue(localeID, keyword, value), (Locale)null);
- }
-
- /**
- * Given a locale id, a keyword, and a value, return a new locale id with an updated
- * keyword and value. If keyword is null, this removes all keywords from the locale id.
- * Otherwise, if the value is null, this removes the value for this keyword from the
- * locale id. Otherwise, this adds/replaces the value for this keyword in the locale id.
- * The keyword and value must not be empty.
- * @param localeID the locale id to modify
- * @param keyword the keyword to add/remove, or null to remove all keywords.
- * @param value the value to add/set, or null to remove this particular keyword.
- * @return the updated locale id
- * @stable ICU 3.2
- */
- public static String setKeywordValue(String localeID, String keyword, String value) {
- IDParser parser = new IDParser(localeID);
- parser.setKeywordValue(keyword, value);
- return parser.getName();
- }
-
- /*
- * Given a locale id, a keyword, and a value, return a new locale id with an updated
- * keyword and value, if the keyword does not already have a value. The keyword and
- * value must not be null or empty.
- * @param localeID the locale id to modify
- * @param keyword the keyword to add, if not already present
- * @param value the value to add, if not already present
- * @return the updated locale id
- * @internal
- */
-/* private static String defaultKeywordValue(String localeID, String keyword, String value) {
- IDParser parser = new IDParser(localeID);
- parser.defaultKeywordValue(keyword, value);
- return parser.getName();
- }*/
-
- /**
- * Returns a three-letter abbreviation for this locale's language. If the locale
- * doesn't specify a language, returns the empty string. Otherwise, returns
- * a lowercase ISO 639-2/T language code.
- * The ISO 639-2 language codes can be found on-line at
- * ftp://dkuug.dk/i18n/iso-639-2.txt
- * @exception MissingResourceException Throws MissingResourceException if the
- * three-letter language abbreviation is not available for this locale.
- * @stable ICU 3.0
- */
- public String getISO3Language(){
- return getISO3Language(localeID);
- }
-
- /**
- * Returns a three-letter abbreviation for this locale's language. If the locale
- * doesn't specify a language, returns the empty string. Otherwise, returns
- * a lowercase ISO 639-2/T language code.
- * The ISO 639-2 language codes can be found on-line at
- * ftp://dkuug.dk/i18n/iso-639-2.txt
- * @exception MissingResourceException Throws MissingResourceException if the
- * three-letter language abbreviation is not available for this locale.
- * @stable ICU 3.0
- */
- public static String getISO3Language(String localeID){
- initLanguageTables();
-
- String language = getLanguage(localeID);
- int offset = findIndex(_languages, language);
- if(offset>=0){
- return _languages3[offset];
- } else {
- offset = findIndex(_obsoleteLanguages, language);
- if (offset >= 0) {
- return _obsoleteLanguages3[offset];
- }
- }
- return EMPTY_STRING;
- }
-
- /**
- * Returns a three-letter abbreviation for this locale's country/region. If the locale
- * doesn't specify a country, returns the empty string. Otherwise, returns
- * an uppercase ISO 3166 3-letter country code.
- * @exception MissingResourceException Throws MissingResourceException if the
- * three-letter country abbreviation is not available for this locale.
- * @stable ICU 3.0
- */
- public String getISO3Country(){
- return getISO3Country(localeID);
- }
- /**
- * Returns a three-letter abbreviation for this locale's country/region. If the locale
- * doesn't specify a country, returns the empty string. Otherwise, returns
- * an uppercase ISO 3166 3-letter country code.
- * @exception MissingResourceException Throws MissingResourceException if the
- * three-letter country abbreviation is not available for this locale.
- * @stable ICU 3.0
- */
- public static String getISO3Country(String localeID){
- initCountryTables();
-
- String country = getCountry(localeID);
- int offset = findIndex(_countries, country);
- if(offset>=0){
- return _countries3[offset];
- }else{
- offset = findIndex(_obsoleteCountries, country);
- if(offset>=0){
- return _obsoleteCountries3[offset];
- }
- }
- return EMPTY_STRING;
- }
-
- // display names
-
-// /**
-// * Utility to fetch locale display data from resource bundle tables.
-// */
-// private static String getTableString(String tableName, String subtableName, String item, String displayLocaleID) {
-// if (item.length() > 0) {
-// try {
-// ICUResourceBundle bundle = (ICUResourceBundle)UResourceBundle.
-// getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, displayLocaleID);
-// return getTableString(tableName, subtableName, item, bundle);
-// } catch (Exception e) {
-//// System.out.println("gtsu: " + e.getMessage());
-// }
-// }
-// return item;
-// }
-//
-// /**
-// * Utility to fetch locale display data from resource bundle tables.
-// */
-// private static String getTableString(String tableName, String subtableName, String item, ICUResourceBundle bundle) {
-//// System.out.println("gts table: " + tableName +
-//// " subtable: " + subtableName +
-//// " item: " + item +
-//// " bundle: " + bundle.getULocale());
-// try {
-// for (;;) {
-// // special case currency
-// if ("currency".equals(subtableName)) {
-// ICUResourceBundle table = bundle.getWithFallback("Currencies");
-// table = table.getWithFallback(item);
-// return table.getString(1);
-// } else {
-// ICUResourceBundle table = bundle.getWithFallback(tableName);
-// try {
-// if (subtableName != null) {
-// table = table.getWithFallback(subtableName);
-// }
-// return table.getStringWithFallback(item);
-// }
-// catch (MissingResourceException e) {
-//
-// if(subtableName==null){
-// try{
-// // may be a deprecated code
-// String currentName = null;
-// if(tableName.equals("Countries")){
-// currentName = getCurrentCountryID(item);
-// }else if(tableName.equals("Languages")){
-// currentName = getCurrentLanguageID(item);
-// }
-// return table.getStringWithFallback(currentName);
-// }catch (MissingResourceException ex){/* fall through*/}
-// }
-//
-// // still can't figure out ?.. try the fallback mechanism
-// String fallbackLocale = table.getWithFallback("Fallback").getString();
-// if (fallbackLocale.length() == 0) {
-// fallbackLocale = "root";
-// }
-//// System.out.println("bundle: " + bundle.getULocale() + " fallback: " + fallbackLocale);
-// if(fallbackLocale.equals(table.getULocale().localeID)){
-// return item;
-// }
-// bundle = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME,
-// fallbackLocale);
-//// System.out.println("fallback from " + table.getULocale() + " to " + fallbackLocale +
-//// ", got bundle " + bundle.getULocale());
-// }
-// }
-// }
-// }
-// catch (Exception e) {
-//// System.out.println("gtsi: " + e.getMessage());
-// }
-// return item;
-// }
-
- /**
- * Returns this locale's language localized for display in the default locale.
- * @return the localized language name.
- * @stable ICU 3.0
- */
- public String getDisplayLanguage() {
- return getDisplayLanguageInternal(localeID, getDefault().localeID);
- }
-
- /**
- * Returns this locale's language localized for display in the provided locale.
- * @param displayLocale the locale in which to display the name.
- * @return the localized language name.
- * @stable ICU 3.0
- */
- public String getDisplayLanguage(ULocale displayLocale) {
- return getDisplayLanguageInternal(localeID, displayLocale.localeID);
- }
-
- /**
- * Returns a locale's language localized for display in the provided locale.
- * This is a cover for the ICU4C API.
- * @param localeID the id of the locale whose language will be displayed
- * @param displayLocaleID the id of the locale in which to display the name.
- * @return the localized language name.
- * @stable ICU 3.0
- */
- public static String getDisplayLanguage(String localeID, String displayLocaleID) {
- return getDisplayLanguageInternal(localeID, getName(displayLocaleID));
- }
-
- /**
- * Returns a locale's language localized for display in the provided locale.
- * This is a cover for the ICU4C API.
- * @param localeID the id of the locale whose language will be displayed.
- * @param displayLocale the locale in which to display the name.
- * @return the localized language name.
- * @stable ICU 3.0
- */
- public static String getDisplayLanguage(String localeID, ULocale displayLocale) {
- return getDisplayLanguageInternal(localeID, displayLocale.localeID);
- }
-
- static String getCurrentCountryID(String oldID){
- initCountryTables();
- int offset = findIndex(_deprecatedCountries, oldID);
- if (offset >= 0) {
- return _replacementCountries[offset];
- }
- return oldID;
- }
- static String getCurrentLanguageID(String oldID){
- initLanguageTables();
- int offset = findIndex(_obsoleteLanguages, oldID);
- if (offset >= 0) {
- return _replacementLanguages[offset];
- }
- return oldID;
- }
-
-
- // displayLocaleID is canonical, localeID need not be since parsing will fix this.
- private static String getDisplayLanguageInternal(String localeID, String displayLocaleID) {
-// return getTableString("Languages", null, new IDParser(localeID).getLanguage(), displayLocaleID);
- return toLocale(localeID).getDisplayLanguage(toLocale(displayLocaleID));
- }
-
- /**
- * Returns this locale's script localized for display in the default locale.
- * @return the localized script name.
- * @stable ICU 3.0
- */
- public String getDisplayScript() {
- return getDisplayScriptInternal(localeID, getDefault().localeID);
- }
-
- /**
- * Returns this locale's script localized for display in the provided locale.
- * @param displayLocale the locale in which to display the name.
- * @return the localized script name.
- * @stable ICU 3.0
- */
- public String getDisplayScript(ULocale displayLocale) {
- return getDisplayScriptInternal(localeID, displayLocale.localeID);
- }
-
- /**
- * Returns a locale's script localized for display in the provided locale.
- * This is a cover for the ICU4C API.
- * @param localeID the id of the locale whose script will be displayed
- * @param displayLocaleID the id of the locale in which to display the name.
- * @return the localized script name.
- * @stable ICU 3.0
- */
- public static String getDisplayScript(String localeID, String displayLocaleID) {
- return getDisplayScriptInternal(localeID, getName(displayLocaleID));
- }
-
- /**
- * Returns a locale's script localized for display in the provided locale.
- * @param localeID the id of the locale whose script will be displayed.
- * @param displayLocale the locale in which to display the name.
- * @return the localized script name.
- * @stable ICU 3.0
- */
- public static String getDisplayScript(String localeID, ULocale displayLocale) {
- return getDisplayScriptInternal(localeID, displayLocale.localeID);
- }
-
- // displayLocaleID is canonical, localeID need not be since parsing will fix this.
- private static String getDisplayScriptInternal(String localeID, String displayLocaleID) {
-// return getTableString("Scripts", null, new IDParser(localeID).getScript(), displayLocaleID);
- return new IDParser(localeID).getScript();
- }
-
- /**
- * Returns this locale's country localized for display in the default locale.
- * @return the localized country name.
- * @stable ICU 3.0
- */
- public String getDisplayCountry() {
- return getDisplayCountryInternal(localeID, getDefault().localeID);
- }
-
- /**
- * Returns this locale's country localized for display in the provided locale.
- * @param displayLocale the locale in which to display the name.
- * @return the localized country name.
- * @stable ICU 3.0
- */
- public String getDisplayCountry(ULocale displayLocale){
- return getDisplayCountryInternal(localeID, displayLocale.localeID);
- }
-
- /**
- * Returns a locale's country localized for display in the provided locale.
- * This is a cover for the ICU4C API.
- * @param localeID the id of the locale whose country will be displayed
- * @param displayLocaleID the id of the locale in which to display the name.
- * @return the localized country name.
- * @stable ICU 3.0
- */
- public static String getDisplayCountry(String localeID, String displayLocaleID) {
- return getDisplayCountryInternal(localeID, getName(displayLocaleID));
- }
-
- /**
- * Returns a locale's country localized for display in the provided locale.
- * This is a cover for the ICU4C API.
- * @param localeID the id of the locale whose country will be displayed.
- * @param displayLocale the locale in which to display the name.
- * @return the localized country name.
- * @stable ICU 3.0
- */
- public static String getDisplayCountry(String localeID, ULocale displayLocale) {
- return getDisplayCountryInternal(localeID, displayLocale.localeID);
- }
-
- // displayLocaleID is canonical, localeID need not be since parsing will fix this.
- private static String getDisplayCountryInternal(String localeID, String displayLocaleID) {
-// return getTableString("Countries", null, new IDParser(localeID).getCountry(), displayLocaleID);
- return toLocale(localeID).getDisplayCountry(toLocale(displayLocaleID));
- }
-
- /**
- * Returns this locale's variant localized for display in the default locale.
- * @return the localized variant name.
- * @stable ICU 3.0
- */
- public String getDisplayVariant() {
- return getDisplayVariantInternal(localeID, getDefault().localeID);
- }
-
- /**
- * Returns this locale's variant localized for display in the provided locale.
- * @param displayLocale the locale in which to display the name.
- * @return the localized variant name.
- * @stable ICU 3.0
- */
- public String getDisplayVariant(ULocale displayLocale) {
- return getDisplayVariantInternal(localeID, displayLocale.localeID);
- }
-
- /**
- * Returns a locale's variant localized for display in the provided locale.
- * This is a cover for the ICU4C API.
- * @param localeID the id of the locale whose variant will be displayed
- * @param displayLocaleID the id of the locale in which to display the name.
- * @return the localized variant name.
- * @stable ICU 3.0
- */
- public static String getDisplayVariant(String localeID, String displayLocaleID){
- return getDisplayVariantInternal(localeID, getName(displayLocaleID));
- }
-
- /**
- * Returns a locale's variant localized for display in the provided locale.
- * This is a cover for the ICU4C API.
- * @param localeID the id of the locale whose variant will be displayed.
- * @param displayLocale the locale in which to display the name.
- * @return the localized variant name.
- * @stable ICU 3.0
- */
- public static String getDisplayVariant(String localeID, ULocale displayLocale) {
- return getDisplayVariantInternal(localeID, displayLocale.localeID);
- }
-
- // displayLocaleID is canonical, localeID need not be since parsing will fix this.
- private static String getDisplayVariantInternal(String localeID, String displayLocaleID) {
-// return getTableString("Variants", null, new IDParser(localeID).getVariant(), displayLocaleID);
- return toLocale(localeID).getDisplayVariant(toLocale(displayLocaleID));
- }
-
- /**
- * Returns a keyword localized for display in the default locale.
- * @param keyword the keyword to be displayed.
- * @return the localized keyword name.
- * @see #getKeywords()
- * @stable ICU 3.0
- */
- public static String getDisplayKeyword(String keyword) {
- return getDisplayKeywordInternal(keyword, getDefault().localeID);
- }
-
- /**
- * Returns a keyword localized for display in the specified locale.
- * @param keyword the keyword to be displayed.
- * @param displayLocaleID the id of the locale in which to display the keyword.
- * @return the localized keyword name.
- * @see #getKeywords(String)
- * @stable ICU 3.0
- */
- public static String getDisplayKeyword(String keyword, String displayLocaleID) {
- return getDisplayKeywordInternal(keyword, getName(displayLocaleID));
- }
-
- /**
- * Returns a keyword localized for display in the specified locale.
- * @param keyword the keyword to be displayed.
- * @param displayLocale the locale in which to display the keyword.
- * @return the localized keyword name.
- * @see #getKeywords(String)
- * @stable ICU 3.0
- */
- public static String getDisplayKeyword(String keyword, ULocale displayLocale) {
- return getDisplayKeywordInternal(keyword, displayLocale.localeID);
- }
-
- // displayLocaleID is canonical, localeID need not be since parsing will fix this.
- private static String getDisplayKeywordInternal(String keyword, String displayLocaleID) {
-// return getTableString("Keys", null, keyword.trim().toLowerCase(), displayLocaleID);
- return keyword.trim().toLowerCase();
- }
-
- /**
- * Returns a keyword value localized for display in the default locale.
- * @param keyword the keyword whose value is to be displayed.
- * @return the localized value name.
- * @stable ICU 3.0
- */
- public String getDisplayKeywordValue(String keyword) {
- return getDisplayKeywordValueInternal(localeID, keyword, getDefault().localeID);
- }
-
- /**
- * Returns a keyword value localized for display in the specified locale.
- * @param keyword the keyword whose value is to be displayed.
- * @param displayLocale the locale in which to display the value.
- * @return the localized value name.
- * @stable ICU 3.0
- */
- public String getDisplayKeywordValue(String keyword, ULocale displayLocale) {
- return getDisplayKeywordValueInternal(localeID, keyword, displayLocale.localeID);
- }
-
- /**
- * Returns a keyword value localized for display in the specified locale.
- * This is a cover for the ICU4C API.
- * @param localeID the id of the locale whose keyword value is to be displayed.
- * @param keyword the keyword whose value is to be displayed.
- * @param displayLocaleID the id of the locale in which to display the value.
- * @return the localized value name.
- * @stable ICU 3.0
- */
- public static String getDisplayKeywordValue(String localeID, String keyword, String displayLocaleID) {
- return getDisplayKeywordValueInternal(localeID, keyword, getName(displayLocaleID));
- }
-
- /**
- * Returns a keyword value localized for display in the specified locale.
- * This is a cover for the ICU4C API.
- * @param localeID the id of the locale whose keyword value is to be displayed.
- * @param keyword the keyword whose value is to be displayed.
- * @param displayLocale the id of the locale in which to display the value.
- * @return the localized value name.
- * @stable ICU 3.0
- */
- public static String getDisplayKeywordValue(String localeID, String keyword, ULocale displayLocale) {
- return getDisplayKeywordValueInternal(localeID, keyword, displayLocale.localeID);
- }
-
- // displayLocaleID is canonical, localeID need not be since parsing will fix this.
- private static String getDisplayKeywordValueInternal(String localeID, String keyword, String displayLocaleID) {
- keyword = keyword.trim().toLowerCase();
- String value = new IDParser(localeID).getKeywordValue(keyword);
-// return getTableString("Types", keyword, value, displayLocaleID);
- return value;
- }
-
- /**
- * Returns this locale name localized for display in the default locale.
- * @return the localized locale name.
- * @stable ICU 3.0
- */
- public String getDisplayName() {
- return getDisplayNameInternal(localeID, getDefault().localeID);
- }
-
- /**
- * Returns this locale name localized for display in the provided locale.
- * @param displayLocale the locale in which to display the locale name.
- * @return the localized locale name.
- * @stable ICU 3.0
- */
- public String getDisplayName(ULocale displayLocale) {
- return getDisplayNameInternal(localeID, displayLocale.localeID);
- }
-
- /**
- * Returns the locale ID localized for display in the provided locale.
- * This is a cover for the ICU4C API.
- * @param localeID the locale whose name is to be displayed.
- * @param displayLocaleID the id of the locale in which to display the locale name.
- * @return the localized locale name.
- * @stable ICU 3.0
- */
- public static String getDisplayName(String localeID, String displayLocaleID) {
- return getDisplayNameInternal(localeID, getName(displayLocaleID));
- }
-
- /**
- * Returns the locale ID localized for display in the provided locale.
- * This is a cover for the ICU4C API.
- * @param localeID the locale whose name is to be displayed.
- * @param displayLocale the locale in which to display the locale name.
- * @return the localized locale name.
- * @stable ICU 3.0
- */
- public static String getDisplayName(String localeID, ULocale displayLocale) {
- return getDisplayNameInternal(localeID, displayLocale.localeID);
- }
-
- // displayLocaleID is canonical, localeID need not be since parsing will fix this.
- private static String getDisplayNameInternal(String localeID, String displayLocaleID) {
- // lang
- // lang (script, country, variant, keyword=value, ...)
- // script, country, variant, keyword=value, ...
-
-// final String[] tableNames = { "Languages", "Scripts", "Countries", "Variants" };
-//
-// ICUResourceBundle bundle = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, displayLocaleID);
-
- StringBuffer buf = new StringBuffer();
-
- IDParser parser = new IDParser(localeID);
- String[] names = parser.getLanguageScriptCountryVariant();
-
- Locale locale = toLocale(localeID);
- Locale dispLocale = toLocale(displayLocaleID);
-
- boolean haveLanguage = names[0].length() > 0;
- boolean openParen = false;
- for (int i = 0; i < names.length; ++i) {
- String name = names[i];
- if (name.length() > 0) {
-// name = getTableString(tableNames[i], null, name, bundle);
-
- switch (i) {
- case 0: name = locale.getDisplayLanguage(dispLocale); break;
- case 1: break;
- case 2: name = locale.getDisplayCountry(dispLocale); break;
- case 3: name = locale.getDisplayVariant(dispLocale); break;
- }
-
- if (buf.length() > 0) { // need a separator
- if (haveLanguage & !openParen) {
- buf.append(" (");
- openParen = true;
- } else {
- buf.append(", ");
- }
- }
- buf.append(name);
- }
- }
-
- Map m = parser.getKeywordMap();
- if (!m.isEmpty()) {
- Iterator keys = m.entrySet().iterator();
- while (keys.hasNext()) {
- if (buf.length() > 0) {
- if (haveLanguage & !openParen) {
- buf.append(" (");
- openParen = true;
- } else {
- buf.append(", ");
- }
- }
- Map.Entry e = (Map.Entry)keys.next();
- String key = (String)e.getKey();
- String val = (String)e.getValue();
-// buf.append(getTableString("Keys", null, key, bundle));
-// buf.append("=");
-// buf.append(getTableString("Types", key, val, bundle));
- buf.append(key);
- buf.append("=");
- buf.append(val);
- }
- }
-
- if (openParen) {
- buf.append(")");
- }
-
- return buf.toString();
- }
-
-// /**
-// * Returns this locale's layout orientation for characters. The possible
-// * values are "left-to-right", "right-to-left", "top-to-bottom" or
-// * "bottom-to-top".
-// * @return The locale's layout orientation for characters.
-// * @draft ICU 4.0
-// * @provisional This API might change or be removed in a future release.
-// */
-// public String getCharacterOrientation() {
-// return getTableString("layout", null, "characters", getName());
-// }
-//
-// /**
-// * Returns this locale's layout orientation for lines. The possible
-// * values are "left-to-right", "right-to-left", "top-to-bottom" or
-// * "bottom-to-top".
-// * @return The locale's layout orientation for lines.
-// * @draft ICU 4.0
-// * @provisional This API might change or be removed in a future release.
-// */
-// public String getLineOrientation() {
-// return getTableString("layout", null, "lines", getName());
-// }
-
- /**
- * Selector for getLocale() indicating the locale of the
- * resource containing the data. This is always at or above the
- * valid locale. If the valid locale does not contain the
- * specific data being requested, then the actual locale will be
- * above the valid locale. If the object was not constructed from
- * locale data, then the valid locale is null.
- *
- * @draft ICU 2.8 (retain)
- * @provisional This API might change or be removed in a future release.
- */
- public static Type ACTUAL_LOCALE = new Type();
-
- /**
- * Selector for getLocale() indicating the most specific
- * locale for which any data exists. This is always at or above
- * the requested locale, and at or below the actual locale. If
- * the requested locale does not correspond to any resource data,
- * then the valid locale will be above the requested locale. If
- * the object was not constructed from locale data, then the
- * actual locale is null.
- *
- *