| java.lang.Object org.jaffa.datatypes.Currency
Field Summary | |
public static String | USD The constant to denote US Dollar. |
Constructor Summary | |
public | Currency() Default constructor. | public | Currency(double value) Constructs a Currency object with the specified value. | public | Currency(String s) Constructs a Currency object with the specified value. | public | Currency(Double value) Constructs a Currency object with the specified value. | public | Currency(double value, String currencyType) Constructs a Currency object with the specified value and currency type
A RuntimeException will be thrown if the input currency type is not supported. | public | Currency(String s, String currencyType) Constructs a Currency object with the specified value and currency type
A RuntimeException will be thrown if the input currency type is not supported. | public | Currency(Double value, String currencyType) Constructs a Currency object with the specified value and currency type
A RuntimeException will be thrown if the input currency type is not supported. |
Method Summary | |
public Currency | add(Currency c) Returns a new Currency object, which has the same currency type as this object,
and a value which is the sum of the 2 Currency objects. | public Object | clone() Returns a clone of the object. | public int | compareTo(Object obj) Compares this object with another Currency object.
Note: this class has a natural ordering that is inconsistent with equals
The target object is converted to the same currencyType before the comparison is performed.
Hence, it is quite possible that this method might indicate a equality, while the 'equals' method may return a false.
Parameters: obj - the other Currency object. | public Currency | convert(String currencyType) Returns a new Currency object, which will have the value of the current object converted to the input currency type.
A RuntimeException will be thrown if the input currency type is not supported.
Parameters: currencyType - the type to convert to. | public boolean | equals(Object obj) Compares this object with another Currency object.
Returns a true if both the objects have the same currency type and value.
Parameters: obj - the other Currency object. | public String | getCurrencyType() Getter for property currencyType. | public Double | getValue() Getter for property value. | public int | hashCode() Returns an int which will be the sum of the of the hashcodes of the value and the currency type. | public String | toString() Returns the diagnostic information. |
USD | public static String USD(Code) | | The constant to denote US Dollar.
|
Currency | public Currency()(Code) | | Default constructor. This creates a Currency object with 0 value.
This will default to USD as the currency type.
|
Currency | public Currency(double value)(Code) | | Constructs a Currency object with the specified value.
This will default to USD as the currency type.
Parameters: value - the value of the object. |
Currency | public Currency(String s)(Code) | | Constructs a Currency object with the specified value.
This will default to USD as the currency type.
Parameters: s - the value of the object. |
Currency | public Currency(Double value)(Code) | | Constructs a Currency object with the specified value.
This will default to USD as the currency type.
Parameters: value - the value of the object. |
Currency | public Currency(double value, String currencyType)(Code) | | Constructs a Currency object with the specified value and currency type
A RuntimeException will be thrown if the input currency type is not supported.
Parameters: value - the value of the object. Parameters: currencyType - the currency type. |
Currency | public Currency(String s, String currencyType)(Code) | | Constructs a Currency object with the specified value and currency type
A RuntimeException will be thrown if the input currency type is not supported.
Parameters: s - the value of the object. Parameters: currencyType - the currency type. |
Currency | public Currency(Double value, String currencyType)(Code) | | Constructs a Currency object with the specified value and currency type
A RuntimeException will be thrown if the input currency type is not supported.
Parameters: value - the value of the object. Parameters: currencyType - the currency type. |
add | public Currency add(Currency c)(Code) | | Returns a new Currency object, which has the same currency type as this object,
and a value which is the sum of the 2 Currency objects. The input Currency is first converted
to the same currency type, before adding the values.
Parameters: c - the other Currency object. a new Currency object which has the same currency type as this object, and a value which is the sum of the 2 Currency objects |
clone | public Object clone()(Code) | | Returns a clone of the object.
a clone of the object. |
compareTo | public int compareTo(Object obj)(Code) | | Compares this object with another Currency object.
Note: this class has a natural ordering that is inconsistent with equals
The target object is converted to the same currencyType before the comparison is performed.
Hence, it is quite possible that this method might indicate a equality, while the 'equals' method may return a false.
Parameters: obj - the other Currency object. a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. |
convert | public Currency convert(String currencyType)(Code) | | Returns a new Currency object, which will have the value of the current object converted to the input currency type.
A RuntimeException will be thrown if the input currency type is not supported.
Parameters: currencyType - the type to convert to. a new Currency object, which will have the value of the current object converted to the input currency type. |
equals | public boolean equals(Object obj)(Code) | | Compares this object with another Currency object.
Returns a true if both the objects have the same currency type and value.
Parameters: obj - the other Currency object. a true if both the objects have the same currency type and value. |
getCurrencyType | public String getCurrencyType()(Code) | | Getter for property currencyType.
Value of property currencyType. |
getValue | public Double getValue()(Code) | | Getter for property value.
Value of property value. |
hashCode | public int hashCode()(Code) | | Returns an int which will be the sum of the of the hashcodes of the value and the currency type.
an int which will be the sum of the of the hashcodes of the value and the currency type. |
toString | public String toString()(Code) | | Returns the diagnostic information.
the diagnostic information. |
|
|