public class DefaultEvaluator extends AbstractStandardStackEvaluator
standard operators with
common built-in types (i.e.: Booleans, Strings and
Numbers). 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.parsington.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."
The main class, to give it a spin.| Constructor and Description |
|---|
DefaultEvaluator() |
DefaultEvaluator(ExpressionParser parser) |
addAssign, andAssign, assign, divAssign, dotDivAssign, dotPowAssign, dotRightDivAssign, execute, leftShiftAssign, modAssign, mulAssign, orAssign, postDec, postInc, powAssign, preDec, preInc, rightDivAssign, rightShiftAssign, subAssign, unsignedRightShiftAssignevaluateevaluate, evaluate, get, getParser, isStrict, set, setAll, setStrict, valuepublic DefaultEvaluator()
public DefaultEvaluator(ExpressionParser parser)
public Object function(Object a, Object b)
StandardEvaluatorFunction operator.public Object dot(Object a, Object b)
StandardEvaluatorOperators.DOT operator.public Object parens(Object[] args)
StandardEvaluatorOperators.PARENS operator.public Object brackets(Object[] args)
StandardEvaluatorOperators.BRACKETS operator.public Object braces(Object[] args)
StandardEvaluatorOperators.BRACES operator.public Object transpose(Object a)
StandardEvaluatorOperators.TRANSPOSE operator.public Object dotTranspose(Object a)
StandardEvaluatorOperators.DOT_TRANSPOSE operator.public Object pow(Object a, Object b)
StandardEvaluatorOperators.POW operator.public double pow(double a,
double b)
public BigInteger pow(BigInteger a, int b)
public BigDecimal pow(BigDecimal a, int b)
public Object dotPow(Object a, Object b)
StandardEvaluatorOperators.DOT_POW operator.public Object pos(Object a)
StandardEvaluatorOperators.POS operator.public int pos(int num)
public long pos(long num)
public float pos(float num)
public double pos(double num)
public Object neg(Object a)
StandardEvaluatorOperators.NEG operator.public int neg(int num)
public long neg(long num)
public float neg(float num)
public double neg(double num)
public BigInteger neg(BigInteger num)
public BigDecimal neg(BigDecimal num)
public Object complement(Object a)
StandardEvaluatorOperators.COMPLEMENT operator.public int complement(int a)
public long complement(long a)
public Object not(Object a)
StandardEvaluatorOperators.NOT operator.public boolean not(boolean a)
public Object mul(Object a, Object b)
StandardEvaluatorOperators.MUL operator.public int mul(int a,
int b)
public long mul(long a,
long b)
public float mul(float a,
float b)
public double mul(double a,
double b)
public BigInteger mul(BigInteger a, BigInteger b)
public BigDecimal mul(BigDecimal a, BigDecimal b)
public Object div(Object a, Object b)
StandardEvaluatorOperators.DIV operator.public int div(int a,
int b)
public long div(long a,
long b)
public float div(float a,
float b)
public double div(double a,
double b)
public BigInteger div(BigInteger a, BigInteger b)
public BigDecimal div(BigDecimal a, BigDecimal b)
public Object mod(Object a, Object b)
StandardEvaluatorOperators.MOD operator.public int mod(int a,
int b)
public long mod(long a,
long b)
public float mod(float a,
float b)
public double mod(double a,
double b)
public BigInteger mod(BigInteger a, BigInteger b)
public BigDecimal mod(BigDecimal a, BigDecimal b)
public Object rightDiv(Object a, Object b)
StandardEvaluatorOperators.RIGHT_DIV operator.public Object dotMul(Object a, Object b)
StandardEvaluatorOperators.DOT_MUL operator.public Object dotDiv(Object a, Object b)
StandardEvaluatorOperators.DOT_DIV operator.public Object dotRightDiv(Object a, Object b)
StandardEvaluatorOperators.DOT_RIGHT_DIV operator.public Object add(Object a, Object b)
StandardEvaluatorOperators.ADD operator.public int add(int a,
int b)
public long add(long a,
long b)
public float add(float a,
float b)
public double add(double a,
double b)
public BigInteger add(BigInteger a, BigInteger b)
public BigDecimal add(BigDecimal a, BigDecimal b)
public Object sub(Object a, Object b)
StandardEvaluatorOperators.SUB operator.public int sub(int a,
int b)
public long sub(long a,
long b)
public float sub(float a,
float b)
public double sub(double a,
double b)
public BigInteger sub(BigInteger a, BigInteger b)
public BigDecimal sub(BigDecimal a, BigDecimal b)
public Object leftShift(Object a, Object b)
StandardEvaluatorOperators.LEFT_SHIFT operator.public int leftShift(int a,
int b)
public long leftShift(long a,
long b)
public BigInteger leftShift(BigInteger a, int b)
public Object rightShift(Object a, Object b)
StandardEvaluatorOperators.RIGHT_SHIFT operator.public int rightShift(int a,
int b)
public long rightShift(long a,
long b)
public BigInteger rightShift(BigInteger a, int b)
public Object unsignedRightShift(Object a, Object b)
StandardEvaluatorOperators.UNSIGNED_RIGHT_SHIFT operator.public int unsignedRightShift(int a,
int b)
public long unsignedRightShift(long a,
long b)
public Object colon(Object a, Object b)
StandardEvaluatorOperators.COLON operator.public Object lessThan(Object a, Object b)
StandardEvaluatorOperators.LESS_THAN operator.public <T> boolean lessThan(Comparable<T> a, T b)
public Object greaterThan(Object a, Object b)
StandardEvaluatorOperators.GREATER_THAN operator.public <T> boolean greaterThan(Comparable<T> a, T b)
public Object lessThanOrEqual(Object a, Object b)
StandardEvaluatorOperators.LESS_THAN_OR_EQUAL operator.public <T> boolean lessThanOrEqual(Comparable<T> a, T b)
public Object greaterThanOrEqual(Object a, Object b)
StandardEvaluatorOperators.GREATER_THAN_OR_EQUAL operator.public <T> boolean greaterThanOrEqual(Comparable<T> a, T b)
public Object instanceOf(Object a, Object b)
StandardEvaluatorOperators.INSTANCEOF operator.public Object equal(Object a, Object b)
StandardEvaluatorOperators.EQUAL operator.public Object notEqual(Object a, Object b)
StandardEvaluatorOperators.NOT_EQUAL operator.public Object bitwiseAnd(Object a, Object b)
StandardEvaluatorOperators.BITWISE_AND operator.public int bitwiseAnd(int a,
int b)
public long bitwiseAnd(long a,
long b)
public BigInteger bitwiseAnd(BigInteger a, BigInteger b)
public Object bitwiseOr(Object a, Object b)
StandardEvaluatorOperators.BITWISE_OR operator.public int bitwiseOr(int a,
int b)
public long bitwiseOr(long a,
long b)
public BigInteger bitwiseOr(BigInteger a, BigInteger b)
public Object logicalAnd(Object a, Object b)
StandardEvaluatorOperators.LOGICAL_AND operator.public boolean logicalAnd(boolean a,
boolean b)
public Object logicalOr(Object a, Object b)
StandardEvaluatorOperators.LOGICAL_OR operator.public boolean logicalOr(boolean a,
boolean b)
Copyright © 2015–2022 SciJava. All rights reserved.