Class AbstractEvaluator

java.lang.Object
org.scijava.parsington.eval.AbstractEvaluator
All Implemented Interfaces:
Evaluator
Direct Known Subclasses:
AbstractStandardEvaluator

public abstract class AbstractEvaluator extends Object implements Evaluator
Base class for Evaluator implementations.
Author:
Curtis Rueden
  • Constructor Details

    • AbstractEvaluator

      public AbstractEvaluator()
    • AbstractEvaluator

      public AbstractEvaluator(ExpressionParser parser)
  • Method Details

    • getParser

      public ExpressionParser getParser()
      Description copied from interface: Evaluator
      Gets the parser used when evaluating expressions.
      Specified by:
      getParser in interface Evaluator
      Returns:
      The expression parser used by this evaluator.
    • isStrict

      public boolean isStrict()
      Description copied from interface: Evaluator
      Gets whether the evaluator is operating in strict mode.
      Specified by:
      isStrict in interface Evaluator
      Returns:
      True iff the evaluator is operating in strict mode.
      See Also:
    • setStrict

      public void setStrict(boolean strict)
      Description copied from interface: Evaluator
      Sets whether the evaluator is operating in strict mode. Evaluators operate in strict mode by default.

      When evaluating strictly, usage of an unassigned variable token in a place where its value is needed will generate an IllegalArgumentException with an "Unknown variable" message; in non-strict mode, such a variable will instead be resolved to an object of type Unresolved with the same name as the original variable.

      In cases such as assignment, this may be sufficient to complete the evaluation; for example, the expression foo=bar will complete successfully in non-strict mode, with the variable foo containing an object of type Unresolved and token value "bar". But in cases where the unresolved value is needed as an input for additional operations, the evaluation may still ultimately fail if the operation in question is not defined for unresolved values. For example, the DefaultStackEvaluator will fail with an "Unsupported binary operator" exception when given the expression foo+bar, since foo and bar are unresolved variables, and the + operator cannot handle such objects.

      Specified by:
      setStrict in interface Evaluator
      Parameters:
      strict - True iff the evaluator should operate in strict mode.
    • get

      public Object get(String name)
      Description copied from interface: Evaluator
      Gets the value of a variable.
      Specified by:
      get in interface Evaluator
      Parameters:
      name - The name of the variable whose value you want.
      Returns:
      The variable's value.
    • set

      public void set(String name, Object value)
      Description copied from interface: Evaluator
      Sets the value of a variable.
      Specified by:
      set in interface Evaluator
      Parameters:
      name - The name of the variable whose value you want to set.
      value - The value to assign to the variable.
    • setAll

      public void setAll(Map<? extends String,? extends Object> map)
      Description copied from interface: Evaluator
      Assigns variables en masse.
      Specified by:
      setAll in interface Evaluator
      Parameters:
      map - A map from variable names to variable values.