Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.singularsys.jep.functions
Class LazyLogical

    java.lang.Object
      com.singularsys.jep.functions.PostfixMathCommand
          com.singularsys.jep.functions.LazyLogical

All Implemented Interfaces:
  CallbackEvaluationI, PostfixMathCommandI, java.io.Serializable

    public class LazyLogical

extends PostfixMathCommand
implements CallbackEvaluationI

A version of the logical operators which use lazy evaluation. The first argument is always evaluated but the second argument is only evaluated if needed. Hence

- `0 || arg2` arg2 is evaluated
- `1 || arg2` arg2 is not evaluated and true is returned
- `0 && arg2` arg2 is not evaluated and false is returned
- `1 && arg2` arg2 is evaluated

Since:
  3.1
See Also:
  Serialized Form

Field Summary
`static int` | `AND`
`static int` | `OR`

Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
`curNumberOfParameters, numberOfParameters`

Constructor Summary
`LazyLogical(int id_in)`

Method Summary
`java.lang.Object` | `evaluate(Node node, Evaluator pv)` Performs some special evaluation on the node.
`void` | `run(java.util.Stack<java.lang.Object> inStack)` Run the function on the stack.

Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand
`checkNumberOfParameters, checkStack, getNumberOfParameters, setCurNumberOfParameters`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### AND

    public static final int AND

See Also:
  Constant Field Values

### OR

    public static final int OR

See Also:
  Constant Field Values

Constructor Detail

### LazyLogical

    public LazyLogical(int id_in)

Method Detail

### run

    public void run(java.util.Stack<java.lang.Object> inStack)
             throws EvaluationException

  Description copied from interface: `PostfixMathCommandI`
  Run the function on the stack. Pops the arguments from the stack, and pushes the result on the top of the stack.

  Specified by:
    `run` in interface `PostfixMathCommandI`
  Throws:
    `EvaluationException`

### evaluate

    public java.lang.Object evaluate(Node node,
                                     Evaluator pv)
                              throws EvaluationException

  Description copied from interface: `CallbackEvaluationI`
  Performs some special evaluation on the node. This method has the responsibility for evaluating the children of the node and it should generally call

       pv.eval(node.jjtGetChild(i))

  for each child. The SymbolTable is not passed as an argument. This is because it is better practice to get and set variable values by using node.getVar().setValue() rather that through the SymbolTable with requires a hashtable lookup.

  Specified by:
    `evaluate` in interface `CallbackEvaluationI`
  Parameters:
    `node` - The current node
    `pv` - The visitor, can be used evaluate the children
  Returns:
    the value after evaluation
  Throws:
    `EvaluationException`
  See Also:
    `Evaluator`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2007 Singular Systems http://www.singularsys.com/jep