java.lang.Object
javax.money.format.MonetaryFormats
public final class MonetaryFormats
extends java.lang.Object
This class models the singleton accessor for
MonetaryAmountFormat instances.
This class is thread-safe.
- Author:
- Anatole Tresch, Werner Keil
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMonetaryFormats.DefaultMonetaryFormatsSingletonSpiThis class models the singleton accessor forMonetaryAmountFormatinstances. -
Method Summary
Modifier and Type Method Description static MonetaryAmountFormatgetAmountFormat(java.lang.String formatName, java.lang.String... providers)Access the aMonetaryAmountFormatgiven its styleId.static MonetaryAmountFormatgetAmountFormat(java.util.Locale locale, java.lang.String... providers)Access the defaultMonetaryAmountFormatgiven aLocale.static MonetaryAmountFormatgetAmountFormat(AmountFormatQuery formatQuery)Access the defaultMonetaryAmountFormatgiven aLocale.static java.util.Collection<MonetaryAmountFormat>getAmountFormats(AmountFormatQuery formatQuery)Access allMonetaryAmountFormatinstances that match the given aAmountFormatQuery.static java.util.Set<java.util.Locale>getAvailableLocales(java.lang.String... providers)Get all available locales.static java.util.List<java.lang.String>getDefaultFormatProviderChain()Get the default provider chain, identified by the unique provider names in order as evaluated and used.static java.util.Collection<java.lang.String>getFormatProviderNames()Get the names of the currently registered format providers.static booleanisAvailable(java.util.Locale locale, java.lang.String... providers)Checks if aMonetaryAmountFormatis available for the givenLocaleand providers.static booleanisAvailable(AmountFormatQuery formatQuery)Checks if aMonetaryAmountFormatis available for the givenAmountFormatQuery.
-
Method Details
-
isAvailable
public static boolean isAvailable(java.util.Locale locale, java.lang.String... providers)Checks if aMonetaryAmountFormatis available for the givenLocaleand providers.- Parameters:
locale- the targetLocale, notnull.providers- The providers to be queried, if not set the providers as defined by #getDefaultCurrencyProviderChain() are queried.- Returns:
- true, if a corresponding
MonetaryAmountFormatis accessible.
-
getAmountFormat
public static MonetaryAmountFormat getAmountFormat(java.util.Locale locale, java.lang.String... providers)Access the defaultMonetaryAmountFormatgiven aLocale.- Parameters:
locale- the targetLocale, notnull.providers- The providers to be queried, if not set the providers as defined by #getDefaultCurrencyProviderChain() are queried.- Returns:
- the matching
MonetaryAmountFormat - Throws:
MonetaryException- if no registeredMonetaryAmountFormatProviderSpican provide a correspondingMonetaryAmountFormatinstance.
-
isAvailable
Checks if aMonetaryAmountFormatis available for the givenAmountFormatQuery.- Parameters:
formatQuery- the requiredAmountFormatQuery, notnull. If the query does not define any explicit provider chain, the providers as defined by #getDefaultCurrencyProviderChain() are used.- Returns:
- true, if a corresponding
MonetaryAmountFormatis accessible.
-
getAmountFormat
Access the defaultMonetaryAmountFormatgiven aLocale.- Parameters:
formatQuery- the requiredAmountFormatQuery, notnull. If the query does not define any explicit provider chain, the providers as defined by #getDefaultCurrencyProviderChain() are used.- Returns:
- the matching
MonetaryAmountFormat - Throws:
MonetaryException- if no registeredMonetaryAmountFormatProviderSpican provide a correspondingMonetaryAmountFormatinstance.
-
getAmountFormats
public static java.util.Collection<MonetaryAmountFormat> getAmountFormats(AmountFormatQuery formatQuery)Access allMonetaryAmountFormatinstances that match the given aAmountFormatQuery.- Parameters:
formatQuery- the requiredAmountFormatQuery, notnull. If the query does not define any explicit provider chain, the providers as defined by #getDefaultCurrencyProviderChain() are used.- Returns:
- the matching
MonetaryAmountFormat - Throws:
MonetaryException- if no registeredMonetaryAmountFormatProviderSpican provide a correspondingMonetaryAmountFormatinstance.
-
getAmountFormat
public static MonetaryAmountFormat getAmountFormat(java.lang.String formatName, java.lang.String... providers)Access the aMonetaryAmountFormatgiven its styleId.- Parameters:
formatName- the target format name, notnull.providers- The providers to be used, if not set the providers as defined by #getDefaultCurrencyProviderChain() are used.- Returns:
- the matching
MonetaryAmountFormat - Throws:
MonetaryException- if no registeredMonetaryAmountFormatProviderSpican provide a correspondingMonetaryAmountFormatinstance.
-
getAvailableLocales
public static java.util.Set<java.util.Locale> getAvailableLocales(java.lang.String... providers)Get all available locales. This equals toMonetaryAmountFormatProviderSpi.getAvailableLocales().- Parameters:
providers- The providers to be used, if not set the providers as defined by #getDefaultCurrencyProviderChain() are used.- Returns:
- all available locales, never
null.
-
getFormatProviderNames
public static java.util.Collection<java.lang.String> getFormatProviderNames()Get the names of the currently registered format providers.- Returns:
- the provider names, never null.
-
getDefaultFormatProviderChain
public static java.util.List<java.lang.String> getDefaultFormatProviderChain()Get the default provider chain, identified by the unique provider names in order as evaluated and used.- Returns:
- the default provider chain, never null.
-