javatools.util
Class FormattedNumber

java.lang.Object
  |
  +--java.lang.Number
        |
        +--javatools.util.FormattedNumber
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
FormattedInteger, FormattedLong

public abstract class FormattedNumber
extends java.lang.Number

It's a java.lang.Number, except in the fact it returns its "toString" value in a formatted way.

See Also:
Serialized Form

Field Summary
protected  java.text.DecimalFormat formatter
          The formatter.
protected  java.lang.Number num
          The number to use.
 
Constructor Summary
FormattedNumber()
          Creates new FormattedNumber
 
Method Summary
 byte byteValue()
          Returns the byte value for out num object.
 double doubleValue()
          Returns the double value for out num object.
 boolean equals(java.lang.Object obj)
          Checks if an object is equal to our num object.
 float floatValue()
          Returns the float value for out num object.
 java.text.DecimalFormat getFormatter()
          Returns the currently using formatter.
 int hashCode()
          Returns the hash code for the num object.
 int intValue()
          Returns the int value for out num object.
 long longValue()
          Returns the long value for out num object.
 void setFormatter(java.text.DecimalFormat pFormatter)
          Sets the formatter to use.
 short shortValue()
          Returns the short value for out num object.
 java.lang.String toString()
          Returns a formatted string representing the contained number.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

num

protected java.lang.Number num
The number to use.


formatter

protected java.text.DecimalFormat formatter
The formatter.

Constructor Detail

FormattedNumber

public FormattedNumber()
Creates new FormattedNumber

Method Detail

hashCode

public int hashCode()
Returns the hash code for the num object.

Overrides:
hashCode in class java.lang.Object
Returns:
The requested hash code.

toString

public java.lang.String toString()
Returns a formatted string representing the contained number.

Overrides:
toString in class java.lang.Object
Returns:
The formatted string.

equals

public boolean equals(java.lang.Object obj)
Checks if an object is equal to our num object.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The object to check.
Returns:
true: the objects are equal; false: the objects are NOT equal.

byteValue

public byte byteValue()
Returns the byte value for out num object.

Overrides:
byteValue in class java.lang.Number
Returns:
The requested value.

doubleValue

public double doubleValue()
Returns the double value for out num object.

Specified by:
doubleValue in class java.lang.Number
Returns:
The requested value.

floatValue

public float floatValue()
Returns the float value for out num object.

Specified by:
floatValue in class java.lang.Number
Returns:
The requested value.

intValue

public int intValue()
Returns the int value for out num object.

Specified by:
intValue in class java.lang.Number
Returns:
The requested value.

longValue

public long longValue()
Returns the long value for out num object.

Specified by:
longValue in class java.lang.Number
Returns:
The requested value.

shortValue

public short shortValue()
Returns the short value for out num object.

Overrides:
shortValue in class java.lang.Number
Returns:
The requested value.

setFormatter

public void setFormatter(java.text.DecimalFormat pFormatter)
Sets the formatter to use.

Parameters:
pFormatter - The formatter to use.

getFormatter

public java.text.DecimalFormat getFormatter()
Returns the currently using formatter.

Returns:
The formatter.