Top Description Inners Constructors Methods
javax.money.format

public final Class MonetaryFormats

extends Object
Class Inheritance
Imports
javax.money.MonetaryException, javax.money.spi.Bootstrap, .MonetaryAmountFormatProviderSpi, .MonetaryFormatsSingletonSpi, java.util.*, java.util.concurrent.ConcurrentHashMap, java.util.logging.Level, .Logger

This class models the singleton accessor for MonetaryAmountFormat instances.

This class is thread-safe.

Authors
Anatole Tresch, Werner Keil

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Constructor Summary

AccessConstructor and Description
private
MonetaryFormats()

Private singleton constructor.

Method Summary

Modifier and TypeMethod and Description
public static MonetaryAmountFormat

Returns:

the matching MonetaryAmountFormat
getAmountFormat
(Locale
the target Locale, not null.
locale
,
String...
The providers to be queried, if not set the providers as defined by #getDefaultCurrencyProviderChain() are queried.
providers
)

Access the default MonetaryAmountFormat given a Locale.

public static MonetaryAmountFormat

Returns:

the matching MonetaryAmountFormat
getAmountFormat
(AmountFormatQuery
the required AmountFormatQuery, not null. If the query does not define any explicit provider chain, the providers as defined by #getDefaultCurrencyProviderChain() are used.
formatQuery
)

Access the default MonetaryAmountFormat given a Locale.

public static MonetaryAmountFormat

Returns:

the matching MonetaryAmountFormat
getAmountFormat
(String
the target format name, not null.
formatName
,
String...
The providers to be used, if not set the providers as defined by #getDefaultCurrencyProviderChain() are used.
providers
)

Access the a MonetaryAmountFormat given its styleId.

public static Collection<MonetaryAmountFormat>

Returns:

the matching MonetaryAmountFormat
getAmountFormats
(AmountFormatQuery
the required AmountFormatQuery, not null. If the query does not define any explicit provider chain, the providers as defined by #getDefaultCurrencyProviderChain() are used.
formatQuery
)

Access all MonetaryAmountFormat instances that match the given a AmountFormatQuery.

public static Set<Locale>

Returns:

all available locales, never null.
getAvailableLocales
(String...
The providers to be used, if not set the providers as defined by #getDefaultCurrencyProviderChain() are used.
providers
)

Get all available locales.

public static List<String>

Returns:

the default provider chain, never null.
getDefaultFormatProviderChain
()

Get the default provider chain, identified by the unique provider names in order as evaluated and used.

public static Collection<String>

Returns:

the provider names, never null.
getFormatProviderNames
()

Get the names of the currently registered format providers.

private static MonetaryFormatsSingletonSpi
public static boolean

Returns:

true, if a corresponding MonetaryAmountFormat is accessible.
isAvailable
(Locale
the target Locale, not null.
locale
,
String...
The providers to be queried, if not set the providers as defined by #getDefaultCurrencyProviderChain() are queried.
providers
)

Checks if a MonetaryAmountFormat is available for the given Locale and providers.

public static boolean

Returns:

true, if a corresponding MonetaryAmountFormat is accessible.
isAvailable
(AmountFormatQuery
the required AmountFormatQuery, not null. If the query does not define any explicit provider chain, the providers as defined by #getDefaultCurrencyProviderChain() are used.
formatQuery
)

Checks if a MonetaryAmountFormat is available for the given javax.money.format.AmountFormatQuery.

private static MonetaryFormatsSingletonSpi

Returns:

the instance of MonetaryFormatsSingletonSpi to be used by this singleton.
loadMonetaryFormatsSingletonSpi
()

Loads the SPI backing bean.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

MonetaryFormatsback to summary
private MonetaryFormats()

Private singleton constructor.

Method Detail

getAmountFormatback to summary
public static MonetaryAmountFormat getAmountFormat(Locale locale, String... providers)

Access the default MonetaryAmountFormat given a Locale.

Parameters
locale:Locale

the target Locale, not null.

providers:String[]

The providers to be queried, if not set the providers as defined by #getDefaultCurrencyProviderChain() are queried.

Returns:MonetaryAmountFormat

