calypso.util
Class SignedInteger

java.lang.Object
  |
  +--calypso.util.SignedInteger

public class SignedInteger
extends java.lang.Object

Utility class that represents the parse state from parsing a signed integer. The sign of the integer is maintained so that "10" can be distinguished from "+10". In addition, we can optionally handle numbers expressed as percentages.

See Also:
Integer.parseInt

Field Summary
protected  boolean fPct
           
protected  int fSign
           
protected  int fValue
           
static int MINUS
           
static int NONE
           
static int PLUS
           
 
Constructor Summary
SignedInteger(int aValue, int aSign)
           
SignedInteger(java.lang.String aString, boolean aAllowPct)
          The integer part works (almost) the same as atoi(): Skip leading white spaces.
 
Method Summary
 int computeValue(int aBaseValue)
          Compute a value based on "aBaseValue".
 int getSign()
          Return the sign of the value.
 int intValue()
           
 boolean isPct()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PLUS

public static final int PLUS

MINUS

public static final int MINUS

NONE

public static final int NONE

fValue

protected int fValue

fSign

protected int fSign

fPct

protected boolean fPct
Constructor Detail

SignedInteger

public SignedInteger(java.lang.String aString,
                     boolean aAllowPct)
              throws java.lang.NumberFormatException
The integer part works (almost) the same as atoi():

SignedInteger

public SignedInteger(int aValue,
                     int aSign)
Method Detail

intValue

public int intValue()

isPct

public boolean isPct()

computeValue

public int computeValue(int aBaseValue)
Compute a value based on "aBaseValue". Apply the sign of this SignedInteger to determine the value to return.

getSign

public int getSign()
Return the sign of the value.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object