Class DefaultEvaluator
- All Implemented Interfaces:
Evaluator,StackEvaluator,StandardEvaluator
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:
-
Constructor Summary
Constructors -
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.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.parse.eval.AbstractStandardStackEvaluator
addAssign, andAssign, assign, divAssign, dotDivAssign, dotPowAssign, dotRightDivAssign, execute, leftShiftAssign, modAssign, mulAssign, orAssign, postDec, postInc, powAssign, preDec, preInc, rightDivAssign, rightShiftAssign, subAssign, unsignedRightShiftAssignMethods inherited from class org.scijava.parse.eval.AbstractStackEvaluator
evaluateMethods inherited from class org.scijava.parse.eval.AbstractEvaluator
evaluate, evaluate, get, getParser, isStrict, set, setAll, setStrict, value
-
Constructor Details
-
DefaultEvaluator
public DefaultEvaluator() -
DefaultEvaluator
-
-
Method Details
-
function
Description copied from interface:StandardEvaluatorApplies theFunctionoperator. -
dot
Description copied from interface:StandardEvaluatorApplies theOperators.DOToperator. -
parens
Description copied from interface:StandardEvaluatorApplies theOperators.PARENSoperator. -
brackets
Description copied from interface:StandardEvaluatorApplies theOperators.BRACKETSoperator. -
braces
Description copied from interface:StandardEvaluatorApplies theOperators.BRACESoperator. -
transpose
Description copied from interface:StandardEvaluatorApplies theOperators.TRANSPOSEoperator. -
dotTranspose
Description copied from interface:StandardEvaluatorApplies theOperators.DOT_TRANSPOSEoperator. -
pow
Description copied from interface:StandardEvaluatorApplies theOperators.POWoperator. -
pow
public double pow(double a, double b) -
pow
-
pow
-
dotPow
Description copied from interface:StandardEvaluatorApplies theOperators.DOT_POWoperator. -
pos
Description copied from interface:StandardEvaluatorApplies theOperators.POSoperator. -
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. -
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. -
complement
public int complement(int a) -
complement
public long complement(long a) -
not
Description copied from interface:StandardEvaluatorApplies theOperators.NOToperator. -
not
public boolean not(boolean a) -
mul
Description copied from interface:StandardEvaluatorApplies theOperators.MULoperator. -
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. -
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. -
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. -
dotMul
Description copied from interface:StandardEvaluatorApplies theOperators.DOT_MULoperator. -
dotDiv
Description copied from interface:StandardEvaluatorApplies theOperators.DOT_DIVoperator. -
dotRightDiv
Description copied from interface:StandardEvaluatorApplies theOperators.DOT_RIGHT_DIVoperator. -
add
Description copied from interface:StandardEvaluatorApplies theOperators.ADDoperator. -
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. -
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. -
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. -
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. -
unsignedRightShift
public int unsignedRightShift(int a, int b) -
unsignedRightShift
public long unsignedRightShift(long a, long b) -
colon
Description copied from interface:StandardEvaluatorApplies theOperators.COLONoperator. -
lessThan
Description copied from interface:StandardEvaluatorApplies theOperators.LESS_THANoperator. -
lessThan
-
greaterThan
Description copied from interface:StandardEvaluatorApplies theOperators.GREATER_THANoperator. -
greaterThan
-
lessThanOrEqual
Description copied from interface:StandardEvaluatorApplies theOperators.LESS_THAN_OR_EQUALoperator. -
lessThanOrEqual
-
greaterThanOrEqual
Description copied from interface:StandardEvaluatorApplies theOperators.GREATER_THAN_OR_EQUALoperator. -
greaterThanOrEqual
-
instanceOf
Description copied from interface:StandardEvaluatorApplies theOperators.INSTANCEOFoperator. -
equal
Description copied from interface:StandardEvaluatorApplies theOperators.EQUALoperator. -
notEqual
Description copied from interface:StandardEvaluatorApplies theOperators.NOT_EQUALoperator. -
bitwiseAnd
Description copied from interface:StandardEvaluatorApplies theOperators.BITWISE_ANDoperator. -
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. -
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. -
logicalAnd
public boolean logicalAnd(boolean a, boolean b) -
logicalOr
Description copied from interface:StandardEvaluatorApplies theOperators.LOGICAL_ORoperator. -
logicalOr
public boolean logicalOr(boolean a, boolean b)
-