public class

SimpleTest

extends Object
java.lang.Object
   ↳ webwork.util.SimpleTest

Class Overview

This class is used to handle test expressions in an efficient way. It is more than 5 times faster than the javacc generated Parser.java Instances of the class are retrieved through the static method getSimpleTest. If the method returns null it means the expression was too complex for this class too handle. Complex expressions are those using parenthesis to control the order of evaluation. Those expressions will instead be handled by the old javacc Parser.java class.

Summary

Constants
int AND
char AND_CHAR
int CHECK_NULL
int EQUAL
char EQUAL_CHAR
int GREATER
char GREATER_CHAR
int GREATER_EQUAL
int LESS
char LESS_CHAR
int LESS_EQUAL
int NONE
char NOT_CHAR
int NOT_EQUAL
int OR
char OR_CHAR
char QUOTE_CHAR
Fields
protected int condition
protected String exp1
protected String exp2
protected boolean neg1
protected boolean neg2
protected SimpleTest nextTest
protected int operator
protected Query q1
protected Query q2
protected int sameVal1
protected int sameVal2
protected Object value1
protected Object value2
Public Constructors
SimpleTest()
SimpleTest(SimpleTest prevTest, String exp)
Create a SimpleTest for the expression exp, and make use of the values found in the previously evaluated expression prevText if possible
SimpleTest(String exp)
Public Methods
static SimpleTest getSimpleTest(String expression)
Get a SimpleTest object for the expression.
boolean test(ValueStack stack)
Protected Methods
int checkOperator(String str)
Look through the expression to find any operators like && or ||, etc.
Object getConstant(String exp)
This method checks if the expression is a constant value.
boolean resolve(int comp, int condition)
determine true or false by comparing the comparison result with the operator.
boolean test(ValueStack stack, Object prevVal1, Object prevVal2)
The values in prevVal1 and prevVal2 will always be sent in.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

protected static final int AND

Constant Value: 1 (0x00000001)

protected static final char AND_CHAR

Constant Value: 38 (0x00000026)

protected static final int CHECK_NULL

Constant Value: 0 (0x00000000)

protected static final int EQUAL

Constant Value: 1 (0x00000001)

protected static final char EQUAL_CHAR

Constant Value: 61 (0x0000003d)

protected static final int GREATER

Constant Value: 3 (0x00000003)

protected static final char GREATER_CHAR

Constant Value: 62 (0x0000003e)

protected static final int GREATER_EQUAL

Constant Value: 4 (0x00000004)

protected static final int LESS

Constant Value: 5 (0x00000005)

protected static final char LESS_CHAR

Constant Value: 60 (0x0000003c)

protected static final int LESS_EQUAL

Constant Value: 6 (0x00000006)

protected static final int NONE

Constant Value: 0 (0x00000000)

protected static final char NOT_CHAR

Constant Value: 33 (0x00000021)

protected static final int NOT_EQUAL

Constant Value: 2 (0x00000002)

protected static final int OR

Constant Value: 2 (0x00000002)

protected static final char OR_CHAR

Constant Value: 124 (0x0000007c)

protected static final char QUOTE_CHAR

Constant Value: 39 (0x00000027)

Fields

protected int condition

protected String exp1

protected String exp2

protected boolean neg1

protected boolean neg2

protected SimpleTest nextTest

protected int operator

protected Query q1

protected Query q2

protected int sameVal1

protected int sameVal2

protected Object value1

protected Object value2

Public Constructors

public SimpleTest ()

public SimpleTest (SimpleTest prevTest, String exp)

Create a SimpleTest for the expression exp, and make use of the values found in the previously evaluated expression prevText if possible

public SimpleTest (String exp)

Public Methods

public static SimpleTest getSimpleTest (String expression)

Get a SimpleTest object for the expression. If the expression is too complex then null is returned If the expression has been handled before then a cached SimpleTest object is returned. Otherwise a new one is created

public boolean test (ValueStack stack)

Protected Methods

protected int checkOperator (String str)

Look through the expression to find any operators like && or ||, etc. If found then the operator variable is updated.

protected Object getConstant (String exp)

This method checks if the expression is a constant value. If it is not a constant then the method returns the object NO_CONSTANT If it is a constant then it returns the constant value which may be null

protected boolean resolve (int comp, int condition)

determine true or false by comparing the comparison result with the operator.

Parameters
comp the comparison result
condition the condition
Returns
  • the boolean result

protected boolean test (ValueStack stack, Object prevVal1, Object prevVal2)

The values in prevVal1 and prevVal2 will always be sent in. They can be null because they are not used or because the value found was null. This does not matter. The expression after this one will only care about the value IF the same expression existed in this test as in the next test.