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 class
MonetaryFormats.DefaultMonetaryFormatsSingletonSpi
This class models the singleton accessor forMonetaryAmountFormat
instances. -
Method Summary
Modifier and Type Method Description static MonetaryAmountFormat
getAmountFormat(java.lang.String formatName, java.lang.String... providers)
Access the aMonetaryAmountFormat
given its styleId.static MonetaryAmountFormat
getAmountFormat(java.util.Locale locale, java.lang.String... providers)
Access the defaultMonetaryAmountFormat
given aLocale
.static MonetaryAmountFormat
getAmountFormat(AmountFormatQuery formatQuery)
Access the defaultMonetaryAmountFormat
given aLocale
.static java.util.Collection<MonetaryAmountFormat>
getAmountFormats(AmountFormatQuery formatQuery)
Access allMonetaryAmountFormat
instances 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 boolean
isAvailable(java.util.Locale locale, java.lang.String... providers)
Checks if aMonetaryAmountFormat
is available for the givenLocale
and providers.static boolean
isAvailable(AmountFormatQuery formatQuery)
Checks if aMonetaryAmountFormat
is available for the givenAmountFormatQuery
.
-
Method Details
-
isAvailable
public static boolean isAvailable(java.util.Locale locale, java.lang.String... providers)Checks if aMonetaryAmountFormat
is available for the givenLocale
and 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
MonetaryAmountFormat
is accessible.
-
getAmountFormat
public static MonetaryAmountFormat getAmountFormat(java.util.Locale locale, java.lang.String... providers)Access the defaultMonetaryAmountFormat
given 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 registeredMonetaryAmountFormatProviderSpi
can provide a correspondingMonetaryAmountFormat
instance.
-
isAvailable
Checks if aMonetaryAmountFormat
is 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
MonetaryAmountFormat
is accessible.
-
getAmountFormat
Access the defaultMonetaryAmountFormat
given 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 registeredMonetaryAmountFormatProviderSpi
can provide a correspondingMonetaryAmountFormat
instance.
-
getAmountFormats
public static java.util.Collection<MonetaryAmountFormat> getAmountFormats(AmountFormatQuery formatQuery)Access allMonetaryAmountFormat
instances 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 registeredMonetaryAmountFormatProviderSpi
can provide a correspondingMonetaryAmountFormat
instance.
-
getAmountFormat
public static MonetaryAmountFormat getAmountFormat(java.lang.String formatName, java.lang.String... providers)Access the aMonetaryAmountFormat
given 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 registeredMonetaryAmountFormatProviderSpi
can provide a correspondingMonetaryAmountFormat
instance.
-
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.
-