Package com.ibm.icu.text
Class NumberFormat.NumberFormatFactory
java.lang.Object
com.ibm.icu.text.NumberFormat.NumberFormatFactory
- Direct Known Subclasses:
NumberFormat.SimpleNumberFormatFactory
- Enclosing class:
NumberFormat
A NumberFormatFactory is used to register new number formats. The factory
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.
Note: 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 one of these two methods MUST be overridden or else an infinite loop will occur.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Value passed to format requesting a currency format.static final int
Value passed to format requesting an integer format.static final int
Value passed to format requesting a default number format.static final int
Value passed to format requesting a percent format.static final int
Value passed to format requesting a scientific format. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateFormat
(ULocale loc, int formatType) Returns a number format of the appropriate type.createFormat
(Locale loc, int formatType) Returns a number format of the appropriate type.Returns an immutable collection of the locale names directly supported by this factory.boolean
visible()
Returns true if this factory is visible.
-
Field Details
-
FORMAT_NUMBER
public static final int FORMAT_NUMBERValue passed to format requesting a default number format.- See Also:
-
FORMAT_CURRENCY
public static final int FORMAT_CURRENCYValue passed to format requesting a currency format.- See Also:
-
FORMAT_PERCENT
public static final int FORMAT_PERCENTValue passed to format requesting a percent format.- See Also:
-
FORMAT_SCIENTIFIC
public static final int FORMAT_SCIENTIFICValue passed to format requesting a scientific format.- See Also:
-
FORMAT_INTEGER
public static final int FORMAT_INTEGERValue passed to format requesting an integer format.- See Also:
-
-
Constructor Details
-
NumberFormatFactory
protected NumberFormatFactory()
-
-
Method Details
-
visible
public boolean visible()Returns true if this factory is visible. Default is true. If not visible, the locales supported by this factory will not be listed by getAvailableLocales. This value must not change.- Returns:
- true if the factory is visible.
-
getSupportedLocaleNames
Returns an immutable collection of the locale names directly supported by this factory.- Returns:
- the supported locale names.
-
createFormat
Returns a number format of the appropriate type. If the locale is not supported, return null. If the locale is supported, but the type is not provided by this service, return null. Otherwise return an appropriate instance of NumberFormat. Note: as of ICU4J 3.2, implementations should override this method instead of createFormat(Locale, int).- Parameters:
loc
- the locale for which to create the formatformatType
- the type of format- Returns:
- the NumberFormat, or null.
-
createFormat
Returns a number format of the appropriate type. If the locale is not supported, return null. If the locale is supported, but the type is not provided by this service, return null. Otherwise return an appropriate instance of NumberFormat. Note: as of ICU4J 3.2, createFormat(ULocale, int) should be overridden instead of this method. This method is no longer abstract and delegates to that method.- Parameters:
loc
- the locale for which to create the formatformatType
- the type of format- Returns:
- the NumberFormat, or null.
-