org.jboss.util
Class MuDouble

java.lang.Object
  extended byjava.lang.Number
      extended byorg.jboss.util.MuNumber (src) 
          extended byorg.jboss.util.MuDouble
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, Mutable (src) , java.io.Serializable

public class MuDouble
extends MuNumber (src)

A mutable double class.

See Also:
Serialized Form

Constructor Summary
MuDouble()
          Construct a new mutable double.
MuDouble(double d)
          Construct a new mutable double.
MuDouble(java.lang.Object obj)
          Construct a new mutable double.
 
Method Summary
 double add(double amount)
          Add the specified amount.
 byte byteValue()
          Return the byte value of this object.
 java.lang.Object clone()
          Return a cloned copy of this mutable double.
 boolean commit(double assumed, double b)
          Set the value to value only if the current value is equal to the assumed value.
 int compareTo(double other)
          Compares this object with the specified double for order.
 int compareTo(java.lang.Object obj)
          Compares this object with the specified object for order.
 double divide(double factor)
          Divide by the specified factor.
 double doubleValue()
          Return the double value of this object.
 boolean equals(java.lang.Object obj)
          Test the equality of this mutable double with another object.
 float floatValue()
          Return the float value of this object.
 double get()
          Get the current value.
 java.lang.Object getValue()
          Get the value of this mutable double.
 int hashCode()
          Get the hash code for this mutable double.
 int intValue()
          Return the int value of this object.
 long longValue()
          Return the long value of this object.
 double multiply(double factor)
          Multiply by the specified factor.
 double negate()
          Set the value to the negative of its current value.
 double set(double f)
          Set the value.
 void setValue(java.lang.Object obj)
          Set the value of this mutable double.
 short shortValue()
          Return the short value of this object.
 double subtract(double amount)
          Subtract the specified amount.
 double swap(MuDouble (src)  b)
          Swap values with another mutable double.
 java.lang.String toString()
          Convert this mutable double to a string.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MuDouble

public MuDouble()
Construct a new mutable double.


MuDouble

public MuDouble(double d)
Construct a new mutable double.

Parameters:
d - double value.

MuDouble

public MuDouble(java.lang.Object obj)
Construct a new mutable double.

Parameters:
obj - Object to convert to a double value.
Method Detail

set

public double set(double f)
Set the value.

Parameters:
f - double value.
Returns:
The previous value.

get

public double get()
Get the current value.

Returns:
The current value.

commit

public boolean commit(double assumed,
                      double b)
Set the value to value only if the current value is equal to the assumed value.

Parameters:
assumed - The assumed value.
b - The new value.
Returns:
True if value was changed.

swap

public double swap(MuDouble (src)  b)
Swap values with another mutable double.

Parameters:
b - Mutable double to swap values with.
Returns:
The new value.

add

public double add(double amount)
Add the specified amount.

Parameters:
amount - Amount to add.
Returns:
The new value.

subtract

public double subtract(double amount)
Subtract the specified amount.

Parameters:
amount - Amount to subtract.
Returns:
The new value.

multiply

public double multiply(double factor)
Multiply by the specified factor.

Parameters:
factor - Factor to multiply by.
Returns:
The new value.

divide

public double divide(double factor)
Divide by the specified factor.

Parameters:
factor - Factor to divide by.
Returns:
The new value.

negate

public double negate()
Set the value to the negative of its current value.

Returns:
The new value.

compareTo

public int compareTo(double other)
Compares this object with the specified double for order.

Parameters:
other - Value to compare with.
Returns:
A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

compareTo

public int compareTo(java.lang.Object obj)
Compares this object with the specified object for order.

Returns:
A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
java.lang.ClassCastException - Object is not a MuDouble.

toString

public java.lang.String toString()
Convert this mutable double to a string.

Returns:
String value.

hashCode

public int hashCode()
Get the hash code for this mutable double.

Returns:
Hash code.

equals

public boolean equals(java.lang.Object obj)
Test the equality of this mutable double with another object.

Parameters:
obj - Object to test
Returns:
Is equal

clone

public java.lang.Object clone()
Return a cloned copy of this mutable double.

Returns:
Cloaned mutable double.

byteValue

public byte byteValue()
Return the byte value of this object.

Overrides:
byteValue in class MuNumber (src)
Returns:
byte value.

shortValue

public short shortValue()
Return the short value of this object.

Overrides:
shortValue in class MuNumber (src)
Returns:
short value.

intValue

public int intValue()
Return the int value of this object.

Overrides:
intValue in class MuNumber (src)
Returns:
int value.

longValue

public long longValue()
Return the long value of this object.

Returns:
long value.

floatValue

public float floatValue()
Return the float value of this object.

Overrides:
floatValue in class MuNumber (src)
Returns:
float value.

doubleValue

public double doubleValue()
Return the double value of this object.

Returns:
double value.

setValue

public void setValue(java.lang.Object obj)
Set the value of this mutable double.

Parameters:
obj - Object to convert to a double value.
Throws:
NotCoercibleException (src) - Can not convert to double.

getValue

public java.lang.Object getValue()
Get the value of this mutable double.

Returns:
java.lang.Double value