Package webwork.util

Class SimpleTest

java.lang.Object
webwork.util.SimpleTest

public class SimpleTest extends Object
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.
Version:
$Revision: 1.2 $
Author:
Dick Zetterberg (dick@transitor.se)
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • getSimpleTest

      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
    • checkOperator

      protected int checkOperator(String str) throws ComplexException
      Look through the expression to find any operators like invalid input: '&'invalid input: '&' or ||, invalid input: '<', > etc. If found then the operator variable is updated.
      Throws:
      ComplexException
    • getConstant

      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
    • test

      public boolean test(ValueStack stack)
    • test

      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.
    • resolve

      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