jwo.utils.expression
Class MathToken

java.lang.Object
  extended by jwo.utils.expression.MathToken

public final class MathToken
extends Object

Stores an enumerated list of tokens that may be parsed by the MathParser. Includes arithmetical, trig operators, variable substitution, control statements and parenthases. Fields starting with LEX_ indicate the textual representation of the token and fields starting with TOK_ indicate the token itself.

Based on original code described at www.devx.com/premier/mgznarch/javapro/2001/05may01/ps0105/ps0105.asp.

Version:
2.3, 1st October, 2008.
Author:
Original code Daniel Savarese with additions and modifications by Jo Wood.

Field Summary
static String LEX_ABS
          Text representing absolute function.
static String LEX_ACOS
          Text representing trigonometrical inverse cosine function.
static String LEX_ADD
          Text representing addition operator.
static String LEX_AND
          Text representing Boolean 'and' operator.
static String LEX_ASIN
          Text representing trigonometrical inverse sine function.
static String LEX_ATAN
          Text representing trigonometrical inverse tangent (semicircular angle +-pi/2) function.
static String LEX_ATAN2
          Text representing trigonometrical inverse tangent (full circular +-pi) function.
static String LEX_BLUE
          Text representing blue colour component extraction function.
static String LEX_CLOSE_INDEX
          Close index text representation.
static String LEX_CLOSE_PAREN
          Close parenthesis text representation.
static String LEX_COMPARE
          Text representing string compare function.
static String LEX_CONCATENATE
          Text representing string concatenation operator.
static String LEX_COS
          Text representing trigonometrical cosine function.
static String LEX_DIVIDE
          Text representing division operator.
static String LEX_E
          Text representing constant e.
static String LEX_EQUAL
          Text representing 'equal to' operator.
static String LEX_EXPONENT
          Text representing exponential (power) operator.
static String LEX_FOCAL
          Text representing focal operator.
static String LEX_GAUSS
          Text representing Gaussian (normal) function.
static String LEX_GREATER_THAN
          Text representing 'greater than' operator.
static String LEX_GREATER_THAN_EQUAL
          Text representing 'greater than or equal to' operator.
static String LEX_GREEN
          Text representing green colour component extraction function.
static String LEX_IF
          Text representing logical 'if' construction.
static String LEX_IFELSE
          Text representing logical 'ifelse' function (conditional operator).
static String LEX_LESS_THAN
          Text representing 'less than' operator.
static String LEX_LESS_THAN_EQUAL
          Text representing 'less than or equal to' operator.
static String LEX_LN
          Text representing natural logarithm function.
static String LEX_MAX
          Text representing maximum function.
static String LEX_MEDIAN
          Text representing median function.
static String LEX_MIN
          Text representing minimum function.
static String LEX_MODE
          Text representing mode function.
static String LEX_MODULUS
          Text representing modulus operator.
static String LEX_MULTIPLY
          Text representing multiplication operator.
static String LEX_NOT
          Text representing Boolean 'not' operator.
static String LEX_NOT_EQUAL
          Text representing 'not equal to' operator.
static String LEX_NULL
          Text representing null identifier.
static String LEX_OPEN_INDEX
          Open index text representation.
static String LEX_OPEN_PAREN
          Open parenthesis text representation.
static String LEX_OR
          Text representing Boolean 'or' operator.
static String LEX_PERCENTILE
          Text representing percentile function.
static String LEX_PI
          Text representing constant pi.
static String LEX_QUOTE
          Quotation mark text representation.
static String LEX_QUOTEFN
          Text representing the string quote function.
static String LEX_RAND
          Text representing rectangular random function.
static String LEX_RANK
          Text representing ranking function.
static String LEX_RED
          Text representing red colour component extraction function.
static String LEX_RGB
          Text representing colour creation function.
static String LEX_ROUND
          Text representing decimal rounding function.
static String LEX_SEPARATOR
          Parameter separator symbol.
