Package chemaxon.jep

Interface ChemContext

All Superinterfaces:
chemaxon.marvin.util.CallbackIface, Serializable
All Known Implementing Classes:
AtomContext, MolContext, ReactionContext

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

  • Method Details

    • getContextFunctionNames

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) default String[] getContextFunctionNames()
      Deprecated, for removal: This API element is subject to removal in a future version.
      This method is the legacy option for specifying the supported context functions. Use the ChemContext.ProvidesFunction annotation instead.
      Returns context element accessor function names. Implementations override this method to add specific context elements accessors.
      Returns:
      the context element accessor function names
    • 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
    • callback

      @Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) default Object callback(String method, Object arg)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Implements CallbackIface. Implementations override this method to implement the specific context elements accessors returned by getContextFunctionNames().
      Specified by:
      callback in interface chemaxon.marvin.util.CallbackIface
      Parameters:
      method - is the accessor method name (returned by getContextFunctionNames())
      arg - is the accessor method argument (the JEP parameter stack as null, a single parameter object or a parameter object array depending on the number of parameters on the stack)
      Returns:
      the context element
    • callContextFunction

      default Object callContextFunction(String name, List<Object> params) throws JepException
      Executes the specified context function with the given parameters. Implementations override this method to implement the specific context element accessors as specified by ChemContext.ProvidesFunction annotations on the implementation.
      Parameters:
      name - the context function name (as specified by ChemContext.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:
      JepException - on error
    • clear

      void clear()
      Clears the context.