the matching MonetaryAmountFormat

Exceptions
MonetaryException:
if no registered MonetaryAmountFormatProviderSpi can provide a corresponding MonetaryAmountFormat instance.
getAmountFormatback to summary
public static MonetaryAmountFormat getAmountFormat(AmountFormatQuery formatQuery)

Access the default MonetaryAmountFormat given a Locale.

Parameters
formatQuery:AmountFormatQuery

the required AmountFormatQuery, not null. If the query does not define any explicit provider chain, the providers as defined by #getDefaultCurrencyProviderChain() are used.

Returns:MonetaryAmountFormat

the matching MonetaryAmountFormat

Exceptions
MonetaryException:
if no registered MonetaryAmountFormatProviderSpi can provide a corresponding MonetaryAmountFormat instance.
getAmountFormatback to summary
public static MonetaryAmountFormat getAmountFormat(String formatName, String... providers)

Access the a MonetaryAmountFormat given its styleId.

Parameters
formatName:String

the target format name, not null.

providers:String[]

The providers to be used, if not set the providers as defined by #getDefaultCurrencyProviderChain() are used.

Returns:MonetaryAmountFormat

the matching MonetaryAmountFormat

Exceptions
MonetaryException:
if no registered MonetaryAmountFormatProviderSpi can provide a corresponding MonetaryAmountFormat instance.
getAmountFormatsback to summary
public static Collection<MonetaryAmountFormat> getAmountFormats(AmountFormatQuery formatQuery)

Access all MonetaryAmountFormat instances that match the given a AmountFormatQuery.

Parameters
formatQuery:AmountFormatQuery

the required AmountFormatQuery, not null. If the query does not define any explicit provider chain, the providers as defined by #getDefaultCurrencyProviderChain() are used.

Returns:Collection<MonetaryAmountFormat>

the matching MonetaryAmountFormat

Exceptions
MonetaryException:
if no registered MonetaryAmountFormatProviderSpi can provide a corresponding MonetaryAmountFormat instance.
getAvailableLocalesback to summary
public static Set<Locale> getAvailableLocales(String... providers)

Get all available locales. This equals to MonetaryAmountFormatProviderSpi#getAvailableLocales().

Parameters
providers:String[]

The providers to be used, if not set the providers as defined by #getDefaultCurrencyProviderChain() are used.

Returns:Set<Locale>

all available locales, never null.

getDefaultFormatProviderChainback to summary
public static List<String> getDefaultFormatProviderChain()

Get the default provider chain, identified by the unique provider names in order as evaluated and used.

Returns:List<String>

the default provider chain, never null.

getFormatProviderNamesback to summary
public static Collection<String> getFormatProviderNames()

Get the names of the currently registered format providers.

Returns:Collection<String>

the provider names, never null.

getMonetaryFormatsSpiback to summary
private static MonetaryFormatsSingletonSpi getMonetaryFormatsSpi()
isAvailableback to summary
public static boolean isAvailable(Locale locale, String... providers)

Checks if a MonetaryAmountFormat is available for the given Locale and providers.

Parameters
locale:Locale

the target Locale, not null.

providers:String[]

The providers to be queried, if not set the providers as defined by #getDefaultCurrencyProviderChain() are queried.

Returns:boolean

true, if a corresponding MonetaryAmountFormat is accessible.

isAvailableback to summary
public static boolean isAvailable(AmountFormatQuery formatQuery)

Checks if a MonetaryAmountFormat is available for the given javax.money.format.AmountFormatQuery.

Parameters
formatQuery:AmountFormatQuery

the required AmountFormatQuery, not null. If the query does not define any explicit provider chain, the providers as defined by #getDefaultCurrencyProviderChain() are used.

Returns:boolean

true, if a corresponding MonetaryAmountFormat is accessible.

loadMonetaryFormatsSingletonSpiback to summary
private static MonetaryFormatsSingletonSpi loadMonetaryFormatsSingletonSpi()

Loads the SPI backing bean.

Returns:MonetaryFormatsSingletonSpi

the instance of MonetaryFormatsSingletonSpi to be used by this singleton.

