Class ChemTermsExpression<C extends ChemTermsContext>

java.lang.Object
chemaxon.chemterms.ChemTermsExpression<C>

@PublicApi public final class ChemTermsExpression<C extends ChemTermsContext> extends Object
Expression parser and evaluator for chemical expressions.
Since:
JChem 2.2, Marvin 5.1
See Also:
  • Field Details

  • Method Details

    • constantTable

      public ConstantTable constantTable()
      Returns the constant table used by this parser.
    • compile

      public void compile(String expression) throws ParseException
      Updates this object to represent the given expression.
      Parameters:
      expression - is the expression string
      Throws:
      ParseException - on compile error
    • evaluate

      public Object evaluate(C context) throws ParseException
      Evaluates the expression.
      Parameters:
      context - is the evaluation context
      Returns:
      the evaluation result
      Throws:
      ParseException - on evaluation error
    • evaluate_double

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2027) public double evaluate_double(C context) throws ParseException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use evaluateDouble(C) instead.
      Evaluates the expression and converts the result to double.
      Parameters:
      context - is the evaluation context
      Returns:
      the evaluation result
      Throws:
      ParseException - on evaluation error
    • evaluateDouble

      public double evaluateDouble(C context) throws ParseException
      Evaluates the expression and converts the result to double.
      Parameters:
      context - is the evaluation context
      Returns:
      the evaluation result
      Throws:
      ParseException - on evaluation error
    • evaluate_doubles

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2027) public double[] evaluate_doubles(C context) throws ParseException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Evaluates the expression and converts the result to double[]. This is useful if the result is an object array in which case each element is converted to double.
      Parameters:
      context - is the evaluation context
      Returns:
      the evaluation result
      Throws:
      ParseException - on evaluation error
    • evaluateDoubleArray

      public double[] evaluateDoubleArray(C context) throws ParseException
      Evaluates the expression and converts the result to double[]. This is useful if the result is an object array in which case each element is converted to double.
      Parameters:
      context - is the evaluation context
      Returns:
      the evaluation result
      Throws:
      ParseException - on evaluation error
    • evaluate_boolean

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2027) public boolean evaluate_boolean(C context) throws ParseException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use evaluateBoolean(C) instead.
      Evaluates the expression and converts the result boolean. Boolean return values are returned as double: 1.0 for true and 0.0 for false. This function returns true for a value greater than 0.5, false otherwise. This means that for boolean expressions the return value will be OK (and we also eliminated floating-point comparison inaccuracy :-).
      Parameters:
      context - is the evaluation context
      Returns:
      the evaluation result
      Throws:
      ParseException - on evaluation error
    • evaluateBoolean

      public boolean evaluateBoolean(C context) throws ParseException
      Evaluates the expression and converts the result boolean. Boolean return values are returned as double: 1.0 for true and 0.0 for false. This function returns true for a value greater than 0.5, false otherwise. This means that for boolean expressions the return value will be OK (and we also eliminated floating-point comparison inaccuracy :-).
      Parameters:
      context - is the evaluation context
      Returns:
      the evaluation result
      Throws:
      ParseException - on evaluation error
    • evaluate_booleans

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2027) public boolean[] evaluate_booleans(C context) throws ParseException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Evaluates the expression and converts the result to boolean[]. This is useful if the result is an object array in which case each element is converted to boolean.
      Parameters:
      context - is the evaluation context
      Returns:
      the evaluation result
      Throws:
      ParseException - on evaluation error
    • evaluateBooleanArray

      public boolean[] evaluateBooleanArray(C context) throws ParseException
      Evaluates the expression and converts the result to boolean[]. This is useful if the result is an object array in which case each element is converted to boolean.
      Parameters:
      context - is the evaluation context
      Returns:
      the evaluation result
      Throws:
      ParseException - on evaluation error
    • getLogicalValue

      public static int getLogicalValue(Object result)
      Returns the logical correspondent of the specified result object: TRUE, FALSE or UNDECIDED.
      Parameters:
      result - is the result object
      Returns:
      the corresponding logical value
      Since:
      JChem 3.2
    • isUndecided

      public static boolean isUndecided(Object result)
      Returns whether the result object is undecided.
      Returns:
      true if the result is undecided