java.lang.Object
jpicedt.graphic.io.parser.AbstractRegularExpression
jpicedt.graphic.io.parser.NumericalExpression
- All Implemented Interfaces:
- ExpressionConstants
- public class NumericalExpression
- extends AbstractRegularExpression
An expression containing only digits, possibly preceded by whitespaces ;
a post-delimiters can be specified, as well as the number's type (int or double) and its sign
Fields inherited from interface jpicedt.graphic.io.parser.ExpressionConstants |
ANY_CHAR, ANY_CHAR_EOL, ANY_SIGN, AT_LEAST, AT_MOST, DEBUG, DOUBLE, EOL, EXACTLY, INTEGER, NEGATIVE, NON_NULL, POSITIVE, STRICTLY_NEGATIVE, STRICTLY_POSITIVE, WHITE_SPACES, WHITE_SPACES_OR_EOL |
Method Summary |
java.lang.Number |
getValue()
Return the parsed value, wrapped in a Number (either Integer or Double) |
boolean |
interpret(Context context)
Parses this expression, possibly using Context to fetch the String to interpret
if this Expression is a leaf expression. |
java.lang.String |
toString()
Convert this Object to a human-readable String. |
numberType
private int numberType
sign
private int sign
postfix
private java.lang.String postfix
swallowPostFix
private boolean swallowPostFix
value
private java.lang.Number value
NumericalExpression
public NumericalExpression(int numberType,
int sign,
java.lang.String postfix,
boolean swallowPostFix)
NumericalExpression
public NumericalExpression(int numberType,
int sign)
- Constructor w/o postfix, i.e. parse as many digits as possible.
NumericalExpression
public NumericalExpression()
- Constructor w/o postfix, type=DOUBLE and sign=ANY_SIGN.
interpret
public boolean interpret(Context context)
throws ParserException
- Description copied from class:
AbstractRegularExpression
- Parses this expression, possibly using Context to fetch the String to interpret
if this Expression is a leaf expression.
- Specified by:
interpret
in class AbstractRegularExpression
getValue
public java.lang.Number getValue()
- Return the parsed value, wrapped in a Number (either Integer or Double)
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object
- Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method
never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string
concatenation with this object. If the result is
null
, string concatenation will instead
use "null"
.
The default implementation returns
getClass().getName() + "@" +
Integer.toHexString(hashCode())
.