javax.money.format back to summary

public final Class MonetaryFormats.DefaultMonetaryFormatsSingletonSpi

extends Object
implements MonetaryFormatsSingletonSpi
Class Inheritance
  • java.lang.Object
  • javax.money.format.MonetaryFormats.DefaultMonetaryFormatsSingletonSpi
All Implemented Interfaces
javax.money.spi.MonetaryFormatsSingletonSpi

This class models the singleton accessor for javax.money.format.MonetaryAmountFormat instances.

This class is thread-safe.

Authors
Anatole Tresch, Werner Keil

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Collection<MonetaryAmountFormat>

Returns:

the corresponding javax.money.format.MonetaryAmountFormat
getAmountFormats
(AmountFormatQuery
The format query defining the requirements of the formatter.
formatQuery
)

Implements javax.money.spi.MonetaryFormatsSingletonSpi.getAmountFormats.

Access an javax.money.format.MonetaryAmountFormat given a .AmountFormatContext.
public Set<Locale>

Returns:

all available locales, never null.
getAvailableLocales
(String...
The (optional) providers to be used, ordered correspondingly.
providerNames
)

Implements javax.money.spi.MonetaryFormatsSingletonSpi.getAvailableLocales.

Get all available locales.
public List<String>

Returns:

the default provider chain, never null.
getDefaultProviderChain
()

Implements javax.money.spi.MonetaryFormatsSingletonSpi.getDefaultProviderChain.

This default implementation simply returns all providers defined in arbitrary order.
public Set<String>
getProviderNames()

Implements javax.money.spi.MonetaryFormatsSingletonSpi.getProviderNames.

Get the names of the currently registered format providers.
private Collection<MonetaryAmountFormatProviderSpi>
getSpis(String... providerNames)

private Map<String, MonetaryAmountFormatProviderSpi>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DefaultMonetaryFormatsSingletonSpiback to summary
public DefaultMonetaryFormatsSingletonSpi()

Method Detail

getAmountFormatsback to summary
public Collection<MonetaryAmountFormat> getAmountFormats(AmountFormatQuery formatQuery)

Implements javax.money.spi.MonetaryFormatsSingletonSpi.getAmountFormats.

Access an javax.money.format.MonetaryAmountFormat given a .AmountFormatContext.

Parameters
formatQuery:AmountFormatQuery

The format query defining the requirements of the formatter.

Returns:Collection<MonetaryAmountFormat>

the corresponding javax.money.format.MonetaryAmountFormat

Annotations
@Override
Exceptions
MonetaryException:
if no registered .MonetaryAmountFormatProviderSpi can provide a corresponding javax.money.format.MonetaryAmountFormat instance.
getAvailableLocalesback to summary
public Set<Locale> getAvailableLocales(String... providerNames)

Implements javax.money.spi.MonetaryFormatsSingletonSpi.getAvailableLocales.

Get all available locales. This equals to .MonetaryAmountFormatProviderSpi#getAvailableLocales().

Parameters
providerNames:String[]

Doc from javax.money.spi.MonetaryFormatsSingletonSpi.getAvailableLocales.

The (optional) providers to be used, ordered correspondingly.

Returns:Set<Locale>

all available locales, never null.

Annotations
@Override
getDefaultProviderChainback to summary
public List<String> getDefaultProviderChain()

Implements javax.money.spi.MonetaryFormatsSingletonSpi.getDefaultProviderChain.

This default implementation simply returns all providers defined in arbitrary order.

Returns:List<String>

the default provider chain, never null.

Annotations
@Override
getProviderNamesback to summary
public Set<String> getProviderNames()

Implements javax.money.spi.MonetaryFormatsSingletonSpi.getProviderNames.

Doc from javax.money.spi.MonetaryFormatsSingletonSpi.getProviderNames.

Get the names of the currently registered format providers.

Returns:Set<String>

the provider names, never null.

Annotations
@Override
getSpisback to summary
private Collection<MonetaryAmountFormatProviderSpi> getSpis(String... providerNames)
getSpisAsMapback to summary
private Map<String, MonetaryAmountFormatProviderSpi> getSpisAsMap()