Class AbstractStandardEvaluator
- All Implemented Interfaces:
Evaluator,StandardEvaluator
- Direct Known Subclasses:
DefaultStackEvaluator,DefaultTreeEvaluator
StandardEvaluator implementations on common
built-in types: 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."
- Author:
- Curtis Rueden
-
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptiondoubleadd(double a, double b) floatadd(float a, float b) intadd(int a, int b) longadd(long a, long b) Applies theOperators.ADDoperator.add(BigDecimal a, BigDecimal b) add(BigInteger a, BigInteger b) intbitwiseAnd(int a, int b) longbitwiseAnd(long a, long b) bitwiseAnd(Object a, Object b) Applies theOperators.BITWISE_ANDoperator.bitwiseAnd(BigInteger a, BigInteger b) intbitwiseOr(int a, int b) longbitwiseOr(long a, long b) Applies theOperators.BITWISE_ORoperator.bitwiseOr(BigInteger a, BigInteger b) Applies theOperators.BRACESoperator.Applies theOperators.BRACKETSoperator.Applies theOperators.COLONoperator.intcomplement(int a) longcomplement(long a) complement(Object a) Applies theOperators.COMPLEMENToperator.doublediv(double a, double b) floatdiv(float a, float b) intdiv(int a, int b) longdiv(long a, long b) Applies theOperators.DIVoperator.div(BigDecimal a, BigDecimal b) div(BigInteger a, BigInteger b) Applies theOperators.DOToperator.Applies theOperators.DOT_DIVoperator.Applies theOperators.DOT_MULoperator.Applies theOperators.DOT_POWoperator.dotRightDiv(Object a, Object b) Applies theOperators.DOT_RIGHT_DIVoperator.Applies theOperators.DOT_TRANSPOSEoperator.Applies theOperators.EQUALoperator.Applies theFunctionoperator.<T> booleangreaterThan(Comparable<T> a, T b) greaterThan(Object a, Object b) Applies theOperators.GREATER_THANoperator.<T> booleangreaterThanOrEqual(Comparable<T> a, T b) greaterThanOrEqual(Object a, Object b) Applies theOperators.GREATER_THAN_OR_EQUALoperator.instanceOf(Object a, Object b) Applies theOperators.INSTANCEOFoperator.intleftShift(int a, int b) longleftShift(long a, long b) Applies theOperators.LEFT_SHIFToperator.leftShift(BigInteger a, int b) <T> booleanlessThan(Comparable<T> a, T b) Applies theOperators.LESS_THANoperator.<T> booleanlessThanOrEqual(Comparable<T> a, T b) lessThanOrEqual(Object a, Object b) Applies theOperators.LESS_THAN_OR_EQUALoperator.booleanlogicalAnd(boolean a, boolean b) logicalAnd(Object a, Object b) Applies theOperators.LOGICAL_ANDoperator.booleanlogicalOr(boolean a, boolean b) Applies theOperators.LOGICAL_ORoperator.doublemod(double a, double b) floatmod(float a, float b) intmod(int a, int b) longmod(long a, long b) Applies theOperators.MODoperator.mod(BigDecimal a, BigDecimal b) mod(BigInteger a, BigInteger b) doublemul(double a, double b) floatmul(float a, float b) intmul(int a, int b) longmul(long a, long b) Applies theOperators.MULoperator.mul(BigDecimal a, BigDecimal b) mul(BigInteger a, BigInteger b) doubleneg(double num) floatneg(float num) intneg(int num) longneg(long num) Applies theOperators.NEGoperator.neg(BigDecimal num) neg(BigInteger num) booleannot(boolean a) Applies theOperators.NOToperator.Applies theOperators.NOT_EQUALoperator.Applies theOperators.PARENSoperator.doublepos(double num) floatpos(float num) intpos(int num) longpos(long num) Applies theOperators.POSoperator.doublepow(double a, double b) Applies theOperators.POWoperator.pow(BigDecimal a, int b) pow(BigInteger a, int b) Applies theOperators.QUESTIONoperator.Applies theOperators.RIGHT_DIVoperator.intrightShift(int a, int b) longrightShift(long a, long b) rightShift(Object a, Object b) Applies theOperators.RIGHT_SHIFToperator.rightShift(BigInteger a, int b) doublesub(double a, double b) floatsub(float a, float b) intsub(int a, int b) longsub(long a, long b) Applies theOperators.SUBoperator.sub(BigDecimal a, BigDecimal b) sub(BigInteger a, BigInteger b) Applies theOperators.TRANSPOSEoperator.intunsignedRightShift(int a, int b) longunsignedRightShift(long a, long b) unsignedRightShift(Object a, Object b) Applies theOperators.UNSIGNED_RIGHT_SHIFToperator.Methods inherited from class org.scijava.parsington.eval.AbstractEvaluator
get, getParser, isStrict, set, setAll, setStrictMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.scijava.parsington.eval.Evaluator
evaluate, evaluate, evaluate, get, get, getParser, isStrict, set, set, setAll, setStrict, value, varMethods inherited from interface org.scijava.parsington.eval.StandardEvaluator
addAssign, andAssign, assign, divAssign, dotDivAssign, dotPowAssign, dotRightDivAssign, execute, leftShiftAssign, modAssign, mulAssign, orAssign, postDec, postInc, powAssign, preDec, preInc, rightDivAssign, rightShiftAssign, subAssign, unsignedRightShiftAssign
-
Constructor Details
-
AbstractStandardEvaluator
public AbstractStandardEvaluator() -
AbstractStandardEvaluator
-
-
Method Details
-
function
Description copied from interface:StandardEvaluatorApplies theFunctionoperator.- Specified by:
functionin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
dot
Description copied from interface:StandardEvaluatorApplies theOperators.DOToperator.- Specified by:
dotin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
parens
Description copied from interface:StandardEvaluatorApplies theOperators.PARENSoperator.- Specified by:
parensin interfaceStandardEvaluator- Parameters:
args- The arguments.- Returns:
- The result of the operation.
-
brackets
Description copied from interface:StandardEvaluatorApplies theOperators.BRACKETSoperator.- Specified by:
bracketsin interfaceStandardEvaluator- Parameters:
args- The arguments.- Returns:
- The result of the operation.
-
braces
Description copied from interface:StandardEvaluatorApplies theOperators.BRACESoperator.- Specified by:
bracesin interfaceStandardEvaluator- Parameters:
args- The arguments.- Returns:
- The result of the operation.
-
transpose
Description copied from interface:StandardEvaluatorApplies theOperators.TRANSPOSEoperator.- Specified by:
transposein interfaceStandardEvaluator- Parameters:
a- The argument.- Returns:
- The result of the operation.
-
dotTranspose
Description copied from interface:StandardEvaluatorApplies theOperators.DOT_TRANSPOSEoperator.- Specified by:
dotTransposein interfaceStandardEvaluator- Parameters:
a- The argument.- Returns:
- The result of the operation.
-
pow
Description copied from interface:StandardEvaluatorApplies theOperators.POWoperator.- Specified by:
powin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
pow
public double pow(double a, double b) -
pow
-
pow
-
dotPow
Description copied from interface:StandardEvaluatorApplies theOperators.DOT_POWoperator.- Specified by:
dotPowin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
pos
Description copied from interface:StandardEvaluatorApplies theOperators.POSoperator.- Specified by:
posin interfaceStandardEvaluator- Parameters:
a- The argument.- Returns:
- The result of the operation.
-
pos
public int pos(int num) -
pos
public long pos(long num) -
pos
public float pos(float num) -
pos
public double pos(double num) -
neg
Description copied from interface:StandardEvaluatorApplies theOperators.NEGoperator.- Specified by:
negin interfaceStandardEvaluator- Parameters:
a- The argument.- Returns:
- The result of the operation.
-
neg
public int neg(int num) -
neg
public long neg(long num) -
neg
public float neg(float num) -
neg
public double neg(double num) -
neg
-
neg
-
complement
Description copied from interface:StandardEvaluatorApplies theOperators.COMPLEMENToperator.- Specified by:
complementin interfaceStandardEvaluator- Parameters:
a- The argument.- Returns:
- The result of the operation.
-
complement
public int complement(int a) -
complement
public long complement(long a) -
not
Description copied from interface:StandardEvaluatorApplies theOperators.NOToperator.- Specified by:
notin interfaceStandardEvaluator- Parameters:
a- The argument.- Returns:
- The result of the operation.
-
not
public boolean not(boolean a) -
mul
Description copied from interface:StandardEvaluatorApplies theOperators.MULoperator.- Specified by:
mulin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
mul
public int mul(int a, int b) -
mul
public long mul(long a, long b) -
mul
public float mul(float a, float b) -
mul
public double mul(double a, double b) -
mul
-
mul
-
div
Description copied from interface:StandardEvaluatorApplies theOperators.DIVoperator.- Specified by:
divin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
div
public int div(int a, int b) -
div
public long div(long a, long b) -
div
public float div(float a, float b) -
div
public double div(double a, double b) -
div
-
div
-
mod
Description copied from interface:StandardEvaluatorApplies theOperators.MODoperator.- Specified by:
modin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
mod
public int mod(int a, int b) -
mod
public long mod(long a, long b) -
mod
public float mod(float a, float b) -
mod
public double mod(double a, double b) -
mod
-
mod
-
rightDiv
Description copied from interface:StandardEvaluatorApplies theOperators.RIGHT_DIVoperator.- Specified by:
rightDivin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
dotMul
Description copied from interface:StandardEvaluatorApplies theOperators.DOT_MULoperator.- Specified by:
dotMulin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
dotDiv
Description copied from interface:StandardEvaluatorApplies theOperators.DOT_DIVoperator.- Specified by:
dotDivin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
dotRightDiv
Description copied from interface:StandardEvaluatorApplies theOperators.DOT_RIGHT_DIVoperator.- Specified by:
dotRightDivin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
add
Description copied from interface:StandardEvaluatorApplies theOperators.ADDoperator.- Specified by:
addin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
add
-
add
public int add(int a, int b) -
add
public long add(long a, long b) -
add
public float add(float a, float b) -
add
public double add(double a, double b) -
add
-
add
-
sub
Description copied from interface:StandardEvaluatorApplies theOperators.SUBoperator.- Specified by:
subin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
sub
public int sub(int a, int b) -
sub
public long sub(long a, long b) -
sub
public float sub(float a, float b) -
sub
public double sub(double a, double b) -
sub
-
sub
-
leftShift
Description copied from interface:StandardEvaluatorApplies theOperators.LEFT_SHIFToperator.- Specified by:
leftShiftin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
leftShift
public int leftShift(int a, int b) -
leftShift
public long leftShift(long a, long b) -
leftShift
-
rightShift
Description copied from interface:StandardEvaluatorApplies theOperators.RIGHT_SHIFToperator.- Specified by:
rightShiftin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
rightShift
public int rightShift(int a, int b) -
rightShift
public long rightShift(long a, long b) -
rightShift
-
unsignedRightShift
Description copied from interface:StandardEvaluatorApplies theOperators.UNSIGNED_RIGHT_SHIFToperator.- Specified by:
unsignedRightShiftin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
unsignedRightShift
public int unsignedRightShift(int a, int b) -
unsignedRightShift
public long unsignedRightShift(long a, long b) -
lessThan
Description copied from interface:StandardEvaluatorApplies theOperators.LESS_THANoperator.- Specified by:
lessThanin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
lessThan
-
greaterThan
Description copied from interface:StandardEvaluatorApplies theOperators.GREATER_THANoperator.- Specified by:
greaterThanin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
greaterThan
-
lessThanOrEqual
Description copied from interface:StandardEvaluatorApplies theOperators.LESS_THAN_OR_EQUALoperator.- Specified by:
lessThanOrEqualin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
lessThanOrEqual
-
greaterThanOrEqual
Description copied from interface:StandardEvaluatorApplies theOperators.GREATER_THAN_OR_EQUALoperator.- Specified by:
greaterThanOrEqualin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
greaterThanOrEqual
-
instanceOf
Description copied from interface:StandardEvaluatorApplies theOperators.INSTANCEOFoperator.- Specified by:
instanceOfin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
equal
Description copied from interface:StandardEvaluatorApplies theOperators.EQUALoperator.- Specified by:
equalin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
notEqual
Description copied from interface:StandardEvaluatorApplies theOperators.NOT_EQUALoperator.- Specified by:
notEqualin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
bitwiseAnd
Description copied from interface:StandardEvaluatorApplies theOperators.BITWISE_ANDoperator.- Specified by:
bitwiseAndin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
bitwiseAnd
public int bitwiseAnd(int a, int b) -
bitwiseAnd
public long bitwiseAnd(long a, long b) -
bitwiseAnd
-
bitwiseOr
Description copied from interface:StandardEvaluatorApplies theOperators.BITWISE_ORoperator.- Specified by:
bitwiseOrin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
bitwiseOr
public int bitwiseOr(int a, int b) -
bitwiseOr
public long bitwiseOr(long a, long b) -
bitwiseOr
-
logicalAnd
Description copied from interface:StandardEvaluatorApplies theOperators.LOGICAL_ANDoperator.- Specified by:
logicalAndin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
logicalAnd
public boolean logicalAnd(boolean a, boolean b) -
logicalOr
Description copied from interface:StandardEvaluatorApplies theOperators.LOGICAL_ORoperator.- Specified by:
logicalOrin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
logicalOr
public boolean logicalOr(boolean a, boolean b) -
question
Description copied from interface:StandardEvaluatorApplies theOperators.QUESTIONoperator.- Specified by:
questionin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-
colon
Description copied from interface:StandardEvaluatorApplies theOperators.COLONoperator.- Specified by:
colonin interfaceStandardEvaluator- Parameters:
a- The first argument.b- The second argument.- Returns:
- The result of the operation.
-