org.jboss.util
Class MuInteger

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

public class MuInteger
extends MuNumber (src)

A mutable integer class.

See Also:
Serialized Form

Constructor Summary
MuInteger()
          Construct a new mutable integer.
MuInteger(int i)
          Construct a new mutable integer.
MuInteger(java.lang.Object obj)
          Construct a new mutable integer.
 
Method Summary
 int add(int amount)
          Add the specified amount.
 int and(int b)
          ANDs the current value with the specified value.
 byte byteValue()
          Return the byte value of this object.
 java.lang.Object clone()
          Return a cloned copy of this mutable integer.
 boolean commit(int assumed, int i)
          Set the value to value only if the current value is equal to the assumed value.
 int compareTo(int other)
          Compares this object with the specified int for order.
 int compareTo(java.lang.Object obj)
          Compares this object with the specified object for order.
 int complement()
          Set the value to its complement.
 int decrement()
          Decrement the value of this mutable integer.
 int divide(int 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 integer and another object.
 float floatValue()
          Return the float value of this object.
 java.lang.Object getValue()
          Get the value of this mutable integer.
 int hashCode()
          Get the hash code for this mutable integer.
 int increment()
          Increment the value of this mutable integer.
 int intValue()
          Return the int value of this object.
 long longValue()
          Return the long value of this object.
 int multiply(int factor)
          Multiply by the specified factor.
 int negate()
          Set the value to the negative of its current value.
 int or(int b)
          ORs the current value with the specified value.
 void setValue(java.lang.Object obj)
          Set the value of this mutable integer.
 int shiftLeft(int bits)
          Shift the current value to the left.
 int shiftRight(int bits)
          Shift the current value to the right.
 int shiftRightZero(int bits)
          Shift the current value to the right with a zero extension.
 short shortValue()
          Return the short value of this object.
 int subtract(int amount)
          Subtract the specified amount.
 int swap(MuInteger (src)  i)
          Swap values with another mutable integer.
 java.lang.String toString()
          Convert this mutable integer to a string.
 int xor(int b)
          XORs the current value with the specified value.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MuInteger

public MuInteger()
Construct a new mutable integer.


MuInteger

public MuInteger(int i)
Construct a new mutable integer.

Parameters:
i - Integer value.

MuInteger

public MuInteger(java.lang.Object obj)
Construct a new mutable integer.

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

commit

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

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

swap

public int swap(MuInteger (src)  i)
Swap values with another mutable integer.

Parameters:
i - Mutable integer to swap values with.
Returns:
The new value.

increment

public int increment()
Increment the value of this mutable integer.

Returns:
Int value.

decrement

public int decrement()
Decrement the value of this mutable integer.

Returns:
Int value.

add

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

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

subtract

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

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

multiply

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

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

divide

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

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

negate

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

Returns:
The new value.

complement

public int complement()
Set the value to its complement.

Returns:
The new value.

and

public int and(int b)
ANDs the current value with the specified value.

Parameters:
b - Value to and with.
Returns:
The new value.

or

public int or(int b)
ORs the current value with the specified value.

Parameters:
b - Value to or with.
Returns:
The new value.

xor

public int xor(int b)
XORs the current value with the specified value.

Parameters:
b - Value to xor with.
Returns:
The new value.

shiftRight

public int shiftRight(int bits)
Shift the current value to the right.

Parameters:
bits - The number of bits to shift.
Returns:
The new value.

shiftRightZero

public int shiftRightZero(int bits)
Shift the current value to the right with a zero extension.

Parameters:
bits - The number of bits to shift.
Returns:
The new value.

shiftLeft

public int shiftLeft(int bits)
Shift the current value to the left.

Parameters:
bits - The number of bits to shift.
Returns:
The new value.

compareTo

public int compareTo(int other)
Compares this object with the specified int 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 MuInteger.

toString

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

Returns:
String value

hashCode

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

Returns:
Hash code.

equals

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

Parameters:
obj - Qbject to test equality with.
Returns:
True if object is equal.

clone

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

Returns:
Cloned mutable integer.

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 integer.

Parameters:
obj - Target value for object.
Throws:
NotCoercibleException (src) - Can not convert to int.

getValue

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

Returns:
java.lang.Integer value.