org.jscience.economics.money
Class CurrencyConverter

Object
  extended by UnitConverter
      extended by CurrencyConverter
All Implemented Interfaces:
Serializable

public class CurrencyConverter
extends UnitConverter

This class represents a converter between two currencies.

Currency converters convert values based upon the current exchange rate exchange rate. If the exchange rate from the target currency to the source currency is not set, conversion fails. In others words, the converter from a currency A to a currency B is independant from the converter from B to A.

Version:
5.0, January 2, 2010
Author:
Jean-Marie Dautelle
See Also:
Currency.setExchangeRate(java.lang.Number, org.jscience.economics.money.Currency), Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class UnitConverter
UnitConverter.Compound
 
Field Summary
 
Fields inherited from class UnitConverter
IDENTITY
 
Constructor Summary
CurrencyConverter(Currency source, Currency target)
          Creates the currency converter from the source currency to the target currency.
 
Method Summary
 BigDecimal convert(BigDecimal value, MathContext ctx)
           
 double convert(double x)
           
 boolean equals(Object cvtr)
           
 Currency getSource()
          Returns the source currency.
 Currency getTarget()
          Returns the target currency.
 int hashCode()
           
 CurrencyConverter inverse()
           
 boolean isLinear()
           
 String toString()
           
 
Methods inherited from class UnitConverter
concatenate
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CurrencyConverter

public CurrencyConverter(Currency source,
                         Currency target)
Creates the currency converter from the source currency to the target currency.

Parameters:
source - the source currency.
target - the target currency.
factor - the multiplier factor from source to target.
Method Detail

getSource

public Currency getSource()
Returns the source currency.

Returns:
the source currency.

getTarget

public Currency getTarget()
Returns the target currency.

Returns:
the target currency.

inverse

public CurrencyConverter inverse()
Specified by:
inverse in class UnitConverter

convert

public double convert(double x)
Specified by:
convert in class UnitConverter

convert

public BigDecimal convert(BigDecimal value,
                          MathContext ctx)
                   throws ArithmeticException
Specified by:
convert in class UnitConverter
Throws:
ArithmeticException

equals

public boolean equals(Object cvtr)
Specified by:
equals in class UnitConverter

hashCode

public int hashCode()
Specified by:
hashCode in class UnitConverter

toString

public final String toString()
Overrides:
toString in class Object

isLinear

public boolean isLinear()
Specified by:
isLinear in class UnitConverter


Copyright © 2005-2010 JScience. All Rights Reserved.