Class DefaultEvaluator

All Implemented Interfaces:
Evaluator, StackEvaluator, StandardEvaluator

public class DefaultEvaluator extends AbstractStandardStackEvaluator
An expression evaluator for most standard operators with common built-in types (i.e.: Booleans, Strings and Numbers).

Caveats

This class is a big bag of case logic for various operators and types. Looking at it, you might think: "It sure would be nice to modularize this, with each operation in its own class, with properly declared types, and called dynamically at runtime as appropriate."

"Great idea!" I would reply. Then I would suggest you have a look at the SciJava Ops and ImageJ Ops projects, which do exactly that in an extensible way.

Or maybe you are thinking: "This can't possibly work as well as awesome JVM-based scripting languages like Jython and Groovy..."

To which I would reply: "You are absolutely right! This class is mostly just a demonstration of an extensible, working evaluator built using the org.scijava.parse.eval package. If your use case is only concerned with feature-rich evaluation of standard types, then building on top of a scripting language might make more sense."

Author:
Curtis Rueden
See Also: