ICU-7389 icu tags, doc cleanup

X-SVN-Rev: 27430
This commit is contained in:
Doug Felt 2010-01-28 03:14:00 +00:00
parent 54910a7c91
commit 635a36de58
22 changed files with 3205 additions and 2861 deletions

View file

@ -21,6 +21,8 @@ import com.ibm.icu.util.UResourceBundle;
import com.ibm.icu.util.VersionInfo;
/**
* {@icuenhanced java.text.Collator}.{@icu _usage_}
*
* <p>Collator performs locale-sensitive string comparison. A concrete
* subclass, RuleBasedCollator, allows customization of the collation
* ordering by the use of rule sets.</p>
@ -157,7 +159,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
public final static int TERTIARY = 2;
/**
* Fourth level collator strength value.
* {@icu} Fourth level collator strength value.
* When punctuation is ignored
* <a href="http://www.icu-project.org/userguide/Collate_Concepts.html#Ignoring_Punctuation">
* (see Ignoring Punctuations in the user guide)</a> at PRIMARY to TERTIARY
@ -171,7 +173,6 @@ public abstract class Collator implements Comparator<Object>, Cloneable
public final static int QUATERNARY = 3;
/**
* <p>
* 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
@ -186,7 +187,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
public final static int IDENTICAL = 15;
/**
* This is for backwards compatibility with Java APIs only. It
* {@icunote} 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
@ -194,7 +195,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
public final static int FULL_DECOMPOSITION = IDENTICAL;
/**
* <p>Decomposition mode value. With NO_DECOMPOSITION set, Strings
* 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.</p>
@ -208,7 +209,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
public final static int NO_DECOMPOSITION = 16;
/**
* <p>Decomposition mode value. With CANONICAL_DECOMPOSITION set,
* Decomposition mode value. With CANONICAL_DECOMPOSITION set,
* characters that are canonical variants according to the Unicode standard
* will be decomposed for collation.</p>
*
@ -228,7 +229,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
// public setters --------------------------------------------------------
/**
* <p>Sets this Collator's strength property. The strength property
* Sets this Collator's strength property. The strength property
* determines the minimum level of difference considered significant
* during comparison.</p>
*
@ -243,7 +244,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
* @see #TERTIARY
* @see #QUATERNARY
* @see #IDENTICAL
* @exception IllegalArgumentException if the new strength value is not one
* @throws IllegalArgumentException if the new strength value is not one
* of PRIMARY, SECONDARY, TERTIARY, QUATERNARY or IDENTICAL.
* @stable ICU 2.8
*/
@ -270,7 +271,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
}
/**
* <p>Set the decomposition mode of this Collator. Setting this
* Sets 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
@ -295,7 +296,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
* @see #getDecomposition
* @see #NO_DECOMPOSITION
* @see #CANONICAL_DECOMPOSITION
* @exception IllegalArgumentException If the given value is not a valid
* @throws IllegalArgumentException If the given value is not a valid
* decomposition mode.
* @stable ICU 2.8
*/
@ -311,7 +312,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
// public getters --------------------------------------------------------
/**
* Gets the Collator for the current default locale.
* Returns 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
@ -327,7 +328,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
}
/**
* Clone the collator.
* Clones the collator.
* @stable ICU 2.6
* @return a clone of this collator.
*/
@ -477,7 +478,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
}
/**
* Gets the Collator for the desired locale.
* {@icu} Returns 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
@ -495,7 +496,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
}
/**
* Gets the Collator for the desired locale.
* Returns 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
@ -512,7 +513,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
}
/**
* Register a collator as the default collator for the provided locale. The
* {@icu} Registers a collator as the default collator for the provided locale. The
* collator should not be modified after it is registered.
*
* @param collator the collator to register
@ -526,7 +527,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
}
/**
* Register a collator factory.
* {@icu} Registers a collator factory.
*
* @param factory the factory to register
* @return an object that can be used to unregister the registered factory.
@ -538,7 +539,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
}
/**
* Unregister a collator previously registered using registerInstance.
* {@icu} Unregisters a collator previously registered using registerInstance.
* @param registryKey the object previously returned by registerInstance.
* @return true if the collator was successfully unregistered.
* @stable ICU 2.6
@ -551,7 +552,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
}
/**
* Get the set of locales, as Locale objects, for which collators
* Returns 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
@ -562,13 +563,14 @@ public abstract class Collator implements Comparator<Object>, Cloneable
// TODO make this wrap getAvailableULocales later
if (shim == null) {
ClassLoader cl = Collator.class.getClassLoader();
return ICUResourceBundle.getAvailableLocales(ICUResourceBundle.ICU_COLLATION_BASE_NAME, cl);
return ICUResourceBundle.getAvailableLocales(
ICUResourceBundle.ICU_COLLATION_BASE_NAME, cl);
}
return shim.getAvailableLocales();
}
/**
* Get the set of locales, as ULocale objects, for which collators
* {@icu} Returns 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
@ -578,7 +580,8 @@ public abstract class Collator implements Comparator<Object>, Cloneable
public static final ULocale[] getAvailableULocales() {
if (shim == null) {
ClassLoader cl = Collator.class.getClassLoader();
return ICUResourceBundle.getAvailableULocales(ICUResourceBundle.ICU_COLLATION_BASE_NAME, cl);
return ICUResourceBundle.getAvailableULocales(
ICUResourceBundle.ICU_COLLATION_BASE_NAME, cl);
}
return shim.getAvailableULocales();
}
@ -604,7 +607,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
private static final String BASE = ICUResourceBundle.ICU_COLLATION_BASE_NAME;
/**
* Return an array of all possible keywords that are relevant to
* {@icu} Returns 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.
@ -616,7 +619,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
}
/**
* Given a keyword, return an array of all values for
* {@icu} Given a keyword, returns an array of all values for
* that keyword that are currently in use.
* @param keyword one of the keywords returned by getKeywords.
* @see #getKeywords
@ -630,7 +633,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
}
/**
* Given a key and a locale, returns an array of string values in a preferred
* {@icu} Given a key and a locale, returns an array of string values in a preferred
* order that would make a difference. These are all and only those values where
* the open (creation) of the service with the locale formed from the input locale
* plus input keyword and that value has different behavior than creation with the
@ -644,7 +647,8 @@ public abstract class Collator implements Comparator<Object>, Cloneable
* @return an array of string values for the given key and the locale.
* @stable ICU 4.2
*/
public static final String[] getKeywordValuesForLocale(String key, ULocale locale, boolean commonlyUsed) {
public static final String[] getKeywordValuesForLocale(String key, ULocale locale,
boolean commonlyUsed) {
// Note: The parameter commonlyUsed is actually not used.
// The switch is in the method signature for consistency
// with other locale services.
@ -686,8 +690,9 @@ public abstract class Collator implements Comparator<Object>, Cloneable
}
return result;
}
/**
* Return the functionally equivalent locale for the given
* {@icu} Returns the functionally equivalent locale for the given
* requested locale, with respect to given keyword, for the
* collation service. If two locales return the same result, then
* collators instantiated for these locales will behave
@ -720,7 +725,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
}
/**
* Return the functionally equivalent locale for the given
* {@icu} Returns the functionally equivalent locale for the given
* requested locale, with respect to given keyword, for the
* collation service.
* @param keyword a particular keyword as enumerated by
@ -736,7 +741,8 @@ public abstract class Collator implements Comparator<Object>, Cloneable
}
/**
* Get the name of the collator for the objectLocale, localized for the displayLocale.
* {@icu} Returns the name of the collator for the objectLocale, localized for the
* displayLocale.
* @param objectLocale the locale of the collator
* @param displayLocale the locale for the collator's display name
* @return the display name
@ -748,7 +754,8 @@ public abstract class Collator implements Comparator<Object>, Cloneable
}
/**
* Get the name of the collator for the objectLocale, localized for the displayLocale.
* {@icu} Returns the name of the collator for the objectLocale, localized for the
* displayLocale.
* @param objectLocale the locale of the collator
* @param displayLocale the locale for the collator's display name
* @return the display name
@ -759,7 +766,8 @@ public abstract class Collator implements Comparator<Object>, Cloneable
}
/**
* Get the name of the collator for the objectLocale, localized for the current locale.
* {@icu} Returns the name of the collator for the objectLocale, localized for the
* current locale.
* @param objectLocale the locale of the collator
* @return the display name
* @stable ICU 2.6
@ -769,7 +777,8 @@ public abstract class Collator implements Comparator<Object>, Cloneable
}
/**
* Get the name of the collator for the objectLocale, localized for the current locale.
* {@icu} Returns the name of the collator for the objectLocale, localized for the
* current locale.
* @param objectLocale the locale of the collator
* @return the display name
* @stable ICU 3.2
@ -779,9 +788,11 @@ public abstract class Collator implements Comparator<Object>, Cloneable
}
/**
* <p>Returns this Collator's strength property. The strength property
* Returns this Collator's strength property. The strength property
* determines the minimum level of difference considered significant.
* </p>
* {@icunote} This can return QUATERNARY strength, which is not supported by the
* JDK version.
* <p>
* See the Collator class description for more details.
* </p>
@ -800,8 +811,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
}
/**
* <p>
* Get the decomposition mode of this Collator. Decomposition mode
* Returns the decomposition mode of this Collator. The decomposition mode
* determines how Unicode composed characters are handled.
* </p>
* <p>
@ -821,14 +831,14 @@ public abstract class Collator implements Comparator<Object>, Cloneable
// public other methods -------------------------------------------------
/**
* Convenience method for comparing the equality of two text Strings using
* this Collator's rules, strength and decomposition mode.
* Compares the equality of two text Strings using
* this Collator's rules, strength and decomposition mode. Convenience method.
* @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.
* @throws NullPointerException thrown if either arguments is null.
* @stable ICU 2.8
*/
public boolean equals(String source, String target)
@ -837,8 +847,8 @@ public abstract class Collator implements Comparator<Object>, Cloneable
}
/**
* Get an UnicodeSet that contains all the characters and sequences
* tailored in this collator.
* {@icu} Returns a UnicodeSet that contains all the characters and sequences tailored
* in this collator.
* @return a pointer to a UnicodeSet object containing all the
* code points and sequences that may sort differently than
* in the UCA.
@ -850,7 +860,6 @@ public abstract class Collator implements Comparator<Object>, Cloneable
}
/**
* <p>
* 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,
@ -865,21 +874,20 @@ public abstract class Collator implements Comparator<Object>, Cloneable
* value is greater than zero if source is greater than target.
* @see CollationKey
* @see #getCollationKey
* @exception NullPointerException thrown if either arguments is null.
* @throws NullPointerException thrown if either argument is null.
* @stable ICU 2.8
*/
public abstract int compare(String source, String target);
/**
* <p>
* Compares the source Object to te target Object.
* Compares the source Object to the target Object.
* </p>
* @param source the source Object.
* @param target the target Object.
* @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.
* @exception ClassCastException thrown if either arguments cannot be cast to String.
* @throws ClassCastException thrown if either arguments cannot be cast to String.
* @stable ICU 4.2
*/
public int compare(Object source, Object target) {
@ -905,12 +913,10 @@ public abstract class Collator implements Comparator<Object>, Cloneable
public abstract CollationKey getCollationKey(String source);
/**
* Gets the simpler form of a CollationKey for the String source following
* the rules of this Collator and stores the result into the user provided
* argument key.
* If key has a internal byte array of length that's too small for the
* result, the internal byte array will be grown to the exact required
* size.
* {@icu} Returns the simpler form of a CollationKey for the String source following
* the rules of this Collator and stores the result into the user provided argument
* key. If key has a internal byte array of length that's too small for the result,
* the internal byte array will be grown to the exact required size.
* @param source the text String to be transformed into a RawCollationKey
* @return If key is null, a new instance of RawCollationKey will be
* created and returned, otherwise the user provided key will be
@ -924,8 +930,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
RawCollationKey key);
/**
* <p>
* Variable top is a two byte primary value which causes all the codepoints
* {@icu} Variable top is a two byte primary value which causes all the codepoints
* with primary values that are less or equal than the variable top to be
* shifted when alternate handling is set to SHIFTED.
* </p>
@ -936,7 +941,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
* variable top should be set
* @return a int value containing the value of the variable top in upper 16
* bits. Lower 16 bits are undefined.
* @exception IllegalArgumentException is thrown if varTop argument is not
* @throws IllegalArgumentException is thrown if varTop argument is not
* a valid variable top element. A variable top element is
* invalid when it is a contraction that does not exist in the
* Collation order or when the PRIMARY strength collation
@ -948,7 +953,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
public abstract int setVariableTop(String varTop);
/**
* Gets the variable top value of a Collator.
* {@icu} Returns the variable top value of a Collator.
* Lower 16 bits are undefined and should be ignored.
* @return the variable top value of a Collator.
* @see #setVariableTop
@ -957,7 +962,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
public abstract int getVariableTop();
/**
* Sets the variable top to a collation element value supplied.
* {@icu} Sets the variable top to a collation element value supplied.
* Variable top is set to the upper 16 bits.
* Lower 16 bits are ignored.
* @param varTop Collation element value, as returned by setVariableTop or
@ -969,14 +974,14 @@ public abstract class Collator implements Comparator<Object>, Cloneable
public abstract void setVariableTop(int varTop);
/**
* Get the version of this collator object.
* {@icu} Returns the version of this collator object.
* @return the version object associated with this collator
* @stable ICU 2.8
*/
public abstract VersionInfo getVersion();
/**
* Get the UCA version of this collator object.
* {@icu} Returns the UCA version of this collator object.
* @return the version object associated with this collator
* @stable ICU 2.8
*/
@ -1015,7 +1020,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable
// -------- BEGIN ULocale boilerplate --------
/**
* Return the locale that was used to create this object, or null.
* {@icu} Returns the locale that was used to create this object, or null.
* This may may differ from the locale requested at the time of
* this object's creation. For example, if an object is created
* for locale <tt>en_US_CALIFORNIA</tt>, the actual data may be

File diff suppressed because it is too large Load diff

View file

@ -17,7 +17,9 @@ import com.ibm.icu.impl.ICUDebug;
import com.ibm.icu.util.ULocale;
/**
* A class that locates boundaries in text. This class defines a protocol for
* {@icuenhanced java.text.BreakIterator}.{@icu _usage_}
*
* <p>A class that locates boundaries in text. This class defines a protocol for
* objects that break up a piece of natural-language text according to a set
* of criteria. Instances or subclasses of BreakIterator can be provided, for
* example, to break a piece of text into words, sentences, or logical characters
@ -72,7 +74,7 @@ import com.ibm.icu.util.ULocale;
* it possible to use BreakIterator to analyze text in any text-storage vehicle that
* provides a CharacterIterator interface.
*
* <b>NOTE:</b> Some types of BreakIterator can take a long time to create, and
* <b>Note:</b> Some types of BreakIterator can take a long time to create, and
* instances of BreakIterator are not currently cached by the system. For
* optimal performance, keep instances of BreakIterator around as long as makes
* sense. For example, when word-wrapping a document, don't create and destroy a
@ -205,7 +207,7 @@ public abstract class BreakIterator implements Cloneable
{
private static final boolean DEBUG = ICUDebug.enabled("breakiterator");
/**
* Default constructor. There is no state that is carried by this abstract
* base class.
@ -411,15 +413,15 @@ public abstract class BreakIterator implements Cloneable
*/
public abstract void setText(CharacterIterator newText);
/** @stable ICU 2.4 */
/** {@icu} @stable ICU 2.4 */
public static final int KIND_CHARACTER = 0;
/** @stable ICU 2.4 */
/** {@icu} @stable ICU 2.4 */
public static final int KIND_WORD = 1;
/** @stable ICU 2.4 */
/** {@icu} @stable ICU 2.4 */
public static final int KIND_LINE = 2;
/** @stable ICU 2.4 */
/** {@icu} @stable ICU 2.4 */
public static final int KIND_SENTENCE = 3;
/** @stable ICU 2.4 */
/** {@icu} @stable ICU 2.4 */
public static final int KIND_TITLE = 4;
/** @since ICU 2.8 */
@ -452,7 +454,7 @@ public abstract class BreakIterator implements Cloneable
}
/**
* Returns a new instance of BreakIterator that locates word boundaries.
* {@icu} Returns a new instance of BreakIterator that locates word boundaries.
* @param where A locale specifying the language of the text to be
* analyzed.
* @return An instance of BreakIterator that locates word boundaries.
@ -490,7 +492,7 @@ public abstract class BreakIterator implements Cloneable
}
/**
* Returns a new instance of BreakIterator that locates legal line-
* {@icu} Returns a new instance of BreakIterator that locates legal line-
* wrapping positions.
* @param where A Locale specifying the language of the text being broken.
* @return A new instance of BreakIterator that locates legal
@ -529,7 +531,7 @@ public abstract class BreakIterator implements Cloneable
}
/**
* Returns a new instance of BreakIterator that locates logical-character
* {@icu} Returns a new instance of BreakIterator that locates logical-character
* boundaries.
* @param where A Locale specifying the language of the text being analyzed.
* @return A new instance of BreakIterator that locates logical-character
@ -565,7 +567,7 @@ public abstract class BreakIterator implements Cloneable
}
/**
* Returns a new instance of BreakIterator that locates sentence boundaries.
* {@icu} Returns a new instance of BreakIterator that locates sentence boundaries.
* @param where A Locale specifying the language of the text being analyzed.
* @return A new instance of BreakIterator that locates sentence boundaries.
* @stable ICU 3.2
@ -576,9 +578,9 @@ public abstract class BreakIterator implements Cloneable
}
/**
* Returns a new instance of BreakIterator that locates title boundaries.
* {@icu} Returns a new instance of BreakIterator that locates title boundaries.
* This function assumes the text being analyzed is in the default locale's
* language. The iterator returned locates title boundaries as described for
* language. The iterator returned locates title boundaries as described for
* Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration,
* please use a word boundary iterator. {@link #getWordInstance}
* @return A new instance of BreakIterator that locates title boundaries.
@ -590,8 +592,8 @@ public abstract class BreakIterator implements Cloneable
}
/**
* Returns a new instance of BreakIterator that locates title boundaries.
* The iterator returned locates title boundaries as described for
* {@icu} Returns a new instance of BreakIterator that locates title boundaries.
* The iterator returned locates title boundaries as described for
* Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration,
* please use Word Boundary iterator.{@link #getWordInstance}
* @param where A Locale specifying the language of the text being analyzed.
@ -604,8 +606,8 @@ public abstract class BreakIterator implements Cloneable
}
/**
* Returns a new instance of BreakIterator that locates title boundaries.
* The iterator returned locates title boundaries as described for
* {@icu} Returns a new instance of BreakIterator that locates title boundaries.
* The iterator returned locates title boundaries as described for
* Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration,
* please use Word Boundary iterator.{@link #getWordInstance}
* @param where A Locale specifying the language of the text being analyzed.
@ -618,10 +620,9 @@ s */
}
/**
* Register a new break iterator of the indicated kind, to use in the given locale.
* Clones of the iterator will be returned
* if a request for a break iterator of the given kind matches or falls back to
* this locale.
* {@icu} Registers a new break iterator of the indicated kind, to use in the given
* locale. Clones of the iterator will be returned if a request for a break iterator
* of the given kind matches or falls back to this locale.
* @param iter the BreakIterator instance to adopt.
* @param locale the Locale for which this instance is to be registered
* @param kind the type of iterator for which this instance is to be registered
@ -633,10 +634,9 @@ s */
}
/**
* Register a new break iterator of the indicated kind, to use in the given locale.
* Clones of the iterator will be returned
* if a request for a break iterator of the given kind matches or falls back to
* this locale.
* {@icu} Registers a new break iterator of the indicated kind, to use in the given
* locale. Clones of the iterator will be returned if a request for a break iterator
* of the given kind matches or falls back to this locale.
* @param iter the BreakIterator instance to adopt.
* @param locale the Locale for which this instance is to be registered
* @param kind the type of iterator for which this instance is to be registered
@ -658,8 +658,9 @@ s */
}
/**
* Unregister a previously-registered BreakIterator using the key returned from the
* register call. Key becomes invalid after this call and should not be used again.
* {@icu} Unregisters a previously-registered BreakIterator using the key returned
* from the register call. Key becomes invalid after this call and should not be used
* again.
* @param key the registry key returned by a previous call to registerInstance
* @return true if the iterator for the key was successfully unregistered
* @stable ICU 2.4
@ -694,8 +695,8 @@ s */
// end of registration
/**
* Get a particular kind of BreakIterator for a locale.
* Avoids writing a switch statement with getXYZInstance(where) calls.
* Returns a particular kind of BreakIterator for a locale.
* Avoids writing a switch statement with getXYZInstance(where) calls.
* @internal
* @deprecated This API is ICU internal only.
*/
@ -732,7 +733,7 @@ s */
}
/**
* Returns a list of locales for which BreakIterators can be used.
* {@icu} Returns a list of locales for which BreakIterators can be used.
* @return An array of Locales. All of the locales in the array can
* be used when creating a BreakIterator.
* @draft ICU 3.2 (retain)
@ -801,7 +802,7 @@ s */
// -------- BEGIN ULocale boilerplate --------
/**
* Return the locale that was used to create this object, or null.
* {@icu} Returns the locale that was used to create this object, or null.
* This may may differ from the locale requested at the time of
* this object's creation. For example, if an object is created
* for locale <tt>en_US_CALIFORNIA</tt>, the actual data may be
@ -809,10 +810,8 @@ s */
* <tt>en_US</tt> may be the most specific locale that exists (the
* <i>valid</i> locale).
*
* <p>Note: This method will be implemented in ICU 3.0; ICU 2.8
* contains a partial preview implementation. The * <i>actual</i>
* locale is returned correctly, but the <i>valid</i> locale is
* not, in most cases.
* <p>Note: The <i>actual</i> locale is returned correctly, but the <i>valid</i>
* locale is not, in most cases.
* @param type type of information requested, either {@link
* com.ibm.icu.util.ULocale#VALID_LOCALE} or {@link
* com.ibm.icu.util.ULocale#ACTUAL_LOCALE}.

File diff suppressed because it is too large Load diff

View file

@ -27,14 +27,15 @@ import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.UResourceBundle;
/**
* <code>DateFormatSymbols</code> is a public class for encapsulating
* {@icuenhanced java.text.DateFormatSymbols}.{@icu _usage_}
*
* <p><code>DateFormatSymbols</code> 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.
* <code>DateFormat</code> and <code>SimpleDateFormat</code> both use
* <code>DateFormatSymbols</code> to encapsulate this information.
*
* <p>
* Typically you shouldn't use <code>DateFormatSymbols</code> directly.
* <p>Typically you shouldn't use <code>DateFormatSymbols</code> directly.
* Rather, you are encouraged to create a date-time formatter with the
* <code>DateFormat</code> class's factory methods: <code>getTimeInstance</code>,
* <code>getDateInstance</code>, or <code>getDateTimeInstance</code>.
@ -45,8 +46,7 @@ import com.ibm.icu.util.UResourceBundle;
* creating formatters using <code>DateFormat</code>'s factory methods,
* see {@link DateFormat}.
*
* <p>
* If you decide to create a date-time formatter with a specific
* <p>If you decide to create a date-time formatter with a specific
* format pattern for a specific locale, you can do so with:
* <blockquote>
* <pre>
@ -54,18 +54,16 @@ import com.ibm.icu.util.UResourceBundle;
* </pre>
* </blockquote>
*
* <p>
* <code>DateFormatSymbols</code> objects are clonable. When you obtain
* <p><code>DateFormatSymbols</code> objects are clonable. When you obtain
* a <code>DateFormatSymbols</code> 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.
*
* <p>
* New <code>DateFormatSymbols</code> subclasses may be added to support
* <p>New <code>DateFormatSymbols</code> subclasses may be added to support
* <code>SimpleDateFormat</code> for date-time formatting for additional locales.
*
* @see DateFormat
* @see SimpleDateFormat
* @see com.ibm.icu.util.SimpleTimeZone
@ -81,19 +79,19 @@ public class DateFormatSymbols implements Serializable, Cloneable {
// Constants for context
/**
* Constant for context.
* {@icu} Constant for context.
* @stable ICU 3.6
*/
public static final int FORMAT = 0;
/**
* Constant for context.
* {@icu} Constant for context.
* @stable ICU 3.6
*/
public static final int STANDALONE = 1;
/**
* Constant for context.
* {@icu} Constant for context.
* @internal
* @deprecated This API is ICU internal only.
*/
@ -102,49 +100,49 @@ public class DateFormatSymbols implements Serializable, Cloneable {
// Constants for width
/**
* Constant for width.
* {@icu} Constant for width.
* @stable ICU 3.6
*/
public static final int ABBREVIATED = 0;
/**
* Constant for width.
* {@icu} Constant for width.
* @stable ICU 3.6
*/
public static final int WIDE = 1;
/**
* Constant for width.
* {@icu} Constant for width.
* @stable ICU 3.6
*/
public static final int NARROW = 2;
/**
* Constant for width.
* {@icu} Constant for width.
* @internal
* @deprecated This API is ICU internal only.
*/
public static final int DT_WIDTH_COUNT = 3;
/**
* Construct a DateFormatSymbols object by loading format data from
* Constructs 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.
* @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(ULocale.getDefault());
}
/**
* Construct a DateFormatSymbols object by loading format data from
* Constructs 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.
* @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)
@ -153,11 +151,11 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Construct a DateFormatSymbols object by loading format data from
* {@icu} Constructs 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.
* @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)
@ -166,13 +164,13 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Gets a DateFormatSymbols instance for the default locale.
* <br><br>
* <b>Note:</b> Unlike <code>java.text.DateFormatSymbols#getInstance</code>,
* Returns a DateFormatSymbols instance for the default locale.
*
* {@icunote} Unlike <code>java.text.DateFormatSymbols#getInstance</code>,
* this method simply returns <code>new com.ibm.icu.text.DateFormatSymbols()</code>.
* ICU does not support <code>DateFormatSymbolsProvider</code> introduced in Java 6
* or its equivalent implementation for now.
*
*
* @return A DateFormatSymbols instance.
* @stable ICU 3.8
*/
@ -181,13 +179,13 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Gets a DateFormatSymbols instance for the given locale.
* <br><br>
* <b>Note:</b> Unlike <code>java.text.DateFormatSymbols#getInstance</code>,
* Returns a DateFormatSymbols instance for the given locale.
*
* {@icunote} Unlike <code>java.text.DateFormatSymbols#getInstance</code>,
* this method simply returns <code>new com.ibm.icu.text.DateFormatSymbols(locale)</code>.
* ICU does not support <code>DateFormatSymbolsProvider</code> introduced in Java 6
* or its equivalent implementation for now.
*
*
* @param locale the locale.
* @return A DateFormatSymbols instance.
* @stable ICU 3.8
@ -197,13 +195,13 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Gets a DateFormatSymbols instance for the given locale.
* <br><br>
* <b>Note:</b> Unlike <code>java.text.DateFormatSymbols#getInstance</code>,
* {@icu} Returns a DateFormatSymbols instance for the given locale.
*
* {@icunote} Unlike <code>java.text.DateFormatSymbols#getInstance</code>,
* this method simply returns <code>new com.ibm.icu.text.DateFormatSymbols(locale)</code>.
* ICU does not support <code>DateFormatSymbolsProvider</code> introduced in Java 6
* or its equivalent implementation for now.
*
*
* @param locale the locale.
* @return A DateFormatSymbols instance.
* @stable ICU 3.8
@ -213,15 +211,16 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Returns an array of all locales for which the <code>getInstance</code> methods of this
* class can return localized instances.
* <br><br>
* <b>Note:</b> Unlike <code>java.text.DateFormatSymbols#getAvailableLocales</code>,
* this method simply returns the array of <code>Locale</code>s available in this class.
* ICU does not support <code>DateFormatSymbolsProvider</code> introduced in Java 6
* or its equivalent implementation for now.
*
* @return An array of <code>Locale</code>s for which localized <code>DateFormatSymbols</code> instances are available.
* Returns an array of all locales for which the <code>getInstance</code> methods of
* this class can return localized instances.
*
* {@icunote} Unlike <code>java.text.DateFormatSymbols#getAvailableLocales</code>,
* this method simply returns the array of <code>Locale</code>s available in this
* class. ICU does not support <code>DateFormatSymbolsProvider</code> introduced in
* Java 6 or its equivalent implementation for now.
*
* @return An array of <code>Locale</code>s for which localized
* <code>DateFormatSymbols</code> instances are available.
* @stable ICU 3.8
*/
public static Locale[] getAvailableLocales() {
@ -229,22 +228,23 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Returns an array of all locales for which the <code>getInstance</code> methods of this
* class can return localized instances.
* <br><br>
* <b>Note:</b> Unlike <code>java.text.DateFormatSymbols#getAvailableLocales</code>,
* this method simply returns the array of <code>ULocale</code>s available in this class.
* ICU does not support <code>DateFormatSymbolsProvider</code> introduced in Java 6
* or its equivalent implementation for now.
*
* @return An array of <code>ULocale</code>s for which localized <code>DateFormatSymbols</code> instances are available.
* {@icu} Returns an array of all locales for which the <code>getInstance</code>
* methods of this class can return localized instances.
*
* {@icunote} Unlike <code>java.text.DateFormatSymbols#getAvailableLocales</code>,
* this method simply returns the array of <code>ULocale</code>s available in this
* class. ICU does not support <code>DateFormatSymbolsProvider</code> introduced in
* Java 6 or its equivalent implementation for now.
*
* @return An array of <code>ULocale</code>s for which localized
* <code>DateFormatSymbols</code> instances are available.
* @draft ICU 3.8 (retain)
* @provisional This API might change or be removed in a future release.
*/
public static ULocale[] getAvailableULocales() {
return ICUResourceBundle.getAvailableULocales();
}
/**
* Era strings. For example: "AD" and "BC". An array of 2 strings,
* indexed by <code>Calendar.BC</code> and <code>Calendar.AD</code>.
@ -258,7 +258,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
* @serial
*/
String eraNames[] = null;
/**
* Narrow era names. For example: "A" and "B". An array of 2 strings,
* indexed by <code>Calendar.BC</code> and <code>Calendar.AD</code>.
@ -379,28 +379,28 @@ public class DateFormatSymbols implements Serializable, Cloneable {
* @serial
*/
String ampms[] = null;
/**
* Abbreviated quarter names. For example: "Q1", "Q2", "Q3", "Q4". An array
* of 4 strings indexed by the month divided by 3.
* @serial
*/
String shortQuarters[] = null;
/**
* Full quarter names. For example: "1st Quarter", "2nd Quarter", "3rd Quarter",
* "4th Quarter". An array of 4 strings, indexed by the month divided by 3.
* @serial
*/
String quarters[] = null;
/**
* Standalone abbreviated quarter names. For example: "Q1", "Q2", "Q3", "Q4". An array
* of 4 strings indexed by the month divided by 3.
* @serial
*/
String standaloneShortQuarters[] = null;
/**
* Standalone full quarter names. For example: "1st Quarter", "2nd Quarter", "3rd Quarter",
* "4th Quarter". An array of 4 strings, indexed by the month divided by 3.
@ -458,14 +458,14 @@ public class DateFormatSymbols implements Serializable, Cloneable {
* @see com.ibm.icu.util.TimeZone
* @serial
*/
private String zoneStrings[][] = null;
private String zoneStrings[][] = null;
/**
* Since ICU 3.8.1, we use ZoneStringFormat to access localized
* zone names. This field remains null unless setZoneStrings is
* called.
*/
private transient ZoneStringFormat zsformat = null;
private transient ZoneStringFormat zsformat = null;
/**
* Unlocalized date-time pattern characters. For example: 'y', 'd', etc.
@ -483,13 +483,13 @@ public class DateFormatSymbols implements Serializable, Cloneable {
* "Xz...", then localized patterns would use 'X' for era and 'z' for year.
* @serial
*/
String localPatternChars = null;
String localPatternChars = null;
/* use serialVersionUID from JDK 1.1.4 for interoperability */
private static final long serialVersionUID = -5987973545549424702L;
/**
* Gets era strings. For example: "AD" and "BC".
* Returns era strings. For example: "AD" and "BC".
* @return the era strings.
* @stable ICU 2.0
*/
@ -507,7 +507,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Gets era name strings. For example: "Anno Domini" and "Before Christ".
* {@icu} Returns era name strings. For example: "Anno Domini" and "Before Christ".
* @return the era strings.
* @stable ICU 3.4
*/
@ -516,7 +516,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Sets era name strings. For example: "Anno Domini" and "Before Christ".
* {@icu} Sets era name strings. For example: "Anno Domini" and "Before Christ".
* @param newEraNames the new era strings.
* @stable ICU 3.8
*/
@ -525,7 +525,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Gets month strings. For example: "January", "February", etc.
* Returns month strings. For example: "January", "February", etc.
* @return the month strings.
* @stable ICU 2.0
*/
@ -534,7 +534,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Gets month strings. For example: "January", "February", etc.
* Returns month strings. For example: "January", "February", etc.
* @param context The month context, FORMAT or STANDALONE.
* @param width The width or the returned month string,
* either WIDE, ABBREVIATED, or NARROW.
@ -621,9 +621,9 @@ public class DateFormatSymbols implements Serializable, Cloneable {
break;
}
}
/**
* Gets short month strings. For example: "Jan", "Feb", etc.
* Returns short month strings. For example: "Jan", "Feb", etc.
* @return the short month strings.
* @stable ICU 2.0
*/
@ -641,7 +641,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Gets weekday strings. For example: "Sunday", "Monday", etc.
* Returns weekday strings. For example: "Sunday", "Monday", etc.
* @return the weekday strings. Use <code>Calendar.SUNDAY</code>,
* <code>Calendar.MONDAY</code>, etc. to index the result array.
* @stable ICU 2.0
@ -651,7 +651,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Gets weekday strings. For example: "Sunday", "Monday", etc.
* Returns weekday strings. For example: "Sunday", "Monday", etc.
* @return the weekday strings. Use <code>Calendar.SUNDAY</code>,
* <code>Calendar.MONDAY</code>, etc. to index the result array.
* @param context Formatting context, either FORMAT or STANDALONE.
@ -743,7 +743,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Gets short weekday strings. For example: "Sun", "Mon", etc.
* Returns short weekday strings. For example: "Sun", "Mon", etc.
* @return the short weekday strings. Use <code>Calendar.SUNDAY</code>,
* <code>Calendar.MONDAY</code>, etc. to index the result array.
* @stable ICU 2.0
@ -763,7 +763,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
shortWeekdays = duplicate(newShortWeekdays);
}
/**
* Gets quarter strings. For example: "1st Quarter", "2nd Quarter", etc.
* {@icu} Returns quarter strings. For example: "1st Quarter", "2nd Quarter", etc.
* @param context The quarter context, FORMAT or STANDALONE.
* @param width The width or the returned quarter string,
* either WIDE or ABBREVIATED. There are no NARROW quarters.
@ -786,7 +786,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
break;
}
break;
case STANDALONE :
switch(width) {
case WIDE :
@ -795,7 +795,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
case ABBREVIATED :
returnValue = standaloneShortQuarters;
break;
case NARROW:
case NARROW:
returnValue = null;
break;
}
@ -805,7 +805,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Sets quarter strings. For example: "1st Quarter", "2nd Quarter", etc.
* {@icu} Sets quarter strings. For example: "1st Quarter", "2nd Quarter", etc.
* @param newQuarters the new quarter strings.
* @param context The formatting context, FORMAT or STANDALONE.
* @param width The width of the quarter string,
@ -844,7 +844,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Gets ampm strings. For example: "AM" and "PM".
* Returns am/pm strings. For example: "AM" and "PM".
* @return the weekday strings.
* @stable ICU 2.0
*/
@ -853,7 +853,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Sets ampm strings. For example: "AM" and "PM".
* Sets am/pm strings. For example: "AM" and "PM".
* @param newAmpms the new ampm strings.
* @stable ICU 2.0
*/
@ -862,7 +862,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Gets timezone strings.
* Returns timezone strings.
* @return the timezone strings.
* @stable ICU 2.0
*/
@ -884,9 +884,9 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Gets localized date-time pattern characters. For example: 'u', 't', etc.
* <p>
* Note: ICU no longer provides localized date-time pattern characters for a locale
* Returns localized date-time pattern characters. For example: 'u', 't', etc.
*
* <p>Note: ICU no longer provides localized date-time pattern characters for a locale
* starting ICU 3.8. This method returns the non-localized date-time pattern
* characters unless user defined localized data is set by setLocalPatternChars.
* @return the localized date-time pattern characters.
@ -907,7 +907,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Overrides Cloneable
* Overrides clone.
* @stable ICU 2.0
*/
public Object clone()
@ -933,7 +933,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Override equals
* Overrides equals.
* @stable ICU 2.0
*/
public boolean equals(Object obj)
@ -969,16 +969,17 @@ public class DateFormatSymbols implements Serializable, Cloneable {
// =======================privates===============================
/*
/**
* Useful constant for defining timezone offsets.
*/
static final int millisPerHour = 60*60*1000;
// DateFormatSymbols cache
private static ICUCache<String, DateFormatSymbols> DFSCACHE = new SimpleCache<String, DateFormatSymbols>();
private static ICUCache<String, DateFormatSymbols> DFSCACHE =
new SimpleCache<String, DateFormatSymbols>();
/**
* Initialize format symbols for the locale and calendar type
* Initializes format symbols for the locale and calendar type
* @param desiredLocale The locale whose symbols are desired.
* @param type The calendar type whose date format symbols are desired.
* @stable ICU 3.0
@ -1000,9 +1001,9 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
}
/*
* Initialize format symbols using another instance.
*
/**
* Initializes format symbols using another instance.
*
* TODO Clean up initialization methods for subclasses
*/
void initializeData(DateFormatSymbols dfs) {
@ -1039,7 +1040,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Initialize format symbols for the locale and calendar type
* Initializes format symbols for the locale and calendar type
* @param desiredLocale The locale whose symbols are desired.
* @param calData The calendar resource data
* @internal
@ -1059,7 +1060,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
catch (MissingResourceException e) {
eraNames = calData.getEras("abbreviated");
}
// NOTE: since the above code assumes that abbreviated
// era names exist, we make the same assumption here too.
try {
@ -1073,7 +1074,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
try {
narrowMonths = calData.getStringArray("monthNames", "narrow");
}
}
catch (MissingResourceException e) {
try {
narrowMonths = calData.getStringArray("monthNames", "stand-alone", "narrow");
@ -1085,27 +1086,29 @@ public class DateFormatSymbols implements Serializable, Cloneable {
try {
standaloneMonths = calData.getStringArray("monthNames", "stand-alone", "wide");
}
}
catch (MissingResourceException e) {
standaloneMonths = calData.getStringArray("monthNames", "format", "wide");
}
try {
standaloneShortMonths = calData.getStringArray("monthNames", "stand-alone", "abbreviated");
}
standaloneShortMonths =
calData.getStringArray("monthNames", "stand-alone", "abbreviated");
}
catch (MissingResourceException e) {
standaloneShortMonths = calData.getStringArray("monthNames", "format", "abbreviated");
}
try {
standaloneNarrowMonths = calData.getStringArray("monthNames", "stand-alone", "narrow");
}
}
catch (MissingResourceException e) {
try {
standaloneNarrowMonths = calData.getStringArray("monthNames", "format", "narrow");
}
catch (MissingResourceException e1) {
standaloneNarrowMonths = calData.getStringArray("monthNames", "format", "abbreviated");
standaloneNarrowMonths =
calData.getStringArray("monthNames", "format", "abbreviated");
}
}
@ -1174,20 +1177,20 @@ public class DateFormatSymbols implements Serializable, Cloneable {
System.arraycopy(snWeekdays, 0, standaloneNarrowWeekdays, 1, snWeekdays.length);
ampms = calData.getStringArray("AmPmMarkers");
quarters = calData.getStringArray("quarters", "wide");
shortQuarters = calData.getStringArray("quarters", "abbreviated");
try {
standaloneQuarters = calData.getStringArray("quarters", "stand-alone", "wide");
}
}
catch (MissingResourceException e) {
standaloneQuarters = calData.getStringArray("quarters", "format", "wide");
}
try {
standaloneShortQuarters = calData.getStringArray("quarters", "stand-alone", "abbreviated");
}
}
catch (MissingResourceException e) {
standaloneShortQuarters = calData.getStringArray("quarters", "format", "abbreviated");
}
@ -1197,7 +1200,9 @@ public class DateFormatSymbols implements Serializable, Cloneable {
requestedLocale = desiredLocale;
ICUResourceBundle rb = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, desiredLocale);
ICUResourceBundle rb =
(ICUResourceBundle)UResourceBundle.getBundleInstance(
ICUResourceBundle.ICU_BASE_NAME, desiredLocale);
// Because localized date/time pattern characters will be obsolete in CLDR,
// we decided not to maintain localized pattern characters in ICU any more.
@ -1217,8 +1222,8 @@ public class DateFormatSymbols implements Serializable, Cloneable {
{"+HH:mm:ss", "+HH:mm"}
};
/*
* Initialize localized GMT format patterns
/**
* Initializes localized GMT format patterns
*/
private void initializeGMTFormat(ULocale desiredLocale) {
// TimeZone format localization is not included in CalendarData
@ -1241,18 +1246,24 @@ public class DateFormatSymbols implements Serializable, Cloneable {
// CLDR 1.5 does not have GMT offset pattern including second field.
// For now, append "ss" to the end.
if (gmtHourFormats[OFFSET_POSITIVE][OFFSET_HM].indexOf(':') != -1) {
gmtHourFormats[OFFSET_POSITIVE][OFFSET_HMS] = gmtHourFormats[OFFSET_POSITIVE][OFFSET_HM] + ":ss";
gmtHourFormats[OFFSET_POSITIVE][OFFSET_HMS] =
gmtHourFormats[OFFSET_POSITIVE][OFFSET_HM] + ":ss";
} else if (gmtHourFormats[OFFSET_POSITIVE][OFFSET_HM].indexOf('.') != -1) {
gmtHourFormats[OFFSET_POSITIVE][OFFSET_HMS] = gmtHourFormats[OFFSET_POSITIVE][OFFSET_HM] + ".ss";
gmtHourFormats[OFFSET_POSITIVE][OFFSET_HMS] =
gmtHourFormats[OFFSET_POSITIVE][OFFSET_HM] + ".ss";
} else {
gmtHourFormats[OFFSET_POSITIVE][OFFSET_HMS] = gmtHourFormats[OFFSET_POSITIVE][OFFSET_HM] + "ss";
gmtHourFormats[OFFSET_POSITIVE][OFFSET_HMS] =
gmtHourFormats[OFFSET_POSITIVE][OFFSET_HM] + "ss";
}
if (gmtHourFormats[OFFSET_NEGATIVE][OFFSET_HM].indexOf(':') != -1) {
gmtHourFormats[OFFSET_NEGATIVE][OFFSET_HMS] = gmtHourFormats[OFFSET_NEGATIVE][OFFSET_HM] + ":ss";
gmtHourFormats[OFFSET_NEGATIVE][OFFSET_HMS] =
gmtHourFormats[OFFSET_NEGATIVE][OFFSET_HM] + ":ss";
} else if (gmtHourFormats[OFFSET_NEGATIVE][OFFSET_HM].indexOf('.') != -1) {
gmtHourFormats[OFFSET_NEGATIVE][OFFSET_HMS] = gmtHourFormats[OFFSET_NEGATIVE][OFFSET_HM] + ".ss";
gmtHourFormats[OFFSET_NEGATIVE][OFFSET_HMS] =
gmtHourFormats[OFFSET_NEGATIVE][OFFSET_HM] + ".ss";
} else {
gmtHourFormats[OFFSET_NEGATIVE][OFFSET_HMS] = gmtHourFormats[OFFSET_NEGATIVE][OFFSET_HM] + "ss";
gmtHourFormats[OFFSET_NEGATIVE][OFFSET_HMS] =
gmtHourFormats[OFFSET_NEGATIVE][OFFSET_HM] + "ss";
}
} catch (MissingResourceException e) {
gmtHourFormats = DEFAULT_GMT_HOUR_PATTERNS;
@ -1279,7 +1290,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
return equal;
}
/*
/**
* Package local method (for now) to get localized GMT format pattern.
*/
String getGmtFormat() {
@ -1321,8 +1332,8 @@ public class DateFormatSymbols implements Serializable, Cloneable {
/*
* save the input locale
*/
private ULocale requestedLocale;
private ULocale requestedLocale;
/*
* Clones an array of Strings.
* @param srcArray the source array to be cloned.
@ -1359,7 +1370,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/**
* Get the {@link DateFormatSymbols} object that should be used to format a
* Returns the {@link DateFormatSymbols} object that should be used to format a
* calendar system's dates in the given locale.
* <p>
* <b>Subclassing:</b><br>
@ -1423,7 +1434,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Get the {@link DateFormatSymbols} object that should be used to format a
* Returns the {@link DateFormatSymbols} object that should be used to format a
* calendar system's dates in the given locale.
* <p>
* <b>Subclassing:</b><br>
@ -1512,7 +1523,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Fetch a custom calendar's DateFormatSymbols out of the given resource
* Fetches a custom calendar's DateFormatSymbols out of the given resource
* bundle. Symbols that are not overridden are inherited from the
* default DateFormatSymbols for the locale.
* @see DateFormatSymbols#DateFormatSymbols(java.util.Locale)
@ -1523,19 +1534,19 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
/**
* Fetch a custom calendar's DateFormatSymbols out of the given resource
* Fetches a custom calendar's DateFormatSymbols out of the given resource
* bundle. Symbols that are not overridden are inherited from the
* default DateFormatSymbols for the locale.
* @see DateFormatSymbols#DateFormatSymbols(java.util.Locale)
* @stable ICU 3.2
*/
public DateFormatSymbols(ResourceBundle bundle, ULocale locale) {
initializeData(locale,
initializeData(locale,
new CalendarData((ICUResourceBundle)bundle, CalendarUtil.getCalendarType(locale)));
}
/**
* Find the ResourceBundle containing the date format information for
* Finds the ResourceBundle containing the date format information for
* a specified calendar subclass in a given locale.
* <p>
* The resource bundle name is based on the calendar's fully-specified
@ -1549,13 +1560,14 @@ public class DateFormatSymbols implements Serializable, Cloneable {
* @deprecated ICU 4.0
*/
// This API was formerly @stable ICU 2.0
static public ResourceBundle getDateFormatBundle(Class<? extends Calendar> calendarClass, Locale locale)
static public ResourceBundle getDateFormatBundle(Class<? extends Calendar> calendarClass,
Locale locale)
throws MissingResourceException {
return null;
}
/**
* Find the ResourceBundle containing the date format information for
* Finds the ResourceBundle containing the date format information for
* a specified calendar subclass in a given locale.
* <p>
* The resource bundle name is based on the calendar's fully-specified
@ -1569,7 +1581,8 @@ public class DateFormatSymbols implements Serializable, Cloneable {
* @deprecated ICU 4.0
*/
// This API was formerly @stable ICU 3.2
static public ResourceBundle getDateFormatBundle(Class<? extends Calendar> calendarClass, ULocale locale)
static public ResourceBundle getDateFormatBundle(Class<? extends Calendar> calendarClass,
ULocale locale)
throws MissingResourceException {
return null;
}
@ -1588,7 +1601,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
throws MissingResourceException {
return null;
}
/**
* Variant of getDateFormatBundle(java.lang.Class, java.util.Locale) that takes
* a Calendar instance instead of a Calendar class.
@ -1607,7 +1620,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
// -------- BEGIN ULocale boilerplate --------
/**
* Return the locale that was used to create this object, or null.
* Returns the locale that was used to create this object, or null.
* This may may differ from the locale requested at the time of
* this object's creation. For example, if an object is created
* for locale <tt>en_US_CALIFORNIA</tt>, the actual data may be
@ -1635,8 +1648,8 @@ public class DateFormatSymbols implements Serializable, Cloneable {
this.actualLocale : this.validLocale;
}
/*
* Set information about the locales that were used to create this
/**
* Sets information about the locales that were used to create this
* object. If the object was not constructed from locale data,
* both arguments should be set to null. Otherwise, neither
* should be null. The actual locale must be at the same level or
@ -1664,13 +1677,13 @@ public class DateFormatSymbols implements Serializable, Cloneable {
this.actualLocale = actual;
}
/*
/**
* The most specific locale containing any resource data, or null.
* @see com.ibm.icu.util.ULocale
*/
private ULocale validLocale;
/*
/**
* The locale containing data used to construct this object, or
* null.
* @see com.ibm.icu.util.ULocale
@ -1679,7 +1692,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
// -------- END ULocale boilerplate --------
/*
/**
* 3.8 or older version did not have localized GMT format
* patterns.
*/

View file

@ -31,10 +31,9 @@ import com.ibm.icu.util.Currency;
import com.ibm.icu.util.CurrencyAmount;
import com.ibm.icu.util.ULocale;
// This is an enhanced version of DecimalFormat that is based on the
// standard version in the JDK.
/**
* {@icuenhanced java.text.DecimalFormat}.{@icu _usage_}
*
* <code>DecimalFormat</code> is a concrete subclass of {@link NumberFormat} that formats
* decimal numbers. It has a variety of features designed to make it possible to parse and
* format numbers in any locale, including support for Western, Arabic, or Indic digits.
@ -43,7 +42,6 @@ import com.ibm.icu.util.ULocale;
* amounts ("$123.00", "USD123.00", "123.00 US dollars"). All of these flavors can be
* easily localized.
*
*
* <p>To obtain a {@link NumberFormat} for a specific locale (including the default
* locale) call one of <code>NumberFormat</code>'s factory methods such as {@link
* NumberFormat#getInstance}. Do not call the <code>DecimalFormat</code> constructors
@ -697,7 +695,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Create a DecimalFormat from the given pattern, symbols, information used for
* Creates a DecimalFormat from the given pattern, symbols, information used for
* currency plural format, and format style. Use this constructor when you need to
* completely customize the behavior of the format.
*
@ -1016,7 +1014,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Format a BigInteger number.
* Formats a BigInteger number.
*
* @stable ICU 2.0
*/
@ -1047,7 +1045,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Format a BigDecimal number.
* Formats a BigDecimal number.
*
* @stable ICU 2.0
*/
@ -1076,7 +1074,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Format a BigDecimal number.
* Formats a BigDecimal number.
*
* @stable ICU 2.0
*/
@ -2823,7 +2821,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Gets the positive prefix.
* Returns the positive prefix.
*
* <p>Examples: +123, $123, sFr123
* @return the prefix
@ -2846,7 +2844,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Gets the negative prefix.
* Returns the negative prefix.
*
* <p>Examples: -123, ($123) (with negative suffix), sFr-123
*
@ -2870,7 +2868,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Gets the positive suffix.
* Returns the positive suffix.
*
* <p>Example: 123%
*
@ -2894,7 +2892,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Gets the negative suffix.
* Returns the negative suffix.
*
* <p>Examples: -123%, ($123) (with positive suffixes)
*
@ -2918,7 +2916,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Gets the multiplier for use in percent, permill, etc. For a percentage, set the
* Returns 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.
@ -2951,7 +2949,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Gets the rounding increment.
* {@icu} Returns the rounding increment.
*
* @return A positive rounding increment, or <code>null</code> if rounding is not in
* effect.
@ -2967,7 +2965,8 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Set the rounding increment. This method also controls whether rounding is enabled.
* {@icu} Sets the rounding increment. This method also controls whether rounding is
* enabled.
*
* @param newValue A positive rounding increment, or <code>null</code> or
* <code>BigDecimal(0.0)</code> to disable rounding.
@ -2986,7 +2985,8 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Sets the rounding increment. This method also controls whether rounding is enabled.
* {@icu} Sets the rounding increment. This method also controls whether rounding is
* enabled.
*
* @param newValue A positive rounding increment, or <code>null</code> or
* <code>BigDecimal(0.0)</code> to disable rounding.
@ -3010,7 +3010,8 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Sets the rounding increment. This method also controls whether rounding is enabled.
* {@icu} Sets the rounding increment. This method also controls whether rounding is
* enabled.
*
* @param newValue A positive rounding increment, or 0.0 to disable rounding.
* @throws IllegalArgumentException if <code>newValue</code> is < 0.0
@ -3047,7 +3048,7 @@ public class DecimalFormat extends NumberFormat {
static final double roundingIncrementEpsilon = 0.000000001;
/**
* Gets the rounding mode.
* Returns the rounding mode.
*
* @return A rounding mode, between <code>BigDecimal.ROUND_UP</code> and
* <code>BigDecimal.ROUND_UNNECESSARY</code>.
@ -3087,7 +3088,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Gets the width to which the output of <code>format()</code> is padded. The width is
* Returns the width to which the output of <code>format()</code> is padded. The width is
* counted in 16-bit code units.
*
* @return the format width, or zero if no padding is in effect
@ -3103,7 +3104,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Set the width to which the output of <code>format()</code> is
* Sets the width to which the output of <code>format()</code> is
* padded. The width is counted in 16-bit code units. This method
* also controls whether padding is enabled.
*
@ -3125,7 +3126,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Gets the character used to pad to the format width. The default is ' '.
* {@icu} Returns the character used to pad to the format width. The default is ' '.
*
* @return the pad character
* @see #setFormatWidth
@ -3140,8 +3141,8 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Sets the character used to pad to the format width. If padding is not enabled, then
* this will take effect if padding is later enabled.
* {@icu} Sets the character used to pad to the format width. If padding is not
* enabled, then this will take effect if padding is later enabled.
*
* @param padChar the pad character
* @see #setFormatWidth
@ -3156,9 +3157,9 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Gets the position at which padding will take place. This is the location at which
* padding will be inserted if the result of <code>format()</code> is shorter than the
* format width.
* {@icu} Returns the position at which padding will take place. This is the location at
* which padding will be inserted if the result of <code>format()</code> is shorter
* than the format width.
*
* @return the pad position, one of <code>PAD_BEFORE_PREFIX</code>,
* <code>PAD_AFTER_PREFIX</code>, <code>PAD_BEFORE_SUFFIX</code>, or
@ -3179,9 +3180,9 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Sets the position at which padding will take place. This is the location at which
* padding will be inserted if the result of <code>format()</code> is shorter than the
* format width. This has no effect unless padding is enabled.
* {@icu} Sets the position at which padding will take place. This is the location at
* which padding will be inserted if the result of <code>format()</code> is shorter
* than the format width. This has no effect unless padding is enabled.
*
* @param padPos the pad position, one of <code>PAD_BEFORE_PREFIX</code>,
* <code>PAD_AFTER_PREFIX</code>, <code>PAD_BEFORE_SUFFIX</code>, or
@ -3206,7 +3207,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Returns whether or not scientific notation is used.
* {@icu} Returns whether or not scientific notation is used.
*
* @return true if this object formats and parses scientific notation
* @see #setScientificNotation
@ -3221,11 +3222,11 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Sets whether or not scientific notation is used. When scientific notation is used,
* the effective maximum number of integer digits is <= 8. If the maximum number of
* integer digits is set to more than 8, the effective maximum will be 1. This allows
* this call to generate a 'default' scientific number format without additional
* changes.
* {@icu} Sets whether or not scientific notation is used. When scientific notation is
* used, the effective maximum number of integer digits is <= 8. If the maximum number
* of integer digits is set to more than 8, the effective maximum will be 1. This
* allows this call to generate a 'default' scientific number format without
* additional changes.
*
* @param useScientific true if this object formats and parses scientific notation
* @see #isScientificNotation
@ -3240,7 +3241,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Returns the minimum exponent digits that will be shown.
* {@icu} Returns the minimum exponent digits that will be shown.
*
* @return the minimum exponent digits that will be shown
* @see #setScientificNotation
@ -3255,8 +3256,8 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Sets the minimum exponent digits that will be shown. This has no effect unless
* scientific notation is in use.
* {@icu} Sets the minimum exponent digits that will be shown. This has no effect
* unless scientific notation is in use.
*
* @param minExpDig a value >= 1 indicating the fewest exponent
* digits that will be shown
@ -3276,7 +3277,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Returns whether the exponent sign is always shown.
* {@icu} Returns whether the exponent sign is always shown.
*
* @return true if the exponent is always prefixed with either the localized minus
* sign or the localized plus sign, false if only negative exponents are prefixed with
@ -3293,7 +3294,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Sets whether the exponent sign is always shown. This has no effect unless
* {@icu} Sets whether the exponent sign is always shown. This has no effect unless
* scientific notation is in use.
*
* @param expSignAlways true if the exponent is always prefixed with either the
@ -3339,13 +3340,13 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Returns the secondary grouping size. In some locales one grouping interval is used
* for the least significant integer digits (the primary grouping size), and another
* is used for all others (the secondary grouping size). A formatter supporting a
* secondary grouping size will return a positive integer unequal to the primary
* grouping size returned by <code>getGroupingSize()</code>. For example, if the
* primary grouping size is 4, and the secondary grouping size is 2, then the number
* 123456789 formats as "1,23,45,6789", and the pattern appears as "#,##,###0".
* {@icu} Returns the secondary grouping size. In some locales one grouping interval
* is used for the least significant integer digits (the primary grouping size), and
* another is used for all others (the secondary grouping size). A formatter
* supporting a secondary grouping size will return a positive integer unequal to the
* primary grouping size returned by <code>getGroupingSize()</code>. For example, if
* the primary grouping size is 4, and the secondary grouping size is 2, then the
* number 123456789 formats as "1,23,45,6789", and the pattern appears as "#,##,###0".
*
* @return the secondary grouping size, or a value less than one if there is none
* @see #setSecondaryGroupingSize
@ -3358,9 +3359,9 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Sets the secondary grouping size. If set to a value less than 1, then secondary
* grouping is turned off, and the primary grouping size is used for all intervals,
* not just the least significant.
* {@icu} Sets the secondary grouping size. If set to a value less than 1, then
* secondary grouping is turned off, and the primary grouping size is used for all
* intervals, not just the least significant.
*
* @see #getSecondaryGroupingSize
* @see NumberFormat#setGroupingUsed
@ -3372,7 +3373,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Returns the MathContext used by this format.
* {@icu} Returns the MathContext used by this format.
*
* @return desired MathContext
* @see #getMathContext
@ -3383,7 +3384,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Returns the MathContext used by this format.
* {@icu} Returns the MathContext used by this format.
*
* @return desired MathContext
* @see #getMathContext
@ -3400,7 +3401,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Sets the MathContext used by this format.
* {@icu} Sets the MathContext used by this format.
*
* @param newValue desired MathContext
* @see #getMathContext
@ -3411,7 +3412,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Sets the MathContext used by this format.
* {@icu} Sets the MathContext used by this format.
*
* @param newValue desired MathContext
* @see #getMathContext
@ -3423,7 +3424,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Gets the behavior of the decimal separator with integers. (The decimal
* Returns the behavior of the decimal separator with integers. (The decimal
* separator will always appear with decimals.) <p> Example: Decimal ON: 12345 ->
* 12345.; OFF: 12345 -> 12345
*
@ -3452,10 +3453,11 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Returns a copy of the CurrencyPluralInfo used by this format. It might return null
* if the decimal format is not a plural type currency decimal format. Plural type
* currency decimal format means either the pattern in the decimal format contains 3
* currency signs, or the decimal format is initialized with PLURALCURRENCYSTYLE.
* {@icu} Returns a copy of the CurrencyPluralInfo used by this format. It might
* return null if the decimal format is not a plural type currency decimal
* format. Plural type currency decimal format means either the pattern in the decimal
* format contains 3 currency signs, or the decimal format is initialized with
* PLURALCURRENCYSTYLE.
*
* @return desired CurrencyPluralInfo
* @see CurrencyPluralInfo
@ -3472,8 +3474,8 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Sets the CurrencyPluralInfo used by this format. The format uses a copy of the
* provided information.
* {@icu} Sets the CurrencyPluralInfo used by this format. The format uses a copy of
* the provided information.
*
* @param newInfo desired CurrencyPluralInfo
* @see CurrencyPluralInfo
@ -3485,8 +3487,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Standard override; no change in semantics.
*
* Overrides clone.
* @stable ICU 2.0
*/
public Object clone() {
@ -3508,8 +3509,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Overrides equals
*
* Overrides equals.
* @stable ICU 2.0
*/
public boolean equals(Object obj) {
@ -3589,8 +3589,7 @@ public class DecimalFormat extends NumberFormat {
// }
/**
* Overrides hashCode
*
* Overrides hashCode.
* @stable ICU 2.0
*/
public int hashCode() {
@ -3881,8 +3880,7 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Formats the object to an attributed string, and return the corresponding iterator
* Overrides superclass method.
* Formats the object to an attributed string, and return the corresponding iterator.
*
* @stable ICU 3.6
*/
@ -4730,8 +4728,9 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Returns the minimum number of significant digits that will be displayed. This value
* has no effect unless areSignificantDigitsUsed() returns true.
* {@icu} Returns the minimum number of significant digits that will be
* displayed. This value has no effect unless {@link #areSignificantDigitsUsed()}
* returns true.
*
* @return the fewest significant digits that will be shown
* @stable ICU 3.0
@ -4741,8 +4740,9 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Returns the maximum number of significant digits that will be displayed. This value
* has no effect unless areSignificantDigitsUsed() returns true.
* {@icu} Returns the maximum number of significant digits that will be
* displayed. This value has no effect unless {@link #areSignificantDigitsUsed()}
* returns true.
*
* @return the most significant digits that will be shown
* @stable ICU 3.0
@ -4752,10 +4752,10 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Sets the minimum number of significant digits that will be displayed. If
* {@icu} Sets the minimum number of significant digits that will be displayed. If
* <code>min</code> is less than one then it is set to one. If the maximum significant
* digits count is less than <code>min</code>, then it is set to
* <code>min</code>. This value has no effect unless areSignificantDigitsUsed()
* <code>min</code>. This value has no effect unless {@link #areSignificantDigitsUsed()}
* returns true.
*
* @param min the fewest significant digits to be shown
@ -4772,10 +4772,10 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Sets the maximum number of significant digits that will be displayed. If
* {@icu} Sets the maximum number of significant digits that will be displayed. If
* <code>max</code> is less than one then it is set to one. If the minimum significant
* digits count is greater than <code>max</code>, then it is set to
* <code>max</code>. This value has no effect unless areSignificantDigitsUsed()
* <code>max</code>. This value has no effect unless {@link #areSignificantDigitsUsed()}
* returns true.
*
* @param max the most significant digits to be shown
@ -4792,8 +4792,8 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Returns true if significant digits are in use or false if integer and fraction
* digit counts are in use.
* {@icu} Returns true if significant digits are in use or false if integer and
* fraction digit counts are in use.
*
* @return true if significant digits are in use
* @stable ICU 3.0
@ -4803,8 +4803,8 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Sets whether significant digits are in use, or integer and fraction digit counts
* are in use.
* {@icu} Sets whether significant digits are in use, or integer and fraction digit
* counts are in use.
*
* @param useSignificantDigits true to use significant digits, or false to use integer
* and fraction digit counts
@ -4887,11 +4887,11 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Sets whether {@link #parse(String, ParsePosition)} method returns BigDecimal. The
* Sets whether {@link #parse(String, ParsePosition)} returns BigDecimal. The
* default value is false.
*
* @param value true if {@link #parse(String, ParsePosition)}
* method returns BigDecimal.
* returns BigDecimal.
* @stable ICU 3.6
*/
public void setParseBigDecimal(boolean value) {
@ -4899,9 +4899,9 @@ public class DecimalFormat extends NumberFormat {
}
/**
* Returns whether {@link #parse(String, ParsePosition)} method returns BigDecimal.
* Returns whether {@link #parse(String, ParsePosition)} returns BigDecimal.
*
* @return true if {@link #parse(String, ParsePosition)} method returns BigDecimal.
* @return true if {@link #parse(String, ParsePosition)} returns BigDecimal.
* @stable ICU 3.6
*/
public boolean isParseBigDecimal() {
@ -5319,8 +5319,8 @@ public class DecimalFormat extends NumberFormat {
// ----------------------------------------------------------------------
/**
* Constant for <code>getPadPosition()</code> and <code>setPadPosition()</code>
* specifying pad characters inserted before the prefix.
* {@icu} Constant for {@link #getPadPosition()} and {@link #setPadPosition(int)} to
* specify pad characters inserted before the prefix.
*
* @see #setPadPosition
* @see #getPadPosition
@ -5332,8 +5332,8 @@ public class DecimalFormat extends NumberFormat {
public static final int PAD_BEFORE_PREFIX = 0;
/**
* Constant for <code>getPadPosition()</code> and <code>setPadPosition()</code>
* specifying pad characters inserted after the prefix.
* {@icu} Constant for {@link #getPadPosition()} and {@link #setPadPosition(int)} to
* specify pad characters inserted after the prefix.
*
* @see #setPadPosition
* @see #getPadPosition
@ -5345,8 +5345,8 @@ public class DecimalFormat extends NumberFormat {
public static final int PAD_AFTER_PREFIX = 1;
/**
* Constant for <code>getPadPosition()</code> and <code>setPadPosition()</code>
* specifying pad characters inserted before the suffix.
* {@icu} Constant for {@link #getPadPosition()} and {@link #setPadPosition(int)} to
* specify pad characters inserted before the suffix.
*
* @see #setPadPosition
* @see #getPadPosition
@ -5358,8 +5358,8 @@ public class DecimalFormat extends NumberFormat {
public static final int PAD_BEFORE_SUFFIX = 2;
/**
* Constant for <code>getPadPosition()</code> and <code>setPadPosition()</code>
* specifying pad characters inserted after the suffix.
* {@icu} Constant for {@link #getPadPosition()} and {@link #setPadPosition(int)} to
* specify pad characters inserted after the suffix.
*
* @see #setPadPosition
* @see #getPadPosition

View file

@ -23,6 +23,8 @@ import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.UResourceBundle;
/**
* {@icuenhanced java.text.DecimalFormatSymbols}.{@icu _usage_}
*
* This class represents the set of symbols (such as the decimal separator, the grouping
* separator, and so on) needed by <code>DecimalFormat</code> to format
* numbers. <code>DecimalFormat</code> creates for itself an instance of
@ -30,11 +32,6 @@ import com.ibm.icu.util.UResourceBundle;
* these symbols, you can get the <code>DecimalFormatSymbols</code> object from your
* <code>DecimalFormat</code> and modify it.
*
* <p><strong>Note:</strong> This is an enhanced version of
* <code>DecimalFormatSymbols</code> that is based on the standard version in the JDK.
* New or changed functionality is labeled <strong><font face=helvetica
* color=red>NEW</font></strong>.
*
* @see java.util.Locale
* @see DecimalFormat
* @author Mark Davis
@ -51,7 +48,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
}
/**
* Create a DecimalFormatSymbols object for the given locale.
* Creates a DecimalFormatSymbols object for the given locale.
* @param locale the locale
* @stable ICU 2.0
*/
@ -60,7 +57,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
}
/**
* Create a DecimalFormatSymbols object for the given locale.
* {@icu} Creates a DecimalFormatSymbols object for the given locale.
* @param locale the locale
* @stable ICU 3.2
*/
@ -136,8 +133,8 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
}
/**
* Returns an array of all locales for which the <code>getInstance</code> methods of
* this class can return localized instances.
* {@icu} Returns an array of all locales for which the <code>getInstance</code>
* methods of this class can return localized instances.
*
* <p><strong>Note:</strong> Unlike
* <code>java.text.DecimalFormatSymbols#getAvailableLocales</code>, this method simply
@ -219,7 +216,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
}
/**
* Set the character used for decimal sign. Different for French, etc.
* Sets the character used for decimal sign. Different for French, etc.
* @param decimalSeparator the decimal character
* @stable ICU 2.0
*/
@ -264,7 +261,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
}
/**
* Return the character used for a digit in a pattern.
* Returns the character used for a digit in a pattern.
* @return the digit pattern character
* @stable ICU 2.0
*/
@ -273,7 +270,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
}
/**
* Set the character used for a digit in a pattern.
* Sets the character used for a digit in a pattern.
* @param digit the digit pattern character
* @stable ICU 2.0
*/
@ -448,7 +445,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
}
/**
* Returns the monetary grouping separator.
* {@icu} Returns the monetary grouping separator.
* @return the monetary grouping separator character
* @stable ICU 3.6
*/
@ -483,8 +480,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
}
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* Returns the string used to separate the mantissa from the exponent.
* {@icu} Returns the string used to separate the mantissa from the exponent.
* Examples: "x10^" for 1.23x10^4, "E" for 1.23E4.
* @return the localized exponent symbol, used in localized patterns
* and formatted strings
@ -496,8 +492,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
}
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* Sets the string used to separate the mantissa from the exponent.
* {@icu} Sets the string used to separate the mantissa from the exponent.
* Examples: "x10^" for 1.23x10^4, "E" for 1.23E4.
* @param exp the localized exponent symbol, used in localized patterns
* and formatted strings
@ -509,8 +504,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
}
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* Returns the localized plus sign.
* {@icu} Returns the localized plus sign.
* @return the plus sign, used in localized patterns and formatted
* strings
* @see #setPlusSign
@ -523,8 +517,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
}
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* Sets the localized plus sign.
* {@icu} Sets the localized plus sign.
* @param plus the plus sign, used in localized patterns and formatted
* strings
* @see #getPlusSign
@ -537,11 +530,10 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
}
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* Returns the character used to pad numbers out to a specified width. This
* is not the pad character itself; rather, it is the special pattern
* character <em>preceding</em> the pad character. In the pattern
* "*_#,##0", '*' is the pad escape, and '_' is the pad character.
* {@icu} Returns the character used to pad numbers out to a specified width. This is
* not the pad character itself; rather, it is the special pattern character
* <em>preceding</em> the pad character. In the pattern "*_#,##0", '*' is the pad
* escape, and '_' is the pad character.
* @return the character
* @see #setPadEscape
* @see DecimalFormat#getFormatWidth
@ -554,11 +546,10 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
}
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* Sets the character used to pad numbers out to a specified width. This is
* not the pad character itself; rather, it is the special pattern character
* <em>preceding</em> the pad character. In the pattern "*_#,##0", '*' is
* the pad escape, and '_' is the pad character.
* {@icu} Sets the character used to pad numbers out to a specified width. This is not
* the pad character itself; rather, it is the special pattern character
* <em>preceding</em> the pad character. In the pattern "*_#,##0", '*' is the pad
* escape, and '_' is the pad character.
* @see #getPadEscape
* @see DecimalFormat#setFormatWidth
* @see DecimalFormat#setPadPosition
@ -570,20 +561,20 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
}
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* Indicates the currency match pattern used in {@link #getPatternForCurrencySpacing}.
* {@icu} Indicates the currency match pattern used in {@link #getPatternForCurrencySpacing}.
* @draft ICU 4.2
*/
public static final int CURRENCY_SPC_CURRENCY_MATCH = 0;
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* Indicates the surrounding match pattern used in {@link #getPatternForCurrencySpacing}.
* {@icu} Indicates the surrounding match pattern used in {@link
* #getPatternForCurrencySpacing}.
* @draft ICU 4.2
*/
public static final int CURRENCY_SPC_SURROUNDING_MATCH = 1;
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* Indicates the insertion value used in {@link #getPatternForCurrencySpacing}.
* {@icu} Indicates the insertion value used in {@link #getPatternForCurrencySpacing}.
* @draft ICU 4.4
*/
public static final int CURRENCY_SPC_INSERT = 2;
@ -592,9 +583,8 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
private String[] currencySpcAfterSym;
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* Returns the desired currency spacing value. Original values come from ICU's CLDR
* data based on the locale provided during construction, and can be null. These
* {@icu} Returns the desired currency spacing value. Original values come from ICU's
* CLDR data based on the locale provided during construction, and can be null. These
* values govern what and when text is inserted between a currency code/name/symbol
* and the currency amount when formatting money.
*
@ -623,12 +613,11 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
}
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* Sets the indicated currency spacing pattern or value. See {@link
* {@icu} Sets the indicated currency spacing pattern or value. See {@link
* #getPatternForCurrencySpacing} for more information.
*
* <p>Values for currency match and surrounding match must be {@link
* com.ibm.icu.text.UnicodeSet} patterns. Values for insert can be any string.
* com.ibm.icu.text.UnicodeSet} patterns. Values for insert can be any string.
*
* <p><strong>Note:</strong> ICU4J does not currently use this information.
*
@ -714,9 +703,9 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
NaN.equals(other.NaN) &&
currencySymbol.equals(other.currencySymbol) &&
intlCurrencySymbol.equals(other.intlCurrencySymbol) &&
padEscape == other.padEscape && // [NEW]
plusSign == other.plusSign && // [NEW]
exponentSeparator.equals(other.exponentSeparator) && // [NEW]
padEscape == other.padEscape &&
plusSign == other.plusSign &&
exponentSeparator.equals(other.exponentSeparator) &&
monetarySeparator == other.monetarySeparator);
}
@ -1034,7 +1023,6 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
private String exponentSeparator;
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* The character used to indicate a padding character in a format,
* e.g., '*' in a pattern such as "$*_#,##0.00".
* @serial
@ -1043,7 +1031,6 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
private char padEscape;
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* The character used to indicate a plus sign.
* @serial
* @since AlphaWorks
@ -1116,7 +1103,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
// -------- BEGIN ULocale boilerplate --------
/**
* Return the locale that was used to create this object, or null.
* {@icu} Returns the locale that was used to create this object, or null.
* This may may differ from the locale requested at the time of
* this object's creation. For example, if an object is created
* for locale <tt>en_US_CALIFORNIA</tt>, the actual data may be
@ -1124,10 +1111,8 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
* <tt>en_US</tt> may be the most specific locale that exists (the
* <i>valid</i> locale).
*
* <p>Note: This method will be implemented in ICU 3.0; ICU 2.8
* contains a partial preview implementation. The * <i>actual</i>
* locale is returned correctly, but the <i>valid</i> locale is
* not, in most cases.
* <p>Note: The <i>actual</i> locale is returned correctly, but the <i>valid</i>
* locale is not, in most cases.
* @param type type of information requested, either {@link
* com.ibm.icu.util.ULocale#VALID_LOCALE} or {@link
* com.ibm.icu.util.ULocale#ACTUAL_LOCALE}.
@ -1145,7 +1130,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
}
/**
* Set information about the locales that were used to create this
* {@icu} Sets information about the locales that were used to create this
* object. If the object was not constructed from locale data,
* both arguments should be set to null. Otherwise, neither
* should be null. The actual locale must be at the same level or

View file

@ -36,7 +36,9 @@ import com.ibm.icu.lang.UCharacter;
import com.ibm.icu.util.ULocale;
/**
* MessageFormat produces concatenated messages in a language-neutral
* {@icuenhanced java.text.MessageFormat}.{@icu _usage_}
*
* <p>MessageFormat produces concatenated messages in a language-neutral
* way. Use this whenever concatenating strings that are displayed to
* end users.
*
@ -44,11 +46,11 @@ import com.ibm.icu.util.ULocale;
* within a <em>template string</em>. Together, the subformats and
* template string determine how the MessageFormat will operate during
* formatting and parsing.
*
*
* <p>Typically, both the subformats and the template string are
* specified at once in a <em>pattern</em>. By using different
* patterns for different locales, messages may be localized.
*
*
* <p>When formatting, MessageFormat takes a collection of arguments
* and produces a user-readable string. The arguments may be passed
* as an array or as a Map. Each argument is matched up with its
@ -71,7 +73,7 @@ import com.ibm.icu.util.ULocale;
* <code>:ID_START:</code> and continue with characters in <code>:ID_CONTINUE:</code>,
* in particular they do not start with a digit. If named arguments
* are used, {@link #usesNamedArguments()} will return true.
*
*
* <p>The other new methods supporting named arguments are
* {@link #setFormatsByArgumentName(Map)},
* {@link #setFormatByArgumentName(String, Format)},
@ -82,11 +84,11 @@ import com.ibm.icu.util.ULocale;
* the keys in the input or output <code>Map</code>s use
* <code>String</code>s that name the argument indices, e.g. "0",
* "1", "2"... etc.
*
*
* <p>When named arguments are used, certain methods on MessageFormat that take or
* return arrays will throw an exception, since it is not possible to
* identify positions in an array using a name. These methods are
* {@link #setFormatsByArgumentIndex(Format[])},
* identify positions in an array using a name. These methods are
* {@link #setFormatsByArgumentIndex(Format[])},
* {@link #setFormatByArgumentIndex(int, Format)},
* {@link #getFormatsByArgumentIndex()},
* {@link #getFormats()},
@ -95,7 +97,7 @@ import com.ibm.icu.util.ULocale;
* {@link #parse(String, ParsePosition)}, and
* {@link #parse(String)}.
* These APIs all have corresponding new versions as listed above.
*
*
* <p>The API {@link #format(Object, StringBuffer, FieldPosition)} has
* been modified so that the <code>Object</code> argument can be
* either an <code>Object</code> array or a <code>Map</code>. If this
@ -155,16 +157,16 @@ import com.ibm.icu.util.ULocale;
*
* <i>RulesetName:</i>
* <i>UnquotedString</i>
* <p>
* Within a <i>String</i>, <code>"''"</code> represents a single
*
* <p>Within a <i>String</i>, <code>"''"</code> represents a single
* quote. A <i>QuotedString</i> can contain arbitrary characters
* except single quotes; the surrounding single quotes are removed.
* An <i>UnquotedString</i> 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
* <code>"'''{'0}''"</code> or <code>"'''{0}'''"</code>.
* <p>
* Within a <i>SubformatPattern</i>, different rules apply.
*
* <p>Within a <i>SubformatPattern</i>, different rules apply.
* A <i>QuotedPattern</i> can contain arbitrary characters
* except single quotes; but the surrounding single quotes are
* <strong>not</strong> removed, so they may be interpreted by the
@ -176,8 +178,8 @@ import com.ibm.icu.util.ULocale;
* For example, <code>"ab {0} de"</code> and <code>"ab '}' de"</code>
* are valid subformat patterns, but <code>"ab {0'}' de"</code> and
* <code>"ab } de"</code> are not.
* <p>
* <dl><dt><b>Warning:</b><dd>The rules for using quotes within message
*
* <p><dl><dt><b>Warning:</b><dd>The rules for using quotes within message
* format patterns unfortunately have shown to be somewhat confusing.
* In particular, it isn't always obvious to localizers whether single
* quotes need to be doubled or not. Make sure to inform localizers about
@ -185,25 +187,26 @@ import com.ibm.icu.util.ULocale;
* bundle source files) which strings will be processed by MessageFormat.
* Note that localizers may need to use single quotes in translated
* strings where the original version doesn't have them.
*
* <br>Note also that the simplest way to avoid the problem is to
* use the real apostrophe (single quote) character \u2019 (') for
* human-readable text, and to use the ASCII apostrophe (\u0027 ' )
* only in program syntax, like quoting in MessageFormat.
* See the annotations for U+0027 Apostrophe in The Unicode Standard.</p>
* </dl>
* <p>
* The <i>ArgumentIndex</i> value is a non-negative integer written
*
* <p>The <i>ArgumentIndex</i> value is a non-negative integer written
* using the digits '0' through '9', and represents an index into the
* <code>arguments</code> array passed to the <code>format</code> methods
* or the result array returned by the <code>parse</code> methods.
* <p>
* The <i>FormatType</i> and <i>FormatStyle</i> values are used to create
*
* <p>The <i>FormatType</i> and <i>FormatStyle</i> values are used to create
* a <code>Format</code> 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 <i>SubformatPattern</i> must
* be a valid pattern string for the Format subclass used.
* <p>
* <table border=1>
*
* <p><table border=1>
* <tr>
* <th>Format Type
* <th>Format Style
@ -297,8 +300,7 @@ import com.ibm.icu.util.ULocale;
*
* <h4>Usage Information</h4>
*
* <p>
* Here are some examples of usage:
* <p>Here are some examples of usage:
* <blockquote>
* <pre>
* Object[] arguments = {
@ -319,8 +321,7 @@ import com.ibm.icu.util.ULocale;
* Typically, the message format will come from resources, and the
* arguments will be dynamically set at runtime.
*
* <p>
* Example 2:
* <p>Example 2:
* <blockquote>
* <pre>
* Object[] testArgs = {new Long(3), "MyDisk"};
@ -337,8 +338,7 @@ import com.ibm.icu.util.ULocale;
* </pre>
* </blockquote>
*
* <p>
* For more sophisticated patterns, you can use a <code>ChoiceFormat</code> to get
* <p>For more sophisticated patterns, you can use a <code>ChoiceFormat</code> to get
* output such as:
* <blockquote>
* <pre>
@ -368,15 +368,15 @@ import com.ibm.icu.util.ULocale;
* "There {0,choice,0#are no files|1#is one file|1&lt;are {0,number,integer} files}.");
* </pre>
* </blockquote>
* <p>
* <strong>Note:</strong> As we see above, the string produced
*
* <p><strong>Note:</strong> As we see above, the string produced
* by a <code>ChoiceFormat</code> in <code>MessageFormat</code> is treated specially;
* occurances of '{' are used to indicated subformats, and cause recursion.
* If you create both a <code>MessageFormat</code> and <code>ChoiceFormat</code>
* 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.
* <p>
* When a single argument is parsed more than once in the string, the last match
*
* <p>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,
* <pre>
* MessageFormat mf = new MessageFormat("{0,number,#.##}, {0,number,#.#}");
@ -387,8 +387,8 @@ import com.ibm.icu.util.ULocale;
* objs = mf.parse(result, new ParsePosition(0));
* // objs now equals {new Double(3.1)}
* </pre>
* <p>
* Likewise, parsing with a MessageFormat object using patterns containing
*
* <p>Likewise, parsing with a MessageFormat object using patterns containing
* multiple occurances of the same argument would return the last match. For
* example,
* <pre>
@ -400,8 +400,7 @@ import com.ibm.icu.util.ULocale;
*
* <h4><a name="synchronization">Synchronization</a></h4>
*
* <p>
* Message formats are not synchronized.
* <p>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.
@ -507,7 +506,7 @@ public class MessageFormat extends UFormat {
}
/**
* Gets the locale that's used when creating or comparing subformats.
* Returns the locale that's used when creating or comparing subformats.
*
* @return the locale used when creating or comparing subformats
* @stable ICU 3.0
@ -517,7 +516,7 @@ public class MessageFormat extends UFormat {
}
/**
* Gets the locale that's used when creating or comparing subformats.
* {@icu} Returns the locale that's used when creating or comparing subformats.
*
* @return the locale used when creating or comparing subformats
* @stable ICU 3.2
@ -751,7 +750,7 @@ public class MessageFormat extends UFormat {
}
/**
* Sets the formats to use for the values passed into
* {@icu} Sets the formats to use for the values passed into
* <code>format</code> methods or returned from <code>parse</code>
* methods. The keys in <code>newFormats</code> are the argument
* names in the previously set pattern string, and the values
@ -849,7 +848,7 @@ public class MessageFormat extends UFormat {
}
/**
* Sets the format to use for the format elements within the
* {@icu} Sets the format to use for the format elements within the
* previously set pattern string that use the given argument
* name.
* <p>
@ -898,7 +897,7 @@ public class MessageFormat extends UFormat {
}
/**
* Gets the formats used for the values passed into
* Returns the formats used for the values passed into
* <code>format</code> methods or returned from <code>parse</code>
* methods. The indices of elements in the returned array
* correspond to the argument indices used in the previously set
@ -944,7 +943,7 @@ public class MessageFormat extends UFormat {
// Where Map is: String argumentName --> Format format.
/**
* Gets the formats used for the format elements in the
* Returns 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.
@ -969,9 +968,9 @@ public class MessageFormat extends UFormat {
System.arraycopy(formats, 0, resultArray, 0, maxOffset + 1);
return resultArray;
}
/**
* Get the format argument names. For more details, see
* {@icu} Returns the format argument names. For more details, see
* {@link #setFormatByArgumentName(String, Format)}.
* @return List of names
* @internal
@ -984,9 +983,9 @@ public class MessageFormat extends UFormat {
}
return result;
}
/**
* Get the formats according to their argument names. For more details, see
* {@icu} Returns the formats according to their argument names. For more details, see
* {@link #setFormatByArgumentName(String, Format)}.
* @return format associated with the name, or null if there isn't one.
* @internal
@ -1044,7 +1043,7 @@ public class MessageFormat extends UFormat {
* <tr>
* <td><code>null</code>
* <td><code>instanceof Date</code>
* <td><code>DateFormat.getDateTimeInstance(DateFormat.SHORT,
* <td><code>DateFormat.getDateTimeInstance(DateFormat.SHORT,
* DateFormat.SHORT, getLocale()).format(argument)</code>
* <tr>
* <td><code>null</code>
@ -1122,8 +1121,8 @@ public class MessageFormat extends UFormat {
* Creates a MessageFormat with the given pattern and uses it
* to format the given arguments. This is equivalent to
* <blockquote>
* <code>(new {@link #MessageFormat(String) MessageFormat}(pattern)).{@link
* #format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)
* <code>(new {@link #MessageFormat(String) MessageFormat}(pattern)).{@link
* #format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)
* format}(arguments, new StringBuffer(), null).toString()</code>
* </blockquote>
*
@ -1158,7 +1157,7 @@ public class MessageFormat extends UFormat {
}
/**
* Returns true if this MessageFormat uses named arguments,
* {@icu} Returns true if this MessageFormat uses named arguments,
* and false otherwise. See class description.
*
* @return true if named arguments are used.
@ -1175,9 +1174,9 @@ public class MessageFormat extends UFormat {
* provided <code>StringBuffer</code>.
* This is equivalent to either of
* <blockquote>
* <code>{@link #format(java.lang.Object[], java.lang.StringBuffer,
* <code>{@link #format(java.lang.Object[], java.lang.StringBuffer,
* java.text.FieldPosition) format}((Object[]) arguments, result, pos)</code>
* <code>{@link #format(java.util.Map, java.lang.StringBuffer,
* <code>{@link #format(java.util.Map, java.lang.StringBuffer,
* java.text.FieldPosition) format}((Map) arguments, result, pos)</code>
* </blockquote>
* A map must be provided if this format uses named arguments, otherwise
@ -1220,7 +1219,7 @@ public class MessageFormat extends UFormat {
* The text of the returned <code>AttributedCharacterIterator</code> is
* the same that would be returned by
* <blockquote>
* <code>{@link #format(java.lang.Object[], java.lang.StringBuffer,
* <code>{@link #format(java.lang.Object[], java.lang.StringBuffer,
* java.text.FieldPosition) format}(arguments, new StringBuffer(), null).toString()</code>
* </blockquote>
* <p>
@ -1248,7 +1247,7 @@ public class MessageFormat extends UFormat {
@SuppressWarnings("unchecked")
public AttributedCharacterIterator formatToCharacterIterator(Object arguments) {
StringBuffer result = new StringBuffer();
ArrayList<AttributedCharacterIterator> iterators =
ArrayList<AttributedCharacterIterator> iterators =
new ArrayList<AttributedCharacterIterator>();
if (arguments == null) {
@ -1329,7 +1328,7 @@ public class MessageFormat extends UFormat {
}
/**
* Parses the string, returning the results in a Map.
* {@icu} Parses the string, returning the results in a Map.
* This is similar to the version that returns an array
* of Object. This supports both named and numbered
* arguments-- if numbered, the keys in the map are the
@ -1347,15 +1346,6 @@ public class MessageFormat extends UFormat {
return empty;
}
// int maximumArgumentNumber = -1;
// for (int i = 0; i <= maxOffset; i++) {
// int argumentNumber = Integer.parseInt(argumentNames[i]);
// if (argumentNumber > maximumArgumentNumber) {
// maximumArgumentNumber = argumentNumber;
// }
// }
// Object[] resultArray = new Object[maximumArgumentNumber + 1];
Map<String, Object> resultMap = new HashMap<String, Object>();
int patternOffset = 0;
@ -1446,11 +1436,11 @@ public class MessageFormat extends UFormat {
}
/**
* Parses text from the beginning of the given string to produce a map from
* {@icu} Parses text from the beginning of the given string to produce a map from
* argument to values. The method may not use the entire text of the given string.
* <p>
* See the {@link #parse(String, ParsePosition)} method for more information
* on message parsing.
*
* <p>See the {@link #parse(String, ParsePosition)} method for more information on
* message parsing.
*
* @param source A <code>String</code> whose beginning should be parsed.
* @return A <code>Map</code> parsed from the string.
@ -1506,7 +1496,7 @@ public class MessageFormat extends UFormat {
}
/**
* Creates and returns a copy of this object.
* Overrides clone.
*
* @return a clone of this instance.
* @stable ICU 3.0
@ -1529,7 +1519,7 @@ public class MessageFormat extends UFormat {
}
/**
* Equality comparison between two message format objects
* Overrides equals.
* @stable ICU 3.0
*/
public boolean equals(Object obj) {
@ -1548,7 +1538,7 @@ public class MessageFormat extends UFormat {
}
/**
* Generates a hash code for the message format object.
* Overrides hashCode.
* @stable ICU 3.0
*/
public int hashCode() {
@ -1784,8 +1774,8 @@ public class MessageFormat extends UFormat {
characterIterators.add(
_createAttributedCharacterIterator(
subIterator, Field.ARGUMENT,
argumentNamesAreNumeric ?
(Object)new Integer(argumentName) :
argumentNamesAreNumeric ?
(Object)new Integer(argumentName) :
(Object)argumentName));
last = result.length();
}
@ -1796,8 +1786,8 @@ public class MessageFormat extends UFormat {
characterIterators.add(
_createAttributedCharacterIterator(
arg, Field.ARGUMENT,
argumentNamesAreNumeric ?
(Object)new Integer(argumentName) :
argumentNamesAreNumeric ?
(Object)new Integer(argumentName) :
(Object)argumentName));
last = result.length();
}
@ -1851,7 +1841,7 @@ public class MessageFormat extends UFormat {
TYPE_SPELLOUT = 5,
TYPE_ORDINAL = 6,
TYPE_DURATION = 7,
TYPE_PLURAL = 8,
TYPE_PLURAL = 8,
TYPE_SELECT = 9;
private static final String[] modifierList =
@ -1953,7 +1943,7 @@ public class MessageFormat extends UFormat {
newFormat = NumberFormat.getIntegerInstance(ulocale);
break;
default: // pattern
newFormat = new DecimalFormat(segments[3].toString(),
newFormat = new DecimalFormat(segments[3].toString(),
new DecimalFormatSymbols(ulocale));
break;
}
@ -2012,7 +2002,7 @@ public class MessageFormat extends UFormat {
break;
case TYPE_SPELLOUT:
{
RuleBasedNumberFormat rbnf = new RuleBasedNumberFormat(ulocale,
RuleBasedNumberFormat rbnf = new RuleBasedNumberFormat(ulocale,
RuleBasedNumberFormat.SPELLOUT);
String ruleset = segments[3].toString().trim();
if (ruleset.length() != 0) {
@ -2028,7 +2018,7 @@ public class MessageFormat extends UFormat {
break;
case TYPE_ORDINAL:
{
RuleBasedNumberFormat rbnf = new RuleBasedNumberFormat(ulocale,
RuleBasedNumberFormat rbnf = new RuleBasedNumberFormat(ulocale,
RuleBasedNumberFormat.ORDINAL);
String ruleset = segments[3].toString().trim();
if (ruleset.length() != 0) {
@ -2044,7 +2034,7 @@ public class MessageFormat extends UFormat {
break;
case TYPE_DURATION:
{
RuleBasedNumberFormat rbnf = new RuleBasedNumberFormat(ulocale,
RuleBasedNumberFormat rbnf = new RuleBasedNumberFormat(ulocale,
RuleBasedNumberFormat.DURATION);
String ruleset = segments[3].toString().trim();
if (ruleset.length() != 0) {
@ -2110,7 +2100,7 @@ public class MessageFormat extends UFormat {
return -1;
}
private static final void copyAndFixQuotes(String source, int start, int end,
private static final void copyAndFixQuotes(String source, int start, int end,
StringBuilder target) {
// added 'gotLB' logic from ICU4C - questionable [alan]
boolean gotLB = false;
@ -2213,7 +2203,7 @@ public class MessageFormat extends UFormat {
private static final int STATE_MSG_ELEMENT = 3;
/**
* Convert an 'apostrophe-friendly' pattern into a standard
* {@icu} Converts 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

View file

@ -26,8 +26,9 @@ import com.ibm.icu.util.CurrencyAmount;
import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.UResourceBundle;
// this is an enhanced version that is based on the standard version in the JDK
/**
* {@icuenhanced java.text.NumberFormat}.{@icu _usage_}
*
* <code>NumberFormat</code> is the abstract base class for all number
* formats. This class provides the interface for formatting and parsing
* numbers. <code>NumberFormat</code> also provides methods for determining
@ -80,15 +81,15 @@ import com.ibm.icu.util.UResourceBundle;
*
* <p>
* Starting from ICU 4.2, you can use getInstance() by passing in a 'style'
* as parameter to get the correct instance.
* For example,
* as parameter to get the correct instance.
* For example,
* use getInstance(...NUMBERSTYLE) to get the normal number format,
* getInstance(...PERCENTSTYLE) to get a format for displaying percentage,
* getInstance(...SCIENTIFICSTYLE) to get a format for displaying scientific number,
* getInstance(...INTEGERSTYLE) to get an integer number format,
* getInstance(...CURRENCYSTYLE) to get the currency number format,
* getInstance(...CURRENCYSTYLE) to get the currency number format,
* in which the currency is represented by its symbol, for example, "$3.00".
* getInstance(...ISOCURRENCYSTYLE) to get the currency number format,
* getInstance(...ISOCURRENCYSTYLE) to get the currency number format,
* in which the currency is represented by its ISO code, for example "USD3.00".
* getInstance(...PLURALCURRENCYSTYLE) to get the currency number format,
* in which the currency is represented by its full name in plural format,
@ -145,9 +146,9 @@ import com.ibm.icu.util.UResourceBundle;
*
* <h4>Synchronization</h4>
* <p>
* Number formats are generally not synchronized. It is recommended to create
* 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.
* concurrently, it must be synchronized externally.
* <p>
*
* <h4>DecimalFormat</h4>
@ -165,39 +166,39 @@ import com.ibm.icu.util.UResourceBundle;
public abstract class NumberFormat extends UFormat {
/**
* Constants to specify normal number style of format.
* {@icu} Constant to specify normal number style of format.
* @stable ICU 4.2
*/
public static final int NUMBERSTYLE = 0;
/**
* Constants to specify currency style of format which uses currency symbol
* {@icu} Constant to specify currency style of format which uses currency symbol
* to represent currency, for example: "$3.00".
* @stable ICU 4.2
*/
public static final int CURRENCYSTYLE = 1;
/**
* Constants to specify a style of format to display percent.
* {@icu} Constant to specify a style of format to display percent.
* @stable ICU 4.2
*/
public static final int PERCENTSTYLE = 2;
/**
* Constants to specify a style of format to display scientific number.
* {@icu} Constant to specify a style of format to display scientific number.
* @stable ICU 4.2
*/
public static final int SCIENTIFICSTYLE = 3;
/**
* Constants to specify a integer number style format.
* {@icu} Constant to specify a integer number style format.
* @stable ICU 4.2
*/
public static final int INTEGERSTYLE = 4;
/**
* Constants to specify currency style of format which uses currency
* {@icu} Constant to specify currency style of format which uses currency
* ISO code to represent currency, for example: "USD3.00".
* @stable ICU 4.2
*/
public static final int ISOCURRENCYSTYLE = 5;
/**
* Constants to specify currency style of format which uses currency
* {@icu} Constant to specify currency style of format which uses currency
* long name with plural format to represent currency, for example,
* "3.00 US Dollars".
* @stable ICU 4.2
@ -220,16 +221,16 @@ public abstract class NumberFormat extends UFormat {
*/
public static final int FRACTION_FIELD = 1;
// changed in ICU4J
/**
* Format an object. Change: recognizes <code>BigInteger</code>
* Formats a number and appends the resulting text to the given string buffer.
* {@icunote} recognizes <code>BigInteger</code>
* and <code>BigDecimal</code> objects.
* @see java.text.Format#format(Object, StringBuffer, FieldPosition)
* @stable ICU 2.0
*/
public StringBuffer format(Object number,
StringBuffer toAppendTo,
FieldPosition pos)
{
FieldPosition pos) {
if (number instanceof Long) {
return format(((Long)number).longValue(), toAppendTo, pos);
} else if (number instanceof BigInteger) {
@ -248,11 +249,15 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Parses text from a string to produce a number.
* @param source the String to parse
* @param parsePosition the position at which to start the parse
* @return the parsed number, or null
* @see java.text.NumberFormat#parseObject(String, ParsePosition)
* @stable ICU 2.0
*/
public final Object parseObject(String source,
ParsePosition parsePosition)
{
ParsePosition parsePosition) {
return parse(source, parsePosition);
}
@ -277,9 +282,9 @@ public abstract class NumberFormat extends UFormat {
format(number, buf, pos);
return buf.toString();
}
/**
* Convenience method to format a BigInteger.
* {@icu} Convenience method to format a BigInteger.
* @stable ICU 2.0
*/
public final String format(BigInteger number) {
@ -297,7 +302,7 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Convenience method to format an ICU BigDecimal.
* {@icu} Convenience method to format an ICU BigDecimal.
* @stable ICU 2.0
*/
public final String format(com.ibm.icu.math.BigDecimal number) {
@ -306,7 +311,7 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Convenience method to format a CurrencyAmount.
* {@icu} Convenience method to format a CurrencyAmount.
* @stable ICU 3.0
*/
public final String format(CurrencyAmount currAmt) {
@ -332,15 +337,15 @@ public abstract class NumberFormat extends UFormat {
StringBuffer toAppendTo,
FieldPosition pos);
/**
* Format a BigInteger.
* {@icu} Formats a BigInteger. Specialization of format.
* @see java.text.Format#format(Object, StringBuffer, FieldPosition)
* @stable ICU 2.0
*/
public abstract StringBuffer format(BigInteger number,
StringBuffer toAppendTo,
FieldPosition pos);
FieldPosition pos);
/**
* Format a BigDecimal.
* {@icu} Formats a BigDecimal. Specialization of format.
* @see java.text.Format#format(Object, StringBuffer, FieldPosition)
* @stable ICU 2.0
*/
@ -348,7 +353,7 @@ public abstract class NumberFormat extends UFormat {
StringBuffer toAppendTo,
FieldPosition pos);
/**
* Format a BigDecimal.
* {@icu} Formats an ICU BigDecimal. Specialization of format.
* @see java.text.Format#format(Object, StringBuffer, FieldPosition)
* @stable ICU 2.0
*/
@ -356,7 +361,7 @@ public abstract class NumberFormat extends UFormat {
StringBuffer toAppendTo,
FieldPosition pos);
/**
* Format a CurrencyAmount.
* {@icu} Formats a CurrencyAmount. Specialization of format.
* @see java.text.Format#format(Object, StringBuffer, FieldPosition)
* @stable ICU 3.0
*/
@ -392,7 +397,7 @@ public abstract class NumberFormat extends UFormat {
*
* @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
* @throws ParseException if the beginning of the specified string
* cannot be parsed.
* @see #format
* @stable ICU 2.0
@ -457,7 +462,7 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Sets whether strict parsing is in effect. When this is true, the
* {@icu} Sets whether strict parsing is in effect. When this is true, the
* following conditions cause a parse failure (examples use the pattern "#,##0.#"):<ul>
* <li>Leading zeros<br>
* '00', '0123' fail the parse, but '0' and '0.001' pass</li>
@ -480,7 +485,7 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Return whether strict parsing is in effect.
* {@icu} Returns whether strict parsing is in effect.
* @return true if strict parsing is in effect
* @see #setParseStrict
* @stable ICU 3.6
@ -516,7 +521,7 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Returns the default number format for the specified locale.
* {@icu} 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.
@ -527,7 +532,7 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Returns a specific style number format for default locale.
* {@icu} Returns a specific style number format for default locale.
* @param style number format style
* @stable ICU 4.2
*/
@ -536,7 +541,7 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Returns a specific style number format for a specific locale.
* {@icu} Returns a specific style number format for a specific locale.
* @param inLocale the specific locale.
* @param style number format style
* @stable ICU 4.2
@ -563,7 +568,7 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Returns a general-purpose number format for the specified locale.
* {@icu} Returns a general-purpose number format for the specified locale.
* @stable ICU 3.2
*/
public static NumberFormat getNumberInstance(ULocale inLocale) {
@ -573,7 +578,7 @@ public abstract class NumberFormat extends UFormat {
/**
* 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
* 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}).
@ -589,7 +594,7 @@ public abstract class NumberFormat extends UFormat {
/**
* 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
* 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}).
@ -604,9 +609,9 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Returns an integer number format for the specified locale. The
* {@icu} 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
* 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}).
@ -638,7 +643,7 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Returns a currency format for the specified locale.
* {@icu} Returns a currency format for the specified locale.
* @return a number format for currency
* @stable ICU 3.2
*/
@ -665,7 +670,7 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Returns a percentage format for the specified locale.
* {@icu} Returns a percentage format for the specified locale.
* @return a number format for percents
* @stable ICU 3.2
*/
@ -674,7 +679,7 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Returns a scientific format for the current default locale.
* {@icu} Returns a scientific format for the current default locale.
* @return a scientific number format
* @stable ICU 2.0
*/
@ -683,7 +688,7 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Returns a scientific format for the specified locale.
* {@icu} Returns a scientific format for the specified locale.
* @return a scientific number format
* @stable ICU 2.0
*/
@ -692,7 +697,7 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Returns a scientific format for the specified locale.
* {@icu} Returns a scientific format for the specified locale.
* @return a scientific number format
* @stable ICU 3.2
*/
@ -706,6 +711,7 @@ public abstract class NumberFormat extends UFormat {
* should be able to create any of the predefined formats for each locale it
* supports. When registered, the locales it supports extend or override the
* locales already supported by ICU.
*
* <p><b>Note:</b> as of ICU4J 3.2, the default API for NumberFormatFactory uses
* ULocale instead of Locale. Instead of overriding createFormat(Locale, int),
* new implementations should override createFactory(ULocale, int). Note that
@ -757,7 +763,7 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Returns an immutable collection of the locale names directly
* Returns an immutable collection of the locale names directly
* supported by this factory.
* @return the supported locale names.
* @stable ICU 2.6
@ -786,7 +792,7 @@ public abstract class NumberFormat extends UFormat {
* the type is not provided by this service, return null. Otherwise
* return an appropriate instance of NumberFormat.
* <b>Note:</b> as of ICU4J 3.2, createFormat(ULocale, int) should be
* overridden instead of this method. This method is no longer
* overridden instead of this method. This method is no longer
* abstract and delegates to that method.
* @param loc the locale for which to create the format
* @param formatType the type of format
@ -819,7 +825,7 @@ public abstract class NumberFormat extends UFormat {
public SimpleNumberFormatFactory(Locale locale) {
this(locale, true);
}
/**
* Constructs a SimpleNumberFormatFactory with the given locale and the
* visibility.
@ -837,7 +843,7 @@ public abstract class NumberFormat extends UFormat {
public SimpleNumberFormatFactory(ULocale locale) {
this(locale, true);
}
/**
* Constructs a SimpleNumberFormatFactory with the given locale and the
* visibility.
@ -899,7 +905,7 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Get the list of Locales for which NumberFormats are available.
* Returns the list of Locales for which NumberFormats are available.
* @return the available locales
* @stable ICU 2.0
*/
@ -911,7 +917,7 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Get the list of Locales for which NumberFormats are available.
* {@icu} Returns the list of Locales for which NumberFormats are available.
* @return the available locales
* @draft ICU 3.2 (retain)
* @provisional This API might change or be removed in a future release.
@ -919,17 +925,17 @@ public abstract class NumberFormat extends UFormat {
public static ULocale[] getAvailableULocales() {
if (shim == null) {
return ICUResourceBundle.getAvailableULocales();
}
}
return getShim().getAvailableULocales();
}
/**
* Registers a new NumberFormatFactory. The factory is adopted by
* {@icu} Registers a new NumberFormatFactory. The factory is adopted by
* the service and must not be modified. The returned object is a
* key that can be used to unregister this factory.
* @param factory the factory to register
* @return a key with which to unregister the factory
* @stable ICU 2.6
* @stable ICU 2.6
*/
public static Object registerFactory(NumberFormatFactory factory) {
if (factory == null) {
@ -939,7 +945,7 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Unregister the factory or instance associated with this key (obtained from
* {@icu} Unregisters the factory or instance associated with this key (obtained from
* registerInstance or registerFactory).
* @param registryKey a key obtained from registerFactory
* @return true if the object was successfully unregistered
@ -960,7 +966,7 @@ public abstract class NumberFormat extends UFormat {
// ===== End of factory stuff =====
/**
* Overrides hashCode
* Overrides hashCode.
* @stable ICU 2.0
*/
public int hashCode() {
@ -969,7 +975,8 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Overrides equals. Two NumberFormats are equal if they are of the same class
* 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
@ -993,11 +1000,10 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Overrides Cloneable.
* Overrides clone.
* @stable ICU 2.0
*/
public Object clone()
{
public Object clone() {
NumberFormat other = (NumberFormat) super.clone();
return other;
}
@ -1094,11 +1100,11 @@ public abstract class NumberFormat extends UFormat {
* 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
* 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
* @stable ICU 2.0
*/
public int getMaximumFractionDigits() {
return maximumFractionDigits;
@ -1169,14 +1175,14 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Gets the <tt>Currency</tt> object used to display currency
* Returns the <tt>Currency</tt> object used to display currency
* amounts. This may be null.
* @stable ICU 2.6
*/
public Currency getCurrency() {
return currency;
}
/**
* Returns the currency in effect for this formatter. Subclasses
* should override this method as needed. Unlike getCurrency(),
@ -1198,7 +1204,7 @@ public abstract class NumberFormat extends UFormat {
}
/**
* Get the rounding mode used in this NumberFormat. The default implementation of
* Returns the rounding mode used in this NumberFormat. The default implementation of
* tis method in NumberFormat always throws <code>UnsupportedOperationException</code>.
* @return A rounding mode, between <code>BigDecimal.ROUND_UP</code>
* and <code>BigDecimal.ROUND_UNNECESSARY</code>.
@ -1206,7 +1212,8 @@ public abstract class NumberFormat extends UFormat {
* @stable ICU 4.0
*/
public int getRoundingMode() {
throw new UnsupportedOperationException("getRoundingMode must be implemented by the subclass implementation.");
throw new UnsupportedOperationException(
"getRoundingMode must be implemented by the subclass implementation.");
}
/**
@ -1219,7 +1226,8 @@ public abstract class NumberFormat extends UFormat {
* @stable ICU 4.0
*/
public void setRoundingMode(int roundingMode) {
throw new UnsupportedOperationException("setRoundingMode must be implemented by the subclass implementation.");
throw new UnsupportedOperationException(
"setRoundingMode must be implemented by the subclass implementation.");
}
@ -1228,16 +1236,17 @@ public abstract class NumberFormat extends UFormat {
* @param desiredLocale the specific locale.
* @param choice number format style
* @throws IllegalArgumentException if choice is not one of
* NUMBERSTYLE, CURRENCYSTYLE,
* PERCENTSTYLE, SCIENTIFICSTYLE,
* INTEGERSTYLE,
* NUMBERSTYLE, CURRENCYSTYLE,
* PERCENTSTYLE, SCIENTIFICSTYLE,
* INTEGERSTYLE,
* ISOCURRENCYSTYLE, PLURALCURRENCYSTYLE,
* @stable ICU 4.2
*/
public static NumberFormat getInstance(ULocale desiredLocale, int choice) {
if (choice < NUMBERSTYLE || choice > PLURALCURRENCYSTYLE) {
throw new IllegalArgumentException("choice should be from NUMBERSTYLE to PLURALCURRENCYSTYLE");
}
throw new IllegalArgumentException(
"choice should be from NUMBERSTYLE to PLURALCURRENCYSTYLE");
}
// if (shim == null) {
// return createInstance(desiredLocale, choice);
// } else {
@ -1253,15 +1262,15 @@ public abstract class NumberFormat extends UFormat {
// If the choice is PLURALCURRENCYSTYLE, the pattern is not a single
// pattern, it is a pattern set, so we do not need to get them here.
// If the choice is ISOCURRENCYSTYLE, the pattern is the currrency
// pattern in the locale but by replacing the single currency sign
// pattern in the locale but by replacing the single currency sign
// with double currency sign.
String pattern = getPattern(desiredLocale, choice);
DecimalFormatSymbols symbols = new DecimalFormatSymbols(desiredLocale);
// Here we assume that the locale passed in is in the canonical
// form, e.g: pt_PT_@currency=PTE not pt_PT_PREEURO
// This style wont work for currency plural format.
// For currency plural format, the pattern is get from
// For currency plural format, the pattern is get from
// the locale (from CurrencyUnitPatterns) without override.
if(choice == CURRENCYSTYLE || choice == ISOCURRENCYSTYLE){
String temp = symbols.getCurrencyPattern();
@ -1315,7 +1324,7 @@ public abstract class NumberFormat extends UFormat {
} else {
DecimalFormat f = new DecimalFormat(pattern, symbols, choice);
// System.out.println("loc: " + desiredLocale + " choice: " + choice + " pat: " + pattern + " sym: " + symbols + " result: " + format);
/*Bug 4408066
Add codes for the new method getIntegerInstance() [Richard/GCL]
*/
@ -1327,14 +1336,14 @@ public abstract class NumberFormat extends UFormat {
f.setParseIntegerOnly(true);
}
format = f;
}
}
// TODO: the actual locale of the *pattern* may differ from that
// for the *symbols*. For now, we use the data for the symbols.
// Revisit this.
ULocale valid = symbols.getLocale(ULocale.VALID_LOCALE);
ULocale actual = symbols.getLocale(ULocale.ACTUAL_LOCALE);
format.setLocale(valid, actual);
return format;
}
@ -1366,7 +1375,7 @@ public abstract class NumberFormat extends UFormat {
* We detect these cases here and return various hard-coded
* resource data. This is the simplest solution for now, but
* it is not a good long-term mechanism.
*
*
* We should replace this code with a data-driven mechanism
* that reads the bundle com.ibm.icu.impl.data.LocaleElements
* and parses an exception table that overrides the standard
@ -1407,7 +1416,7 @@ public abstract class NumberFormat extends UFormat {
{ "com.ibm.icu.impl.data.LocaleElements", RESOURCE_BASE }, forLocale);
numberPatterns = resource.getStringArray("NumberPatterns");
// Update the cache
cachedLocaleData.put(forLocale, numberPatterns);
cachedLocaleData.put(forLocale, numberPatterns);
}
*/
@ -1419,7 +1428,7 @@ public abstract class NumberFormat extends UFormat {
* but by replacing the single currency sign with
* double currency sign or triple currency sign.
*/
int entry = (choice == INTEGERSTYLE) ? NUMBERSTYLE :
int entry = (choice == INTEGERSTYLE) ? NUMBERSTYLE :
((choice == ISOCURRENCYSTYLE || choice == PLURALCURRENCYSTYLE)?
CURRENCYSTYLE : choice); //[Richard/GCL]
return numberPatterns[entry]; //[Richard/GCL]
@ -1516,7 +1525,7 @@ public abstract class NumberFormat extends UFormat {
* When writing to a stream, <code>maxIntegerDigits</code> is set to
* <code>maximumIntegerDigits</code> or <code>Byte.MAX_VALUE</code>,
* whichever is smaller. When reading from a stream, this field is used
* only if <code>serialVersionOnStream</code> is less than 1.
* only if <code>serialVersionOnStream</code> is less than 1.
*
* @serial
* @see #getMaximumIntegerDigits
@ -1534,7 +1543,7 @@ public abstract class NumberFormat extends UFormat {
* When writing to a stream, <code>minIntegerDigits</code> is set to
* <code>minimumIntegerDigits</code> or <code>Byte.MAX_VALUE</code>,
* whichever is smaller. When reading from a stream, this field is used
* only if <code>serialVersionOnStream</code> is less than 1.
* only if <code>serialVersionOnStream</code> is less than 1.
*
* @serial
* @see #getMinimumIntegerDigits
@ -1552,7 +1561,7 @@ public abstract class NumberFormat extends UFormat {
* When writing to a stream, <code>maxFractionDigits</code> is set to
* <code>maximumFractionDigits</code> or <code>Byte.MAX_VALUE</code>,
* whichever is smaller. When reading from a stream, this field is used
* only if <code>serialVersionOnStream</code> is less than 1.
* only if <code>serialVersionOnStream</code> is less than 1.
*
* @serial
* @see #getMaximumFractionDigits
@ -1570,7 +1579,7 @@ public abstract class NumberFormat extends UFormat {
* When writing to a stream, <code>minFractionDigits</code> is set to
* <code>minimumFractionDigits</code> or <code>Byte.MAX_VALUE</code>,
* whichever is smaller. When reading from a stream, this field is used
* only if <code>serialVersionOnStream</code> is less than 1.
* only if <code>serialVersionOnStream</code> is less than 1.
*
* @serial
* @see #getMinimumFractionDigits
@ -1688,7 +1697,7 @@ public abstract class NumberFormat extends UFormat {
public static class Field extends Format.Field {
// generated by serialver from JDK 1.4.1_01
static final long serialVersionUID = -4516273749929385842L;
/**
* @stable ICU 3.6
*/

View file

@ -41,7 +41,9 @@ import com.ibm.icu.util.ULocale;
/**
* <code>SimpleDateFormat</code> is a concrete class for formatting and
* {@icuenhanced java.text.SimpleDateFormat}.{@icu _usage_}
*
* <p><code>SimpleDateFormat</code> 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.
*
@ -163,8 +165,7 @@ import com.ibm.icu.util.ULocale;
* the "hour in am/pm" pattern symbol is used. This information loss can
* happen when formatting the time in PM.
*
* <p>
* When parsing a date string using the abbreviated year pattern ("yy"),
* <p>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
@ -180,13 +181,11 @@ import com.ibm.icu.util.ULocale;
* 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.
*
* <p>
* If the year pattern does not have exactly two 'y' characters, the year is
* <p>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.
*
* <p>
* When numeric fields abut one another directly, with no intervening delimiter
* <p>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
@ -197,12 +196,10 @@ import com.ibm.icu.util.ULocale;
* leftmost field is one character in length. If the parse still fails at that
* point, the parse of the run fails.
*
* <p>
* For time zones that have no names, use strings GMT+hours:minutes or
* <p>For time zones that have no names, use strings GMT+hours:minutes or
* GMT-hours:minutes.
*
* <p>
* The calendar defines what is the first day of the week, the first week
* <p>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.
@ -234,13 +231,13 @@ public class SimpleDateFormat extends DateFormat {
static final int currentSerialVersion = 1;
static boolean DelayedHebrewMonthCheck = false;
/*
* From calendar field to its level.
* Used to order calendar field.
* For example, calendar fields can be defined in the following order:
* year > month > date > am-pm > hour > minute
* YEAR --> 10, MONTH -->20, DATE --> 30;
* YEAR --> 10, MONTH -->20, DATE --> 30;
* AM_PM -->40, HOUR --> 50, MINUTE -->60
*/
private static final int[] CALENDAR_FIELD_TO_LEVEL =
@ -249,14 +246,14 @@ public class SimpleDateFormat extends DateFormat {
/*wW*/ 20, 30,
/*dDEF*/ 30, 20, 30, 30,
/*ahHm*/ 40, 50, 50, 60,
/*sS..*/ 70, 80,
/*z?Y*/ 0, 0, 10,
/*sS..*/ 70, 80,
/*z?Y*/ 0, 0, 10,
/*eug*/ 30, 10, 0,
/*A*/ 40
/*A*/ 40
};
/*
* From calendar field letter to its level.
* Used to order calendar field.
@ -264,7 +261,7 @@ public class SimpleDateFormat extends DateFormat {
* year > month > date > am-pm > hour > minute
* 'y' --> 10, 'M' -->20, 'd' --> 30; 'a' -->40, 'h' --> 50, 'm' -->60
*/
private static final int[] PATTERN_CHAR_TO_LEVEL =
private static final int[] PATTERN_CHAR_TO_LEVEL =
{
// A B C D E F G H I J K L M N O
-1, 40, -1, -1, 20, 30, 30, 0, 50, -1, -1, 50, 20, 20, -1, -1,
@ -364,7 +361,7 @@ public class SimpleDateFormat extends DateFormat {
private transient boolean useFastFormat;
/**
* Construct a SimpleDateFormat using the default pattern for the default
* Constructs a SimpleDateFormat using the default pattern for the default
* locale. <b>Note:</b> Not all locales support SimpleDateFormat; for full
* generality, use the factory methods in the DateFormat class.
*
@ -376,7 +373,7 @@ public class SimpleDateFormat extends DateFormat {
}
/**
* Construct a SimpleDateFormat using the given pattern in the default
* Constructs a SimpleDateFormat using the given pattern in the default
* locale. <b>Note:</b> Not all locales support SimpleDateFormat; for full
* generality, use the factory methods in the DateFormat class.
* @stable ICU 2.0
@ -387,7 +384,7 @@ public class SimpleDateFormat extends DateFormat {
}
/**
* Construct a SimpleDateFormat using the given pattern and locale.
* Constructs a SimpleDateFormat using the given pattern and locale.
* <b>Note:</b> Not all locales support SimpleDateFormat; for full
* generality, use the factory methods in the DateFormat class.
* @stable ICU 2.0
@ -398,7 +395,7 @@ public class SimpleDateFormat extends DateFormat {
}
/**
* Construct a SimpleDateFormat using the given pattern and locale.
* Constructs a SimpleDateFormat using the given pattern and locale.
* <b>Note:</b> Not all locales support SimpleDateFormat; for full
* generality, use the factory methods in the DateFormat class.
* @stable ICU 3.2
@ -409,7 +406,7 @@ public class SimpleDateFormat extends DateFormat {
}
/**
* Construct a SimpleDateFormat using the given pattern , override and locale.
* Constructs a SimpleDateFormat using the given pattern , override and locale.
* @stable ICU 4.2
*/
public SimpleDateFormat(String pattern, String override, ULocale loc)
@ -418,7 +415,7 @@ public class SimpleDateFormat extends DateFormat {
}
/**
* Construct a SimpleDateFormat using the given pattern and
* Constructs a SimpleDateFormat using the given pattern and
* locale-specific symbol data.
* Warning: uses default locale for digits!
* @stable ICU 2.0
@ -464,14 +461,14 @@ public class SimpleDateFormat extends DateFormat {
}
/**
* Create an instance of SimpleDateForamt for the given format configuration
* Creates an instance of SimpleDateForamt for the given format configuration
* @param formatConfig the format configuration
* @return A SimpleDateFormat instance
* @internal
* @deprecated This API is ICU internal only.
*/
public static SimpleDateFormat getInstance(Calendar.FormatConfiguration formatConfig) {
String ostr = formatConfig.getOverrideString();
boolean useFast = ( ostr != null && ostr.length() > 0 );
@ -615,8 +612,7 @@ public class SimpleDateFormat extends DateFormat {
}
/**
* Overrides DateFormat.
* <p>Formats a date or time, which is the standard millis
* Formats a date or time, which is the standard millis
* since January 1, 1970, 00:00:00 GMT.
* <p>Example: using the US locale:
* "yyyy.MM.dd G 'at' HH:mm:ss zzz" ->> 1996.07.10 AD at 15:08:56 PDT
@ -674,7 +670,8 @@ public class SimpleDateFormat extends DateFormat {
if (useFastFormat) {
subFormat(toAppendTo, item.type, item.length, toAppendTo.length(), pos, cal);
} else {
toAppendTo.append(subFormat(item.type, item.length, toAppendTo.length(), pos, formatData, cal));
toAppendTo.append(subFormat(item.type, item.length, toAppendTo.length(), pos,
formatData, cal));
}
if (attributes != null) {
// Check the sub format length
@ -691,7 +688,7 @@ public class SimpleDateFormat extends DateFormat {
}
}
return toAppendTo;
}
// Map pattern character to index
@ -707,7 +704,7 @@ public class SimpleDateFormat extends DateFormat {
// p q r s t u v w x y z
-1, 28, -1, 7, -1, 20, 24, 12, -1, 1, 17, -1, -1, -1, -1, -1
};
// Map pattern character index to Calendar field number
private static final int[] PATTERN_INDEX_TO_CALENDAR_FIELD =
{
@ -736,11 +733,11 @@ public class SimpleDateFormat extends DateFormat {
/*hKz*/ DateFormat.HOUR1_FIELD, DateFormat.HOUR0_FIELD, DateFormat.TIMEZONE_FIELD,
/*Yeu*/ DateFormat.YEAR_WOY_FIELD, DateFormat.DOW_LOCAL_FIELD, DateFormat.EXTENDED_YEAR_FIELD,
/*gAZ*/ DateFormat.JULIAN_DAY_FIELD, DateFormat.MILLISECONDS_IN_DAY_FIELD, DateFormat.TIMEZONE_RFC_FIELD,
/*v*/ DateFormat.TIMEZONE_GENERIC_FIELD,
/*v*/ DateFormat.TIMEZONE_GENERIC_FIELD,
/*c*/ DateFormat.STANDALONE_DAY_FIELD,
/*L*/ DateFormat.STANDALONE_MONTH_FIELD,
/*Qq*/ DateFormat.QUARTER_FIELD, DateFormat.STANDALONE_QUARTER_FIELD,
/*V*/ DateFormat.TIMEZONE_SPECIAL_FIELD,
/*V*/ DateFormat.TIMEZONE_SPECIAL_FIELD,
};
// Map pattern character index to DateFormat.Field
@ -761,12 +758,12 @@ public class SimpleDateFormat extends DateFormat {
};
/**
* Return a DateFormat.Field constant associated with the specified format pattern
* Returns a DateFormat.Field constant associated with the specified format pattern
* character.
*
*
* @param ch The pattern character
* @return DateFormat.Field associated with the pattern character
*
*
* @stable ICU 3.8
*/
protected DateFormat.Field patternCharToDateFormatField(char ch) {
@ -781,7 +778,7 @@ public class SimpleDateFormat extends DateFormat {
}
/**
* Format a single field, given its pattern character. Subclasses may
* Formats a single field, given its pattern character. Subclasses may
* override this method in order to modify or add formatting
* capabilities.
* @param ch the pattern character
@ -804,7 +801,7 @@ public class SimpleDateFormat extends DateFormat {
}
/**
* Format a single field; useFastFormat variant. Reuses a
* Formats a single field; useFastFormat variant. Reuses a
* StringBuffer for results instead of creating a String on the
* heap for each call.
*
@ -820,6 +817,8 @@ public class SimpleDateFormat extends DateFormat {
char ch, int count, int beginOffset,
FieldPosition pos,
Calendar cal) {
final boolean COMMONLY_USED = true;
final int maxIntCount = Integer.MAX_VALUE;
final int bufstart = buf.length();
@ -945,7 +944,8 @@ public class SimpleDateFormat extends DateFormat {
case 17: // 'z' - ZONE_OFFSET
if (count < 4) {
// "z", "zz", "zzz"
zoneString = formatData.getZoneStringFormat().getSpecificShortString(cal, true /* commonly used only */);
zoneString = formatData.getZoneStringFormat()
.getSpecificShortString(cal, COMMONLY_USED);
} else {
zoneString = formatData.getZoneStringFormat().getSpecificLongString(cal);
}
@ -997,7 +997,8 @@ public class SimpleDateFormat extends DateFormat {
case 24: // 'v' - TIMEZONE_GENERIC
if (count == 1) {
// "v"
zoneString = formatData.getZoneStringFormat().getGenericShortString(cal, true /* commonly used only */);
zoneString = formatData.getZoneStringFormat()
.getGenericShortString(cal, COMMONLY_USED);
} else if (count == 4) {
// "vvvv"
zoneString = formatData.getZoneStringFormat().getGenericLongString(cal);
@ -1009,7 +1010,7 @@ public class SimpleDateFormat extends DateFormat {
appendGMT(currentNumberFormat,buf, cal);
}
break;
case 25: // 'c' - STANDALONE DAY (use DOW_LOCAL for numeric, DAY_OF_WEEK for standalone names)
case 25: // 'c' - STANDALONE DAY (use DOW_LOCAL for numeric, DAY_OF_WEEK for standalone)
if (count < 3) {
zeroPaddingNumber(currentNumberFormat,buf, value, 1, maxIntCount);
break;
@ -1057,7 +1058,8 @@ public class SimpleDateFormat extends DateFormat {
case 29: // 'V' - TIMEZONE_SPECIAL
if (count == 1) {
// "V"
zoneString = formatData.getZoneStringFormat().getSpecificShortString(cal, false /* ignoring commonly used */);
zoneString = formatData.getZoneStringFormat()
.getSpecificShortString(cal, !COMMONLY_USED);
} else if (count == 4) {
// "VVVV"
zoneString = formatData.getZoneStringFormat().getGenericLocationString(cal);
@ -1093,7 +1095,8 @@ public class SimpleDateFormat extends DateFormat {
if (pos.getField() == PATTERN_INDEX_TO_DATE_FORMAT_FIELD[patternCharIndex]) {
pos.setBeginIndex(beginOffset);
pos.setEndIndex(beginOffset + buf.length() - bufstart);
} else if (pos.getFieldAttribute() == PATTERN_INDEX_TO_DATE_FORMAT_ATTRIBUTE[patternCharIndex]) {
} else if (pos.getFieldAttribute() ==
PATTERN_INDEX_TO_DATE_FORMAT_ATTRIBUTE[patternCharIndex]) {
pos.setBeginIndex(beginOffset);
pos.setEndIndex(beginOffset + buf.length() - bufstart);
}
@ -1121,7 +1124,8 @@ public class SimpleDateFormat extends DateFormat {
}
}
private static ICUCache<String, Object[]> PARSED_PATTERN_CACHE = new SimpleCache<String, Object[]>();
private static ICUCache<String, Object[]> PARSED_PATTERN_CACHE =
new SimpleCache<String, Object[]>();
private transient Object[] patternItems;
/*
@ -1205,7 +1209,7 @@ public class SimpleDateFormat extends DateFormat {
patternItems = items.toArray(new Object[items.size()]);
PARSED_PATTERN_CACHE.put(pattern, patternItems);
return patternItems;
}
@ -1233,7 +1237,9 @@ public class SimpleDateFormat extends DateFormat {
offset = -offset;
sign = DateFormatSymbols.OFFSET_NEGATIVE;
}
int width = offset%(60*1000) == 0 ? DateFormatSymbols.OFFSET_HM : DateFormatSymbols.OFFSET_HMS;
int width = offset%(60*1000) == 0
? DateFormatSymbols.OFFSET_HM
: DateFormatSymbols.OFFSET_HMS;
MessageFormat fmt = getGMTFormatter(sign, width);
fmt.format(new Object[] {new Long(offset)}, buf, null);
@ -1282,10 +1288,12 @@ public class SimpleDateFormat extends DateFormat {
int offset;
// Try negative Hms
fmt = getGMTFormatter(DateFormatSymbols.OFFSET_NEGATIVE, DateFormatSymbols.OFFSET_HMS);
fmt = getGMTFormatter(DateFormatSymbols.OFFSET_NEGATIVE,
DateFormatSymbols.OFFSET_HMS);
parsedObjects = fmt.parse(text, pos);
if ((parsedObjects != null) && (parsedObjects[0] instanceof Date)
&& (pos.getIndex() - start) >= getGMTFormatMinHMSLen(DateFormatSymbols.OFFSET_NEGATIVE)) {
&& (pos.getIndex() - start) >= getGMTFormatMinHMSLen(
DateFormatSymbols.OFFSET_NEGATIVE)) {
offset = (int)((Date)parsedObjects[0]).getTime();
return new Integer(-offset /* negative */);
}
@ -1295,10 +1303,12 @@ public class SimpleDateFormat extends DateFormat {
pos.setErrorIndex(-1);
// Try positive Hms
fmt = getGMTFormatter(DateFormatSymbols.OFFSET_POSITIVE, DateFormatSymbols.OFFSET_HMS);
fmt = getGMTFormatter(DateFormatSymbols.OFFSET_POSITIVE,
DateFormatSymbols.OFFSET_HMS);
parsedObjects = fmt.parse(text, pos);
if ((parsedObjects != null) && (parsedObjects[0] instanceof Date)
&& (pos.getIndex() - start) >= getGMTFormatMinHMSLen(DateFormatSymbols.OFFSET_POSITIVE)) {
&& (pos.getIndex() - start) >= getGMTFormatMinHMSLen(
DateFormatSymbols.OFFSET_POSITIVE)) {
offset = (int)((Date)parsedObjects[0]).getTime();
return new Integer(offset);
}
@ -1308,7 +1318,8 @@ public class SimpleDateFormat extends DateFormat {
pos.setErrorIndex(-1);
// Try negative Hm
fmt = getGMTFormatter(DateFormatSymbols.OFFSET_NEGATIVE, DateFormatSymbols.OFFSET_HM);
fmt = getGMTFormatter(DateFormatSymbols.OFFSET_NEGATIVE,
DateFormatSymbols.OFFSET_HM);
parsedObjects = fmt.parse(text, pos);
if ((parsedObjects != null) && (parsedObjects[0] instanceof Date)) {
offset = (int)((Date)parsedObjects[0]).getTime();
@ -1320,7 +1331,8 @@ public class SimpleDateFormat extends DateFormat {
pos.setErrorIndex(-1);
// Try positive Hm
fmt = getGMTFormatter(DateFormatSymbols.OFFSET_POSITIVE, DateFormatSymbols.OFFSET_HM);
fmt = getGMTFormatter(DateFormatSymbols.OFFSET_POSITIVE,
DateFormatSymbols.OFFSET_HM);
parsedObjects = fmt.parse(text, pos);
if ((parsedObjects != null) && (parsedObjects[0] instanceof Date)) {
offset = (int)((Date)parsedObjects[0]).getTime();
@ -1336,7 +1348,8 @@ public class SimpleDateFormat extends DateFormat {
return parseGMTDefault(text, pos, currentNumberFormat);
}
private Integer parseGMTDefault(String text, ParsePosition pos, NumberFormat currentNumberFormat) {
private Integer parseGMTDefault(String text, ParsePosition pos,
NumberFormat currentNumberFormat) {
int start = pos.getIndex();
if (start + STR_UT_LEN + 1 >= text.length()) {
@ -1487,7 +1500,9 @@ public class SimpleDateFormat extends DateFormat {
boolean res = true;
for (int sign = 0; sign < 2 && res; sign++) {
for (int width = 0; width < 2; width++) {
if (!DateFormatSymbols.DEFAULT_GMT_HOUR_PATTERNS[sign][width].equals(formatData.getGmtHourFormat(sign, width))) {
if (!DateFormatSymbols.DEFAULT_GMT_HOUR_PATTERNS[sign][width]
.equals(formatData.getGmtHourFormat(sign, width))) {
res = false;
break;
}
@ -1560,13 +1575,13 @@ public class SimpleDateFormat extends DateFormat {
/*
* Lightweight zero padding integer number format function.
*
*
* Note: This implementation is almost equivalent to format method in DateNumberFormat.
* In the method zeroPaddingNumber above should be able to use the one in DateNumberFormat,
* but, it does not help IBM J9's JIT to optimize the performance much. In simple repeative
* date format test case, having local implementation is ~10% faster than using one in
* DateNumberFormat on IBM J9 VM. On Sun Hotspot VM, I do not see such difference.
*
*
* -Yoshito
*/
private void fastZeroPaddingNumber(StringBuffer buf, int value, int minDigits, int maxDigits) {
@ -1585,7 +1600,7 @@ public class SimpleDateFormat extends DateFormat {
decimalBuf[--index] = zeroDigit;
}
int length = limit - index;
buf.append(decimalBuf, index, length);
buf.append(decimalBuf, index, length);
}
/**
@ -1664,13 +1679,13 @@ public class SimpleDateFormat extends DateFormat {
// try 4/2/2, 3/2/2, 2/2/2, and finally 1/2/2.
if (numericFieldStart == -1) {
// check if this field is followed by abutting another numeric field
if ((i + 1) < items.length
if ((i + 1) < items.length
&& (items[i + 1] instanceof PatternItem)
&& ((PatternItem)items[i + 1]).isNumeric) {
// record the first numeric field within a numeric text run
numericFieldStart = i;
numericFieldLength = field.length;
numericStartPos = pos;
numericStartPos = pos;
}
}
}
@ -1731,7 +1746,8 @@ public class SimpleDateFormat extends DateFormat {
while (idx < plen && pos < tlen) {
char pch = patl.charAt(idx);
char ich = text.charAt(pos);
if (UCharacterProperty.isRuleWhiteSpace(pch) && UCharacterProperty.isRuleWhiteSpace(ich)) {
if (UCharacterProperty.isRuleWhiteSpace(pch)
&& UCharacterProperty.isRuleWhiteSpace(ich)) {
// White space characters found in both patten and input.
// Skip contiguous white spaces.
while ((idx + 1) < plen &&
@ -1833,15 +1849,19 @@ public class SimpleDateFormat extends DateFormat {
// but following code work in most case.
tz.getOffset(localMillis, true, offsets);
if (tztype == TZTYPE_STD && offsets[1] != 0 || tztype == TZTYPE_DST && offsets[1] == 0) {
if (tztype == TZTYPE_STD && offsets[1] != 0
|| tztype == TZTYPE_DST && offsets[1] == 0) {
// Roll back one day and try it again.
// Note: This code assumes 1. timezone transition only happens once within 24 hours at max
// 2. the difference of local offsets at the transition is less than 24 hours.
// Note: This code assumes 1. timezone transition only happens
// once within 24 hours at max
// 2. the difference of local offsets at the transition is
// less than 24 hours.
tz.getOffset(localMillis - (24*60*60*1000), true, offsets);
}
}
// Now, compare the results with parsed type, either standard or daylight saving time
// Now, compare the results with parsed type, either standard or
// daylight saving time
int resolvedSavings = offsets[1];
if (tztype == TZTYPE_STD) {
if (offsets[1] != 0) {
@ -2018,15 +2038,15 @@ public class SimpleDateFormat extends DateFormat {
bestMatchLength = length;
}
}
if (bestMatch >= 0) {
cal.set(field, bestMatch * 3);
return start + bestMatchLength;
}
return -start;
}
/**
* Protected method that converts one field of the input string into a
* numeric field value in <code>cal</code>. Returns -start (for
@ -2067,7 +2087,7 @@ public class SimpleDateFormat extends DateFormat {
}
currentNumberFormat = getNumberFormat(ch);
int field = PATTERN_INDEX_TO_CALENDAR_FIELD[patternCharIndex];
// If there are any spaces here, skip over them. If we hit the end
@ -2157,9 +2177,10 @@ public class SimpleDateFormat extends DateFormat {
// while pattern uses numeric style: M or MM.
// [We computed 'value' above.]
cal.set(Calendar.MONTH, value - 1);
// When parsing month numbers from the Hebrew Calendar, we might need to adjust the month depending on whether
// or not it was a leap year. We may or may not yet know what year it is, so might have to delay checking
// until the year is parsed.
// When parsing month numbers from the Hebrew Calendar, we might need
// to adjust the month depending on whether or not it was a leap year.
// We may or may not yet know what year it is, so might have to delay
// checking until the year is parsed.
if (cal.getType().equals("hebrew") && value >= 6) {
if (cal.isSet(Calendar.YEAR)) {
if (!HebrewCalendar.isLeapYear(cal.get(Calendar.YEAR))) {
@ -2283,7 +2304,7 @@ public class SimpleDateFormat extends DateFormat {
// Check if this is an RFC822 time zone offset.
// ICU supports the standard RFC822 format [+|-]HHmm
// and its extended form [+|-]HHmmSS.
do {
int sign = 0;
char signChar = text.charAt(start);
@ -2346,8 +2367,9 @@ public class SimpleDateFormat extends DateFormat {
}
if (parsed) {
// offset was successfully parsed as either a long GMT string or RFC822 zone offset
// string. Create normalized zone ID for the offset.
// offset was successfully parsed as either a long GMT string or
// RFC822 zone offset string. Create normalized zone ID for the
// offset.
tz = ZoneMeta.getCustomTimeZone(offset);
cal.setTimeZone(tz);
return pos.getIndex();
@ -2495,7 +2517,7 @@ public class SimpleDateFormat extends DateFormat {
NumberFormat fmt) {
return parseInt(text, -1, pos, allowNegative, fmt);
}
/**
* Parse an integer using numberFormat up to maxDigits.
*/
@ -2520,7 +2542,7 @@ public class SimpleDateFormat extends DateFormat {
if (dateNumberFormat) {
((DateNumberFormat)fmt).setParsePositiveOnly(true);
}
number = fmt.parse(text, pos);
number = fmt.parse(text, pos);
if (dateNumberFormat) {
((DateNumberFormat)fmt).setParsePositiveOnly(false);
}
@ -2544,7 +2566,7 @@ public class SimpleDateFormat extends DateFormat {
return number;
}
/**
* Translate a pattern, mapping each character in the from string to the
* corresponding character in the to string.
@ -2692,7 +2714,7 @@ public class SimpleDateFormat extends DateFormat {
}
stream.defaultWriteObject();
}
/**
* Override readObject.
*/
@ -2719,10 +2741,10 @@ public class SimpleDateFormat extends DateFormat {
/**
* Format the object to an attributed string, and return the corresponding iterator
* Overrides superclass method.
*
*
* @param obj The object to format
* @return <code>AttributedCharacterIterator</code> describing the formatted value.
*
*
* @stable ICU 3.8
*/
public AttributedCharacterIterator formatToCharacterIterator(Object obj) {
@ -2733,7 +2755,7 @@ public class SimpleDateFormat extends DateFormat {
calendar.setTime((Date)obj);
} else if (obj instanceof Number) {
calendar.setTimeInMillis(((Number)obj).longValue());
} else {
} else {
throw new IllegalArgumentException("Cannot format given Object as a Date");
}
StringBuffer toAppendTo = new StringBuffer();
@ -2742,7 +2764,7 @@ public class SimpleDateFormat extends DateFormat {
format(cal, toAppendTo, pos, attributes);
AttributedString as = new AttributedString(toAppendTo.toString());
// add DateFormat field attributes to the AttributedString
for (int i = 0; i < attributes.size(); i++) {
FieldPosition fp = attributes.get(i);
@ -2759,20 +2781,20 @@ public class SimpleDateFormat extends DateFormat {
*
* @return locale in this simple date formatter
*/
ULocale getLocale()
ULocale getLocale()
{
return locale;
}
/**
* Check whether the 'field' is smaller than all the fields covered in
* pattern, return true if it is.
* The sequence of calendar field,
* from large to small is: ERA, YEAR, MONTH, DATE, AM_PM, HOUR, MINUTE,...
* @param field the calendar field need to check against
* @return true if the 'field' is smaller than all the fields
* @return true if the 'field' is smaller than all the fields
* covered in pattern. false otherwise.
*/
@ -2788,7 +2810,7 @@ public class SimpleDateFormat extends DateFormat {
* from large to small is: ERA, YEAR, MONTH, DATE, AM_PM, HOUR, MINUTE,...
* @param pattern the pattern to check against
* @param field the calendar field need to check against
* @return true if the 'field' is smaller than all the fields
* @return true if the 'field' is smaller than all the fields
* covered in pattern. false otherwise.
*/
static boolean isFieldUnitIgnored(String pattern, int field) {
@ -2798,7 +2820,7 @@ public class SimpleDateFormat extends DateFormat {
boolean inQuote = false;
char prevCh = 0;
int count = 0;
for (int i = 0; i < pattern.length(); ++i) {
ch = pattern.charAt(i);
if (ch != prevCh && count > 0) {
@ -2814,7 +2836,7 @@ public class SimpleDateFormat extends DateFormat {
} else {
inQuote = ! inQuote;
}
} else if ( ! inQuote && ((ch >= 0x0061 /*'a'*/ && ch <= 0x007A /*'z'*/)
} else if ( ! inQuote && ((ch >= 0x0061 /*'a'*/ && ch <= 0x007A /*'z'*/)
|| (ch >= 0x0041 /*'A'*/ && ch <= 0x005A /*'Z'*/))) {
prevCh = ch;
++count;
@ -2832,7 +2854,7 @@ public class SimpleDateFormat extends DateFormat {
/**
* Format date interval by algorithm.
* Format date interval by algorithm.
* It is supposed to be used only by CLDR survey tool.
*
* @param fromCalendar calendar set to the from date in date interval
@ -2859,7 +2881,7 @@ public class SimpleDateFormat extends DateFormat {
if ( !fromCalendar.isEquivalentTo(toCalendar) ) {
throw new IllegalArgumentException("can not format on two different calendars");
}
Object[] items = getPatternItems();
int diffBegin = -1;
int diffEnd = -1;
@ -2872,13 +2894,13 @@ public class SimpleDateFormat extends DateFormat {
diffBegin = i;
break;
}
}
if ( diffBegin == -1 ) {
}
if ( diffBegin == -1 ) {
// no difference, single date format
return format(fromCalendar, appendTo, pos);
}
// look for end of difference
for (int i = items.length-1; i >= diffBegin; i--) {
if ( diffCalFieldValue(fromCalendar, toCalendar, items, i) ) {
@ -2904,20 +2926,20 @@ public class SimpleDateFormat extends DateFormat {
for (int i = diffBegin; i <= diffEnd; i++) {
if ( items[i] instanceof String) {
continue;
}
}
PatternItem item = (PatternItem)items[i];
char ch = item.type;
char ch = item.type;
int patternCharIndex = -1;
if ('A' <= ch && ch <= 'z') {
patternCharIndex = PATTERN_CHAR_TO_LEVEL[(int)ch - PATTERN_CHAR_BASE];
}
if (patternCharIndex == -1) {
throw new IllegalArgumentException("Illegal pattern character " +
"'" + ch + "' in \"" +
pattern + '"');
}
if ( patternCharIndex < highestLevel ) {
highestLevel = patternCharIndex;
}
@ -2933,8 +2955,8 @@ public class SimpleDateFormat extends DateFormat {
break;
}
}
for (int i = items.length-1; i > diffEnd; i--) {
if ( lowerLevel(items, i, highestLevel) ) {
diffEnd = i;
@ -2967,9 +2989,11 @@ public class SimpleDateFormat extends DateFormat {
} else {
PatternItem item = (PatternItem)items[i];
if (useFastFormat) {
subFormat(appendTo, item.type, item.length, appendTo.length(), pos, fromCalendar);
subFormat(appendTo, item.type, item.length, appendTo.length(), pos,
fromCalendar);
} else {
appendTo.append(subFormat(item.type, item.length, appendTo.length(), pos, formatData, fromCalendar));
appendTo.append(subFormat(item.type, item.length, appendTo.length(), pos,
formatData, fromCalendar));
}
}
}
@ -2985,7 +3009,8 @@ public class SimpleDateFormat extends DateFormat {
if (useFastFormat) {
subFormat(appendTo, item.type, item.length, appendTo.length(), pos, toCalendar);
} else {
appendTo.append(subFormat(item.type, item.length, appendTo.length(), pos, formatData, toCalendar));
appendTo.append(subFormat(item.type, item.length, appendTo.length(), pos,
formatData, toCalendar));
}
}
}
@ -3005,7 +3030,7 @@ public class SimpleDateFormat extends DateFormat {
* @param i the i-th item in pattern items
* @exception IllegalArgumentException when there is non-recognized
* pattern letter
* @return true is i-th item in 2 calendar is in different
* @return true is i-th item in 2 calendar is in different
* value, false otherwise.
*/
private boolean diffCalFieldValue(Calendar fromCalendar,
@ -3014,20 +3039,20 @@ public class SimpleDateFormat extends DateFormat {
int i) throws IllegalArgumentException {
if ( items[i] instanceof String) {
return false;
}
}
PatternItem item = (PatternItem)items[i];
char ch = item.type;
char ch = item.type;
int patternCharIndex = -1;
if ('A' <= ch && ch <= 'z') {
patternCharIndex = PATTERN_CHAR_TO_INDEX[(int)ch - PATTERN_CHAR_BASE];
}
if (patternCharIndex == -1) {
throw new IllegalArgumentException("Illegal pattern character " +
"'" + ch + "' in \"" +
pattern + '"');
}
final int field = PATTERN_INDEX_TO_CALENDAR_FIELD[patternCharIndex];
int value = fromCalendar.get(field);
int value_2 = toCalendar.get(field);
@ -3052,27 +3077,27 @@ public class SimpleDateFormat extends DateFormat {
* @return true if i-th pattern item is lower than 'level',
* false otherwise
*/
private boolean lowerLevel(Object[] items, int i, int level)
private boolean lowerLevel(Object[] items, int i, int level)
throws IllegalArgumentException {
if ( items[i] instanceof String) {
return false;
}
}
PatternItem item = (PatternItem)items[i];
char ch = item.type;
char ch = item.type;
int patternCharIndex = -1;
if ('A' <= ch && ch <= 'z') {
patternCharIndex = PATTERN_CHAR_TO_LEVEL[(int)ch - PATTERN_CHAR_BASE];
}
if (patternCharIndex == -1) {
throw new IllegalArgumentException("Illegal pattern character " +
"'" + ch + "' in \"" +
pattern + '"');
}
if ( patternCharIndex >= level ) {
return true;
}
}
return false;
}
@ -3093,7 +3118,7 @@ public class SimpleDateFormat extends DateFormat {
numberFormatters = new HashMap<String, NumberFormat>();
overrideMap = new HashMap<Character, String>();
processOverrideString(loc,override);
processOverrideString(loc,override);
}
@ -3132,7 +3157,7 @@ public class SimpleDateFormat extends DateFormat {
ULocale ovrLoc = new ULocale(loc.getBaseName()+"@numbers="+nsName);
NumberFormat nf = NumberFormat.createInstance(ovrLoc,NumberFormat.NUMBERSTYLE);
if (fullOverride) {
setNumberFormat(nf);
} else {

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2007-2009, International Business Machines Corporation and *
* Copyright (C) 2007-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -14,14 +14,15 @@ import java.util.List;
import com.ibm.icu.impl.Grego;
/**
* <code>BasicTimeZone</code> is an abstract class extending <code>TimeZone</code>.
* This class provides some additional methods to access time zone transitions
* and rules. All ICU <code>TimeZone</code> concrete subclasses extend this
* class.
*
* {@icu} BasicTimeZone extends <code>TimeZone</code> with additional methods to access
* time zone transitions and rules. All ICU <code>TimeZone</code> concrete subclasses
* extend this class. APIs added to <code>java.util.TimeZone</code> by
* <code>BasicTimeZone</code> are annotated with <strong>'<font
* style="color:red">[icu]</font>'</strong>.
*
* @see com.ibm.icu.util.TimeZoneRule
* @see com.ibm.icu.util.TimeZoneTransition
*
*
* @stable ICU 3.8
*/
public abstract class BasicTimeZone extends TimeZone {
@ -31,47 +32,47 @@ public abstract class BasicTimeZone extends TimeZone {
private static final long MILLIS_PER_YEAR = 365*24*60*60*1000L;
/**
* Gets the first time zone transition after the base time.
*
* {@icu} Returns the first time zone transition after the base time.
*
* @param base The base time.
* @param inclusive Whether the base time is inclusive or not.
*
*
* @return A <code>Date</code> holding the first time zone transition time
* after the given base time, or null if no time zone transitions
* are available after the base time.
*
*
* @stable ICU 3.8
*/
public abstract TimeZoneTransition getNextTransition(long base, boolean inclusive);
/**
* Gets the last time zone transition before the base time.
*
* {@icu} Returns the last time zone transition before the base time.
*
* @param base The base time.
* @param inclusive Whether the base time is inclusive or not.
*
*
* @return A <code>Date</code> holding the last time zone transition time
* before the given base time, or null if no time zone transitions
* are available before the base time.
*
*
* @stable ICU 3.8
*/
public abstract TimeZoneTransition getPreviousTransition(long base, boolean inclusive);
/**
* Checks if the time zone has equivalent transitions in the time range.
* {@icu} Checks if the time zone has equivalent transitions in the time range.
* This method returns true when all of transition times, from/to standard
* offsets and DST savings used by this time zone match the other in the
* time range.
*
*
* @param tz The instance of <code>TimeZone</code>
* @param start The start time of the evaluated time range (inclusive)
* @param end The end time of the evaluated time range (inclusive)
*
*
* @return true if the other time zone has the equivalent transitions in the
* time range. When tz is not a <code>BasicTimeZone</code>, this method
* returns false.
*
*
* @stable ICU 3.8
*/
public boolean hasEquivalentTransitions(TimeZone tz, long start, long end) {
@ -79,23 +80,28 @@ public abstract class BasicTimeZone extends TimeZone {
}
/**
* Checks if the time zone has equivalent transitions in the time range.
* {@icu} Checks if the time zone has equivalent transitions in the time range.
* This method returns true when all of transition times, from/to standard
* offsets and DST savings used by this time zone match the other in the
* time range.
*
*
* @param tz The instance of <code>TimeZone</code>
* @param start The start time of the evaluated time range (inclusive)
* @param end The end time of the evaluated time range (inclusive)
* @param ignoreDstAmount When true, any transitions with only daylight saving amount changes will be ignored, except either of them is zero. For example, a transition from rawoffset 3:00/dstsavings 1:00 to rawoffset 2:00/dstsavings 2:00 is excluded from the comparison, but a transtion from rawoffset 2:00/dstsavings 1:00 to rawoffset 3:00/dstsavings 0:00 is included.
*
* @param ignoreDstAmount When true, any transitions with only daylight saving amount
* changes will be ignored, except either of them is zero. For example, a transition
* from rawoffset 3:00/dstsavings 1:00 to rawoffset 2:00/dstsavings 2:00 is excluded
* from the comparison, but a transtion from rawoffset 2:00/dstsavings 1:00 to
* rawoffset 3:00/dstsavings 0:00 is included.
*
* @return true if the other time zone has the equivalent transitions in the
* time range. When tz is not a <code>BasicTimeZone</code>, this method
* returns false.
*
*
* @stable ICU 3.8
*/
public boolean hasEquivalentTransitions(TimeZone tz, long start, long end, boolean ignoreDstAmount) {
public boolean hasEquivalentTransitions(TimeZone tz, long start, long end,
boolean ignoreDstAmount) {
if (hasSameRules(tz)) {
return true;
}
@ -119,7 +125,7 @@ public abstract class BasicTimeZone extends TimeZone {
} else {
if (offsets1[0] != offsets2[0] || offsets1[1] != offsets2[1]) {
return false;
}
}
}
// Check transitions in the range
@ -185,31 +191,31 @@ public abstract class BasicTimeZone extends TimeZone {
}
/**
* Gets the array of <code>TimeZoneRule</code> which represents the rule
* {@icu} Returns the array of <code>TimeZoneRule</code> which represents the rule
* of this time zone object. The first element in the result array will
* be the <code>InitialTimeZoneRule</code> instance for the initial rule.
* The rest will be either <code>AnnualTimeZoneRule</code> or
* <code>TimeArrayTimeZoneRule</code> instances representing transitions.
*
*
* @return The array of <code>TimeZoneRule</code> which represents this
* time zone.
*
*
* @stable ICU 3.8
*/
public abstract TimeZoneRule[] getTimeZoneRules();
/**
* Gets the array of <code>TimeZoneRule</code> which represents the rule
* {@icu} Returns the array of <code>TimeZoneRule</code> which represents the rule
* of this time zone object since the specified start time. The first
* element in the result array will be the <code>InitialTimeZoneRule</code>
* instance for the initial rule. The rest will be either
* <code>AnnualTimeZoneRule</code> or <code>TimeArrayTimeZoneRule</code>
* instances representing transitions.
*
*
* @param start The start time (inclusive).
* @return The array of <code>TimeZoneRule</code> which represents this
* time zone since the start time.
*
*
* @stable ICU 3.8
*/
public TimeZoneRule[] getTimeZoneRules(long start) {
@ -345,7 +351,7 @@ public abstract class BasicTimeZone extends TimeZone {
}
/**
* Gets the array of <code>TimeZoneRule</code> which represents the rule of
* {@icu} Returns the array of <code>TimeZoneRule</code> which represents the rule of
* this time zone object near the specified date. Some applications are not
* capable to handle historic time zone rule changes. Also some applications
* can only handle certain type of rule definitions. This method returns
@ -363,7 +369,7 @@ public abstract class BasicTimeZone extends TimeZone {
* <code>InitialTimeZoneRule</code> object, or a pair of <code>AnnualTimeZoneRule</code>
* with a single <code>InitialTimeZoneRule</code>. The first element in the
* array is always a <code>InitialTimeZoneRule</code>.
*
*
* @stable ICU 3.8
*/
public TimeZoneRule[] getSimpleTimeZoneRulesNear(long date) {
@ -411,14 +417,17 @@ public abstract class BasicTimeZone extends TimeZone {
// Check if the next next transition is either DST->STD or STD->DST
// and within roughly 1 year from the next transition
if (((tr.getFrom().getDSTSavings() == 0 && tr.getTo().getDSTSavings() != 0)
|| (tr.getFrom().getDSTSavings() != 0 && tr.getTo().getDSTSavings() == 0))
&& nextTransitionTime + MILLIS_PER_YEAR > tr.getTime()) {
|| (tr.getFrom().getDSTSavings() != 0
&& tr.getTo().getDSTSavings() == 0))
&& nextTransitionTime + MILLIS_PER_YEAR > tr.getTime()) {
// Generate another DOW rule
dtfields = Grego.timeToFields(tr.getTime()
+ tr.getFrom().getRawOffset() + tr.getFrom().getDSTSavings(), dtfields);
weekInMonth = Grego.getDayOfWeekInMonth(dtfields[0], dtfields[1], dtfields[2]);
dtr = new DateTimeRule(dtfields[1], weekInMonth, dtfields[3], dtfields[5],
DateTimeRule.WALL_TIME);
+ tr.getFrom().getRawOffset() + tr.getFrom().getDSTSavings(),
dtfields);
weekInMonth = Grego.getDayOfWeekInMonth(dtfields[0], dtfields[1],
dtfields[2]);
dtr = new DateTimeRule(dtfields[1], weekInMonth, dtfields[3],
dtfields[5], DateTimeRule.WALL_TIME);
secondRule = new AnnualTimeZoneRule(tr.getTo().getName(),
tr.getTo().getRawOffset(), tr.getTo().getDSTSavings(),
dtr, dtfields[0] - 1, AnnualTimeZoneRule.MAX_YEAR);
@ -442,23 +451,27 @@ public abstract class BasicTimeZone extends TimeZone {
// Check if the previous transition is either DST->STD or STD->DST.
// The actual transition time does not matter here.
if ((tr.getFrom().getDSTSavings() == 0 && tr.getTo().getDSTSavings() != 0)
|| (tr.getFrom().getDSTSavings() != 0 && tr.getTo().getDSTSavings() == 0)) {
|| (tr.getFrom().getDSTSavings() != 0
&& tr.getTo().getDSTSavings() == 0)) {
// Generate another DOW rule
dtfields = Grego.timeToFields(tr.getTime()
+ tr.getFrom().getRawOffset() + tr.getFrom().getDSTSavings(), dtfields);
weekInMonth = Grego.getDayOfWeekInMonth(dtfields[0], dtfields[1], dtfields[2]);
dtr = new DateTimeRule(dtfields[1], weekInMonth, dtfields[3], dtfields[5],
DateTimeRule.WALL_TIME);
+ tr.getFrom().getRawOffset() + tr.getFrom().getDSTSavings(),
dtfields);
weekInMonth = Grego.getDayOfWeekInMonth(dtfields[0], dtfields[1],
dtfields[2]);
dtr = new DateTimeRule(dtfields[1], weekInMonth, dtfields[3],
dtfields[5], DateTimeRule.WALL_TIME);
// second rule raw/dst offsets should match raw/dst offsets
// at the given time
secondRule = new AnnualTimeZoneRule(tr.getTo().getName(),
initialRaw, initialDst,
dtr, annualRules[0].getStartYear() - 1, AnnualTimeZoneRule.MAX_YEAR);
secondRule = new AnnualTimeZoneRule(
tr.getTo().getName(), initialRaw, initialDst, dtr,
annualRules[0].getStartYear() - 1, AnnualTimeZoneRule.MAX_YEAR);
// Check if this rule start after the first rule after the specified date
Date d = secondRule.getNextStart(date,
tr.getFrom().getRawOffset(), tr.getFrom().getDSTSavings(), false);
// Check if this rule start after the first rule after the
// specified date
Date d = secondRule.getNextStart(date, tr.getFrom().getRawOffset(),
tr.getFrom().getDSTSavings(), false);
if (d.getTime() > nextTransitionTime) {
// We can use this rule as the second transition rule
annualRules[1] = secondRule;
@ -506,7 +519,7 @@ public abstract class BasicTimeZone extends TimeZone {
}
/**
* The time type option for standard time used by
* {@icu} The time type option for standard time used by
* {@link #getOffsetFromLocal(long, int, int, int[])}
* @internal
* @deprecated This API is ICU internal only.
@ -514,7 +527,7 @@ public abstract class BasicTimeZone extends TimeZone {
public static final int LOCAL_STD = 0x01;
/**
* The time type option for daylight saving time used by
* {@icu} The time type option for daylight saving time used by
* {@link #getOffsetFromLocal(long, int, int, int[])}
* @internal
* @deprecated This API is ICU internal only.
@ -522,7 +535,7 @@ public abstract class BasicTimeZone extends TimeZone {
public static final int LOCAL_DST = 0x03;
/**
* The option designate former time to be used by
* {@icu} The option designate former time to be used by
* {@link #getOffsetFromLocal(long, int, int, int[])}
* @internal
* @deprecated This API is ICU internal only.
@ -530,7 +543,7 @@ public abstract class BasicTimeZone extends TimeZone {
public static final int LOCAL_FORMER = 0x04;
/**
* The option designate latter time to be used by
* {@icu} The option designate latter time to be used by
* {@link #getOffsetFromLocal(long, int, int, int[])}
* @internal
* @deprecated This API is ICU internal only.
@ -538,7 +551,7 @@ public abstract class BasicTimeZone extends TimeZone {
public static final int LOCAL_LATTER = 0x0C;
/**
* The bit mask for the time type option used by
* {@icu} The bit mask for the time type option used by
* {@link #getOffsetFromLocal(long, int, int, int[])}
* @internal
* @deprecated This API is ICU internal only.
@ -546,7 +559,7 @@ public abstract class BasicTimeZone extends TimeZone {
protected static final int STD_DST_MASK = 0x03;
/**
* The bit mask for the former/latter option used by
* {@icu} The bit mask for the former/latter option used by
* {@link #getOffsetFromLocal(long, int, int, int[])}
* @internal
* @deprecated This API is ICU internal only.
@ -554,7 +567,7 @@ public abstract class BasicTimeZone extends TimeZone {
protected static final int FORMER_LATTER_MASK = 0x0C;
/**
* Get time zone offsets from local wall time.
* {@icu} Returns time zone offsets from local wall time.
* @internal
* @deprecated This API is ICU internal only.
*/

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 1996-2009, International Business Machines
* Copyright (C) 1996-2010, International Business Machines
* Corporation and others. All Rights Reserved.
*/
@ -9,21 +9,20 @@ import java.util.Date;
import java.util.Locale;
/**
* <code>GregorianCalendar</code> is a concrete subclass of
* {@icuenhanced java.util.GregorianCalendar}.{@icu _usage_}
*
* <p><code>GregorianCalendar</code> is a concrete subclass of
* {@link Calendar}
* and provides the standard calendar used by most of the world.
*
* <p>
* The standard (Gregorian) calendar has 2 eras, BC and AD.
* <p>The standard (Gregorian) calendar has 2 eras, BC and AD.
*
* <p>
* This implementation handles a single discontinuity, which corresponds by
* <p>This implementation handles a single discontinuity, which corresponds by
* default to the date the Gregorian calendar was instituted (October 15, 1582
* in some countries, later in others). The cutover date may be changed by the
* caller by calling <code>setGregorianChange()</code>.
*
* <p>
* Historically, in those countries which adopted the Gregorian calendar first,
* <p>Historically, in those countries which adopted the Gregorian calendar first,
* October 4, 1582 was thus followed by October 15, 1582. This calendar models
* this correctly. Before the Gregorian cutover, <code>GregorianCalendar</code>
* implements the Julian calendar. The only difference between the Gregorian
@ -31,8 +30,7 @@ import java.util.Locale;
* leap years every four years, whereas the Gregorian calendar omits century
* years which are not divisible by 400.
*
* <p>
* <code>GregorianCalendar</code> implements <em>proleptic</em> Gregorian and
* <p><code>GregorianCalendar</code> implements <em>proleptic</em> Gregorian and
* Julian calendars. That is, dates are computed by extrapolating the current
* rules indefinitely far backward and forward in time. As a result,
* <code>GregorianCalendar</code> may be used for all years to generate
@ -42,8 +40,7 @@ import java.util.Locale;
* leap year rules were applied irregularly, and before 45 BC the Julian
* calendar did not even exist.
*
* <p>
* Prior to the institution of the Gregorian calendar, New Year's Day was
* <p>Prior to the institution of the Gregorian calendar, New Year's Day was
* March 25. To avoid confusion, this calendar always uses January 1. A manual
* adjustment may be made if desired for dates that are prior to the Gregorian
* changeover and which fall between January 1 and March 24.
@ -358,7 +355,7 @@ public class GregorianCalendar extends Calendar {
}
/**
* Constructs a GregorianCalendar based on the current time
* {@icu} Constructs a GregorianCalendar based on the current time
* in the default time zone with the given locale.
* @param locale the given ulocale.
* @stable ICU 3.2
@ -368,7 +365,7 @@ public class GregorianCalendar extends Calendar {
}
/**
* Constructs a GregorianCalendar based on the current time
* {@icu} Constructs a GregorianCalendar based on the current time
* in the given time zone with the given locale.
* @param zone the given time zone.
* @param aLocale the given locale.

View file

@ -1,6 +1,6 @@
/*
******************************************************************************
* Copyright (C) 1996-2004, International Business Machines Corporation and *
* Copyright (C) 1996-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
******************************************************************************
*/
@ -8,23 +8,23 @@
package com.ibm.icu.util;
/**
* <p>Interface for enabling iteration over sets of <int index, int value>,
* where index is the sorted integer index in ascending order and value, its
* <p>Interface for enabling iteration over sets of &lt;int index, int value>,
* where index is the sorted integer index in ascending order and value, its
* associated integer value.</p>
* <p>The result for each iteration is the consecutive range of
* <int index, int value> with the same value. Result is represented by
* <start, limit, value> where</p>
* <p>The result for each iteration is the consecutive range of
* &lt;int index, int value> with the same value. Result is represented by
* &lt;start, limit, value> where</p>
* <ul>
* <li> start is the starting integer of the result range
* <li> limit is 1 after the maximum integer that follows start, such that
* all integers between start and (limit - 1), inclusive, have the same
* all integers between start and (limit - 1), inclusive, have the same
* associated integer value.
* <li> value is the integer value that all integers from start to (limit - 1)
* <li> value is the integer value that all integers from start to (limit - 1)
* share in common.
* </ul>
* <p>
* Hence value(start) = value(start + 1) = .... = value(start + n) = .... =
* value(limit - 1). However value(start -1) != value(start) and
* value(limit - 1). However value(start -1) != value(start) and
* value(limit) != value(start).
* </p>
* <p>Most implementations will be created by factory methods, such as the
@ -35,10 +35,10 @@ package com.ibm.icu.util;
* RangeValueIterator iterator = UCharacter.getTypeIterator();
* RangeValueIterator.Element result = new RangeValueIterator.Element();
* while (iterator.next(result)) {
* System.out.println("Codepoint \\u" +
* Integer.toHexString(result.start) +
* System.out.println("Codepoint \\u" +
* Integer.toHexString(result.start) +
* " to codepoint \\u" +
* Integer.toHexString(result.limit - 1) +
* Integer.toHexString(result.limit - 1) +
* " has the character type " + result.value);
* }
* </pre>
@ -48,7 +48,7 @@ package com.ibm.icu.util;
public interface RangeValueIterator
{
// public inner class ---------------------------------------------
/**
* Return result wrapper for com.ibm.icu.util.RangeValueIterator.
* Stores the start and limit of the continous result range and the
@ -58,15 +58,15 @@ public interface RangeValueIterator
public class Element
{
// public data member ---------------------------------------------
/**
* Starting integer of the continuous result range that has the same
* Starting integer of the continuous result range that has the same
* value
* @stable ICU 2.6
*/
public int start;
/**
* (End + 1) integer of continuous result range that has the same
* (End + 1) integer of continuous result range that has the same
* value
* @stable ICU 2.6
*/
@ -74,26 +74,26 @@ public interface RangeValueIterator
/**
* Gets the common value of the continous result range
* @stable ICU 2.6
*/
*/
public int value;
// public constructor --------------------------------------------
/**
* Empty default constructor to make javadoc happy
* @stable ICU 2.4
*/
public Element()
public Element()
{
}
}
// public methods -------------------------------------------------
/**
* <p>Gets the next maximal result range with a common value and returns
* <p>Returns the next maximal result range with a common value and returns
* true if we are not at the end of the iteration, false otherwise.</p>
* <p>If the return boolean is a false, the contents of elements will not
* <p>If this returns a false, the contents of elements will not
* be updated.</p>
* @param element for storing the result range and value
* @return true if we are not at the end of the iteration, false otherwise.
@ -101,7 +101,7 @@ public interface RangeValueIterator
* @stable ICU 2.6
*/
public boolean next(Element element);
/**
* Resets the iterator to the beginning of the iteration.
* @stable ICU 2.6

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 1996-2009, International Business Machines
* Copyright (C) 1996-2010, International Business Machines
* Corporation and others. All Rights Reserved.
*/
@ -11,15 +11,16 @@ import java.util.Date;
import com.ibm.icu.impl.Grego;
/**
* <code>SimpleTimeZone</code> is a concrete subclass of <code>TimeZone</code>
* {@icuenhanced java.util.SimpleTimeZone}.{@icu _usage_}
*
* <p><code>SimpleTimeZone</code> is a concrete subclass of <code>TimeZone</code>
* that represents a time zone for use with a Gregorian calendar. This
* class does not handle historical changes.
*
* <P>
* Use a negative value for <code>dayOfWeekInMonth</code> to indicate that
* <code>SimpleTimeZone</code> should count from the end of the month backwards.
* For example, if Daylight Savings Time starts or ends at the last Sunday in a month,
* use <code>dayOfWeekInMonth = -1</code> along with <code>dayOfWeek = Calendar.SUNDAY</code>
* <p>Use a negative value for <code>dayOfWeekInMonth</code> to indicate that
* <code>SimpleTimeZone</code> should count from the end of the month backwards. For
* example, if Daylight Savings Time starts or ends at the last Sunday in a month, use
* <code>dayOfWeekInMonth = -1</code> along with <code>dayOfWeek = Calendar.SUNDAY</code>
* to specify the rule.
*
* @see Calendar
@ -70,7 +71,7 @@ public class SimpleTimeZone extends BasicTimeZone {
}
/**
* Construct a SimpleTimeZone with the given base time zone offset from
* Constructs a SimpleTimeZone with the given base time zone offset from
* GMT, time zone ID, time to start and end the daylight time. Timezone IDs
* can be obtained from TimeZone.getAvailableIDs. Normally you should use
* TimeZone.getDefault to create a TimeZone. For a time zone that does not
@ -123,7 +124,7 @@ public class SimpleTimeZone extends BasicTimeZone {
* @param endTime The daylight savings ending time in local wall time,
* which is daylight time in this case. Please see the
* member description for an example.
* @exception IllegalArgumentException the month, day, dayOfWeek, or time
* @throws IllegalArgumentException the month, day, dayOfWeek, or time
* parameters are out of range for the start or end rule
* @stable ICU 2.0
*/
@ -140,11 +141,11 @@ public class SimpleTimeZone extends BasicTimeZone {
}
/**
* Construct a SimpleTimeZone with the given base time zone offset from
* Constructs a SimpleTimeZone with the given base time zone offset from
* GMT, time zone ID, time and its mode to start and end the daylight time.
* The mode specifies either {@link #WALL_TIME} or {@link #STANDARD_TIME}
* or {@link #UTC_TIME}.
*
*
* @param rawOffset The given base time zone offset to GMT.
* @param ID The time zone ID which is obtained from
* TimeZone.getAvailableIDs.
@ -170,7 +171,7 @@ public class SimpleTimeZone extends BasicTimeZone {
* member description for an example.
* @param endTimeMode The mode of the end time specified by endTime.
* @param dstSavings The amount of time in ms saved during DST.
* @exception IllegalArgumentException the month, day, dayOfWeek, or time
* @throws IllegalArgumentException the month, day, dayOfWeek, or time
* parameters are out of range for the start or end rule
* @stable ICU 3.8
*/
@ -216,7 +217,7 @@ public class SimpleTimeZone extends BasicTimeZone {
* which is daylight time in this case. Please see the
* member description for an example.
* @param dstSavings The amount of time in ms saved during DST.
* @exception IllegalArgumentException the month, day, dayOfWeek, or time
* @throws IllegalArgumentException the month, day, dayOfWeek, or time
* parameters are out of range for the start or end rule
* @stable ICU 2.0
*/
@ -229,14 +230,13 @@ public class SimpleTimeZone extends BasicTimeZone {
startTime, WALL_TIME,
endMonth, endDay, endDayOfWeek,
endTime, WALL_TIME,
dstSavings);
dstSavings);
super.setID(ID);
}
/**
* {@inheritDoc}
*
*
* @stable ICU 3.8
*/
public void setID(String ID) {
@ -257,7 +257,7 @@ public class SimpleTimeZone extends BasicTimeZone {
transitionRulesInitialized = false;
}
/**
* Overrides TimeZone
* Gets the GMT offset for this time zone.
@ -300,7 +300,7 @@ public class SimpleTimeZone extends BasicTimeZone {
* @param time The daylight savings starting time in local wall
* time, which is standard time in this case. Please see
* the member description for an example.
* @exception IllegalArgumentException the month, dayOfWeekInMonth,
* @throws IllegalArgumentException the month, dayOfWeekInMonth,
* dayOfWeek, or time parameters are out of range
* @stable ICU 2.0
*/
@ -309,11 +309,12 @@ public class SimpleTimeZone extends BasicTimeZone {
getSTZInfo().setStart(month, dayOfWeekInMonth, dayOfWeek, time, -1, false);
setStartRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME);
}
/**
* Sets the daylight savings starting rule. For example, in the U.S., Daylight Savings
* Time starts at the second Sunday in March, at 2 AM in standard time.
* Therefore, you can set the start rule by calling:
* setStartRule(Calendar.MARCH, 2, Calendar.SUNDAY, 2*60*60*1000);
* <code>setStartRule(Calendar.MARCH, 2, Calendar.SUNDAY, 2*60*60*1000);</code>
* The dayOfWeekInMonth and dayOfWeek parameters together specify how to calculate
* the exact starting date. Their exact meaning depend on their respective signs,
* allowing various types of rules to be constructed, as follows:<ul>
@ -347,9 +348,7 @@ public class SimpleTimeZone extends BasicTimeZone {
* @param time the daylight savings starting time. Please see the member
* description for an example.
*/
private void setStartRule(int month, int dayOfWeekInMonth, int dayOfWeek, int time, int mode)
{
private void setStartRule(int month, int dayOfWeekInMonth, int dayOfWeek, int time, int mode) {
startMonth = month;
startDay = dayOfWeekInMonth;
startDayOfWeek = dayOfWeek;
@ -359,6 +358,7 @@ public class SimpleTimeZone extends BasicTimeZone {
transitionRulesInitialized = false;
}
/**
* Sets the DST start rule to a fixed date within a month.
*
@ -367,7 +367,7 @@ public class SimpleTimeZone extends BasicTimeZone {
* @param time The time of that day (number of millis after midnight)
* when DST takes effect in local wall time, which is
* standard time in this case.
* @exception IllegalArgumentException the month,
* @throws IllegalArgumentException the month,
* dayOfMonth, or time parameters are out of range
* @stable ICU 2.0
*/
@ -391,7 +391,7 @@ public class SimpleTimeZone extends BasicTimeZone {
* @param after If true, this rule selects the first dayOfWeek on
* or after dayOfMonth. If false, this rule selects
* the last dayOfWeek on or before dayOfMonth.
* @exception IllegalArgumentException the month, dayOfMonth,
* @throws IllegalArgumentException the month, dayOfMonth,
* dayOfWeek, or time parameters are out of range
* @stable ICU 2.0
*/
@ -417,13 +417,13 @@ public class SimpleTimeZone extends BasicTimeZone {
* @param time The daylight savings ending time in local wall time,
* which is daylight time in this case. Please see the
* member description for an example.
* @exception IllegalArgumentException the month, dayOfWeekInMonth,
* @throws IllegalArgumentException the month, dayOfWeekInMonth,
* dayOfWeek, or time parameters are out of range
* @stable ICU 2.0
*/
public void setEndRule(int month, int dayOfWeekInMonth, int dayOfWeek, int time) {
getSTZInfo().setEnd(month, dayOfWeekInMonth, dayOfWeek, time, -1, false);
setEndRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME);
setEndRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME);
}
/**
@ -434,7 +434,7 @@ public class SimpleTimeZone extends BasicTimeZone {
* @param time The time of that day (number of millis after midnight)
* when DST ends in local wall time, which is daylight
* time in this case.
* @exception IllegalArgumentException the month,
* @throws IllegalArgumentException the month,
* dayOfMonth, or time parameters are out of range
* @stable ICU 2.0
*/
@ -456,7 +456,7 @@ public class SimpleTimeZone extends BasicTimeZone {
* @param after If true, this rule selects the first dayOfWeek on
* or after dayOfMonth. If false, this rule selects
* the last dayOfWeek on or before dayOfMonth.
* @exception IllegalArgumentException the month, dayOfMonth,
* @throws IllegalArgumentException the month, dayOfMonth,
* dayOfWeek, or time parameters are out of range
* @stable ICU 2.0
*/
@ -464,10 +464,12 @@ public class SimpleTimeZone extends BasicTimeZone {
getSTZInfo().setEnd(month, -1, dayOfWeek, time, dayOfMonth, after);
setEndRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after);
}
private void setEndRule(int month, int dayOfMonth, int dayOfWeek,
private void setEndRule(int month, int dayOfMonth, int dayOfWeek,
int time, int mode, boolean after){
setEndRule(month, after ? dayOfMonth : -dayOfMonth, -dayOfWeek, time, mode);
}
/**
* Sets the daylight savings ending rule. For example, in the U.S., Daylight
* Savings Time ends at the first Sunday in November, at 2 AM in standard time.
@ -495,6 +497,7 @@ public class SimpleTimeZone extends BasicTimeZone {
transitionRulesInitialized = false;
}
/**
* Sets the amount of time in ms that the clock is advanced during DST.
* @param millisSavedDuringDST the number of milliseconds the time is
@ -529,14 +532,17 @@ public class SimpleTimeZone extends BasicTimeZone {
return (java.util.SimpleTimeZone) unwrap();
}
*/
// on JDK 1.4 and later, can't deserialize a SimpleTimeZone as a SimpleTimeZone...
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
private void readObject(java.io.ObjectInputStream in) throws IOException,
ClassNotFoundException {
in.defaultReadObject();
/*
String id = getID();
if (id!=null && !(zone instanceof java.util.SimpleTimeZone && zone.getID().equals(id))) {
// System.out.println("*** readjust " + zone.getClass().getName() + " " + zone.getID() + " ***");
java.util.SimpleTimeZone stz =
// System.out.println("*** readjust " + zone.getClass().getName() +
// " " + zone.getID() + " ***");
java.util.SimpleTimeZone stz =
new java.util.SimpleTimeZone(raw, id);
if (dst != 0) {
stz.setDSTSavings(dst);
@ -551,13 +557,13 @@ public class SimpleTimeZone extends BasicTimeZone {
}
*/
/* set all instance variables in this object
* to the values in zone
*/
* to the values in zone
*/
if (xinfo != null) {
xinfo.applyTo(this);
}
}
/**
* Returns a string representation of this object.
* @return a string representation of this object
@ -591,7 +597,7 @@ public class SimpleTimeZone extends BasicTimeZone {
* @stable ICU 2.0
*/
public int getOffset(int era, int year, int month, int day,
int dayOfWeek, int millis)
int dayOfWeek, int millis)
{
// Check the month before calling Grego.monthLength(). This
// duplicates the test that occurs in the 7-argument getOffset(),
@ -612,7 +618,7 @@ public class SimpleTimeZone extends BasicTimeZone {
* @deprecated This API is ICU internal only.
*/
public int getOffset(int era, int year, int month, int day,
int dayOfWeek, int millis,
int dayOfWeek, int millis,
int monthLength) {
// Check the month before calling Grego.monthLength(). This
// duplicates a test that occurs in the 9-argument getOffset(),
@ -624,13 +630,13 @@ public class SimpleTimeZone extends BasicTimeZone {
if(month < Calendar.JANUARY || month > Calendar.DECEMBER) {
throw new IllegalArgumentException();
}
return getOffset(era, year, month, day, dayOfWeek, millis,
Grego.monthLength(year, month), Grego.previousMonthLength(year, month));
}
int getOffset(int era, int year, int month, int day,
int dayOfWeek, int millis,
int dayOfWeek, int millis,
int monthLength, int prevMonthLength ){
if (true) {
@ -652,7 +658,7 @@ public class SimpleTimeZone extends BasicTimeZone {
|| prevMonthLength > 31) {
throw new IllegalArgumentException();
}
}
}
//Eclipse stated the following is "dead code"
/*else {
// This parameter checking code is better for debugging, but
@ -746,20 +752,22 @@ public class SimpleTimeZone extends BasicTimeZone {
Grego.timeToFields(date, fields);
offsets[1] = getOffset(GregorianCalendar.AD,
fields[0], fields[1], fields[2],
fields[3], fields[5]) - offsets[0];
fields[3], fields[5]) - offsets[0];
boolean recalc = false;
// Now, we need some adjustment
if (offsets[1] > 0) {
if ((nonExistingTimeOpt & STD_DST_MASK) == LOCAL_STD
|| (nonExistingTimeOpt & STD_DST_MASK) != LOCAL_DST && (nonExistingTimeOpt & FORMER_LATTER_MASK) != LOCAL_LATTER) {
|| (nonExistingTimeOpt & STD_DST_MASK) != LOCAL_DST
&& (nonExistingTimeOpt & FORMER_LATTER_MASK) != LOCAL_LATTER) {
date -= getDSTSavings();
recalc = true;
}
} else {
if ((duplicatedTimeOpt & STD_DST_MASK) == LOCAL_DST
|| (duplicatedTimeOpt & STD_DST_MASK) != LOCAL_STD && (duplicatedTimeOpt & FORMER_LATTER_MASK) == LOCAL_FORMER) {
|| (duplicatedTimeOpt & STD_DST_MASK) != LOCAL_STD
&& (duplicatedTimeOpt & FORMER_LATTER_MASK) == LOCAL_FORMER) {
date -= getDSTSavings();
recalc = true;
}
@ -769,7 +777,7 @@ public class SimpleTimeZone extends BasicTimeZone {
Grego.timeToFields(date, fields);
offsets[1] = getOffset(GregorianCalendar.AD,
fields[0], fields[1], fields[2],
fields[3], fields[5]) - offsets[0];
fields[3], fields[5]) - offsets[0];
}
}
@ -795,9 +803,9 @@ public class SimpleTimeZone extends BasicTimeZone {
int ruleDay, int ruleMillis)
{
// Make adjustments for startTimeMode and endTimeMode
millis += millisDelta;
while (millis >= Grego.MILLIS_PER_DAY) {
millis -= Grego.MILLIS_PER_DAY;
++dayOfMonth;
@ -831,7 +839,7 @@ public class SimpleTimeZone extends BasicTimeZone {
}
millis += Grego.MILLIS_PER_DAY;
}
if (month < ruleMonth) return -1;
else if (month > ruleMonth) return 1;
@ -883,7 +891,7 @@ public class SimpleTimeZone extends BasicTimeZone {
}
// data needed for streaming mutated SimpleTimeZones in JDK14
private int raw;// the TimeZone's raw GMT offset
private int raw;// the TimeZone's raw GMT offset
private int dst = 3600000;
private STZInfo xinfo = null;
private int startMonth, startDay, startDayOfWeek; // the month, day, DOW, and time DST starts
@ -891,10 +899,10 @@ public class SimpleTimeZone extends BasicTimeZone {
private int startTimeMode, endTimeMode; // Mode for startTime, endTime; see TimeMode
private int endMonth, endDay, endDayOfWeek; // the month, day, DOW, and time DST ends
private int endTime;
private int startYear; // the year these DST rules took effect
private int startYear; // the year these DST rules took effect
private boolean useDaylight; // flag indicating whether this TimeZone uses DST
private int startMode, endMode; // flags indicating what kind of rules the DST rules are
/**
* Overrides TimeZone
* Queries if this time zone uses Daylight Saving Time.
@ -1069,7 +1077,7 @@ public class SimpleTimeZone extends BasicTimeZone {
}
/**
* Return true if obj is a SimpleTimeZone equivalent to this.
* Overrides equals.
* @return true if obj is a SimpleTimeZone equivalent to this
* @stable ICU 3.6
*/
@ -1109,8 +1117,7 @@ public class SimpleTimeZone extends BasicTimeZone {
}
/**
* Return the hash code.
* @return the hash code
* Overrides hashCode.
* @stable ICU 3.6
*/
public int hashCode(){
@ -1137,8 +1144,7 @@ public class SimpleTimeZone extends BasicTimeZone {
}
/**
* Return a clone of this time zone.
* @return a clone of this time zone
* Overrides clone.
* @stable ICU 3.6
*/
public Object clone() {
@ -1146,7 +1152,7 @@ public class SimpleTimeZone extends BasicTimeZone {
}
/**
* Return true if this zone has the same rules and offset as another zone.
* Returns true if this zone has the same rules and offset as another zone.
* @param othr the TimeZone object to be compared with
* @return true if the given zone has the same rules and offset as this one
* @stable ICU 2.0
@ -1193,8 +1199,10 @@ public class SimpleTimeZone extends BasicTimeZone {
if (base < firstTransitionTime || (inclusive && base == firstTransitionTime)) {
return firstTransition;
}
Date stdDate = stdRule.getNextStart(base, dstRule.getRawOffset(), dstRule.getDSTSavings(), inclusive);
Date dstDate = dstRule.getNextStart(base, stdRule.getRawOffset(), stdRule.getDSTSavings(), inclusive);
Date stdDate = stdRule.getNextStart(base, dstRule.getRawOffset(), dstRule.getDSTSavings(),
inclusive);
Date dstDate = dstRule.getNextStart(base, stdRule.getRawOffset(), stdRule.getDSTSavings(),
inclusive);
if (stdDate != null && (dstDate == null || stdDate.before(dstDate))) {
return new TimeZoneTransition(stdDate.getTime(), dstRule, stdRule);
}
@ -1218,13 +1226,15 @@ public class SimpleTimeZone extends BasicTimeZone {
if (base < firstTransitionTime || (!inclusive && base == firstTransitionTime)) {
return null;
}
Date stdDate = stdRule.getPreviousStart(base, dstRule.getRawOffset(), dstRule.getDSTSavings(), inclusive);
Date dstDate = dstRule.getPreviousStart(base, stdRule.getRawOffset(), stdRule.getDSTSavings(), inclusive);
Date stdDate = stdRule.getPreviousStart(base, dstRule.getRawOffset(),
dstRule.getDSTSavings(), inclusive);
Date dstDate = dstRule.getPreviousStart(base, stdRule.getRawOffset(),
stdRule.getDSTSavings(), inclusive);
if (stdDate != null && (dstDate == null || stdDate.after(dstDate))) {
return new TimeZoneTransition(stdDate.getTime(), dstRule, stdRule);
}
if (dstDate != null && (stdDate == null || dstDate.after(stdDate))) {
return new TimeZoneTransition(dstDate.getTime(), stdRule, dstRule);
return new TimeZoneTransition(dstDate.getTime(), stdRule, dstRule);
}
return null;
}
@ -1269,19 +1279,22 @@ public class SimpleTimeZone extends BasicTimeZone {
dtRule = new DateTimeRule(startMonth, startDay, startTime, timeRuleType);
break;
case DOW_IN_MONTH_MODE:
dtRule = new DateTimeRule(startMonth, startDay, startDayOfWeek, startTime, timeRuleType);
dtRule = new DateTimeRule(startMonth, startDay, startDayOfWeek, startTime,
timeRuleType);
break;
case DOW_GE_DOM_MODE:
dtRule = new DateTimeRule(startMonth, startDay, startDayOfWeek, true, startTime, timeRuleType);
dtRule = new DateTimeRule(startMonth, startDay, startDayOfWeek, true, startTime,
timeRuleType);
break;
case DOW_LE_DOM_MODE:
dtRule = new DateTimeRule(startMonth, startDay, startDayOfWeek, false, startTime, timeRuleType);
dtRule = new DateTimeRule(startMonth, startDay, startDayOfWeek, false, startTime,
timeRuleType);
break;
}
// For now, use ID + "(DST)" as the name
dstRule = new AnnualTimeZoneRule(getID() + "(DST)", getRawOffset(), getDSTSavings(),
dtRule, startYear, AnnualTimeZoneRule.MAX_YEAR);
// Calculate the first DST start time
firstDstStart = dstRule.getFirstStart(getRawOffset(), 0).getTime();
@ -1296,10 +1309,12 @@ public class SimpleTimeZone extends BasicTimeZone {
dtRule = new DateTimeRule(endMonth, endDay, endDayOfWeek, endTime, timeRuleType);
break;
case DOW_GE_DOM_MODE:
dtRule = new DateTimeRule(endMonth, endDay, endDayOfWeek, true, endTime, timeRuleType);
dtRule = new DateTimeRule(endMonth, endDay, endDayOfWeek, true, endTime,
timeRuleType);
break;
case DOW_LE_DOM_MODE:
dtRule = new DateTimeRule(endMonth, endDay, endDayOfWeek, false, endTime, timeRuleType);
dtRule = new DateTimeRule(endMonth, endDay, endDayOfWeek, false, endTime,
timeRuleType);
break;
}
// For now, use ID + "(STD)" as the name
@ -1311,13 +1326,14 @@ public class SimpleTimeZone extends BasicTimeZone {
// Create a TimeZoneRule for initial time
if (firstStdStart < firstDstStart) {
initialRule = new InitialTimeZoneRule(getID() + "(DST)", getRawOffset(), dstRule.getDSTSavings());
initialRule = new InitialTimeZoneRule(getID() + "(DST)", getRawOffset(),
dstRule.getDSTSavings());
firstTransition = new TimeZoneTransition(firstStdStart, initialRule, stdRule);
} else {
initialRule = new InitialTimeZoneRule(getID() + "(STD)", getRawOffset(), 0);
firstTransition = new TimeZoneTransition(firstDstStart, initialRule, dstRule);
}
} else {
// Create a TimeZoneRule for initial time
initialRule = new InitialTimeZoneRule(getID(), getRawOffset(), 0);
@ -1325,4 +1341,3 @@ public class SimpleTimeZone extends BasicTimeZone {
transitionRulesInitialized = true;
}
}

View file

@ -23,26 +23,27 @@ import com.ibm.icu.text.SimpleDateFormat;
import com.ibm.icu.impl.ICULogger;
/**
* <code>TimeZone</code> represents a time zone offset, and also figures out daylight
* {@icuenhanced java.util.TimeZone}.{@icu _usage_}
*
* <p><code>TimeZone</code> represents a time zone offset, and also computes daylight
* savings.
*
* <p>
* Typically, you get a <code>TimeZone</code> using <code>getDefault</code>
* <p>Typically, you get a <code>TimeZone</code> using {@link #getDefault()}
* which creates a <code>TimeZone</code> based on the time zone where the program
* is running. For example, for a program running in Japan, <code>getDefault</code>
* creates a <code>TimeZone</code> object based on Japanese Standard Time.
*
* <p>
* You can also get a <code>TimeZone</code> using <code>getTimeZone</code>
* <p>You can also get a <code>TimeZone</code> using {@link #getTimeZone(String)}
* 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 <code>TimeZone</code> object with:
*
* <blockquote>
* <pre>
* TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
* </pre>
* </blockquote>
* You can use <code>getAvailableIDs</code> method to iterate through
* You can use the {@link #getAvailableIDs()} method to iterate through
* all the supported time zone IDs. You can then choose a
* supported ID to get a <code>TimeZone</code>.
* If the time zone you want is not represented by one of the
@ -59,8 +60,8 @@ import com.ibm.icu.impl.ICULogger;
* time zone ID. The <code>TimeZone</code> that is returned
* when you specify a custom time zone ID does not include
* daylight savings time.
* <p>
* For compatibility with JDK 1.1.x, some other three-letter time zone IDs
*
* <p>For compatibility with JDK 1.1.x, some other three-letter time zone IDs
* (such as "PST", "CTT", "AST") are also supported. However, <strong>their
* use is deprecated</strong> because the same abbreviation is often used
* for multiple time zones (for example, "CST" could be U.S. "Central Standard
@ -74,7 +75,7 @@ import com.ibm.icu.impl.ICULogger;
* set the default time zone implementation type by the new method
* <code>setDefaultTimeZoneType</code>. Alternatively, you can change the initial
* default implementation type by setting a property below.
*
*
* <blockquote>
* <pre>
* #
@ -85,13 +86,13 @@ import com.ibm.icu.impl.ICULogger;
* </pre>
* </blockquote>
*
* <p>This property is included in ICUConfig.properties in com.ibm.icu package.
* When <code>TimeZone</code> class is loaded, the initialization code checks
* if the property <code>com.ibm.icu.util.TimeZone.DefaultTimeZoneType=xxx</code>
* is defined by the system properties. If not available, then it loads ICUConfig.properties
* to get the default time zone implementation type. The property setting is
* only used for the initial default value and you can change the default type
* by <code>setDefaultTimeZoneType</code> at runtime.
* <p>This property is included in ICUConfig.properties in com.ibm.icu package. When the
* <code>TimeZone</code> class is loaded, the initialization code checks if the property
* <code>com.ibm.icu.util.TimeZone.DefaultTimeZoneType=xxx</code> is defined by the system
* properties. If not available, then it loads ICUConfig.properties to get the default
* time zone implementation type. The property setting is only used for the initial
* default value and you can change the default type by calling
* <code>setDefaultTimeZoneType</code> at runtime.
*
* @see Calendar
* @see GregorianCalendar
@ -101,7 +102,8 @@ import com.ibm.icu.impl.ICULogger;
*/
abstract public class TimeZone implements Serializable, Cloneable {
/**
* A logger for TimeZone. Will be null if logging is not on by way of system property: "icu4j.debug.logging"
* {@icu} A logger for TimeZone. Will be null if logging is not on by way of system
* property: "icu4j.debug.logging"
* @draft ICU 4.4
* @provisional This API might change or be removed in a future release.
*/
@ -119,14 +121,14 @@ abstract public class TimeZone implements Serializable, Cloneable {
}
/**
* A time zone implementation type indicating ICU's own TimeZone used by
* {@icu} A time zone implementation type indicating ICU's own TimeZone used by
* <code>getTimeZone</code>, <code>setDefaultTimeZoneType</code>
* and <code>getDefaultTimeZoneType</code>.
* @stable ICU 4.0
*/
public static final int TIMEZONE_ICU = 0;
/**
* A time zone implementation type indicating JDK TimeZone used by
* {@icu} A time zone implementation type indicating JDK TimeZone used by
* <code>getTimeZone</code>, <code>setDefaultTimeZoneType</code>
* and <code>getDefaultTimeZoneType</code>.
* @stable ICU 4.0
@ -150,7 +152,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
public static final int LONG = 1;
/**
* A style specifier for <code>getDisplayName()</code> indicating
* {@icu} A style specifier for <code>getDisplayName()</code> indicating
* a short generic name, such as "PT."
* @see #LONG_GENERIC
* @draft ICU 4.4
@ -159,7 +161,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
public static final int SHORT_GENERIC = 2;
/**
* A style specifier for <code>getDisplayName()</code> indicating
* {@icu} A style specifier for <code>getDisplayName()</code> indicating
* a long generic name, such as "Pacific Time."
* @see #SHORT_GENERIC
* @draft ICU 4.4
@ -168,36 +170,36 @@ abstract public class TimeZone implements Serializable, Cloneable {
public static final int LONG_GENERIC = 3;
/**
* A style specifier for <code>getDisplayName()</code> indicating
* {@icu} A style specifier for <code>getDisplayName()</code> indicating
* a short name derived from the timezone's offset, such as "-0800."
* @see #LONG_GMT
* @draft ICU 4.4
* @provisional This API might change or be removed in a future release.
*/
public static final int SHORT_GMT = 4;
/**
* A style specifier for <code>getDisplayName()</code> indicating
* {@icu} A style specifier for <code>getDisplayName()</code> indicating
* a long name derived from the timezone's offset, such as "GMT-08:00."
* @see #SHORT_GMT
* @draft ICU 4.4
* @provisional This API might change or be removed in a future release.
*/
public static final int LONG_GMT = 5;
/**
* A style specifier for <code>getDisplayName()</code> indicating
* {@icu} A style specifier for <code>getDisplayName()</code> indicating
* a short name derived from the timezone's short standard or daylight
* timezone name ignoring commonlyUsed, such as "PDT."
* @draft ICU 4.4
* @provisional This API might change or be removed in a future release.
*/
public static final int SHORT_COMMONLY_USED = 6;
/**
* A style specifier for <code>getDisplayName()</code> indicating
* a long name derived from the timezone's fallback name, such as
* {@icu} A style specifier for <code>getDisplayName()</code> indicating
* a long name derived from the timezone's fallback name, such as
* "United States (Los Angeles)."
* @draft ICU 4.4
* @provisional This API might change or be removed in a future release.
@ -207,7 +209,8 @@ abstract public class TimeZone implements Serializable, Cloneable {
/**
* Cache to hold the SimpleDateFormat objects for a Locale.
*/
private static ICUCache<ULocale, SimpleDateFormat> cachedLocaleData = new SimpleCache<ULocale, SimpleDateFormat>();
private static ICUCache<ULocale, SimpleDateFormat> cachedLocaleData =
new SimpleCache<ULocale, SimpleDateFormat>();
/**
* Gets the time zone offset, for current date, modified in case of
@ -347,7 +350,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
* @return the human-readable name of this time zone in the default locale.
* @stable ICU 2.0
*/
public final String getDisplayName() {
public final String getDisplayName() {
return _getDisplayName(false, LONG_GENERIC, ULocale.getDefault());
}
@ -377,7 +380,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
* or in the default ulocale if the given ulocale is not recognized.
* @stable ICU 3.2
*/
public final String getDisplayName(ULocale locale) {
public final String getDisplayName(ULocale locale) {
return _getDisplayName(false, LONG_GENERIC, locale);
}
@ -388,7 +391,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
* then this method returns a string in the format
* <code>GMT[+-]hh:mm</code>.
* @param daylight if true, return the daylight savings name.
* @param style the output style of the display name. Valid styles are
* @param style the output style of the display name. Valid styles are
* <code>SHORT</code>, <code>LONG</code>, <code>SHORT_GENERIC</code>,
* <code>LONG_GENERIC</code>, <code>SHORT_GMT</code>, <code>LONG_GMT</code>,
* <code>SHORT_COMMONLY_USED</code> or <code>GENERIC_LOCATION</code>.
@ -406,7 +409,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
* then this method returns a string in the format
* <code>GMT[+-]hh:mm</code>.
* @param daylight if true, return the daylight savings name.
* @param style the output style of the display name. Valid styles are
* @param style the output style of the display name. Valid styles are
* <code>SHORT</code>, <code>LONG</code>, <code>SHORT_GENERIC</code>,
* <code>LONG_GENERIC</code>, <code>SHORT_GMT</code>, <code>LONG_GMT</code>,
* <code>SHORT_COMMONLY_USED</code> or <code>GENERIC_LOCATION</code>.
@ -427,7 +430,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
* then this method returns a string in the format
* <code>GMT[+-]hh:mm</code>.
* @param daylight if true, return the daylight savings name.
* @param style the output style of the display name. Valid styles are
* @param style the output style of the display name. Valid styles are
* <code>SHORT</code>, <code>LONG</code>, <code>SHORT_GENERIC</code>,
* <code>LONG_GENERIC</code>, <code>SHORT_GMT</code>, <code>LONG_GMT</code>,
* <code>SHORT_COMMONLY_USED</code> or <code>GENERIC_LOCATION</code>.
@ -441,13 +444,13 @@ abstract public class TimeZone implements Serializable, Cloneable {
if (style < SHORT || style > GENERIC_LOCATION) {
throw new IllegalArgumentException("Illegal style: " + style);
}
return _getDisplayName(daylight, style, locale);
}
/**
* internal version (which is called by public APIs) accepts
* SHORT, LONG, SHORT_GENERIC, LONG_GENERIC, SHORT_GMT, LONG_GMT,
* internal version (which is called by public APIs) accepts
* SHORT, LONG, SHORT_GENERIC, LONG_GENERIC, SHORT_GMT, LONG_GMT,
* SHORT_COMMONLY_USED and GENERIC_LOCATION.
*/
private synchronized String _getDisplayName(boolean daylight, int style, ULocale locale) {
@ -498,7 +501,8 @@ abstract public class TimeZone implements Serializable, Cloneable {
// they're small and cheap to create.
SimpleTimeZone tz;
if (daylight && useDaylightTime()) {
// The display name for daylight saving time was requested, but currently not in DST
// The display name for daylight saving time was requested, but currently
// not in DST
// Set a fixed date (July 1) in this Gregorian year
GregorianCalendar cal = new GregorianCalendar(this);
@ -519,8 +523,8 @@ abstract public class TimeZone implements Serializable, Cloneable {
}
} else {
// The display name for standard time was requested, but currently in DST
// or display name for daylight saving time was requested, but this zone no longer
// observes DST.
// or display name for daylight saving time was requested, but this zone
// no longer observes DST.
tz = new SimpleTimeZone(offsets[0], getID());
format.setTimeZone(tz);
}
@ -585,10 +589,11 @@ abstract public class TimeZone implements Serializable, Cloneable {
/**
* Gets the <code>TimeZone</code> for the given ID and the timezone type.
* @param ID the ID for a <code>TimeZone</code>, such as "America/Los_Angeles",
* or a custom ID such as "GMT-8:00". Note that the support of abbreviations,
* such as "PST", is for JDK 1.1.x compatibility only and full names should be used.
* @param type Time zone type, either <code>TIMEZONE_ICU</code> or <code>TIMEZONE_JDK</code>.
* @param ID the ID for a <code>TimeZone</code>, such as "America/Los_Angeles", or a
* custom ID such as "GMT-8:00". Note that the support of abbreviations, such as
* "PST", is for JDK 1.1.x compatibility only and full names should be used.
* @param type Time zone type, either <code>TIMEZONE_ICU</code> or
* <code>TIMEZONE_JDK</code>.
* @return the specified <code>TimeZone</code>, or the GMT zone if the given ID
* cannot be understood.
* @stable ICU 4.0
@ -617,7 +622,8 @@ abstract public class TimeZone implements Serializable, Cloneable {
if (result == null) {
/* Log that timezone is using GMT if logging is on. */
if (TimeZoneLogger != null && TimeZoneLogger.isLoggingOn()) {
TimeZoneLogger.warning("\"" +ID + "\" is a bogus id so timezone is falling back to GMT.");
TimeZoneLogger.warning(
"\"" +ID + "\" is a bogus id so timezone is falling back to GMT.");
}
result = ZoneMeta.getGMT();
}
@ -627,7 +633,8 @@ abstract public class TimeZone implements Serializable, Cloneable {
/**
* Sets the default time zone type used by <code>getTimeZone</code>.
* @param type time zone type, either <code>TIMEZONE_ICU</code> or <code>TIMEZONE_JDK</code>.
* @param type time zone type, either <code>TIMEZONE_ICU</code> or
* <code>TIMEZONE_JDK</code>.
* @stable ICU 4.0
*/
public static synchronized void setDefaultTimeZoneType(int type) {
@ -638,14 +645,15 @@ abstract public class TimeZone implements Serializable, Cloneable {
}
/**
* Returns the default time zone type currently used.
* @return The default time zone type, either <code>TIMEZONE_ICU</code> or <code>TIMEZONE_JDK</code>.
* {@icu} Returns the default time zone type currently used.
* @return The default time zone type, either <code>TIMEZONE_ICU</code> or
* <code>TIMEZONE_JDK</code>.
* @stable ICU 4.0
*/
public static int getDefaultTimeZoneType() {
return TZ_IMPL;
}
/**
* Return a new String array containing all system TimeZone IDs
* with the given raw offset from GMT. These IDs may be passed to
@ -688,9 +696,9 @@ abstract public class TimeZone implements Serializable, Cloneable {
public static String[] getAvailableIDs() {
return ZoneMeta.getAvailableIDs();
}
/**
* Returns the number of IDs in the equivalency group that
* {@icu} Returns the number of IDs in the equivalency group that
* includes the given ID. An equivalency group contains zones
* that have the same GMT offset and rules.
*
@ -732,7 +740,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
/**
* Gets the default <code>TimeZone</code> for this host.
* The source of the default <code>TimeZone</code>
* The source of the default <code>TimeZone</code>
* may vary with implementation.
* @return a default <code>TimeZone</code>.
* @stable ICU 2.0
@ -807,7 +815,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
}
/**
* Overrides Cloneable
* Overrides clone.
* @stable ICU 2.0
*/
public Object clone() {
@ -821,9 +829,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
}
/**
* Return true if obj is a TimeZone with the same class and ID as this.
* @return true if obj is a TimeZone with the same class and ID as this
* @param obj the object to compare against
* Overrides equals.
* @stable ICU 3.6
*/
public boolean equals(Object obj){
@ -833,8 +839,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
}
/**
* Return the hash code.
* @return the hash code
* Overrides hashCode.
* @stable ICU 3.6
*/
public int hashCode(){
@ -842,12 +847,12 @@ abstract public class TimeZone implements Serializable, Cloneable {
}
/**
* Returns the time zone data version currently used by ICU.
*
* {@icu} Returns the time zone data version currently used by ICU.
*
* @return the version string, such as "2007f"
* @throws MissingResourceException if ICU time zone resource bundle
* is missing or the version information is not available.
*
*
* @stable ICU 3.8
*/
public static synchronized String getTZDataVersion() {
@ -860,7 +865,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
}
/**
* Returns the canonical system time zone ID or the normalized
* {@icu} Returns the canonical system time zone ID or the normalized
* custom time zone ID for the given time zone ID.
* @param id The input time zone ID to be canonicalized.
* @return The canonical system time zone ID or the custom time zone ID
@ -874,7 +879,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
}
/**
* Returns the canonical system time zone ID or the normalized
* {@icu} Returns the canonical system time zone ID or the normalized
* custom time zone ID for the given time zone ID.
* @param id The input time zone ID to be canonicalized.
* @param isSystemID When non-null boolean array is specified and
@ -928,7 +933,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
* TimeZone implementation type
*/
private static int TZ_IMPL = TIMEZONE_ICU;
/**
* TimeZone implementation type initialization
*/

View file

@ -35,6 +35,8 @@ import com.ibm.icu.text.LocaleDisplayNames;
import com.ibm.icu.text.LocaleDisplayNames.DialectHandling;
/**
* {@icuenhanced java.util.Locale}.{@icu _usage_}
*
* 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.
@ -65,7 +67,8 @@ import com.ibm.icu.text.LocaleDisplayNames.DialectHandling;
* <ul>
* <li>POSIX ids are converted to ICU format IDs</li>
* <li>'grandfathered' 3066 ids are converted to ICU standard form</li>
* <li>'PREEURO' and 'EURO' variants are converted to currency keyword form, with the currency
* <li>'PREEURO' and 'EURO' variants are converted to currency keyword form,
* with the currency
* id appropriate to the country of the locale (for PREEURO) or EUR (for EURO).
* </ul>
* All ULocale constructors automatically normalize the locale id. To handle
@ -85,9 +88,7 @@ import com.ibm.icu.text.LocaleDisplayNames.DialectHandling;
* <tt>getLocale()</tt> may be called on it to determine the valid and
* actual locale arrived at during the object's construction.
*
* <p>Note: The <tt>getLocale()</tt> method will be implemented in ICU
* 3.0; ICU 2.8 contains a partial preview implementation. The
* <i>actual</i> locale is returned correctly, but the <i>valid</i>
* <p>Note: The <i>actual</i> locale is returned correctly, but the <i>valid</i>
* locale is not, in most cases.
*
* @see java.util.Locale
@ -386,7 +387,7 @@ public final class ULocale implements Serializable {
}
/**
* Return a ULocale object for a {@link java.util.Locale}.
* {@icu} Returns a ULocale object for a {@link java.util.Locale}.
* The ULocale is canonicalized.
* @param loc a JDK locale
* @stable ICU 3.2
@ -421,7 +422,7 @@ public final class ULocale implements Serializable {
}
/**
* Construct a ULocale from a RFC 3066 locale ID. The locale ID consists
* {@icu} Constructs a ULocale from a RFC 3066 locale ID. The locale ID consists
* of optional language, script, country, and variant fields in that order,
* separated by underscores, followed by an optional keyword list. The
* script, if present, is four characters long-- this distinguishes it
@ -429,8 +430,8 @@ public final class ULocale implements Serializable {
* are distinguished by position as indicated by the underscores. The
* start of the keyword list is indicated by '@', and consists of two
* or more keyword/value pairs separated by semicolons(';').
* <p>
* This constructor does not canonicalize the localeID. So, for
*
* <p>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}
@ -455,10 +456,10 @@ public final class ULocale implements Serializable {
}
/**
* 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 <code>ULocale(String localeID)</code>.
* Constructs 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 <code>ULocale(String
* localeID)</code>.
*
* <p>Java locale strings consisting of language, country, and
* variant will be handled by this form, since the country code
@ -479,7 +480,7 @@ public final class ULocale implements Serializable {
}
/**
* Create a ULocale from the id by first canonicalizing the id.
* {@icu} Creates 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
@ -513,7 +514,7 @@ public final class ULocale implements Serializable {
}
/**
* Convert this ULocale object to a {@link java.util.Locale}.
* {@icu} Converts 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
@ -565,7 +566,7 @@ public final class ULocale implements Serializable {
}
/**
* Sets the default ULocale. This also sets the default Locale.
* {@icu} 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.
@ -622,7 +623,8 @@ public final class ULocale implements Serializable {
}
/**
* Returns a list of all installed locales.
* {@icunote} Unlike the Locale API, this returns an array of <code>ULocale</code>,
* not <code>Locale</code>. Returns a list of all installed locales.
* @stable ICU 3.0
*/
public static ULocale[] getAvailableLocales() {
@ -674,7 +676,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns the script code for this locale, which might be the empty string.
* {@icu} Returns the script code for this locale, which might be the empty string.
* @see #getDisplayScript()
* @see #getDisplayScript(ULocale)
* @stable ICU 3.0
@ -684,7 +686,8 @@ public final class ULocale implements Serializable {
}
/**
* Returns the script code for the specified locale, which might be the empty string.
* {@icu} Returns the script code for the specified locale, which might be the empty
* string.
* @see #getDisplayScript()
* @see #getDisplayScript(ULocale)
* @stable ICU 3.0
@ -737,7 +740,8 @@ public final class ULocale implements Serializable {
}
/**
* Returns the fallback locale for the specified locale, which might be the empty string.
* {@icu} Returns the fallback locale for the specified locale, which might be the
* empty string.
* @stable ICU 3.2
*/
public static String getFallback(String localeID) {
@ -745,7 +749,8 @@ public final class ULocale implements Serializable {
}
/**
* Returns the fallback locale for this locale. If this locale is root, returns null.
* {@icu} Returns the fallback locale for this locale. If this locale is root,
* returns null.
* @stable ICU 3.2
*/
public ULocale getFallback() {
@ -756,7 +761,7 @@ public final class ULocale implements Serializable {
}
/**
* Return the given (canonical) locale id minus the last part before the tags.
* Returns the given (canonical) locale id minus the last part before the tags.
*/
private static String getFallbackString(String fallback) {
int extStart = fallback.indexOf('@');
@ -779,7 +784,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns the (normalized) base name for this locale.
* {@icu} Returns the (normalized) base name for this locale.
* @return the base name as a String.
* @stable ICU 3.0
*/
@ -788,7 +793,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns the (normalized) base name for the specified locale.
* {@icu} 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
@ -801,7 +806,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns the (normalized) full name for this locale.
* {@icu} Returns the (normalized) full name for this locale.
*
* @return String the full name of the localeID
* @stable ICU 3.0
@ -811,7 +816,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns the (normalized) full name for the specified locale.
* {@icu} Returns the (normalized) full name for the specified locale.
*
* @param localeID the localeID as a string
* @return String the full name of the localeID
@ -835,7 +840,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns an iterator over keywords for this locale. If there
* {@icu} 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
@ -845,7 +850,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns an iterator over keywords for the specified locale. If there
* {@icu} 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.
@ -856,7 +861,8 @@ public final class ULocale implements Serializable {
}
/**
* Returns the value for a keyword in this locale. If the keyword is not defined, returns null.
* {@icu} 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
@ -866,9 +872,8 @@ public final class ULocale implements Serializable {
}
/**
* 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.
* {@icu} 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
@ -878,8 +883,8 @@ public final class ULocale implements Serializable {
}
/**
* Returns the canonical name for the specified locale ID. This is used to convert POSIX
* and other grandfathered IDs to standard ICU form.
* {@icu} 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
@ -1055,7 +1060,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns this locale's language localized for display in the provided locale.
* {@icu} 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
@ -1089,7 +1094,7 @@ public final class ULocale implements Serializable {
return getDisplayLanguageInternal(new ULocale(localeID), displayLocale, false);
}
/**
* Returns this locale's language localized for display in the default locale.
* {@icu} Returns this locale's language localized for display in the default locale.
* If a dialect name is present in the data, then it is returned.
* @return the localized language name.
* @draft ICU 4.4
@ -1100,7 +1105,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns this locale's language localized for display in the provided locale.
* {@icu} Returns this locale's language localized for display in the provided locale.
* If a dialect name is present in the data, then it is returned.
* @param displayLocale the locale in which to display the name.
* @return the localized language name.
@ -1112,7 +1117,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns a locale's language localized for display in the provided locale.
* {@icu} Returns a locale's language localized for display in the provided locale.
* If a dialect name is present in the data, then it is returned.
* This is a cover for the ICU4C API.
* @param localeID the id of the locale whose language will be displayed
@ -1127,7 +1132,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns a locale's language localized for display in the provided locale.
* {@icu} Returns a locale's language localized for display in the provided locale.
* If a dialect name is present in the data, then it is returned.
* This is a cover for the ICU4C API.
* @param localeID the id of the locale whose language will be displayed.
@ -1147,7 +1152,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns this locale's script localized for display in the default locale.
* {@icu} Returns this locale's script localized for display in the default locale.
* @return the localized script name.
* @stable ICU 3.0
*/
@ -1156,7 +1161,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns this locale's script localized for display in the provided locale.
* {@icu} 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
@ -1166,7 +1171,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns a locale's script localized for display in the provided locale.
* {@icu} 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.
@ -1178,7 +1183,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns a locale's script localized for display in the provided locale.
* {@icu} 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.
@ -1292,7 +1297,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns a keyword localized for display in the default locale.
* {@icu} Returns a keyword localized for display in the default locale.
* @param keyword the keyword to be displayed.
* @return the localized keyword name.
* @see #getKeywords()
@ -1303,7 +1308,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns a keyword localized for display in the specified locale.
* {@icu} 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.
@ -1315,7 +1320,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns a keyword localized for display in the specified locale.
* {@icu} 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.
@ -1331,7 +1336,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns a keyword value localized for display in the default locale.
* {@icu} 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
@ -1341,7 +1346,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns a keyword value localized for display in the specified locale.
* {@icu} 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.
@ -1352,7 +1357,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns a keyword value localized for display in the specified locale.
* {@icu} 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.
@ -1367,7 +1372,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns a keyword value localized for display in the specified locale.
* {@icu} 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.
@ -1436,7 +1441,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns this locale name localized for display in the default locale.
* {@icu} Returns this locale name localized for display in the default locale.
* If a dialect name is present in the locale data, then it is returned.
* @return the localized locale name.
* @draft ICU 4.4
@ -1447,7 +1452,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns this locale name localized for display in the provided locale.
* {@icu} Returns this locale name localized for display in the provided locale.
* If a dialect name is present in the locale data, then it is returned.
* @param displayLocale the locale in which to display the locale name.
* @return the localized locale name.
@ -1459,7 +1464,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns the locale ID localized for display in the provided locale.
* {@icu} Returns the locale ID localized for display in the provided locale.
* If a dialect name is present in the locale data, then it is returned.
* This is a cover for the ICU4C API.
* @param localeID the locale whose name is to be displayed.
@ -1474,7 +1479,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns the locale ID localized for display in the provided locale.
* {@icu} Returns the locale ID localized for display in the provided locale.
* If a dialect name is present in the locale data, then it is returned.
* This is a cover for the ICU4C API.
* @param localeID the locale whose name is to be displayed.
@ -1493,7 +1498,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns this locale's layout orientation for characters. The possible
* {@icu} 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.
@ -1505,7 +1510,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns this locale's layout orientation for lines. The possible
* {@icu} 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.
@ -1517,7 +1522,7 @@ public final class ULocale implements Serializable {
}
/**
* Selector for <tt>getLocale()</tt> indicating the locale of the
* {@icu} Selector for <tt>getLocale()</tt> 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
@ -1530,7 +1535,7 @@ public final class ULocale implements Serializable {
public static Type ACTUAL_LOCALE = new Type();
/**
* Selector for <tt>getLocale()</tt> indicating the most specific
* {@icu} Selector for <tt>getLocale()</tt> 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,
@ -1558,21 +1563,21 @@ public final class ULocale implements Serializable {
}
/**
* 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.
* {@icu} 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
* @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) {
@ -1591,17 +1596,17 @@ public final class ULocale implements Serializable {
}
/**
* 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.
* {@icu} 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
* @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
*/
@ -1639,44 +1644,44 @@ public final class ULocale implements Serializable {
}
/**
* 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.
* This function will choose a locale from the ULocale.getAvailableLocales() list as available.
* {@icu} 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. This function will choose a locale from the
* ULocale.getAvailableLocales() list as available.
* @param acceptLanguageList list in HTTP "Accept-Language:" format of acceptable locales
* @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 ULocale.getAvailableLocales() list, or null if none match
* @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 ULocale.getAvailableLocales() list, or null if
* none match
* @stable ICU 3.4
*/
public static ULocale acceptLanguage(String acceptLanguageList, boolean[] fallback) {
return acceptLanguage(acceptLanguageList, ULocale.getAvailableLocales(),
fallback);
}
/**
* Based on an ordered array 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.
* This function will choose a locale from the ULocale.getAvailableLocales() list as available.
* {@icu} Based on an ordered array 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. This function will choose a locale from the
* ULocale.getAvailableLocales() list as available.
* @param acceptLanguageList ordered array of acceptable locales (preferred are listed first)
* @param fallback if non-null, a 1-element array containing a boolean to be set with the fallback status
* @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 ULocale.getAvailableLocales() list, or null if none match
* @stable ICU 3.4
*/
public static ULocale acceptLanguage(ULocale[] acceptLanguageList, boolean[]
fallback) {
public static ULocale acceptLanguage(ULocale[] acceptLanguageList, boolean[] fallback) {
return acceptLanguage(acceptLanguageList, ULocale.getAvailableLocales(),
fallback);
}
@ -1684,7 +1689,8 @@ public final class ULocale implements Serializable {
/**
* Package local method used for parsing Accept-Language string
*/
static ULocale[] parseAcceptLanguage(String acceptLanguage, boolean isLenient) throws ParseException {
static ULocale[] parseAcceptLanguage(String acceptLanguage, boolean isLenient)
throws ParseException {
class ULocaleAcceptLanguageQ implements Comparable<ULocaleAcceptLanguageQ> {
private double q;
private double serial;
@ -1709,7 +1715,8 @@ public final class ULocale implements Serializable {
}
// parse out the acceptLanguage into an array
TreeMap<ULocaleAcceptLanguageQ, ULocale> map = new TreeMap<ULocaleAcceptLanguageQ, ULocale>();
TreeMap<ULocaleAcceptLanguageQ, ULocale> map =
new TreeMap<ULocaleAcceptLanguageQ, ULocale>();
StringBuilder languageRangeBuf = new StringBuilder();
StringBuilder qvalBuf = new StringBuilder();
int state = 0;
@ -1916,7 +1923,8 @@ public final class ULocale implements Serializable {
if (languageRangeBuf.charAt(0) != '*') {
int serial = map.size();
ULocaleAcceptLanguageQ entry = new ULocaleAcceptLanguageQ(q, serial);
map.put(entry, new ULocale(canonicalize(languageRangeBuf.toString()))); // sort in reverse order.. 1.0, 0.9, 0.8 .. etc
// sort in reverse order.. 1.0, 0.9, 0.8 .. etc
map.put(entry, new ULocale(canonicalize(languageRangeBuf.toString())));
}
// reset buffer and parse state
@ -1940,8 +1948,8 @@ public final class ULocale implements Serializable {
private static final String UNDEFINED_REGION = "ZZ";
/**
* Add the likely subtags for a provided locale ID, per the algorithm described
* in the following CLDR technical report:
* {@icu} Adds the likely subtags for a provided locale ID, per the algorithm
* described in the following CLDR technical report:
*
* http://www.unicode.org/reports/tr35/#Likely_Subtags
*
@ -1966,9 +1974,7 @@ public final class ULocale implements Serializable {
* @return The maximized ULocale instance.
* @stable ICU 4.0
*/
public static ULocale
addLikelySubtags(ULocale loc)
{
public static ULocale addLikelySubtags(ULocale loc) {
String[] tags = new String[3];
String trailing = null;
@ -1991,17 +1997,18 @@ public final class ULocale implements Serializable {
}
/**
* Minimize the subtags for a provided locale ID, per the algorithm described
* in the following CLDR technical report:
* {@icu} Minimizes the subtags for a provided locale ID, per the algorithm described
* in the following CLDR technical report:<blockquote>
*
* http://www.unicode.org/reports/tr35/#Likely_Subtags
* <a href="http://www.unicode.org/reports/tr35/#Likely_Subtags"
*>http://www.unicode.org/reports/tr35/#Likely_Subtags</a></blockquote>
*
* If the provided ULocale instance is already in the minimal form, or there
* is no data available for minimization, it will be returned. Since the
* minimization algorithm relies on proper maximization, see the comments
* for addLikelySubtags for reasons why there might not be any data.
*
* Examples:
* Examples:<pre>
*
* "en_Latn_US" minimizes to "en"
*
@ -2010,15 +2017,13 @@ public final class ULocale implements Serializable {
* "sr_Cyrl_RS" minimizes to "sr"
*
* "zh_Hant_TW" minimizes to "zh_TW" (The region is preferred to the
* script, and minimizing to "zh" would imply "zh_Hans_CN".)
* script, and minimizing to "zh" would imply "zh_Hans_CN".) </pre>
*
* @param loc The ULocale to minimize
* @return The minimized ULocale instance.
* @stable ICU 4.0
*/
public static ULocale
minimizeSubtags(ULocale loc)
{
public static ULocale minimizeSubtags(ULocale loc) {
String[] tags = new String[3];
int trailingIndex = parseTagString(
@ -2152,11 +2157,7 @@ public final class ULocale implements Serializable {
* @param tag The tag to add.
* @param buffer The output buffer.
**/
private static void
appendTag(
String tag,
StringBuilder buffer) {
private static void appendTag(String tag, StringBuilder buffer) {
if (buffer.length() != 0) {
buffer.append(UNDERSCORE);
}
@ -2180,13 +2181,8 @@ public final class ULocale implements Serializable {
* @param alternateTags A string containing any alternate tags.
* @return The new tag string.
**/
private static String
createTagString(
String lang,
String script,
String region,
String trailing,
String alternateTags) {
private static String createTagString(String lang, String script, String region,
String trailing, String alternateTags) {
LocaleIDParser parser = null;
boolean regionAppended = false;
@ -2324,19 +2320,8 @@ public final class ULocale implements Serializable {
* @param trailing Any trailing data to append to the new tag.
* @return The new String.
**/
static String
createTagString(
String lang,
String script,
String region,
String trailing) {
return createTagString(
lang,
script,
region,
trailing,
null);
static String createTagString(String lang, String script, String region, String trailing) {
return createTagString(lang, script, region, trailing, null);
}
/**
@ -2348,11 +2333,7 @@ public final class ULocale implements Serializable {
* @param tags An array of three String references to return the subtag strings.
* @return The number of chars of the localeID parameter consumed.
**/
private static int
parseTagString(
String localeID,
String tags[])
{
private static int parseTagString(String localeID, String tags[]) {
LocaleIDParser parser = new LocaleIDParser(localeID);
String lang = parser.getLanguage();
@ -2408,8 +2389,7 @@ public final class ULocale implements Serializable {
}
}
private static String
lookupLikelySubtags(String localeId) {
private static String lookupLikelySubtags(String localeId) {
UResourceBundle bundle =
UResourceBundle.getBundleInstance(
ICUResourceBundle.ICU_BASE_NAME, "likelySubtags");
@ -2421,16 +2401,12 @@ public final class ULocale implements Serializable {
}
}
private static String
createLikelySubtagsString(
String lang,
String script,
String region,
private static String createLikelySubtagsString(String lang, String script, String region,
String variants) {
/**
* Try the language with the script and region first.
**/
*/
if (!isEmptyString(script) && !isEmptyString(region)) {
String searchTag =
@ -2452,7 +2428,8 @@ public final class ULocale implements Serializable {
System.err.println("Tag mismatch: \"" + likelySubtags + "\" \"(null)\"");
}
else if (!likelySubtags.equals(likelySubtags2)) {
System.err.println("Tag mismatch: \"" + likelySubtags + "\" \"" + likelySubtags2 + "\"");
System.err.println("Tag mismatch: \"" + likelySubtags + "\" \"" + likelySubtags2
+ "\"");
}
*/
if (likelySubtags != null) {
@ -2555,7 +2532,7 @@ public final class ULocale implements Serializable {
// --------------------------------
/**
* The key for the private use locale extension ('x').
* {@icu} The key for the private use locale extension ('x').
*
* @see #getExtension(char)
* @see Builder#setExtension(char, String)
@ -2563,10 +2540,10 @@ public final class ULocale implements Serializable {
* @draft ICU 4.2
* @provisional This API might change or be removed in a future release.
*/
static public final char PRIVATE_USE_EXTENSION = 'x';
public static final char PRIVATE_USE_EXTENSION = 'x';
/**
* The key for Unicode locale extension ('u').
* {@icu} The key for Unicode locale extension ('u').
*
* @see #getExtension(char)
* @see Builder#setExtension(char, String)
@ -2574,10 +2551,10 @@ public final class ULocale implements Serializable {
* @draft ICU 4.2
* @provisional This API might change or be removed in a future release.
*/
static public final char UNICODE_LOCALE_EXTENSION = 'u';
public static final char UNICODE_LOCALE_EXTENSION = 'u';
/**
* Returns the extension (or private use) value associated with
* {@icu} Returns the extension (or private use) value associated with
* the specified singleton key, or null if there is no extension
* associated with the key. To be valid, the key must be one
* of <code>[0-9A-Za-z]</code>. Keys are case-insensitive, so
@ -2602,7 +2579,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns the set of extension keys associated with this locale, or the
* {@icu} Returns the set of extension keys associated with this locale, or the
* empty set if it has no extensions. The returned set is unmodifiable.
*
* @return the set of extension keys, or the empty set if this locale has
@ -2616,7 +2593,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns the Unicode locale type associated with the specified Unicode
* {@icu} Returns the Unicode locale type associated with the specified Unicode
* locale key for this locale. Unicode locale keywrods are specified
* by the 'u' extension and consist of key/type pairs. The key must be
* two alphanumeric characters in length, or an IllegalArgumentException
@ -2637,7 +2614,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns the set of keys for Unicode locale keywords defined by this locale,
* {@icu} Returns the set of keys for Unicode locale keywords defined by this locale,
* or null if this locale has no locale extension. The returned set is
* immutable.
*
@ -2651,7 +2628,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns a well-formed IETF BCP 47 language tag representing
* {@icu} Returns a well-formed IETF BCP 47 language tag representing
* this locale.
*
* <p>
@ -2712,7 +2689,7 @@ public final class ULocale implements Serializable {
}
/**
* Returns a locale for the specified IETF BCP 47 language tag string.
* {@icu} Returns a locale for the specified IETF BCP 47 language tag string.
* If the specified language tag contains any ill-formed subtags,
* the first such subtag and all following subtags are ignored.
*

View file

@ -25,23 +25,24 @@ import com.ibm.icu.impl.ResourceBundleWrapper;
import com.ibm.icu.impl.SimpleCache;
/**
* A class representing a collection of resource information pertaining to a given
* locale. A resource bundle provides a way of accessing locale- specific information in
* a data file. You create a resource bundle that manages the resources for a given
* locale and then ask it for individual resources.
* <P>
* In ResourceBundle class, an object is created
* and the sub items are fetched using getString, getObject methods.
* In UResourceBundle,each individual element of a resource is a resource by itself.
* {@icuenhanced java.util.ResourceBundle}.{@icu _usage_}
*
* <P>
* Resource bundles in ICU are currently defined using text files which conform to the following
* <a href="http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt">BNF definition</a>.
* More on resource bundle concepts and syntax can be found in the
* <a href="http://www.icu-project.org/userguide/ResourceManagement.html">Users Guide</a>.
* <P>
* <p>A class representing a collection of resource information pertaining to a given
* locale. A resource bundle provides a way of accessing locale- specific information in a
* data file. You create a resource bundle that manages the resources for a given locale
* and then ask it for individual resources.
*
* The packaging of ICU *.res files can be of two types
* <p>In ResourceBundle, an object is created and the sub-items are fetched using the
* getString and getObject methods. In UResourceBundle, each individual element of a
* resource is a resource by itself.
*
* <p>Resource bundles in ICU are currently defined using text files that conform to the
* following <a
* href="http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt">BNF
* definition</a>. More on resource bundle concepts and syntax can be found in the <a
* href="http://www.icu-project.org/userguide/ResourceManagement.html">Users Guide</a>.
*
* <p>The packaging of ICU *.res files can be of two types
* ICU4C:
* <pre>
* root.res
@ -66,14 +67,20 @@ import com.ibm.icu.impl.SimpleCache;
* | |
* LocaleElements_fr_CA.res LocaleElements_fr_FR.res
* </pre>
* Depending on the organization of your resources, the syntax to getBundleInstance will change.
* To open ICU style organization use:
*
* Depending on the organization of your resources, the syntax to getBundleInstance will
* change. To open ICU style organization use:
*
* <pre>
* UResourceBundle bundle = UResourceBundle.getBundleInstance("com/mycompany/resources", "en_US", myClassLoader);
* UResourceBundle bundle =
* UResourceBundle.getBundleInstance("com/mycompany/resources",
* "en_US", myClassLoader);
* </pre>
* To open Java/JDK style organization use:
* <pre>
* UResourceBundle bundle = UResourceBundle.getBundleInstance("com.mycompany.resources.LocaleElements", "en_US", myClassLoader);
* UResourceBundle bundle =
* UResourceBundle.getBundleInstance("com.mycompany.resources.LocaleElements",
* "en_US", myClassLoader);
* </pre>
* <note>
* Please use pass a class loader for loading non-ICU resources. Java security does not
@ -83,56 +90,62 @@ import com.ibm.icu.impl.SimpleCache;
* @stable ICU 3.0
* @author ram
*/
public abstract class UResourceBundle extends ResourceBundle{
public abstract class UResourceBundle extends ResourceBundle {
/**
* Creates a resource bundle using the specified base name and locale.
* {@icu} Creates a resource bundle using the specified base name and locale.
* ICU_DATA_CLASS is used as the default root.
* @param baseName the base name of the resource bundle, a fully qualified class name
* @param localeName the locale for which a resource bundle is desired
* @exception MissingResourceException If no resource bundle for the specified base name can be found
* @throws MissingResourceException If no resource bundle for the specified base name
* can be found
* @return a resource bundle for the given base name and locale
* @stable ICU 3.0
*/
public static UResourceBundle getBundleInstance(String baseName, String localeName){
return getBundleInstance(baseName, localeName, ICUResourceBundle.ICU_DATA_CLASS_LOADER, false);
return getBundleInstance(baseName, localeName, ICUResourceBundle.ICU_DATA_CLASS_LOADER,
false);
}
/**
* Creates a resource bundle using the specified base name, locale, and class root.
* {@icu} Creates a resource bundle using the specified base name, locale, and class root.
*
* @param baseName the base name of the resource bundle, a fully qualified class name
* @param localeName the locale for which a resource bundle is desired
* @param root the class object from which to load the resource bundle
* @exception MissingResourceException If no resource bundle for the specified base name can be found
* @throws MissingResourceException If no resource bundle for the specified base name
* can be found
* @return a resource bundle for the given base name and locale
* @stable ICU 3.0
*/
public static UResourceBundle getBundleInstance(String baseName, String localeName, ClassLoader root){
public static UResourceBundle getBundleInstance(String baseName, String localeName,
ClassLoader root){
return getBundleInstance(baseName, localeName, root, false);
}
/**
* Creates a resource bundle using the specified base name, locale, and class root.
* {@icu} Creates a resource bundle using the specified base name, locale, and class
* root.
*
* @param baseName the base name of the resource bundle, a fully qualified class name
* @param localeName the locale for which a resource bundle is desired
* @param root the class object from which to load the resource bundle
* @param disableFallback Option to disable locale inheritence.
* If true the fallback chain will not be built.
* @exception MissingResourceException
* @throws MissingResourceException
* if no resource bundle for the specified base name can be found
* @return a resource bundle for the given base name and locale
* @stable ICU 3.0
*
*/
protected static UResourceBundle getBundleInstance(String baseName, String localeName, ClassLoader root, boolean disableFallback) {
protected static UResourceBundle getBundleInstance(String baseName, String localeName,
ClassLoader root, boolean disableFallback) {
return instantiateBundle(baseName, localeName, root, disableFallback);
}
/**
* Sole constructor. (For invocation by subclass constructors, typically
* {@icu} Sole constructor. (For invocation by subclass constructors, typically
* implicit.) This is public for compatibility with Java, whose compiler
* will generate public default constructors for an abstract class.
* @stable ICU 3.0
@ -141,8 +154,8 @@ public abstract class UResourceBundle extends ResourceBundle{
}
/**
* Creates a UResourceBundle for the locale specified, from which users can extract resources by using
* their corresponding keys.
* {@icu} Creates a UResourceBundle for the locale specified, from which users can extract
* resources by using their corresponding keys.
* @param locale specifies the locale for which we want to open the resource.
* If null the bundle for default locale is opened.
* @return a resource bundle for the given locale
@ -152,11 +165,12 @@ public abstract class UResourceBundle extends ResourceBundle{
if (locale==null) {
locale = ULocale.getDefault();
}
return getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, locale.toString(), ICUResourceBundle.ICU_DATA_CLASS_LOADER, false);
return getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, locale.toString(),
ICUResourceBundle.ICU_DATA_CLASS_LOADER, false);
}
/**
* Creates a UResourceBundle for the default locale and specified base name,
* {@icu} Creates a UResourceBundle for the default locale and specified base name,
* from which users can extract resources by using their corresponding keys.
* @param baseName specifies the locale for which we want to open the resource.
* If null the bundle for default locale is opened.
@ -168,11 +182,12 @@ public abstract class UResourceBundle extends ResourceBundle{
baseName = ICUResourceBundle.ICU_BASE_NAME;
}
ULocale uloc = ULocale.getDefault();
return getBundleInstance(baseName, uloc.toString(), ICUResourceBundle.ICU_DATA_CLASS_LOADER, false);
return getBundleInstance(baseName, uloc.toString(), ICUResourceBundle.ICU_DATA_CLASS_LOADER,
false);
}
/**
* Creates a UResourceBundle for the specified locale and specified base name,
* {@icu} Creates a UResourceBundle for the specified locale and specified base name,
* from which users can extract resources by using their corresponding keys.
* @param baseName specifies the locale for which we want to open the resource.
* If null the bundle for default locale is opened.
@ -188,11 +203,12 @@ public abstract class UResourceBundle extends ResourceBundle{
}
ULocale uloc = locale == null ? ULocale.getDefault() : ULocale.forLocale(locale);
return getBundleInstance(baseName, uloc.toString(), ICUResourceBundle.ICU_DATA_CLASS_LOADER, false);
return getBundleInstance(baseName, uloc.toString(), ICUResourceBundle.ICU_DATA_CLASS_LOADER,
false);
}
/**
* Creates a UResourceBundle, from which users can extract resources by using
* {@icu} Creates a UResourceBundle, from which users can extract resources by using
* their corresponding keys.
* @param baseName string containing the name of the data package.
* If null the default ICU package name is used.
@ -208,11 +224,12 @@ public abstract class UResourceBundle extends ResourceBundle{
if (locale == null) {
locale = ULocale.getDefault();
}
return getBundleInstance(baseName, locale.toString(), ICUResourceBundle.ICU_DATA_CLASS_LOADER, false);
return getBundleInstance(baseName, locale.toString(),
ICUResourceBundle.ICU_DATA_CLASS_LOADER, false);
}
/**
* Creates a UResourceBundle for the specified locale and specified base name,
* {@icu} Creates a UResourceBundle for the specified locale and specified base name,
* from which users can extract resources by using their corresponding keys.
* @param baseName specifies the locale for which we want to open the resource.
* If null the bundle for default locale is opened.
@ -222,7 +239,8 @@ public abstract class UResourceBundle extends ResourceBundle{
* @return a resource bundle for the given base name and locale
* @stable ICU 3.8
*/
public static UResourceBundle getBundleInstance(String baseName, Locale locale, ClassLoader loader) {
public static UResourceBundle getBundleInstance(String baseName, Locale locale,
ClassLoader loader) {
if (baseName == null) {
baseName = ICUResourceBundle.ICU_BASE_NAME;
}
@ -231,7 +249,7 @@ public abstract class UResourceBundle extends ResourceBundle{
}
/**
* Creates a UResourceBundle, from which users can extract resources by using
* {@icu} Creates a UResourceBundle, from which users can extract resources by using
* their corresponding keys.<br><br>
* Note: Please use this API for loading non-ICU resources. Java security does not
* allow loading of resources across jar files. You must provide your class loader
@ -244,7 +262,8 @@ public abstract class UResourceBundle extends ResourceBundle{
* @return a resource bundle for the given base name and locale
* @stable ICU 3.8
*/
public static UResourceBundle getBundleInstance(String baseName, ULocale locale, ClassLoader loader) {
public static UResourceBundle getBundleInstance(String baseName, ULocale locale,
ClassLoader loader) {
if (baseName == null) {
baseName = ICUResourceBundle.ICU_BASE_NAME;
}
@ -255,7 +274,7 @@ public abstract class UResourceBundle extends ResourceBundle{
}
/**
* Returns the RFC 3066 conformant locale id of this resource bundle.
* {@icu} Returns the RFC 3066 conformant locale id of this resource bundle.
* This method can be used after a call to getBundleInstance() to
* determine whether the resource bundle returned really
* corresponds to the requested locale or is a fallback.
@ -266,20 +285,21 @@ public abstract class UResourceBundle extends ResourceBundle{
public abstract ULocale getULocale();
/**
* Gets the localeID
* {@icu} Returns the localeID
* @return The string representation of the localeID
* @stable ICU 3.0
*/
protected abstract String getLocaleID();
/**
* Gets the base name of the resource bundle
* {@icu} Returns the base name of the resource bundle
* @return The string representation of the base name
* @stable ICU 3.0
*/
protected abstract String getBaseName();
/**
* Gets the parent bundle
* {@icu} Returns the parent bundle
* @return The parent bundle
* @stable ICU 3.0
*/
@ -287,7 +307,7 @@ public abstract class UResourceBundle extends ResourceBundle{
/**
* Get the locale of this bundle
* Returns the locale of this bundle
* @return the locale of this resource bundle
* @stable ICU 3.0
*/
@ -303,15 +323,14 @@ public abstract class UResourceBundle extends ResourceBundle{
* @internal
* @deprecated This API is ICU internal only.
*/
public static void resetBundleCache()
{
public static void resetBundleCache() {
/*
* A HACK!!!!!
* Currently if a resourcebundle with fallback turned ON is added to the cache
* and then a getBundleInstance() is called for a bundle with fallback turned OFF
* it will actually search the cache for any bundle of the same locale
* regaurdless of fallback status. This method has been created so that if
* The calling method KNOWS that instances of the other fallback state may be in the
* The calling method KNOWS that instances of the other fallback state may be in the
* cache, the calling method may call this method to clear out the cache.
*
*/
@ -320,9 +339,9 @@ public abstract class UResourceBundle extends ResourceBundle{
}
/**
* Method used by subclasses to add a resource bundle object to the managed cache.
* Works like a putIfAbsent(): If the cache already contains a matching bundle,
* that one will be retained and returned.
* Method used by subclasses to add a resource bundle object to the managed
* cache. Works like a putIfAbsent(): If the cache already contains a matching
* bundle, that one will be retained and returned.
* @internal
* @deprecated This API is ICU internal only.
*/
@ -338,12 +357,14 @@ public abstract class UResourceBundle extends ResourceBundle{
return b;
}
}
/**
* Method used by sub classes to load a resource bundle object from the managed cache
* @internal
* @deprecated This API is ICU internal only.
*/
protected static UResourceBundle loadFromCache(ClassLoader cl, String fullName, ULocale defaultLocale){
protected static UResourceBundle loadFromCache(ClassLoader cl, String fullName,
ULocale defaultLocale){
synchronized(cacheKey){
cacheKey.setKeyValues(cl, fullName, defaultLocale);
return BUNDLE_CACHE.get(cacheKey);
@ -403,9 +424,11 @@ public abstract class UResourceBundle extends ResourceBundle{
return false;
}
}
public int hashCode() {
return hashCodeCache;
}
public Object clone() {
try {
return super.clone();
@ -414,8 +437,10 @@ public abstract class UResourceBundle extends ResourceBundle{
throw new IllegalStateException();
}
}
///CLOVER:ON
private synchronized void setKeyValues(ClassLoader root, String searchName, ULocale defaultLocale) {
private synchronized void setKeyValues(ClassLoader root, String searchName,
ULocale defaultLocale) {
this.searchName = searchName;
hashCodeCache = searchName.hashCode();
this.defaultLocale = defaultLocale;
@ -442,8 +467,7 @@ public abstract class UResourceBundle extends ResourceBundle{
private static SoftReference<Map<String, Integer>> ROOT_CACHE;
private static int getRootType(String baseName, ClassLoader root)
{
private static int getRootType(String baseName, ClassLoader root) {
Map<String, Integer> m = null;
Integer rootType;
@ -480,8 +504,7 @@ public abstract class UResourceBundle extends ResourceBundle{
return rootType.intValue();
}
private static void setRootType(String baseName, int rootType)
{
private static void setRootType(String baseName, int rootType) {
Integer rt = Integer.valueOf(rootType);
Map<String, Integer> m = null;
@ -496,18 +519,19 @@ public abstract class UResourceBundle extends ResourceBundle{
}
/**
* Loads a new resource bundle for the given base name, locale and class loader.
* {@icu} Loads a new resource bundle for the given base name, locale and class loader.
* Optionally will disable loading of fallback bundles.
* @param baseName the base name of the resource bundle, a fully qualified class name
* @param localeName the locale for which a resource bundle is desired
* @param root the class object from which to load the resource bundle
* @param disableFallback disables loading of fallback lookup chain
* @exception MissingResourceException If no resource bundle for the specified base name can be found
* @throws MissingResourceException If no resource bundle for the specified base name
* can be found
* @return a resource bundle for the given base name and locale
* @stable ICU 3.0
*/
protected static UResourceBundle instantiateBundle(String baseName, String localeName,
ClassLoader root, boolean disableFallback){
ClassLoader root, boolean disableFallback) {
UResourceBundle b = null;
int rootType = getRootType(baseName, root);
@ -520,23 +544,28 @@ public abstract class UResourceBundle extends ResourceBundle{
String fullName = ICUResourceBundle.getFullName(baseName, localeName);
b = loadFromCache(root, fullName, defaultLocale);
if (b == null) {
b = ICUResourceBundle.getBundleInstance(baseName, localeName, root, disableFallback);
b = ICUResourceBundle.getBundleInstance(baseName, localeName, root,
disableFallback);
}
} else {
b = ICUResourceBundle.getBundleInstance(baseName, localeName, root, disableFallback);
b = ICUResourceBundle.getBundleInstance(baseName, localeName, root,
disableFallback);
}
return b;
case ROOT_JAVA:
return ResourceBundleWrapper.getBundleInstance(baseName, localeName, root, disableFallback);
return ResourceBundleWrapper.getBundleInstance(baseName, localeName, root,
disableFallback);
default:
try{
b = ICUResourceBundle.getBundleInstance(baseName, localeName, root, disableFallback);
b = ICUResourceBundle.getBundleInstance(baseName, localeName, root,
disableFallback);
setRootType(baseName, ROOT_ICU);
}catch(MissingResourceException ex){
b = ResourceBundleWrapper.getBundleInstance(baseName, localeName, root, disableFallback);
b = ResourceBundleWrapper.getBundleInstance(baseName, localeName, root,
disableFallback);
setRootType(baseName, ROOT_JAVA);
}
return b;
@ -544,9 +573,10 @@ public abstract class UResourceBundle extends ResourceBundle{
}
/**
* Returns a binary data item from a binary resource, as a read-only ByteBuffer.
* {@icu} Returns a binary data item from a binary resource, as a read-only ByteBuffer.
*
* @return a pointer to a chunk of unsigned bytes which live in a memory mapped/DLL file.
* @return a pointer to a chunk of unsigned bytes which live in a memory mapped/DLL
* file.
* @see #getIntVector
* @see #getInt
* @throws MissingResourceException If no resource bundle can be found.
@ -587,7 +617,7 @@ public abstract class UResourceBundle extends ResourceBundle{
}
/**
* Returns a binary data from a binary resource, as a byte array with a copy
* {@icu} Returns a binary data from a binary resource, as a byte array with a copy
* of the bytes from the resource bundle.
*
* @param ba The byte array to write the bytes to. A null variable is OK.
@ -603,7 +633,7 @@ public abstract class UResourceBundle extends ResourceBundle{
}
/**
* Returns a 32 bit integer array from a resource.
* {@icu} Returns a 32 bit integer array from a resource.
*
* @return a pointer to a chunk of unsigned bytes which live in a memory mapped/DLL file.
* @see #getBinary()
@ -617,7 +647,7 @@ public abstract class UResourceBundle extends ResourceBundle{
}
/**
* Returns a signed integer from a resource.
* {@icu} Returns a signed integer from a resource.
*
* @return an integer value
* @see #getIntVector
@ -631,7 +661,7 @@ public abstract class UResourceBundle extends ResourceBundle{
}
/**
* Returns a unsigned integer from a resource.
* {@icu} Returns a unsigned integer from a resource.
* This integer is originally 28 bit and the sign gets propagated.
*
* @return an integer value
@ -646,7 +676,7 @@ public abstract class UResourceBundle extends ResourceBundle{
}
/**
* Returns a resource in a given resource that has a given key.
* {@icu} Returns a resource in a given resource that has a given key.
*
* @param aKey a key associated with the wanted resource
* @return a resource bundle object representing the resource
@ -663,7 +693,7 @@ public abstract class UResourceBundle extends ResourceBundle{
}
return obj;
}
/**
* Returns a resource in a given resource that has a given key, or null if the
* resource is not found.
@ -675,7 +705,7 @@ public abstract class UResourceBundle extends ResourceBundle{
* @deprecated This API is ICU internal only.
*/
protected UResourceBundle findTopLevel(String aKey) {
// NOTE: this only works for top-level resources. For resources at lower
// NOTE: this only works for top-level resources. For resources at lower
// levels, it fails when you fall back to the parent, since you're now
// looking at root resources, not at the corresponding nested resource.
for (UResourceBundle res = this; res != null; res = res.getParent()) {
@ -691,8 +721,8 @@ public abstract class UResourceBundle extends ResourceBundle{
/**
* Returns the string in a given resource at the specified index.
*
* @param index an index to the wanted string.
* @return a string which lives in the resource.
* @param index an index to the wanted string.
* @return a string which lives in the resource.
* @throws IndexOutOfBoundsException If the index value is out of bounds of accepted values.
* @throws UResourceTypeMismatchException If resource bundle type mismatch.
* @stable ICU 3.8
@ -706,10 +736,10 @@ public abstract class UResourceBundle extends ResourceBundle{
}
/**
* Returns the resource in a given resource at the specified index.
* {@icu} Returns the resource in a given resource at the specified index.
*
* @param index an index to the wanted resource.
* @return the sub resource UResourceBundle object
* @param index an index to the wanted resource.
* @return the sub resource UResourceBundle object
* @throws IndexOutOfBoundsException If the index value is out of bounds of accepted values.
* @throws MissingResourceException If the resource bundle is missing.
* @stable ICU 3.8
@ -730,7 +760,7 @@ public abstract class UResourceBundle extends ResourceBundle{
((ICUResourceBundle)obj).setLoadingStatus(getLocaleID());
return obj;
}
/**
* Returns a resource in a given resource that has a given index, or null if the
* resource is not found.
@ -742,7 +772,7 @@ public abstract class UResourceBundle extends ResourceBundle{
* @deprecated This API is ICU internal only.
*/
protected UResourceBundle findTopLevel(int index) {
// NOTE: this _barely_ works for top-level resources. For resources at lower
// NOTE: this _barely_ works for top-level resources. For resources at lower
// levels, it fails when you fall back to the parent, since you're now
// looking at root resources, not at the corresponding nested resource.
// Not only that, but unless the indices correspond 1-to-1, the index will
@ -757,7 +787,7 @@ public abstract class UResourceBundle extends ResourceBundle{
}
return null;
}
/**
* Returns the keys in this bundle as an enumeration
* @return an enumeration containing key strings,
@ -767,6 +797,7 @@ public abstract class UResourceBundle extends ResourceBundle{
public Enumeration<String> getKeys() {
return Collections.enumeration(keySet());
}
/**
* Returns a Set of all keys contained in this ResourceBundle and its parent bundles.
* @return a Set of all keys contained in this ResourceBundle and its parent bundles,
@ -799,7 +830,7 @@ public abstract class UResourceBundle extends ResourceBundle{
}
return keys;
}
private Set<String> keys = null;
/**
* Returns a Set of the keys contained <i>only</i> in this ResourceBundle.
@ -814,11 +845,11 @@ public abstract class UResourceBundle extends ResourceBundle{
}
/**
* Returns the size of a resource. Size for scalar types is always 1,
* and for vector/table types is the number of child resources.
* <br><b><font color='red'>Warning: </font></b> Integer array is treated as a scalar type. There are no
* APIs to access individual members of an integer array. It
* is always returned as a whole.
* {@icu} Returns the size of a resource. Size for scalar types is always 1, and for
* vector/table types is the number of child resources.
*
* <br><b>Note:</b> Integer array is treated as a scalar type. There are no APIs to
* access individual members of an integer array. It is always returned as a whole.
* @return number of resources in a given resource.
* @stable ICU 3.8
*/
@ -827,7 +858,7 @@ public abstract class UResourceBundle extends ResourceBundle{
}
/**
* Returns the type of a resource.
* {@icu} Returns the type of a resource.
* Available types are {@link #INT INT}, {@link #ARRAY ARRAY},
* {@link #BINARY BINARY}, {@link #INT_VECTOR INT_VECTOR},
* {@link #STRING STRING}, {@link #TABLE TABLE}.
@ -840,7 +871,7 @@ public abstract class UResourceBundle extends ResourceBundle{
}
/**
* Return the version number associated with this UResourceBundle as an
* {@icu} Return the version number associated with this UResourceBundle as an
* VersionInfo object.
* @return VersionInfo object containing the version of the bundle
* @stable ICU 3.8
@ -850,7 +881,7 @@ public abstract class UResourceBundle extends ResourceBundle{
}
/**
* Returns the iterator which iterates over this
* {@icu} Returns the iterator which iterates over this
* resource bundle
* @return UResourceBundleIterator that iterates over the resources in the bundle
* @stable ICU 3.8
@ -858,41 +889,43 @@ public abstract class UResourceBundle extends ResourceBundle{
public UResourceBundleIterator getIterator() {
return new UResourceBundleIterator(this);
}
/**
* Returns the key associated with a given resource. Not all the resources have a key - only
* those that are members of a table.
* {@icu} Returns the key associated with a given resource. Not all the resources have
* a key - only those that are members of a table.
* @return a key associated to this resource, or null if it doesn't have a key
* @stable ICU 3.8
*/
public String getKey() {
return null;
}
/**
* Resource type constant for "no resource".
* {@icu} Resource type constant for "no resource".
* @stable ICU 3.8
*/
public static final int NONE = -1;
/**
* Resource type constant for strings.
* {@icu} Resource type constant for strings.
* @stable ICU 3.8
*/
public static final int STRING = 0;
/**
* Resource type constant for binary data.
* {@icu} Resource type constant for binary data.
* @stable ICU 3.8
*/
public static final int BINARY = 1;
/**
* Resource type constant for tables of key-value pairs.
* {@icu} Resource type constant for tables of key-value pairs.
* @stable ICU 3.8
*/
public static final int TABLE = 2;
/**
* Resource type constant for a single 28-bit integer, interpreted as
* {@icu} Resource type constant for a single 28-bit integer, interpreted as
* signed or unsigned by the getInt() function.
* @see #getInt
* @stable ICU 3.8
@ -900,7 +933,7 @@ public abstract class UResourceBundle extends ResourceBundle{
public static final int INT = 7;
/**
* Resource type constant for arrays of resources.
* {@icu} Resource type constant for arrays of resources.
* @stable ICU 3.8
*/
public static final int ARRAY = 8;
@ -915,7 +948,7 @@ public abstract class UResourceBundle extends ResourceBundle{
//====== protected members ==============
/**
* Actual worker method for fetching a resource based on the given key.
* {@icu} Actual worker method for fetching a resource based on the given key.
* Sub classes must override this method if they support resources with keys.
* @param aKey the key string of the resource to be fetched
* @param table hashtable object to hold references of resources already seen
@ -925,12 +958,13 @@ public abstract class UResourceBundle extends ResourceBundle{
* @return UResourceBundle a resource associated with the key
* @stable ICU 3.8
*/
protected UResourceBundle handleGet(String aKey, HashMap<String, String> table, UResourceBundle requested) {
protected UResourceBundle handleGet(String aKey, HashMap<String, String> table,
UResourceBundle requested) {
return null;
}
/**
* Actual worker method for fetching a resource based on the given index.
* {@icu} Actual worker method for fetching a resource based on the given index.
* Sub classes must override this method if they support arrays of resources.
* @param index the index of the resource to be fetched
* @param table hashtable object to hold references of resources already seen
@ -940,12 +974,13 @@ public abstract class UResourceBundle extends ResourceBundle{
* @return UResourceBundle a resource associated with the index
* @stable ICU 3.8
*/
protected UResourceBundle handleGet(int index, HashMap<String, String> table, UResourceBundle requested) {
protected UResourceBundle handleGet(int index, HashMap<String, String> table,
UResourceBundle requested) {
return null;
}
/**
* Actual worker method for fetching the array of strings in a resource.
* {@icu} Actual worker method for fetching the array of strings in a resource.
* Sub classes must override this method if they support arrays of strings.
* @return String[] An array of strings containing strings
* @stable ICU 3.8
@ -955,7 +990,7 @@ public abstract class UResourceBundle extends ResourceBundle{
}
/**
* Actual worker method for fetching the keys of resources contained in the resource.
* {@icu} Actual worker method for fetching the keys of resources contained in the resource.
* Sub classes must override this method if they support keys and associated resources.
*
* @return Enumeration An enumeration of all the keys in this resource.

View file

@ -1,6 +1,6 @@
/*
******************************************************************************
* Copyright (C) 1996-2004, International Business Machines Corporation and *
* Copyright (C) 1996-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
******************************************************************************
*/
@ -8,12 +8,12 @@
package com.ibm.icu.util;
/**
* <p>Interface for enabling iteration over sets of <int, Object>, where
* int is the sorted integer index in ascending order and Object, its
* <p>Interface for enabling iteration over sets of &lt;int, Object>, where
* int is the sorted integer index in ascending order, and Object its
* associated value.</p>
* <p>The ValueIterator allows iterations over integer indexes in the range
* of Integer.MIN_VALUE to Integer.MAX_VALUE inclusive. Implementations of
* ValueIterator should specify their own maximum subrange within the above
* <p>The ValueIterator allows iterations over integer indexes in the range
* of Integer.MIN_VALUE to Integer.MAX_VALUE inclusive. Implementations of
* ValueIterator should specify their own maximum subrange within the above
* range that is meaningful to its applications.</p>
* <p>Most implementations will be created by factory methods, such as the
* character name iterator in UCharacter.getNameIterator. See example below.
@ -24,8 +24,8 @@ package com.ibm.icu.util;
* ValueIterator.Element result = new ValueIterator.Element();
* iterator.setRange(UCharacter.MIN_VALUE, UCharacter.MAX_VALUE);
* while (iterator.next(result)) {
* System.out.println("Codepoint \\u" +
* Integer.toHexString(result.integer) +
* System.out.println("Codepoint \\u" +
* Integer.toHexString(result.integer) +
* " has the character name " + (String)result.value);
* }
* </pre>
@ -35,16 +35,16 @@ package com.ibm.icu.util;
public interface ValueIterator
{
// public inner class ---------------------------------------------
/**
* <p>The return result container of each iteration. Stores the next
* integer index and its associated value Object.</p>
* <p>The return result container of each iteration. Stores the next
* integer index and its associated value Object.</p>
* @stable ICU 2.6
*/
public static final class Element
{
// public data members ----------------------------------------
/**
* Integer index of the current iteration
* @stable ICU 2.6
@ -53,11 +53,11 @@ public interface ValueIterator
/**
* Gets the Object value associated with the integer index.
* @stable ICU 2.6
*/
*/
public Object value;
// public constructor ------------------------------------------
/**
* Empty default constructor to make javadoc happy
* @stable ICU 2.4
@ -66,13 +66,13 @@ public interface ValueIterator
{
}
}
// public methods -------------------------------------------------
/**
* <p>Gets the next result for this iteration and returns
* <p>Returns the next result for this iteration and returns
* true if we are not at the end of the iteration, false otherwise.</p>
* <p>If the return boolean is a false, the contents of elements will not
* <p>If this returns a false, the contents of elements will not
* be updated.</p>
* @param element for storing the result index and value
* @return true if we are not at the end of the iteration, false otherwise.
@ -80,28 +80,28 @@ public interface ValueIterator
* @stable ICU 2.6
*/
public boolean next(Element element);
/**
* <p>Resets the iterator to start iterating from the integer index
* <p>Resets the iterator to start iterating from the integer index
* Integer.MIN_VALUE or X if a setRange(X, Y) has been called previously.
* </p>
* @stable ICU 2.6
*/
public void reset();
/**
* <p>Restricts the range of integers to iterate and resets the iteration
* <p>Restricts the range of integers to iterate and resets the iteration
* to begin at the index argument start.</p>
* <p>If setRange(start, end) is not performed before next(element) is
* called, the iteration will start from the integer index
* <p>If setRange(start, end) is not performed before next(element) is
* called, the iteration will start from the integer index
* Integer.MIN_VALUE and end at Integer.MAX_VALUE.</p>
* <p>
* If this range is set outside the meaningful range specified by the
* If this range is set outside the meaningful range specified by the
* implementation, next(element) will always return false.
* </p>
* @param start first integer in the range to iterate
* @param limit one more than the last integer in the range
* @exception IllegalArgumentException thrown when attempting to set an
* @param limit one more than the last integer in the range
* @exception IllegalArgumentException thrown when attempting to set an
* illegal range. E.g limit <= start
* @stable ICU 2.6
*/

View file

@ -1,6 +1,6 @@
/**
*******************************************************************************
* Copyright (C) 2002-2008, International Business Machines Corporation and *
* Copyright (C) 2002-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -222,6 +222,21 @@ public class CheckTags {
return UNKNOWN;
}
static final String[] icuTagNames = {
"@icu", "@icunote", "@icuenhanced"
};
static final int ICU = 0;
static final int ICUNOTE = 1;
static final int ICUENHANCED = 2;
static int icuTagIndex(String name) {
for (int i = 0; i < icuTagNames.length; ++i) {
if (icuTagNames[i].equals(name)) {
return i;
}
}
return UNKNOWN;
}
boolean newline = false;
void output(String msg, boolean error, boolean newline) {
@ -252,9 +267,16 @@ public class CheckTags {
output(msg, true, true);
}
void tagErr(Tag tag) {
void tagErr(String msg, Tag tag) {
// Tag.position() requires JDK 1.4, build.xml tests for this
errln(tag.toString() + " [" + tag.position() + "]");
if (msg.length() > 0) {
msg += ": ";
}
errln(msg + tag.toString() + " [" + tag.position() + "]");
};
void tagErr(Tag tag) {
tagErr("", tag);
}
void doDocs(ProgramElementDoc[] docs, String header, boolean reportError) {
@ -306,7 +328,6 @@ public class CheckTags {
/** Return true if subelements of this doc should be checked */
boolean doTags(ProgramElementDoc doc) {
Tag[] tags = doc.tags();
boolean foundRequiredTag = false;
boolean foundDraftTag = false;
boolean foundProvisionalTag = false;
@ -316,9 +337,39 @@ public class CheckTags {
boolean foundStableTag = false;
boolean retainAll = false;
for (int i = 0; i < tags.length; ++i) {
Tag tag = tags[i];
// first check inline tags
for (Tag tag : doc.inlineTags()) {
int index = icuTagIndex(tag.name());
if (index >= 0) {
String text = tag.text().trim();
switch (index) {
case ICU: {
if (doc.isClass() || doc.isInterface()) {
tagErr("tag should appear only in member docs", tag);
}
} break;
case ICUNOTE: {
if (text.length() > 0) {
tagErr("tag should not contain text", tag);
}
} break;
case ICUENHANCED: {
if (text.length() == 0) {
tagErr("text should name related jdk class", tag);
}
if (!(doc.isClass() || doc.isInterface())) {
tagErr("tag should appear only in class/interface docs", tag);
}
} break;
default:
tagErr("unrecognized tag index for tag", tag);
break;
}
}
}
// next check regular tags
for (Tag tag : doc.tags()) {
String kind = tag.kind();
int ix = tagKindIndex(kind);

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2005-2007, International Business Machines Corporation and *
* Copyright (C) 2005-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
@ -253,7 +253,7 @@ public class ICUJDKCompare {
if (trgPrefix == null) {
trgPrefix = kTrgPrefix;
}
if (classPairs == null) {
processPairInfo(kPairInfo);
}
@ -351,6 +351,11 @@ public class ICUJDKCompare {
Set set1 = getFieldSet(fields1);
Set set2 = getFieldSet(fields2);
if (n1.indexOf("DecimalFormatSymbols") != -1) {
pw.format("fields in %s: %s%n", n1, set1);
pw.format("fields in %s: %s%n", n2, set2);
}
Map diffConss = diffMethodMaps(cmap2, cmap1);
Map diffMeths = diffMethodMaps(map2, map1);
Set diffFields = diffFieldSets(set2, set1);
@ -619,7 +624,7 @@ public class ICUJDKCompare {
if (il == null) {
return m1;
}
Map result = new TreeMap(((TreeMap)m1).comparator());
result.putAll(m1);
Iterator iter = result.entrySet().iterator();
@ -633,7 +638,7 @@ public class ICUJDKCompare {
continue loop;
}
}
}
}
return result;
}
@ -660,7 +665,7 @@ public class ICUJDKCompare {
if (il == null) {
return s1;
}
Set result = (Set)((TreeSet)s1).clone();
Iterator iter = result.iterator();
loop: while (iter.hasNext()) {
@ -673,7 +678,7 @@ public class ICUJDKCompare {
continue loop;
}
}
}
}
return result;
}

View file

@ -1,6 +1,6 @@
/**
*******************************************************************************
* Copyright (C) 2002-2009, International Business Machines Corporation and *
* Copyright (C) 2002-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -33,7 +33,8 @@ public abstract class ICUTaglet implements Taglet {
protected static final int MASK_INLINE = 64;
protected static final int MASK_DEFAULT = 0x003f; // no inline
protected static final int MASK_VALID = 0x007f; // includes inline
protected static final int MASK_DEFAULT_INLINE = 0x007f; // includes inline
protected static final int MASK_VALID = 0x007f;
public static void register(Map taglets) {
ICUInternalTaglet.register(taglets);
@ -42,6 +43,9 @@ public abstract class ICUTaglet implements Taglet {
ICUProvisionalTaglet.register(taglets);
ICUObsoleteTaglet.register(taglets);
ICUIgnoreTaglet.register(taglets);
ICUNewTaglet.register(taglets);
ICUNoteTaglet.register(taglets);
ICUEnhancedTaglet.register(taglets);
}
protected ICUTaglet(String name, int mask) {
@ -86,7 +90,7 @@ public abstract class ICUTaglet implements Taglet {
}
public String toString(Tag[] tags) {
if (tags != null) {
if (!isInlineTag() && tags != null) {
if (tags.length > 1) {
String msg = "Should not have more than one ICU tag per element:\n";
for (int i = 0; i < tags.length; ++i) {
@ -100,13 +104,17 @@ public abstract class ICUTaglet implements Taglet {
return null;
}
public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) throws IllegalArgumentException {
public TagletOutput getTagletOutput(Tag tag, TagletWriter writer)
throws IllegalArgumentException {
TagletOutput out = writer.getTagletOutputInstance();
out.setOutput(toString(tag));
return out;
}
public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) throws IllegalArgumentException {
public TagletOutput getTagletOutput(Doc holder, TagletWriter writer)
throws IllegalArgumentException {
TagletOutput out = writer.getTagletOutputInstance();
Tag[] tags = holder.tags(getName());
if (tags.length == 0) {
@ -130,7 +138,8 @@ public abstract class ICUTaglet implements Taglet {
}
public String toString(Tag tag) {
return STATUS + "<dd><em>Internal</em>. <font color='red'>This API is <em>ICU internal only</em>.</font></dd>";
return STATUS + "<dd><em>Internal</em>. <font color='red'>" +
"This API is <em>ICU internal only</em>.</font></dd>";
}
}
@ -212,7 +221,8 @@ public abstract class ICUTaglet implements Taglet {
if (text.length() == 0) {
first = next = 0;
}
return STATUS + "<dd><em>Obsolete.</em> <font color='red'>Will be removed in " + text.substring(first, next) + "</font>. " + text.substring(next) + "</dd>";
return STATUS + "<dd><em>Obsolete.</em> <font color='red'>Will be removed in " +
text.substring(first, next) + "</font>. " + text.substring(next) + "</dd>";
}
}
@ -237,4 +247,110 @@ public abstract class ICUTaglet implements Taglet {
return null;
}
}
private static String ICU_LABEL = "<strong><font color=red>[icu]</font></strong>";
/**
* This taglet should be used in the first line of the class description of classes
* that are enhancements of JDK classes that similar names and APIs. The text should
* provide the full package and name of the JDK class. A period should follow the
* tag. This puts an 'icu enhancement' message into the first line of the class docs,
* where it will also appear in the class summary.
*
* <p>Following this tag (and period), ideally in the first paragraph, the '@icu' tag
* should be used with the text '_label_' to generate the standard boilerplate about
* how that tag is used in the class docs. See {@link ICUNewTaglet}.
*
* <p>This cumbersome process is necessary because the javadoc code that handles
* taglets doesn't look at punctuation in the substitution text to determine when to
* end the first line, it looks in the original javadoc comment. So we need a tag to
* identify the related java class, then a period, then another tag.
*/
public static class ICUEnhancedTaglet extends ICUTaglet {
private static final String NAME = "icuenhanced";
public static void register(Map taglets) {
taglets.put(NAME, new ICUEnhancedTaglet());
}
private ICUEnhancedTaglet() {
super(NAME, MASK_DEFAULT_INLINE);
}
public String toString(Tag tag) {
String text = tag.text().trim();
boolean isClassDoc = tag.holder().isClass() || tag.holder().isInterface();
if (isClassDoc && text.length() > 0) {
StringBuilder sb = new StringBuilder();
return sb.append("<strong><font color=red>[icu enhancement]</font></strong> ")
.append("ICU's replacement for <code>")
.append(text)
.append("</code>")
.toString();
}
return "";
}
}
/**
* This taglet should be used in the first line of any icu-specific members in a class
* that is an enhancement of a JDK class (see {@link ICUEnhancedTaglet}). It generates
* the '[icu]' marker followed by the &lt;strong&gt; text, if any. This does not
* start or end a paragraph or provide additional leading or trailing punctuation such
* as spaces or periods.
*
* <p>Note: if the text is '_usage_' (without quotes) this spits out a boilerplate
* message describing the meaning of the '[icu]' tag. This should be done in the
* first paragraph of the class docs of any class containing '@icu' tags.
*/
public static class ICUNewTaglet extends ICUTaglet {
private static final String NAME = "icu";
public static void register(Map taglets) {
taglets.put(NAME, new ICUNewTaglet());
}
private ICUNewTaglet() {
super(NAME, MASK_DEFAULT_INLINE);
}
public String toString(Tag tag) {
String text = tag.text().trim();
StringBuilder sb = new StringBuilder();
if ("_usage_".equals(text)) {
return sb.append(" Methods, fields, and other functionality specific to ICU ")
.append("are labeled '" + ICU_LABEL + "'.</p>")
.toString();
}
sb.append("<strong><font color=red>[icu]</font>");
if (text.length() > 0) {
sb.append(" ").append(text);
}
sb.append("</strong>");
return sb.toString();
}
}
/**
* This taglet should be used in class or member documentation, after the first line,
* where the behavior of the ICU method or class has notable differences from its JDK
* counterpart. It starts a new paragraph and generates an '[icu] Note:' header.
*/
public static class ICUNoteTaglet extends ICUTaglet {
private static final String NAME = "icunote";
public static void register(Map taglets) {
taglets.put(NAME, new ICUNoteTaglet());
}
private ICUNoteTaglet() {
super(NAME, MASK_DEFAULT_INLINE);
}
public String toString(Tag tag) {
return "<p><strong><font color=red>[icu]</font> Note:</strong> ";
}
}
}