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
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. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
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
SignedInteger
public SignedInteger(java.lang.String aString,
boolean aAllowPct)
throws java.lang.NumberFormatException
- The integer part works (almost) the same as atoi():
- Skip leading white spaces.
- Non-digit char terminates convertion.
- If got a valid integer, don't throw NumberFormatException.
- Throw exception if first nonspace char is not digit(atoi returns 0).
Example: " +4z" works as 4.
SignedInteger
public SignedInteger(int aValue,
int aSign)
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