public abstract class AbstractRateProvider
extends java.lang.Object
implements javax.money.convert.ExchangeRateProvider
ExchangeRateProvider implementations.| Modifier and Type | Field and Description |
|---|---|
protected java.util.logging.Logger |
LOGGER
The logger used.
|
| Constructor and Description |
|---|
AbstractRateProvider(javax.money.convert.ProviderContext providerContext)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected static javax.money.NumberValue |
divide(javax.money.NumberValue dividend,
javax.money.NumberValue divisor)
A protected helper method to divide 2
NumberValue types. |
protected static javax.money.NumberValue |
divide(javax.money.NumberValue dividend,
javax.money.NumberValue divisor,
java.math.MathContext context)
A protected helper method to divide 2
NumberValue types. |
javax.money.convert.CurrencyConversion |
getCurrencyConversion(javax.money.CurrencyUnit termCurrency)
Access a
CurrencyConversion that can be applied as a
MonetaryOperator to an amount. |
javax.money.convert.CurrencyConversion |
getCurrencyConversion(javax.money.CurrencyUnit term,
javax.money.convert.ConversionContext conversionContext)
Access a
CurrencyConversion that can be applied as a
MonetaryOperator to an amount. |
javax.money.convert.CurrencyConversion |
getCurrencyConversion(java.lang.String termCode)
Access a
CurrencyConversion that can be applied as a
MonetaryOperator to an amount. |
javax.money.convert.CurrencyConversion |
getCurrencyConversion(java.lang.String termCode,
javax.money.convert.ConversionContext conversionContext)
Access a
CurrencyConversion that can be applied as a
MonetaryOperator to an amount. |
javax.money.convert.ExchangeRate |
getExchangeRate(javax.money.CurrencyUnit source,
javax.money.CurrencyUnit target)
Access a
ExchangeRate using the given currencies. |
javax.money.convert.ExchangeRate |
getExchangeRate(javax.money.CurrencyUnit base,
javax.money.CurrencyUnit term,
javax.money.convert.ConversionContext conversionContext)
Access a
ExchangeRate using the given currencies. |
javax.money.convert.ExchangeRate |
getExchangeRate(java.lang.String baseCode,
java.lang.String termCode)
Access a
ExchangeRate using the given currencies. |
javax.money.convert.ExchangeRate |
getExchangeRate(java.lang.String baseCode,
java.lang.String termCode,
javax.money.convert.ConversionContext conversionContext)
Access a
ExchangeRate using the given currencies. |
protected abstract javax.money.convert.ExchangeRate |
getExchangeRateInternal(javax.money.CurrencyUnit base,
javax.money.CurrencyUnit term,
javax.money.convert.ConversionContext context) |
javax.money.convert.ProviderContext |
getProviderContext()
Access the
ConversionContext for this
ExchangeRateProvider. |
javax.money.convert.ExchangeRate |
getReversed(javax.money.convert.ExchangeRate rate)
The method reverses the
ExchangeRate to a rate mapping from term
to base CurrencyUnit. |
boolean |
isAvailable(javax.money.CurrencyUnit src,
javax.money.CurrencyUnit target)
Checks if an
ExchangeRate between two CurrencyUnit is
available from this provider. |
boolean |
isAvailable(javax.money.CurrencyUnit base,
javax.money.CurrencyUnit term,
javax.money.convert.ConversionContext conversionContext)
Checks if an
ExchangeRate between two CurrencyUnit is
available from this provider. |
boolean |
isAvailable(java.lang.String baseCode,
java.lang.String termCode)
Checks if an
ExchangeRate between two CurrencyUnit is
available from this provider. |
boolean |
isAvailable(java.lang.String baseCode,
java.lang.String termCode,
javax.money.convert.ConversionContext conversionContext)
Checks if an
ExchangeRate between two CurrencyUnit is
available from this provider. |
protected static javax.money.NumberValue |
multiply(javax.money.NumberValue multiplicand,
javax.money.NumberValue multiplier)
A protected helper method to multiply 2
NumberValue types. |
public AbstractRateProvider(javax.money.convert.ProviderContext providerContext)
providerContext - the ProviderContext, not null.protected static final javax.money.NumberValue divide(javax.money.NumberValue dividend,
javax.money.NumberValue divisor)
NumberValue types.null an ArithmeticException is thrown.dividend - the first value to be divideddivisor - the value to be divided byNumberValueprotected static final javax.money.NumberValue divide(javax.money.NumberValue dividend,
javax.money.NumberValue divisor,
java.math.MathContext context)
NumberValue types.null an ArithmeticException is thrown.dividend - the first value to be divideddivisor - the value to be divided bycontext - the MathContext to useNumberValuepublic javax.money.convert.CurrencyConversion getCurrencyConversion(javax.money.CurrencyUnit termCurrency)
javax.money.convert.ExchangeRateProviderCurrencyConversion that can be applied as a
MonetaryOperator to an amount.getCurrencyConversion in interface javax.money.convert.ExchangeRateProvidertermCurrency - term CurrencyUnit, not nullCurrencyConversion,
never null.public javax.money.convert.CurrencyConversion getCurrencyConversion(javax.money.CurrencyUnit term,
javax.money.convert.ConversionContext conversionContext)
javax.money.convert.ExchangeRateProviderCurrencyConversion that can be applied as a
MonetaryOperator to an amount.getCurrencyConversion in interface javax.money.convert.ExchangeRateProviderterm - term CurrencyUnit, not nullconversionContext - the required ConversionContext, not nullCurrencyConversion,
never null.public javax.money.convert.CurrencyConversion getCurrencyConversion(java.lang.String termCode)
javax.money.convert.ExchangeRateProviderCurrencyConversion that can be applied as a
MonetaryOperator to an amount.getCurrencyConversion in interface javax.money.convert.ExchangeRateProvidertermCode - terminal/target currency code, not nullCurrencyConversion,
never null.public javax.money.convert.CurrencyConversion getCurrencyConversion(java.lang.String termCode,
javax.money.convert.ConversionContext conversionContext)
javax.money.convert.ExchangeRateProviderCurrencyConversion that can be applied as a
MonetaryOperator to an amount.getCurrencyConversion in interface javax.money.convert.ExchangeRateProvidertermCode - terminal/target currency code, not nullconversionContext - the required ConversionContext, not nullCurrencyConversion,
never null.public javax.money.convert.ExchangeRate getExchangeRate(javax.money.CurrencyUnit source,
javax.money.CurrencyUnit target)
javax.money.convert.ExchangeRateProviderExchangeRate using the given currencies. The
ExchangeRate may be, depending on the data provider, eal-time or
deferred. This method should return the rate that is currently
valid. It should be the same as
getExchangeRate(base, term, System.currentTimeMillis()).getExchangeRate in interface javax.money.convert.ExchangeRateProvidersource - base CurrencyUnit, not nulltarget - term CurrencyUnit, not nullExchangeRate.public javax.money.convert.ExchangeRate getExchangeRate(javax.money.CurrencyUnit base,
javax.money.CurrencyUnit term,
javax.money.convert.ConversionContext conversionContext)
javax.money.convert.ExchangeRateProviderExchangeRate using the given currencies. The
ExchangeRate may be, depending on the data provider, eal-time or
deferred. This method should return the rate that is currently
valid. It should be the same as
getExchangeRate(base, term, System.currentTimeMillis()).getExchangeRate in interface javax.money.convert.ExchangeRateProviderbase - base CurrencyUnit, not nullterm - term CurrencyUnit, not nullconversionContext - the required ConversionContext, not nullExchangeRate.public javax.money.convert.ExchangeRate getExchangeRate(java.lang.String baseCode,
java.lang.String termCode)
javax.money.convert.ExchangeRateProviderExchangeRate using the given currencies. The
ExchangeRate may be, depending on the data provider, eal-time or
deferred. This method should return the rate that is currently
valid. It should be the same as
getExchangeRate(base, term, System.currentTimeMillis()).getExchangeRate in interface javax.money.convert.ExchangeRateProviderbaseCode - base currency code, not nulltermCode - term/target currency code, not nullExchangeRate.public javax.money.convert.ExchangeRate getExchangeRate(java.lang.String baseCode,
java.lang.String termCode,
javax.money.convert.ConversionContext conversionContext)
javax.money.convert.ExchangeRateProviderExchangeRate using the given currencies. The
ExchangeRate may be, depending on the data provider, eal-time or
deferred. This method should return the rate that is currently
valid. It should be the same as
getExchangeRate(base, term, System.currentTimeMillis()).getExchangeRate in interface javax.money.convert.ExchangeRateProviderbaseCode - base currency code, not nulltermCode - term/target currency code, not nullconversionContext - the required ConversionContext, not nullExchangeRate.protected abstract javax.money.convert.ExchangeRate getExchangeRateInternal(javax.money.CurrencyUnit base,
javax.money.CurrencyUnit term,
javax.money.convert.ConversionContext context)
public javax.money.convert.ProviderContext getProviderContext()
javax.money.convert.ExchangeRateProviderConversionContext for this
ExchangeRateProvider. Each instance of
ExchangeRateProvider provides conversion data for exact one
ConversionContext .getProviderContext in interface javax.money.convert.ExchangeRateProvidernull.public javax.money.convert.ExchangeRate getReversed(javax.money.convert.ExchangeRate rate)
javax.money.convert.ExchangeRateProviderExchangeRate to a rate mapping from term
to base CurrencyUnit. Hereby the factor must not be
recalculated as 1/oldFactor, since typically reverse rates are
not symmetric in most cases.getReversed in interface javax.money.convert.ExchangeRateProviderExchangeRate, or null, if
the rate cannot be reversed.public boolean isAvailable(javax.money.CurrencyUnit src,
javax.money.CurrencyUnit target)
javax.money.convert.ExchangeRateProviderExchangeRate between two CurrencyUnit is
available from this provider. This method should check, if a given rate
is currently defined. It should be the same as
isAvailable(base, term, System.currentTimeMillis()).isAvailable in interface javax.money.convert.ExchangeRateProvidersrc - the base CurrencyUnittarget - the term CurrencyUnittrue, if such an ExchangeRate is currently
defined.public boolean isAvailable(javax.money.CurrencyUnit base,
javax.money.CurrencyUnit term,
javax.money.convert.ConversionContext conversionContext)
javax.money.convert.ExchangeRateProviderExchangeRate between two CurrencyUnit is
available from this provider. This method should check, if a given rate
is currently defined. It should be the same as
isAvailable(base, term, System.currentTimeMillis()).isAvailable in interface javax.money.convert.ExchangeRateProviderbase - the base CurrencyUnitterm - the term CurrencyUnitconversionContext - the required ConversionContext, not nulltrue, if such an ExchangeRate is currently
defined.public boolean isAvailable(java.lang.String baseCode,
java.lang.String termCode)
javax.money.convert.ExchangeRateProviderExchangeRate between two CurrencyUnit is
available from this provider. This method should check, if a given rate
is currently defined. It should be the same as
isAvailable(base, term, System.currentTimeMillis()).isAvailable in interface javax.money.convert.ExchangeRateProviderbaseCode - the base currency codetermCode - the terminal/target currency codetrue, if such an ExchangeRate is currently
defined.public boolean isAvailable(java.lang.String baseCode,
java.lang.String termCode,
javax.money.convert.ConversionContext conversionContext)
javax.money.convert.ExchangeRateProviderExchangeRate between two CurrencyUnit is
available from this provider. This method should check, if a given rate
is currently defined. It should be the same as
isAvailable(base, term, System.currentTimeMillis()).isAvailable in interface javax.money.convert.ExchangeRateProviderbaseCode - the base currency codetermCode - the terminal/target currency codeconversionContext - the required ConversionContext, not nulltrue, if such an ExchangeRate is currently
defined.protected static final javax.money.NumberValue multiply(javax.money.NumberValue multiplicand,
javax.money.NumberValue multiplier)
NumberValue types.null an ArithmeticException is thrown.multiplicand - the first value to be multipliedmultiplier - the second value to be multipliedNumberValue