org.nakedobjects.object.value
Class Money

java.lang.Object
  extended byorg.nakedobjects.object.value.AbstractNakedValue
      extended byorg.nakedobjects.object.value.Magnitude
          extended byorg.nakedobjects.object.value.Money
All Implemented Interfaces:
Naked, NakedValue, java.io.Serializable

public class Money
extends Magnitude

Value object representing a monetary value including a currency type.

This object does support value listeners

See Also:
Serialized Form

Constructor Summary
Money()
          Create a Money with zero value.
Money(double amount)
           
Money(Money money)
          Create a Money object with the same value as the specified object.
 
Method Summary
 void add(Money money)
          Add the specified money to this money.
 void clear()
          Clears the value so that it is empty, i.e.
 void copyObject(Naked object)
          Copies the specified object's contained data to this instance.
 void divideBy(double operand)
          Divides this value by the specified amount.
 double doubleValue()
           
 float floatValue()
          Returns this value as an float.
 org.apache.log4j.Logger getLogger()
          subclasses can override (didn't make abstract so that existing subclasses won't break)
 java.lang.String getObjectHelpText()
          Returns a textual desctiption of the object - its contents and possible uses.
 int intValue()
          Returns this value as an int.
 boolean isEmpty()
          Returns true if the object contains no data, eg when new
 boolean isEqualTo(Magnitude magnitude)
           
 boolean isLessThan(Magnitude magnitude)
           
 boolean isNegative()
          Returns true if this value is less than zero.
 long longValue()
          Returns this value as an long.
 void multiplyBy(double operand)
          Multiply this value by the specified amount.
 void parse(java.lang.String text)
          Takes a user entry string which is parsed to set up the object.
 void readExternal(java.io.ObjectInput in)
           
 void reset()
          Reset this money so it contains 0.
 void restoreString(java.lang.String data)
          Takes a storage string and uses it reinstate this value object to its previous state/
 java.lang.String saveString()
          Returns a basic string representation of this value for storage purposes.
 void setValue(double amount)
          Set this value to have the specified values.
 void setValue(Money value)
          Set this value to be the same as the specified value.
 short shortValue()
          Returns this value as an short.
 void subtract(Money money)
          Subtract the specified amount from this value.
 Title title()
          Returns a Title object describing the object.
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class org.nakedobjects.object.value.Magnitude
isBetween, isGreaterThan, isGreaterThanOrEqualTo, isLessThanOrEqualTo, isSameAs, max, min
 
Methods inherited from class org.nakedobjects.object.value.AbstractNakedValue
about, addNakedValueListener, checkCanOperate, contextualTitle, deepCopy, dumpObject, fireValueChanged, fireValueChanged, getClassName, getFullClassName, isNull, isValid, nakedValueListeners, removeNakedValueListener, setAbout, setNull, setValidity, summary, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Money

public Money()
Create a Money with zero value.


Money

public Money(Money money)
Create a Money object with the same value as the specified object.


Money

public Money(double amount)
Method Detail

add

public void add(Money money)
Add the specified money to this money.


clear

public void clear()
Description copied from interface: NakedValue
Clears the value so that it is empty, i.e. isEmpty returns true.


copyObject

public void copyObject(Naked object)
Copies the specified object's contained data to this instance.

Parameters:
object - the object to copy the data from

divideBy

public void divideBy(double operand)
Divides this value by the specified amount.


doubleValue

public double doubleValue()

floatValue

public float floatValue()
Returns this value as an float.


getObjectHelpText

public java.lang.String getObjectHelpText()
Description copied from interface: Naked
Returns a textual desctiption of the object - its contents and possible uses.

Specified by:
getObjectHelpText in interface Naked
Overrides:
getObjectHelpText in class AbstractNakedValue

intValue

public int intValue()
Returns this value as an int.


isEmpty

public boolean isEmpty()
Description copied from interface: Naked
Returns true if the object contains no data, eg when new


isEqualTo

public boolean isEqualTo(Magnitude magnitude)
Specified by:
isEqualTo in class Magnitude

isLessThan

public boolean isLessThan(Magnitude magnitude)
Specified by:
isLessThan in class Magnitude

isNegative

public boolean isNegative()
Returns true if this value is less than zero.


longValue

public long longValue()
Returns this value as an long.


multiplyBy

public void multiplyBy(double operand)
Multiply this value by the specified amount.


parse

public void parse(java.lang.String text)
           throws ValueParseException
Description copied from interface: NakedValue
Takes a user entry string which is parsed to set up the object. This needs to accomodate punctuation and adornments such as currency signs.

Throws:
ValueParseException
See Also:
NakedValue.restoreString(String)

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException

reset

public void reset()
Reset this money so it contains 0.

See Also:
NakedValue.reset()

setValue

public void setValue(double amount)
Set this value to have the specified values.


setValue

public void setValue(Money value)
Set this value to be the same as the specified value.


shortValue

public short shortValue()
Returns this value as an short.


subtract

public void subtract(Money money)
Subtract the specified amount from this value.


title

public Title title()
Description copied from interface: Naked
Returns a Title object describing the object.


writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Throws:
java.io.IOException

restoreString

public void restoreString(java.lang.String data)
Description copied from interface: NakedValue
Takes a storage string and uses it reinstate this value object to its previous state/

Parameters:
data -
See Also:
NakedValue.parse(String)

saveString

public java.lang.String saveString()
Description copied from interface: NakedValue
Returns a basic string representation of this value for storage purposes.


getLogger

public org.apache.log4j.Logger getLogger()
Description copied from class: AbstractNakedValue
subclasses can override (didn't make abstract so that existing subclasses won't break)

Overrides:
getLogger in class AbstractNakedValue