ICU-2203 registration for calendar, breakiterator, update service APIs

X-SVN-Rev: 9972
This commit is contained in:
Doug Felt 2002-10-04 19:49:10 +00:00
parent 5dcdf3046e
commit 7e8cea4c33
2 changed files with 32 additions and 27 deletions

View File

@ -5,8 +5,8 @@
******************************************************************************* *******************************************************************************
* *
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/NumberFormat.java,v $ * $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/NumberFormat.java,v $
* $Date: 2002/10/04 19:41:02 $ * $Date: 2002/10/04 19:49:10 $
* $Revision: 1.16 $ * $Revision: 1.17 $
* *
***************************************************************************************** *****************************************************************************************
*/ */
@ -163,7 +163,7 @@ import com.ibm.icu.impl.LocaleUtility;
* *
* see DecimalFormat * see DecimalFormat
* see java.text.ChoiceFormat * see java.text.ChoiceFormat
* @version $Revision: 1.16 $ * @version $Revision: 1.17 $
* @author Mark Davis * @author Mark Davis
* @author Helena Shih * @author Helena Shih
* @author Alan Liu * @author Alan Liu
@ -484,13 +484,10 @@ public abstract class NumberFormat extends Format{
public static final int FORMAT_INTEGER = INTEGERSTYLE; public static final int FORMAT_INTEGER = INTEGERSTYLE;
/** /**
* Return true if this factory will 'cover' other locales that * Return true if this factory will be visible. Default is true. */
* are more specific than the ones in this factory. E.g., if public boolean visible() {
* this 'covers' other locales, then by supporting the 'en' return true;
* locale, this also supports 'en_US', 'en_US_ETC' and so on, }
* even though only the 'en' locale is listed.
*/
public abstract boolean covers();
/** /**
* Return an unmodifiable collection of the locale names directly * Return an unmodifiable collection of the locale names directly
@ -508,15 +505,19 @@ public abstract class NumberFormat extends Format{
public static abstract class SimpleNumberFormatFactory extends NumberFormatFactory { public static abstract class SimpleNumberFormatFactory extends NumberFormatFactory {
final Set localeNames; final Set localeNames;
final boolean covers; final boolean visible;
public SimpleNumberFormatFactory(Locale locale, boolean covers) { public SimpleNumberFormatFactory(Locale locale) {
localeNames = Collections.singleton(LocaleUtility.canonicalLocaleString(locale)); this(locale, true);
this.covers = covers;
} }
public final boolean covers() { public SimpleNumberFormatFactory(Locale locale, boolean visible) {
return covers; localeNames = Collections.singleton(LocaleUtility.canonicalLocaleString(locale));
this.visible = visible;
}
public final boolean visible() {
return visible;
} }
public final Set getSupportedLocaleNames() { public final Set getSupportedLocaleNames() {
@ -528,7 +529,7 @@ public abstract class NumberFormat extends Format{
private NumberFormatFactory delegate; private NumberFormatFactory delegate;
NFFactory(NumberFormatFactory delegate) { NFFactory(NumberFormatFactory delegate) {
super(delegate.covers() ? VISIBLE_COVERS : VISIBLE); super(delegate.visible() ? VISIBLE : INVISIBLE);
this.delegate = delegate; this.delegate = delegate;
} }

View File

@ -632,7 +632,7 @@ import java.util.Set;
* @see GregorianCalendar * @see GregorianCalendar
* @see TimeZone * @see TimeZone
* @see DateFormat * @see DateFormat
* @version $Revision: 1.32 $ $Date: 2002/10/04 19:41:03 $ * @version $Revision: 1.33 $ $Date: 2002/10/04 19:49:10 $
* @author Mark Davis, David Goldsmith, Chen-Lieh Huang, Alan Liu, Laura Werner * @author Mark Davis, David Goldsmith, Chen-Lieh Huang, Alan Liu, Laura Werner
* @since JDK1.1 * @since JDK1.1
*/ */
@ -1546,21 +1546,25 @@ public abstract class Calendar implements Serializable, Cloneable {
} }
/** /**
* Registers a default CalendarFactory for the provided locale. * Convenience override of register(CalendarFactory, Locale, boolean);
* If covers is true, this factory is also used for all locales
* that are more specific than the provided locale. The returned
* object is a key that can be used to unregister this
* CalendarFactory. If the factory has not already been
* registered with registerFactory, it will be.
*/ */
public static Object register(CalendarFactory factory, Locale locale, boolean covers) { public static Object register(CalendarFactory factory, Locale locale) {
return register(factory, locale, true);
}
/**
* Registers a default CalendarFactory for the provided locale.
* If the factory has not already been registered with
* registerFactory, it will be.
*/
public static Object register(CalendarFactory factory, Locale locale, boolean visible) {
if (factory == null) { if (factory == null) {
throw new IllegalArgumentException("calendar must not be null"); throw new IllegalArgumentException("calendar must not be null");
} }
registerFactory(factory); registerFactory(factory);
return getService().registerObject(factory, locale, covers return getService().registerObject(factory, locale, visible
? LocaleKeyFactory.VISIBLE_COVERS ? LocaleKeyFactory.VISIBLE
: LocaleKeyFactory.VISIBLE); : LocaleKeyFactory.INVISIBLE);
} }
/** /**