JADE v6.1

com.dautelle.money
Class Money

java.lang.Object
  extended byjava.lang.Number
      extended bycom.dautelle.math.numbers.RealtimeNumber
          extended bycom.dautelle.physics.Quantity
              extended bycom.dautelle.money.Money
All Implemented Interfaces:
java.lang.Comparable, Operable, Realtime, Representable, java.io.Serializable

public class Money
extends Quantity

This class represents something generally accepted as a medium of exchange, a measure of value, or a means of payment. The system unit for this quantity is a Currency.

Version:
5.3, December 19, 2003
Author:
Jean-Marie Dautelle
See Also:
Currency, Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.dautelle.physics.Quantity
Quantity.Factory, Quantity.Value
 
Field Summary
static Money ZERO
          Represents a Money amounting to nothing.
 
Constructor Summary
protected Money()
          Default constructor (allows for derivation).
 
Method Summary
 java.lang.StringBuffer appendTo(java.lang.StringBuffer sb, Unit currency)
          Appends the text representation of this quantity in fixed points notation to the StringBuffer argument.
 Currency getCurrency()
          Returns the intrinsic Currency of this Money quantity (the original currency from which the money has been created from).
 Unit getOutputUnit()
          Returns the Currency unit that this Money quantity is showed as.
static Money moneyOf(Quantity quantity)
          Returns the Money corresponding to the specified quantity.
static void showAs(Currency currency)
          Shows Money instances in the specified currency.
 
Methods inherited from class com.dautelle.physics.Quantity
abs, add, approxEquals, approxEquals, compareTo, divide, divide, doubleValue, doubleValue, equals, floatValue, floatValue, getAbsoluteError, getMaximum, getMinimum, getRelativeError, getSystemUnit, hashCode, intValue, intValue, inverse, isPossiblyZero, longValue, longValue, multiply, multiply, negate, opposite, plus, pow, random, reciprocal, root, subtract, times, toString, toString, toXml, valueOf, valueOf, valueOf, valueOf
 
Methods inherited from class com.dautelle.math.numbers.RealtimeNumber
clone, export, isLocalObject, isPoolObject, pow, recycle, toHeap
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final Money ZERO
Represents a Money amounting to nothing.

Constructor Detail

Money

protected Money()
Default constructor (allows for derivation).

Method Detail

moneyOf

public static Money moneyOf(Quantity quantity)
Returns the Money corresponding to the specified quantity.

Parameters:
quantity - a quantity compatible with Money.
Returns:
the specified quantity or a new Money instance stated in the reference currency.
Throws:
ConversionException - if the current model does not allow the specified quantity to be converted to Money.
See Also:
Currency.getReferenceCurrency()

getCurrency

public Currency getCurrency()
Returns the intrinsic Currency of this Money quantity (the original currency from which the money has been created from).

Returns:
(Currency) getSystemUnit().

showAs

public static void showAs(Currency currency)
Shows Money instances in the specified currency.

Parameters:
currency - the output currency for Money instances.
See Also:
Quantity.getOutputUnit()

getOutputUnit

public Unit getOutputUnit()
Returns the Currency unit that this Money quantity is showed as. The default is this Money's system unit (the currency used to create this quantity). This default can be overriden using the context-local showAs(com.dautelle.money.Currency) static method.

Overrides:
getOutputUnit in class Quantity
Returns:
the output currency.
See Also:
Quantity.toString(), Quantity.toXml(com.dautelle.xml.XmlElement)

appendTo

public java.lang.StringBuffer appendTo(java.lang.StringBuffer sb,
                                       Unit currency)
Appends the text representation of this quantity in fixed points notation to the StringBuffer argument. The number of digits after the decimal point is determinated by the output currency.

Overrides:
appendTo in class Quantity
Parameters:
sb - the StringBuffer to append.
currency - the currency unit this quantity is showed as.
Returns:
the specified StringBuffer object.
Throws:
ConversionException - if the current model does not allow this quantity to be stated as a currency.
See Also:
Currency.getDefaultFractionDigits(com.dautelle.money.Currency)

JADE v6.1

Copyright © 2004 Jean-Marie Dautelle.