static String LEX_SIN
          Text representing trigonometrical sine function.
static String LEX_SQRT
          Text representing square root function.
static String LEX_STRLEN
          Text representing the string length function.
static String LEX_SUBSTRING
          Text representing the substring function.
static String LEX_SUBTRACT
          Text representing subtraction operator.
static String LEX_TAN
          Text representing trigonometrical tangent function.
static String LEX_WHILE
          Text representing logical 'while loop' construction.
static String LEX_X
          Text representing x variable.
static String LEX_Y
          Text representing y variable.
static String LEX_Z1
          Text representing z1 variable.
static String LEX_Z2
          Text representing z2 variable.
static MathToken TOK_ADDITIVE
          Additive operator token.
static MathToken TOK_BOOLEAN
          Boolean type token.
static MathToken TOK_CLOSE_INDEX
          Close index token.
static MathToken TOK_CLOSE_PAREN
          Close parenthesis token.
static MathToken TOK_COMPARATIVE
          Comparative operator token.
static MathToken TOK_EXPONENT
          Exponential operator token.
static MathToken TOK_FUNC
          Fixed parameter function token.
static MathToken TOK_MULTIPLICATIVE
          Multiplicative operator token.
static MathToken TOK_NUMBER
          Numerical token.
static MathToken TOK_OPEN_INDEX
          Open index token.
static MathToken TOK_OPEN_PAREN
          Open parenthesis token.
static MathToken TOK_QUOTED_STRING
          Any text inside quotation marks.
static MathToken TOK_SEPARATOR
          Parameter separator token.
static MathToken TOK_USER_FUNC
          User-defined function token.
static MathToken TOK_VAR_FUNC
          Variable parameter function token.
static MathToken TOK_VARIABLE
          Variable token.
static Object[][] TOKENS
          Array of valid regular expressions corresponding with their token types.
 
Constructor Summary
MathToken()
           
 
Method Summary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEX_ADD

public static final String LEX_ADD
Text representing addition operator.

See Also:
Constant Field Values

LEX_SUBTRACT

public static final String LEX_SUBTRACT
Text representing subtraction operator.

See Also:
Constant Field Values

LEX_MULTIPLY

public static final String LEX_MULTIPLY
Text representing multiplication operator.

See Also:
Constant Field Values

LEX_DIVIDE

public static final String LEX_DIVIDE
Text representing division operator.

See Also:
Constant Field Values

LEX_MODULUS

public static final String LEX_MODULUS
Text representing modulus operator.

See Also:
Constant Field Values

LEX_EXPONENT

public static final String LEX_EXPONENT
Text representing exponential (power) operator.

See Also:
Constant Field Values

LEX_CONCATENATE

public static final String LEX_CONCATENATE
Text representing string concatenation operator.

See Also:
Constant Field Values

LEX_GREATER_THAN

public static final String LEX_GREATER_THAN
Text representing 'greater than' operator.

See Also:
Constant Field Values

LEX_LESS_THAN

public static final String LEX_LESS_THAN
Text representing 'less than' operator.

See Also:
Constant Field Values

LEX_GREATER_THAN_EQUAL

public static final String LEX_GREATER_THAN_EQUAL
Text representing 'greater than or equal to' operator.

See Also:
Constant Field Values

LEX_LESS_THAN_EQUAL

public static final String LEX_LESS_THAN_EQUAL
Text representing 'less than or equal to' operator.

See Also:
Constant Field Values

LEX_EQUAL

public static final String LEX_EQUAL
Text representing 'equal to' operator.

See Also:
Constant Field Values

LEX_NOT_EQUAL

public static final String LEX_NOT_EQUAL
Text representing 'not equal to' operator.

See Also:
Constant Field Values

LEX_AND

public static final String LEX_AND
Text representing Boolean 'and' operator.

See Also:
Constant Field Values

LEX_OR

