Class JELParser

java.lang.Object
noaa.coastwatch.util.expression.JELParser
All Implemented Interfaces:
ExpressionParser

public class JELParser extends Object implements ExpressionParser
The JELParser class parses expressions using the Java Expressions Library (JEL) by Konstantin L. Metlov available from https://www.gnu.org/software/jel. The syntax follows the Java Language Specification and includes the full set of java.lang.Math static methods and other useful constants and methods.
Since:
3.4.0
Author:
Peter Hollemans
  • Constructor Details

    • JELParser

      public JELParser()
  • Method Details

    • init

      public void init(ParseImp parseImp)
      Description copied from interface: ExpressionParser
      Initializes this parser with the specified implementation.
      Specified by:
      init in interface ExpressionParser
      Parameters:
      parseImp - the parser implementation to use for variable information during parsing.
    • parse

      public void parse(String expr)
      Description copied from interface: ExpressionParser
      Parses the specified expression.
      Specified by:
      parse in interface ExpressionParser
      Parameters:
      expr - the expression to parse.
    • adapt

      public void adapt(ExpressionParser.ResultType type)
      Description copied from interface: ExpressionParser
      Adapts the parsed expression to a specific result type.
      Specified by:
      adapt in interface ExpressionParser
      Parameters:
      type - the result type to adapt the expression. The result type of the parser is set to the specified type.
    • getResultType

      public ExpressionParser.ResultType getResultType()
      Description copied from interface: ExpressionParser
      Gets the result data type.
      Specified by:
      getResultType in interface ExpressionParser
      Returns:
      the result data type.
    • getVariables

      public List<String> getVariables()
      Description copied from interface: ExpressionParser
      Gets the list of variables used in the expression.
      Specified by:
      getVariables in interface ExpressionParser
      Returns:
      the list of variable names.
    • evaluate

      public Object evaluate(EvaluateImp evalImp)
      Description copied from interface: ExpressionParser
      Evaluates the expression to a primitive wrapper object.
      Specified by:
      evaluate in interface ExpressionParser
      Parameters:
      evalImp - the evalutation implementation that provides variable values.
      Returns:
      the result value in a wrapper.
    • evaluateToBoolean

      public boolean evaluateToBoolean(EvaluateImp evalImp)
      Description copied from interface: ExpressionParser
      Evaluates the expression to a boolean value.
      Specified by:
      evaluateToBoolean in interface ExpressionParser
      Parameters:
      evalImp - the evalutation implementation that provides variable values.
      Returns:
      the boolean valued result, or false if the result type is not a boolean.
    • evaluateToByte

      public byte evaluateToByte(EvaluateImp evalImp)
      Description copied from interface: ExpressionParser
      Evaluates the expression to a byte value.
      Specified by:
      evaluateToByte in interface ExpressionParser
      Parameters:
      evalImp - the evalutation implementation that provides variable values.
      Returns:
      the byte valued result, or zero if the result is not a byte.
    • evaluateToShort

      public short evaluateToShort(EvaluateImp evalImp)
      Description copied from interface: ExpressionParser
      Evaluates the expression to a short value.
      Specified by:
      evaluateToShort in interface ExpressionParser
      Parameters:
      evalImp - the evalutation implementation that provides variable values.
      Returns:
      the short valued result, or zero if the result is not a short.
    • evaluateToInt

      public int evaluateToInt(EvaluateImp evalImp)
      Description copied from interface: ExpressionParser
      Evaluates the expression to an int value.
      Specified by:
      evaluateToInt in interface ExpressionParser
      Parameters:
      evalImp - the evalutation implementation that provides variable values.
      Returns:
      the int valued result, or zero if the result is not an int.
    • evaluateToLong

      public long evaluateToLong(EvaluateImp evalImp)
      Description copied from interface: ExpressionParser
      Evaluates the expression to a long value.
      Specified by:
      evaluateToLong in interface ExpressionParser
      Parameters:
      evalImp - the evalutation implementation that provides variable values.
      Returns:
      the long valued result, or zero if the result is not a long.
    • evaluateToFloat

      public float evaluateToFloat(EvaluateImp evalImp)
      Description copied from interface: ExpressionParser
      Evaluates the expression to a float value.
      Specified by:
      evaluateToFloat in interface ExpressionParser
      Parameters:
      evalImp - the evalutation implementation that provides variable values.
      Returns:
      the float valued result, or zero if the result is not a float.
    • evaluateToDouble

      public double evaluateToDouble(EvaluateImp evalImp)
      Description copied from interface: ExpressionParser
      Evaluates the expression to a double value.
      Specified by:
      evaluateToDouble in interface ExpressionParser
      Parameters:
      evalImp - the evalutation implementation that provides variable values.
      Returns:
      the double valued result, or zero if the result is not a double.
    • main

      public static void main(String[] argv) throws Exception
      Tests this class.
      Parameters:
      argv - the array of command line parameters.
      Throws:
      Exception