Class 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
    Since:
    jpicedt 1.3
    Version:
    $Id: NumericalExpression.java,v 1.4.2.1 2007/09/02 11:56:13 reynal Exp $
    Author:
    Sylvain Reynal
    • Constructor Detail

      • NumericalExpression

        public NumericalExpression​(int numberType,
                                   int sign,
                                   java.lang.String postfix,
                                   boolean swallowPostFix)
        Parameters:
        numberType - INTEGER or DOUBLE
        sign - ANY_SIGN, POSITIVE, NEGATIVE, STRICTLY_POSITIVE, STRICTLY_NEGATIVE or NON_NULL
        postfix - a String that signals the end of this numerical expression (if NULL, swallows as many digits as possible)
        swallowPostFix - if TRUE, move cursor JUST BEHIND the postfix; else move it TO THE POSTFIX POSITION N/A if postFix is null.
      • NumericalExpression

        public NumericalExpression​(int numberType,
                                   int sign)
        Constructor w/o postfix, i.e. parse as many digits as possible.
        Parameters:
        numberType - INTEGER or DOUBLE
        sign - ANY_SIGN, POSITIVE, NEGATIVE, STRICTLY_POSITIVE, STRICTLY_NEGATIVE or NON_NULL
      • NumericalExpression

        public NumericalExpression()
        Constructor w/o postfix, type=DOUBLE and sign=ANY_SIGN.
    • Method Detail

      • interpret

        public boolean interpret​(Context context)
                          throws REParserException
        Description copied from class: AbstractRegularExpression
        Parses this expression, possibly using the given Context to fetch the String to interpret if this Expression is a leaf expression.
        Specified by:
        interpret in class AbstractRegularExpression
        Returns:
        TRUE if expr has been found on the current line Calls action() in case of successful parsing, and send a ParserEvent with value=parsed number.
        Throws:
        REParserException - if an error occur during parsing
      • getValue

        public java.lang.Number getValue()
        Return the parsed value, wrapped in a Number (either Integer or Double)
      • toString

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