public static final String LEX_OR
Text representing Boolean 'or' operator.

See Also:
Constant Field Values

LEX_NOT

public static final String LEX_NOT
Text representing Boolean 'not' operator.

See Also:
Constant Field Values

LEX_SIN

public static final String LEX_SIN
Text representing trigonometrical sine function.

See Also:
Constant Field Values

LEX_COS

public static final String LEX_COS
Text representing trigonometrical cosine function.

See Also:
Constant Field Values

LEX_TAN

public static final String LEX_TAN
Text representing trigonometrical tangent function.

See Also:
Constant Field Values

LEX_ASIN

public static final String LEX_ASIN
Text representing trigonometrical inverse sine function.

See Also:
Constant Field Values

LEX_ACOS

public static final String LEX_ACOS
Text representing trigonometrical inverse cosine function.

See Also:
Constant Field Values

LEX_ATAN

public static final String LEX_ATAN
Text representing trigonometrical inverse tangent (semicircular angle +-pi/2) function.

See Also:
Constant Field Values

LEX_ATAN2

public static final String LEX_ATAN2
Text representing trigonometrical inverse tangent (full circular +-pi) function.

See Also:
Constant Field Values

LEX_COMPARE

public static final String LEX_COMPARE
Text representing string compare function.

See Also:
Constant Field Values

LEX_SQRT

public static final String LEX_SQRT
Text representing square root function.

See Also:
Constant Field Values

LEX_LN

public static final String LEX_LN
Text representing natural logarithm function.

See Also:
Constant Field Values

LEX_MAX

public static final String LEX_MAX
Text representing maximum function.

See Also:
Constant Field Values

LEX_MIN

public static final String LEX_MIN
Text representing minimum function.

See Also:
Constant Field Values

LEX_MODE

public static final String LEX_MODE
Text representing mode function.

See Also:
Constant Field Values

LEX_MEDIAN

public static final String LEX_MEDIAN
Text representing median function.

See Also:
Constant Field Values

LEX_PERCENTILE

public static final String LEX_PERCENTILE
Text representing percentile function.

See Also:
Constant Field Values

LEX_RANK

public static final String LEX_RANK
Text representing ranking function.

See Also:
Constant Field Values

LEX_ROUND

public static final String LEX_ROUND
Text representing decimal rounding function.

See Also:
Constant Field Values

LEX_ABS

public static final String LEX_ABS
Text representing absolute function.

See Also:
Constant Field Values

LEX_IFELSE

public static final String LEX_IFELSE
Text representing logical 'ifelse' function (conditional operator).

See Also:
Constant Field Values

LEX_IF

public static final String LEX_IF
Text representing logical 'if' construction.

See Also:
Constant Field Values

LEX_WHILE

public static final String LEX_WHILE
Text representing logical 'while loop' construction.

See Also:
Constant Field Values

LEX_QUOTEFN

public static final String LEX_QUOTEFN
Text representing the string quote function.

See Also:
Constant Field Values

LEX_RED

public static final String LEX_RED
Text representing red colour component extraction function.

See Also:
Constant Field Values

LEX_GREEN

public static final String LEX_GREEN
Text representing green colour component extraction function.

See Also:
Constant Field Values

LEX_BLUE

public static final String LEX_BLUE
Text representing blue colour component extraction function.

See Also:
Constant Field Values

LEX_RGB

public static final String LEX_RGB
Text representing colour creation function.

See Also:
Constant Field Values

LEX_SUBSTRING

public static final String LEX_SUBSTRING
Text representing the substring function.

See Also:
Constant Field Values

LEX_STRLEN

public static final String LEX_STRLEN
Text representing the string length function.

See Also:
Constant Field Values

LEX_Z1

public static final String LEX_Z1
Text representing z1 variable.

See Also:
Constant Field Values

LEX_Z2

public static final String LEX_Z2
Text representing z2 variable.

See Also:
Constant Field Values

