Class LogicEvaluator

java.lang.Object
org.idempiere.expression.logic.LogicEvaluator

public final class LogicEvaluator extends Object
Static method for evaluation of logic expression
Author:
hengsin
  • Method Details

    • evaluateLogic

      public static boolean evaluateLogic(Evaluatee source, String logic)
      Evaluate Logic Expression.
        
        format: <negate>(<expression> [<logic> <expression>]).
        <negate>: $!.
        <expression>: @<context>@<comparison><value>.
        <logic>: | or & (Example '@AD_Table@=Test | @Language@=GERGER).
        <comparison>: = | ! | ^ | < | > | <= | >= | ~ (Equal, Not Equal, Not Equal, Less Than, 
        Greater Than, Less Than or Equal, Greater Than or Equal, Regular Expression Match).
        <Regular Expression Match>: <input string> ~ '<regular expression>'.
        <List>: value1,value2,value3 (Example '@CalculationType@=A,R,S').
        <context>: any global or window context.
        <value>: strings can be with ' or ".
        <logic operators>: AND or OR with the previous result from left to right.
        <()>: override the default left to right evaluation order (Example '@GrandTotal@=0 |(@GrandTotal@>0 & @PaymentRule@=X)").
        
        
      Parameters:
      source - class implementing get_ValueAsString(variable)
      logic - logic expression
      Returns:
      logic evaluation result
    • validate

      public static void validate(String logic)
      Throw exception if logic expression is not valid
      Parameters:
      logic -
      Throws:
      org.antlr.v4.runtime.misc.ParseCancellationException