public class DefaultEvaluator extends AbstractStandardStackEvaluator
standard operators
with
common built-in types (i.e.: Boolean
s, String
s and
Number
s). 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, unsignedRightShiftAssign
evaluate
evaluate, evaluate, get, getParser, isStrict, set, setAll, setStrict, value
public DefaultEvaluator()
public DefaultEvaluator(ExpressionParser parser)
public Object function(Object a, Object b)
StandardEvaluator
Function
operator.public Object dot(Object a, Object b)
StandardEvaluator
Operators.DOT
operator.public Object parens(Object[] args)
StandardEvaluator
Operators.PARENS
operator.public Object brackets(Object[] args)
StandardEvaluator
Operators.BRACKETS
operator.public Object braces(Object[] args)
StandardEvaluator
Operators.BRACES
operator.public Object transpose(Object a)
StandardEvaluator
Operators.TRANSPOSE
operator.public Object dotTranspose(Object a)
StandardEvaluator
Operators.DOT_TRANSPOSE
operator.public Object pow(Object a, Object b)
StandardEvaluator
Operators.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)
StandardEvaluator
Operators.DOT_POW
operator.public Object pos(Object a)
StandardEvaluator
Operators.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)
StandardEvaluator
Operators.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)
StandardEvaluator
Operators.COMPLEMENT
operator.public int complement(int a)
public long complement(long a)
public Object not(Object a)
StandardEvaluator
Operators.NOT
operator.public boolean not(boolean a)
public Object mul(Object a, Object b)
StandardEvaluator
Operators.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)
StandardEvaluator
Operators.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)
StandardEvaluator
Operators.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)
StandardEvaluator
Operators.RIGHT_DIV
operator.public Object dotMul(Object a, Object b)
StandardEvaluator
Operators.DOT_MUL
operator.public Object dotDiv(Object a, Object b)
StandardEvaluator
Operators.DOT_DIV
operator.public Object dotRightDiv(Object a, Object b)
StandardEvaluator
Operators.DOT_RIGHT_DIV
operator.public Object add(Object a, Object b)
StandardEvaluator
Operators.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)
StandardEvaluator
Operators.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)
StandardEvaluator
Operators.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)
StandardEvaluator
Operators.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)
StandardEvaluator
Operators.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)
StandardEvaluator
Operators.COLON
operator.public Object lessThan(Object a, Object b)
StandardEvaluator
Operators.LESS_THAN
operator.public <T> boolean lessThan(Comparable<T> a, T b)
public Object greaterThan(Object a, Object b)
StandardEvaluator
Operators.GREATER_THAN
operator.public <T> boolean greaterThan(Comparable<T> a, T b)
public Object lessThanOrEqual(Object a, Object b)
StandardEvaluator
Operators.LESS_THAN_OR_EQUAL
operator.public <T> boolean lessThanOrEqual(Comparable<T> a, T b)
public Object greaterThanOrEqual(Object a, Object b)
StandardEvaluator
Operators.GREATER_THAN_OR_EQUAL
operator.public <T> boolean greaterThanOrEqual(Comparable<T> a, T b)
public Object instanceOf(Object a, Object b)
StandardEvaluator
Operators.INSTANCEOF
operator.public Object equal(Object a, Object b)
StandardEvaluator
Operators.EQUAL
operator.public Object notEqual(Object a, Object b)
StandardEvaluator
Operators.NOT_EQUAL
operator.public Object bitwiseAnd(Object a, Object b)
StandardEvaluator
Operators.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)
StandardEvaluator
Operators.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)
StandardEvaluator
Operators.LOGICAL_AND
operator.public boolean logicalAnd(boolean a, boolean b)
public Object logicalOr(Object a, Object b)
StandardEvaluator
Operators.LOGICAL_OR
operator.public boolean logicalOr(boolean a, boolean b)
Copyright © 2015–2022 SciJava. All rights reserved.