net.sf.oness.common.model.accounting
Class Money

java.lang.Object
  extended bynet.sf.oness.common.all.BaseObject
      extended bynet.sf.oness.common.model.accounting.Money
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, java.io.Serializable

public class Money
extends net.sf.oness.common.all.BaseObject
implements java.lang.Comparable

Class for Money

Version:
$Revision: 1.1 $
Author:
Carlos Sanchez
See Also:
BigDecimal, Currency, Serialized Form

Field Summary
 
Fields inherited from class net.sf.oness.common.all.BaseObject
log
 
Constructor Summary
Money()
          Create a money object with an amount of 0 and the currency of the default locale as returned by Locale.getDefault()
Money(java.math.BigDecimal amount, java.util.Currency currency)
          Create a money object with the specified amount and currency
Money(java.util.Currency currency)
          Create a money object with an amount of 0 and the specified currency
 
Method Summary
 Money add(Money arg)
           
 int compareTo(java.lang.Object arg)
           
 java.math.BigDecimal getAmount()
           
 java.util.Currency getCurrency()
           
 boolean greaterThan(Money arg)
           
 boolean lessThan(Money arg)
           
 Money multiply(long arg)
           
 Money negate()
           
 Money subtract(Money arg)
           
 
Methods inherited from class net.sf.oness.common.all.BaseObject
clone, equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Money

public Money()
Create a money object with an amount of 0 and the currency of the default locale as returned by Locale.getDefault()

See Also:
Locale.getDefault()

Money

public Money(java.math.BigDecimal amount,
             java.util.Currency currency)
Create a money object with the specified amount and currency

Parameters:
amount -
currency -

Money

public Money(java.util.Currency currency)
Create a money object with an amount of 0 and the specified currency

Parameters:
currency -
Method Detail

getAmount

public java.math.BigDecimal getAmount()

getCurrency

public java.util.Currency getCurrency()

add

public Money add(Money arg)
          throws java.lang.IllegalArgumentException
Parameters:
arg -
Returns:
Throws:
java.lang.IllegalArgumentException - if the currencies are not equal
See Also:
BigDecimal.add(BigDecimal)

subtract

public Money subtract(Money arg)
               throws java.lang.IllegalArgumentException
Parameters:
arg -
Returns:
Throws:
java.lang.IllegalArgumentException - if the currencies are not equal
See Also:
BigDecimal.subtract(BigDecimal)

negate

public Money negate()
Returns:
Throws:
java.lang.IllegalArgumentException - if the currencies are not equal

multiply

public Money multiply(long arg)

compareTo

public int compareTo(java.lang.Object arg)
              throws java.lang.IllegalArgumentException,
                     java.lang.ClassCastException
Specified by:
compareTo in interface java.lang.Comparable
Throws:
java.lang.IllegalArgumentException - if the currencies are not equal
java.lang.ClassCastException
See Also:
Comparable.compareTo(java.lang.Object), BigDecimal.compareTo(Object)

greaterThan

public boolean greaterThan(Money arg)
Parameters:
arg -
Returns:
Throws:
java.lang.IllegalArgumentException - if the currencies are not equal

lessThan

public boolean lessThan(Money arg)
Parameters:
arg -
Returns:
Throws:
java.lang.IllegalArgumentException - if the currencies are not equal


Copyright © 2003-2005 ONess Project. All Rights Reserved.