Project Wonder 2.0

er.extensions
Class ERXMutableInteger

java.lang.Object
  extended byer.extensions.ERXMutableInteger

public class ERXMutableInteger
extends Object

ERXMutableInteger is like Integer but mutable, to avoid the excess object creation involved in i = new Integer(i.getInt() + 1) which can get expensive if done a lot.

Not subclassed from Integer, since Integer is final (for performance.)

Original Author: Ian F. Darwin (Author of "Java Coolbook" ISBN: 0-596-00170-3)


Constructor Summary
ERXMutableInteger(int value)
          Constructs a newly allocated ERXMutableInteger object that represents the primitive int argument.
 
Method Summary
 void decrement()
          Decrements the int value of this ERXMutalbleInteger object by 1.
 void decrement(int amount)
          Decrements the int value of this ERXMutalbleInteger object by the int argument.
 void increment()
          Increments the int value of this ERXMutalbleInteger object by 1.
 void increment(int amount)
          Increments the int value of this ERXMutalbleInteger object by the int argument.
 int intValue()
          Returns the int value represented by this ERXMutalbleInteger object.
static int parseInt(String str)
          Parses the string argument as a signed decimal integer.
 void setIntValue(int value)
          Updates the int value of this ERXMutalbleInteger object to the int argument.
 String toString()
          Returns a string object representing this ERXMutalbeInteger's value.
static String toString(int value)
          Creates a string representation of the int argument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ERXMutableInteger

public ERXMutableInteger(int value)
Constructs a newly allocated ERXMutableInteger object that represents the primitive int argument.

Parameters:
value - the int value to be represented by the ERXMutalbleInteger object
Method Detail

increment

public void increment()
Increments the int value of this ERXMutalbleInteger object by 1.


increment

public void increment(int amount)
Increments the int value of this ERXMutalbleInteger object by the int argument.

Parameters:
amount - the int amount to increment

decrement

public void decrement()
Decrements the int value of this ERXMutalbleInteger object by 1.


decrement

public void decrement(int amount)
Decrements the int value of this ERXMutalbleInteger object by the int argument.

Parameters:
amount - the int amount to decrement

setIntValue

public void setIntValue(int value)
Updates the int value of this ERXMutalbleInteger object to the int argument.

Parameters:
value - the int value to set

intValue

public int intValue()
Returns the int value represented by this ERXMutalbleInteger object.

Returns:
the int value of this object

toString

public String toString()
Returns a string object representing this ERXMutalbeInteger's value. The value is converted to signed decimal representation and returned as a string, exactly as if the integer value were given as an argument to the toString(int) method.

Returns:
a string representation of the value of this object.

toString

public static String toString(int value)
Creates a string representation of the int argument.

Parameters:
value - the int value to convert
Returns:
a string representation of the int argument

parseInt

public static int parseInt(String str)
                    throws NumberFormatException
Parses the string argument as a signed decimal integer. The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' to indicate a negative value. The resulting integer value is returned, exactly as if the argument was given as arguments to the Integer.parseInt method.

Parameters:
str - the string to parse
Returns:
the int represented by the argument in decimal
Throws:
NumberFormatException - if the String cannot be parsed as an int.

Last updated: Do, Dez 9, 2004 • 12:46 PM CET

Copyright © 2002 – 2004 Project Wonder.