LEX_X

public static final String LEX_X
Text representing x variable.

See Also:
Constant Field Values

LEX_Y

public static final String LEX_Y
Text representing y variable.

See Also:
Constant Field Values

LEX_NULL

public static final String LEX_NULL
Text representing null identifier.

See Also:
Constant Field Values

LEX_PI

public static final String LEX_PI
Text representing constant pi.

See Also:
Constant Field Values

LEX_E

public static final String LEX_E
Text representing constant e.

See Also:
Constant Field Values

LEX_RAND

public static final String LEX_RAND
Text representing rectangular random function.

See Also:
Constant Field Values

LEX_GAUSS

public static final String LEX_GAUSS
Text representing Gaussian (normal) function.

See Also:
Constant Field Values

LEX_FOCAL

public static final String LEX_FOCAL
Text representing focal operator.

See Also:
Constant Field Values

LEX_OPEN_PAREN

public static final String LEX_OPEN_PAREN
Open parenthesis text representation.

See Also:
Constant Field Values

LEX_CLOSE_PAREN

public static final String LEX_CLOSE_PAREN
Close parenthesis text representation.

See Also:
Constant Field Values

LEX_QUOTE

public static final String LEX_QUOTE
Quotation mark text representation.

See Also:
Constant Field Values

LEX_OPEN_INDEX

public static final String LEX_OPEN_INDEX
Open index text representation.

See Also:
Constant Field Values

LEX_CLOSE_INDEX

public static final String LEX_CLOSE_INDEX
Close index text representation.

See Also:
Constant Field Values

LEX_SEPARATOR

public static final String LEX_SEPARATOR
Parameter separator symbol.

See Also:
Constant Field Values

TOK_OPEN_PAREN

public static final MathToken TOK_OPEN_PAREN
Open parenthesis token.


TOK_CLOSE_PAREN

public static final MathToken TOK_CLOSE_PAREN
Close parenthesis token.


TOK_OPEN_INDEX

public static final MathToken TOK_OPEN_INDEX
Open index token.


TOK_CLOSE_INDEX

public static final MathToken TOK_CLOSE_INDEX
Close index token.


TOK_QUOTED_STRING

public static final MathToken TOK_QUOTED_STRING
Any text inside quotation marks.


TOK_ADDITIVE

public static final MathToken TOK_ADDITIVE
Additive operator token.


TOK_COMPARATIVE

public static final MathToken TOK_COMPARATIVE
Comparative operator token.


TOK_BOOLEAN

public static final MathToken TOK_BOOLEAN
Boolean type token.


TOK_MULTIPLICATIVE

public static final MathToken TOK_MULTIPLICATIVE
Multiplicative operator token.


TOK_EXPONENT

public static final MathToken TOK_EXPONENT
Exponential operator token.


TOK_NUMBER

public static final MathToken TOK_NUMBER
Numerical token.


TOK_FUNC

public static final MathToken TOK_FUNC
Fixed parameter function token.


TOK_VAR_FUNC

public static final MathToken TOK_VAR_FUNC
Variable parameter function token.


TOK_USER_FUNC

public static final MathToken TOK_USER_FUNC
User-defined function token.


TOK_VARIABLE

public static final MathToken TOK_VARIABLE
Variable token.


TOK_SEPARATOR

public static final MathToken TOK_SEPARATOR
Parameter separator token.


TOKENS

public static final Object[][] TOKENS
Array of valid regular expressions corresponding with their token types. Elements are paired, the first being a string representing the regular expression, the second the type MathToken that is associated with the regular expression. For example TOKENS[0] might be the regular expression [-+] and TOKENS[1] would be TOK_ADDITIVE. There is no guarantee of the order of elements in this array other than all valid token types are included, and a regular expression is always followed by a single MathToken.

Constructor Detail

MathToken

public MathToken()


Copyright Jo Wood, 1996-2009, last modified, 17th April, 2009