Interface ChemTermsContext

All Known Implementing Classes:
AtomContext, MolContext, ReactionContext, SearchContext

@PublicApi public interface ChemTermsContext
Interface of expression evaluation contexts. Provides context functions and evaluation time constants for the evaluator engine. Context functions have to be declared using the ChemTermsContext.ProvidesFunction annotation.
Since:
JChem 2.2, Marvin 5.1
  • Field Details

  • Method Details

    • getVariable

      default Object getVariable(String name)
      Returns the value of a variable.

      In a Chemical Terms expression, a symbol can be either:

      • a constant, provided before compilation,
      • a variable, provided by this method during the evaluation.
      Unlike context functions, supported variables do not have to be listed in an annotation. The evaluator engine simply assumes all unknown symbols (those which were not specified as constants) to be variables, and calls this method to get their value during the evaluation.
      Parameters:
      name - the name of the variable
      Returns:
      the value of the variable, or null if this context does not define the given variable
    • callContextFunction

      default Object callContextFunction(String name, List<Object> params) throws ChemTermsException
      Executes the specified context function with the given parameters. Implementations override this method to implement the specific context element accessors as specified by ChemTermsContext.ProvidesFunction annotations on the implementation.
      Parameters:
      name - the context function name (as specified by ChemTermsContext.ProvidesFunction.names())
      params - the context function parameters. The size of this list must be between the minimum and maximum allowed.
      Returns:
      the context element, or null if the given function is not supported
      Throws:
      ChemTermsException - on error
    • clear

      void clear()
      Clears the context.