org.nakedobjects.object.value
Class WholeNumber

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

public class WholeNumber
extends Magnitude

Value object to represent an integral number.

This object does support value listeners.

See Also:
Serialized Form

Constructor Summary
WholeNumber()
          Creates a WholeNumber with zero value;
WholeNumber(int whole)
          Creates a WholeNumber with the specified value;
WholeNumber(java.lang.String text)
          Deprecated.  
WholeNumber(WholeNumber wholeNumber)
          Creates a WholeNumber with the same value as the specified object;
 
Method Summary
 void abs()
          if non-null, makes the value positive.
 void add(int whole)
          Adds the specified amount to this value.
 void add(WholeNumber whole)
          Adds the specified value to this value.
 void clear()
          Clears the value so that it is empty, i.e.
 int compareTo(int value)
          returns the difference between this obect and the value: 0 means they are equal.
 void copyObject(Naked object)
          Copies the content of the specified object into this object.
 void divide(double whole)
          Divides this value by the specified amount.
 void divide(int whole)
          Divides this value by the specified amount.
 void divide(WholeNumber number)
          Divides this value by the specified amount.
 double doubleValue()
          Returns this value as an double.
 boolean equals(java.lang.Object object)
           
 float floatValue()
          Returns this value as an float.
 int getInt()
          Deprecated.  
protected  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 number)
          returns true if the number of this object has the same value as the specified number
 boolean isLessThan(Magnitude value)
          Returns true if this value is less than the specified value.
 boolean isNegative()
          Returns true if this value is less than 0.
 boolean isZero()
          Returns true if this value is 0.
 long longValue()
          Returns this value as an long.
 void multiply(int whole)
          Multiply this value by the specified amount.
 void multiply(WholeNumber number)
          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 reset()
          Reset this whole number 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 set(int whole)
          Sets this value to be the specified value.
 void set(WholeNumber value)
          Deprecated. replaced by setValue
 void setInt(int whole)
          Deprecated. replaced by setValue
 void setValue(int whole)
           
 void setValue(WholeNumber value)
           
 short shortValue()
          Returns this value as an short.
 void subtract(int whole)
          Substracts the specified amount from this value.
 void subtract(WholeNumber number)
          Subtracts the specified amount from this value.
 Title title()
          Returns a Title object describing the object.
 
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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WholeNumber

public WholeNumber()
Creates a WholeNumber with zero value;


WholeNumber

public WholeNumber(int whole)
Creates a WholeNumber with the specified value;


WholeNumber

public WholeNumber(java.lang.String text)
Deprecated.  

Creates a WholeNumber with parsed value from the specified text;


WholeNumber

public WholeNumber(WholeNumber wholeNumber)
Creates a WholeNumber with the same value as the specified object;

Method Detail

add

public void add(int whole)
Adds the specified amount to this value.


add

public void add(WholeNumber whole)
Adds the specified value to this value.


clear

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


compareTo

public int compareTo(int value)
returns the difference between this obect and the value: 0 means they are equal.


copyObject

public void copyObject(Naked object)
Description copied from interface: Naked
Copies the content of the specified object into this object.


divide

public void divide(int whole)
Divides this value by the specified amount.


divide

public void divide(double whole)
Divides this value by the specified amount.


divide

public void divide(WholeNumber number)
Divides this value by the specified amount.


doubleValue

public double doubleValue()
Returns this value as an double.


equals

public boolean equals(java.lang.Object object)

floatValue

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


getInt

public int getInt()
Deprecated.  

Returns this value as an int.

See Also:
intValue()

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 number)
returns true if the number of this object has the same value as the specified number

Specified by:
isEqualTo in class Magnitude

isLessThan

public boolean isLessThan(Magnitude value)
Returns true if this value is less than the specified value.

Specified by:
isLessThan in class Magnitude

isNegative

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


isZero

public boolean isZero()
Returns true if this value is 0.


longValue

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


multiply

public void multiply(int whole)
Multiply this value by the specified amount.


multiply

public void multiply(WholeNumber number)
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)

reset

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

See Also:
NakedValue.reset()

set

public void set(int whole)
Sets this value to be the specified value.


set

public void set(WholeNumber value)
Deprecated. replaced by setValue

Sets this value to be the same and specified value.


setInt

public void setInt(int whole)
Deprecated. replaced by setValue

Sets this value to be the specified value.


setValue

public void setValue(int whole)

setValue

public void setValue(WholeNumber value)

shortValue

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


subtract

public void subtract(int whole)
Substracts the specified amount from this value.


subtract

public void subtract(WholeNumber number)
Subtracts the specified amount from this value.


abs

public void abs()
if non-null, makes the value positive.

Returns:
this

title

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


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

protected 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