Package com.highdeal.currency
Class PropertyCurrencyBook
java.lang.Object
com.highdeal.currency.PropertyCurrencyBook
- All Implemented Interfaces:
CurrencyBook
A
PropertyCurrencyBook keeps the currencies that can be used in your client
application; The currencies are stored in a property resources.-
Constructor Summary
ConstructorsConstructorDescriptionInitializes a new property currency book from the default resource file (RESOURCE_FILE).PropertyCurrencyBook(InputStream stream) Initializes a new property currency book from a stream.PropertyCurrencyBook(String fileName) Initializes a new property currency book from a specified resource file.PropertyCurrencyBook(String fileName, Locale locale) Initializes a new property currency book from a specified resource file.PropertyCurrencyBook(Locale locale) Initializes a new property currency book from the default resource file (RESOURCE_FILE).PropertyCurrencyBook(ResourceBundle bundle) Initializes a new property currency book from a specified resource bundle -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCurrency(Currency currency) Adds a currency in the currency book.static PropertyCurrencyBookReturns all the current currencies that can be used in your client application.getCurrency(int code) Returns a currency from a given ISO 4217 code.getCurrency(String code) Returns a currency from a specified code.getCurrency(String iso4217code, int precision) Returns a currency from a given ISO 4217 code and with a precision greater or equal to the given precision; If there is no currency a given ISO 4217 code for with a precision greater or equal to the given precision, return null.
-
Constructor Details
-
PropertyCurrencyBook
Initializes a new property currency book from the default resource file (RESOURCE_FILE).- Throws:
IOException- if an error occurred reading the default resource fileMissingResourceException- if the resource file does not contain the specified currency resources
-
PropertyCurrencyBook
Initializes a new property currency book from the default resource file (RESOURCE_FILE).- Parameters:
locale- The locale object- Throws:
IOException- if an error occurred reading the default resource fileMissingResourceException- if the resource file does not contain the specified currency resources
-
PropertyCurrencyBook
Initializes a new property currency book from a specified resource file.- Parameters:
fileName- The name and path of the resource file- Throws:
IOException- if an error occurred reading the specified resource fileMissingResourceException- if the resource file does not contain the specified currency resources
-
PropertyCurrencyBook
public PropertyCurrencyBook(String fileName, Locale locale) throws IOException, MissingResourceException Initializes a new property currency book from a specified resource file.- Parameters:
fileName- The name and path of the resource filelocale- The locale object- Throws:
IOException- if an error occurred reading the specified resource fileMissingResourceException- if the resource file does not contain the specified currency resources
-
PropertyCurrencyBook
Initializes a new property currency book from a stream.- Parameters:
stream- The stream that contains the currency resources- Throws:
IOException- if an error occurred reading the streamMissingResourceException- if the stream does not contain the specified currency resources
-
PropertyCurrencyBook
Initializes a new property currency book from a specified resource bundle- Parameters:
bundle- The resource bundle containing the currency resources- Throws:
MissingResourceException- if the resource bundle does not contain the specified currency resources
-
-
Method Details
-
getCurrencies
Description copied from interface:CurrencyBookReturns all the current currencies that can be used in your client application.- Specified by:
getCurrenciesin interfaceCurrencyBook- Returns:
- The current list of currencies that can be used in your client application
-
getCurrency
Description copied from interface:CurrencyBookReturns a currency from a given ISO 4217 code.- Specified by:
getCurrencyin interfaceCurrencyBook- Parameters:
code- The ISO 4217 three-digit currency code- Returns:
- The currency for this code
-
getCurrency
Description copied from interface:CurrencyBookReturns a currency from a given ISO 4217 code and with a precision greater or equal to the given precision; If there is no currency a given ISO 4217 code for with a precision greater or equal to the given precision, return null.- Specified by:
getCurrencyin interfaceCurrencyBook- Parameters:
iso4217code- The ISO 4217 code of the currencyprecision- The minimum precision of the currency- Returns:
- The currency for this ISO 4217 code and precision or null
-
getCurrency
Description copied from interface:CurrencyBookReturns a currency from a specified code.- Specified by:
getCurrencyin interfaceCurrencyBook- Parameters:
code- The code of the currency- Returns:
- The currency for this code
-
addCurrency
Description copied from interface:CurrencyBookAdds a currency in the currency book.- Specified by:
addCurrencyin interfaceCurrencyBook- Parameters:
currency- The currency to be added
-
createDefaultInstance
-