public class CalculatorExpr
extends java.lang.Object
ZbnfJavaOutput
output from a Zbnf parsing process.
It is converted to the internal format for a stack oriented running model.
DataAccess
.
setExpr(String)
to convert a String given expression to the internal format.
calc(float)
for simple operations with one float input, especially for scaling values. It is fast.
calc(Object...)
for universal expression calculation.
calcDataAccess(Map, Object...)
to calculate with access to other Java data.
CalculatorExpr.Data
to get a data storage to calculate for one thread, able to reuse in the same thread.
calcDataAccess(Data, Map, Object...)
with resued data for the same thread.
CalculatorExpr.SetExprBase.SetExpr
to parse via possibility of Java data access.
That is done in the JZcmd script language.
org.vishia.util.test.TestCalculatorExpr
.Modifier and Type | Class and Description |
---|---|
static class |
CalculatorExpr.Data
It is the data instance for the caluclation.
|
protected static interface |
CalculatorExpr.ExpressionType
Common interface to check and maybe change the type of expression.
|
protected static class |
CalculatorExpr.ExprTypes |
static class |
CalculatorExpr.Operand
Operand for a part of the expression, refer from
CalculatorExpr.Operation . |
static class |
CalculatorExpr.Operation
An Operation in the list of operations.
|
static class |
CalculatorExpr.Operator
An operator for the current value (accu), the given second value maybe the operand from the
CalculatorExpr.Operation ,
or for some additional values in stack. |
protected static class |
CalculatorExpr.Operators
This class contains all Operators as static references.
|
static class |
CalculatorExpr.SetExprBase
This class and its inner class
CalculatorExpr.SetExprBase.SetExpr is a helper class which contains a CalculatorExpr as composite. |
static class |
CalculatorExpr.Value
A value, maybe a constant, any given Object or an access description to a java program element.
|
Modifier and Type | Field and Description |
---|---|
private java.util.List<CalculatorExpr.Operation> |
listOperations_
All Operations which acts with the accumulator and the stack of values.
|
private java.lang.Appendable |
log |
protected static java.util.Map<java.lang.String,CalculatorExpr.Operator> |
operators
Map of all available operators associated with its String expression.
|
protected static java.util.Map<java.lang.String,CalculatorExpr.Operator> |
unaryOperators |
static java.lang.String |
version
Version, history and license.
|
Constructor and Description |
---|
CalculatorExpr()
Map of all available unary operators associated with its String expression.
|
CalculatorExpr(java.lang.String sExpr,
java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables,
java.lang.Class<?> reflData)
Deprecated.
it should be possible to use
#CalculatorExpr(StringPartScan, Map, Class) in all cases. |
CalculatorExpr(StringPartScan sExpr,
java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables,
java.lang.Class<?> reflData,
boolean bSpecialSyntax)
Constructs an String given expression with some variables.
|
Modifier and Type | Method and Description |
---|---|
void |
addOperation(CalculatorExpr.Operation operation)
Adds the given operation to the list of operations.
|
double |
calc(double input)
Calculates the expression with only one input.
|
float |
calc(float input)
Calculates the expression with only one input.
|
CalculatorExpr.Value |
calc(java.lang.Object... args)
Calculates the expression with some inputs, often only 1 input.
|
CalculatorExpr.Value |
calcDataAccess(CalculatorExpr.Data data,
java.util.Map<java.lang.String,DataAccess.Variable<java.lang.Object>> javaVariables,
java.lang.Object... args)
Calculates the expression with possible access to any stored object data with access via reflection.
|
CalculatorExpr.Value |
calcDataAccess(java.util.Map<java.lang.String,DataAccess.Variable<java.lang.Object>> javaVariables,
java.lang.Object... args)
Creates new
CalculatorExpr.Data for calculation and calls
calcDataAccess(Data, Map, Object...) , see there |
long |
calcLong(int input)
Calculates the expression with only one input.
|
long |
calcLong(long input)
Calculates the expression with only one input.
|
(package private) static void |
convertObj(CalculatorExpr.Value val2jar,
java.lang.Object oval2) |
(package private) int |
debug() |
static CalculatorExpr.Operator |
getOperator(java.lang.String op)
Gets a operator to prepare operations.
|
private CalculatorExpr.Value |
getValue(CalculatorExpr.Data data,
CalculatorExpr.Operation oper,
java.util.Map<java.lang.String,DataAccess.Variable<java.lang.Object>> javaVariables,
java.lang.Object[] args) |
CalculatorExpr.Operand |
isSimpleSetExpr() |
java.util.List<CalculatorExpr.Operation> |
listOperations()
Gets the list of operations in return polish notation.
|
static int |
masksh(int val,
int mask,
byte nrofBits)
shift operation, after them mask.
|
float |
Oldcalc(float input)
Calculates the expression with only one float input.
|
float |
Oldcalc(int input)
Calculates the expression with only one integer input.
|
protected void |
parseAddExpr(StringPartScan spExpr,
java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables,
java.lang.Class<?> reflData,
java.lang.String startOperation,
int recursion)
The expression is an add or subtract expression.
|
protected void |
parseAndExpr(StringPartScan spExpr,
java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables,
java.lang.Class<?> reflData,
java.lang.String startOperation,
boolean bSpecialSyntax,
int recursion) |
protected void |
parseArgument(StringPartScan spExpr,
java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables,
java.lang.Class<?> reflData,
java.lang.String operation,
int recursion)
Parses one argument for a
#parseMultExpr(StringPartScan, String, int)
or maybe a #parseAddExpr(StringPartScan, String, int) on absens of multiply operation. |
protected void |
parseCmpExpr(StringPartScan spExpr,
java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables,
java.lang.Class<?> reflData,
java.lang.String startOperation,
boolean bSpecialSyntax,
int recursion)
The expression is an compare expression.
|
private void |
parseException(StringPartScan sExpr) |
protected void |
parseExpr(StringPartScan spExpr,
java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables,
java.lang.Class<?> reflData,
java.lang.String startOperation,
boolean bSpecialSyntax,
int recursion)
Parses a textual given expression.
|
protected java.lang.String |
parseMultExpr(StringPartScan spExpr,
java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables,
java.lang.Class<?> reflData,
java.lang.String startOperation,
int recursion)
The more inner expression is a multiply or divide expression.
|
java.lang.String |
setExpr(java.lang.String sExpr)
Converts the given expression in a stack operable form.
|
java.lang.String |
setExpr(java.lang.String sExpr,
java.lang.Class<?> reflData)
Converts the given expression in a stack operable form.
|
java.lang.String |
setExpr(java.lang.String sExpr,
java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables,
java.lang.Class<?> reflData)
Deprecated.
it should be possible to use
#setExpr(StringPartScan, Map, Class) in all cases. |
java.lang.String |
setExpr(StringPartScan spExpr,
java.lang.Class<?> reflData,
boolean bSpecialSyntax)
Converts the given expression in a stack operable form.
|
java.lang.String |
setExpr(StringPartScan spExpr,
java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables,
java.lang.Class<?> reflData,
boolean bSpecialSyntax)
Converts the given expression in a stack operable form (Reverse Polish Notation) to execute.
|
java.lang.String |
setExpr(java.lang.String sExpr,
java.lang.String[] sIdentifier)
Converts the given expression in a stack operable form.
|
void |
setLog(java.lang.Appendable log) |
void |
setRpnExpr(java.lang.CharSequence sExpr,
java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables,
java.lang.Class<?> reflData)
Sets the expression from a Revers Polish Notation form.
|
int |
setRpnExpr(StringPartScan sExpr,
java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables,
java.lang.Class<?> reflData)
Sets the expression from a Revers Polish Notation form.
|
static int |
sh(int val,
int nrofBits)
This is the ordinary shift operation
|
static int |
shmask(int val,
byte nrofBits,
int mask)
shift operation, after them mask.
|
static java.lang.String[] |
splitFnNameAndParams(java.lang.String expr)
Separates a name and the parameter list from a given String.
|
static java.lang.String[] |
splitFnParams(java.lang.String expr)
Separates String parameters from a list.
|
java.lang.String |
toString() |
public static final java.lang.String version
parseCmpExpr(StringPartScan, Map, Class, String, boolean, int)
now regards also ?lt etc.
parseExpr(StringPartScan, Map, Class, String, boolean, int)
etc. :
If the expression is simple, only an identifier, then a String is sufficient and a StringPartScan needs waste memory.
From calling level it may be known that the argument is only simple. But the simplicity can be used only in a deeper level of nesting.
To optimize it may be sufficient to provide both as argument, whereby the StringPartScan argument may be null.
It should be null if the simplicity is known from calling level. Then the simple String is used as input for the expression.
setExpr(String)
and setExpr(StringPartScan, Class, boolean)
as it would be necessary for all deeper levels to optimize.
Operand#Operand(String, Map, Class, Map)
with given dataConst possible for the operand.
It is used in OutTextPreparer
especially for the String which refers to s called sub-OutTextPreparer
which is an Operand. But it is usable for also other situations where as a Map may be given to select with a dataPath
and where it is not pre-defined that this is part of the Map or another dataPath.
calcDataAccess(Map, Object...)
: Now multidim array for Object possible.
parseExpr(StringPartScan, Map, Class, String, boolean, int)
now regard precedence of && higher as ||,
that was faulty before.
setRpnExpr(CharSequence, Map, Class)
now with unary operators, used, ok
calcDataAccess(Data, Map, Object...)
enhanced, now can access a numeric array.
setRpnExpr(CharSequence, Map, Class)
.
setLog(Appendable)
if this is set writes a log to the given output. For debug.
Operation#Operation(String, Operand)
possible stackOperand
CalculatorExpr.Operators.assignOperation
but not really used.
parseCmpExpr(StringPartScan, Map, Class, String, boolean, int)
to prevent accepting ">". It has another meaning in some envronments, for example <datapath> in an OutTextPreparer
.
setExpr(String, Map, Class)
etc. with reflectionData.
It is used in #parseArgument(StringPartScan, Class, String, int)
: If a given DataPath is not found in the variables,
it is searched as constant input in the reflection class.
CalculatorExpr.Operand.expr
, an Operand can contain a nested expression. It is used as argument value etc.
But for OutTextPreparer
too. Operand#Operand(Map, String, Object)
checks whether the given path presents an expression.
CalculatorExpr.Operation
.value the value is stored in CalculatorExpr.Operand.dataConst
. More systematic. Operand contains all what is an operand.
#setExpr(StringPartScan)
with Stringpart as part of whole parsing in OutTextPreparer.
CalculatorExpr.Operand
is used in OutTextPreparer
too, content was part of CalculatorExpr.Operation
before.
CalculatorExpr#CalculatorExpr(String, Map)
: Set the expression on construction as line of action.
#parseExpr(StringPartScan, String, int)
and #parseCmpExpr(StringPartScan, String, int)
to translate full expression possibilities without ZBNF (before it was only used in JZtxtcmd with parsing with ZBNF).
CalculatorExpr.Operators.cmpContainsOperation
etc. Syntax operand ?contains 'text'
CalculatorExpr.Data
and calcDataAccess(Data, Map, Object...)
.
All routines now can run in parallel threads, because the Data are separated.
CalculatorExpr.Value.toNumValue()
: CalculatorExpr.Value.etype
was not set.
The problem was obvious on a numeric value which were null because an exception in an JZtxtcmd script.
The conversion to Num was done, the value was 0 with type == 'I' but the etype was not change from 'o' to 'I'
Before using toNumValue it was not obvious that there was an exception.
On the fly: CalculatorExpr.Value.toString()
was faulty in this situation (only used in debugging view).
CalculatorExpr.Value.toNumValue()
, conversion especially from String, yet some TODO .
#variableNotFoundExpr
StringPartScan.scanFractionalNumber(long, boolean)
has had a problem with negative numbers.
fixed there, adapted here.
CalculatorExpr.ExpressionType
in parenthesis was another
than the expression type of the stored accumulator. Then the expression type of the parenthesis has taken and the operation
was faulty. Therefore general change: Store the ExpressionType in the accu in CalculatorExpr.Value.etype
. It may be instead CalculatorExpr.Value.type_
but yet both is stored. Set the expression type always in that way that the expression type of the accumulator was taken
and checked against the second operand. Remove the independent variable for the ExpressionType inside calcDataAccess(Map, Object...)
.
CalculatorExpr.Value.oVal
too to execute the instanceof operation. The instanceof operator
is enhanced so that a simple type is recognized with ?instanceof BoxedType.
CalculatorExpr.Value.type()
and CalculatorExpr.Value.longValue()
CalculatorExpr.Value
the Object is used correct now.
calc(float)
now uses the calcDataAccess(Map, Object...)
which is complete.
Some enhancements and tunings. TODO same for calc(double)
etc.
CalculatorExpr.Operators.boolCheckAndOperation
or CalculatorExpr.Operators.boolCheckOrOperation
is necessary to finish the evaluation on AND or OR operation if the result is false or true already.
The older solution: It checks whether the next operation is an AND or OR. But that does not recognize a boolean operation in parenthesis which may follow.
because the AND or OR follows after the calculation of the parenthesis content only.
calcDataAccess(Map, Object...)
accepts CalculatorExpr.Value
as return of dataAccess.
A Value is stored for Num variables in JZcmd especially.
SetExpr#new_datapath()
is offered, all details of a datapath
are handled in DataAccess.DataAccessSet
. To support more complex DataAccess.DatapathElement
especially
with expressions or datapath as arguments, the method CalculatorExpr.SetExprBase.SetExpr.newDataAccessSet()
supports overriding
in a derived class of CalculatorExpr.SetExprBase.SetExpr
, see JZtxtcmdScript.JZcmdCalculatorExpr
.
CalculatorExpr.SetExprBase.SetExpr
should know all possibilities of DataAccess.DataAccessSet
too because an expression may be an DataAccess only. Yet only SetExpr#new_newJavaClass()
realized.
JZtxtcmdExecuter
class. This is because some arguments of methods may be a String.
If the #genString
is set, the CalculatorExpr is a String expression.
Now this class, the DataAccess
and the JZtxtcmdExecuter
are one cluster of functionality.
CalculatorExpr.SetExpr
to set from a ZbnfParseResult using ZbnfJavaOutput
.
This class can be invoked without ZbnfParser too, it is independent of it. But it isn't practicable.
CalculatorExpr.Operation.unaryOperator
DataAccess.DatapathElement
is a attribute of a CalculatorExpr.Operation
, not of a CalculatorExpr.Value
.
A value is only a container for constant values or results.
DataAccess.DatapathElement
to access inside java data
to evaluate the value. The concept is synchronized with org.vishia.zbatch.ZbatchGenScript
,
but not depending on it. The JbatGenScript uses this class, this class participates on the development
and requirements of jbat.
org.vishia.ZbatchExecuter.TextGenerator
.
calc(float)
for float and int
private final java.util.List<CalculatorExpr.Operation> listOperations_
private java.lang.Appendable log
protected static java.util.Map<java.lang.String,CalculatorExpr.Operator> operators
CalculatorExpr()
protected static java.util.Map<java.lang.String,CalculatorExpr.Operator> unaryOperators
public CalculatorExpr()
public CalculatorExpr(java.lang.String sExpr, java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables, java.lang.Class<?> reflData)
#CalculatorExpr(StringPartScan, Map, Class)
in all cases.sExpr
- nameVariables
- public CalculatorExpr(StringPartScan sExpr, java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables, java.lang.Class<?> reflData, boolean bSpecialSyntax)
sExpr
- nameVariables
- see DataAccess.DataAccess(StringPartScan, Map, Class, char)
reflData
- see DataAccess.DataAccess(StringPartScan, Map, Class, char)
public static java.lang.String[] splitFnNameAndParams(java.lang.String expr)
expr
- An expression in form " name (params)"public static java.lang.String[] splitFnParams(java.lang.String expr)
expr
- Any expression with Strings separated with colonpublic static int sh(int val, int nrofBits)
val
- nrofBits
- >0: shift left, <0: shift rigth.sh( 0x80000000, -1) => 0xc0000000
public static int shmask(int val, byte nrofBits, int mask)
val
- nrofBits
- >0: shift left, <0: shift rigth.mask
- of resultpublic static int masksh(int val, int mask, byte nrofBits)
val
- nrofBits
- >0: shift left, <0: shift rigth.mask
- of resultpublic void setLog(java.lang.Appendable log)
public java.lang.String setExpr(java.lang.String sExpr, java.lang.String[] sIdentifier)
sExpr
- String given expression such as "X*(Y-1)+Z"sIdentifier
- Array of identifiers for variables.public java.lang.String setExpr(java.lang.String sExpr, java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables, java.lang.Class<?> reflData)
#setExpr(StringPartScan, Map, Class)
in all cases.sExpr
- String given expression such as "X*(Y-1)+Z"sIdentifier
- List of identifiers for variables.public java.lang.String setExpr(StringPartScan spExpr, java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables, java.lang.Class<?> reflData, boolean bSpecialSyntax)
parseExpr(StringPartScan, Map, Class, String, boolean, int)
for OR expression parts
parseAndExpr(StringPartScan, Map, Class, String, boolean, int)
for AND expression parts
parseCmpExpr(StringPartScan, Map, Class, String, boolean, int)
for comparison expression parts
parseAddExpr(StringPartScan, Map, Class, String, int)
for summation expression parts
parseMultExpr(StringPartScan, Map, Class, String, int)
for multiplication / division expression parts
parseArgument(StringPartScan, Map, Class, String, int)
for the arguments.
spExpr
- given textual expressionnameVariables
- An operand can be given as name of a variable from this index.
Then for execution an array should be given as last argument of calcDataAccess(Map, Object...)
.
It is the same approach as in DataAccess.DataAccess(StringPartScan, Map, Class, char)
.reflData
- An operand can be given with access to this data via reflection.
Then for execution data with this reflection class should be given as argument of calcDataAccess(Map, Object...)
bSpecialSyntax
- true then ">" is not accepted (as compare operator).
It is for texts where the ">" has other meanings. The "gt" can be used to formulate "greater than" insteadjava.text.ParseException
public java.lang.String setExpr(java.lang.String sExpr)
setExpr(StringPartScan, Map, Class, boolean)
sExpr
- For example "5.0*X" or "(X*X+1.5*X)"setExpr(String, String[])
public java.lang.String setExpr(java.lang.String sExpr, java.lang.Class<?> reflData)
sExpr
- For example "5.0*X" or "(X*X+1.5*X)"setExpr(String, String[])
public java.lang.String setExpr(StringPartScan spExpr, java.lang.Class<?> reflData, boolean bSpecialSyntax)
parseExpr(StringPartScan, Map, Class, String, boolean, int)
for OR expression parts
parseAndExpr(StringPartScan, Map, Class, String, boolean, int)
for AND expression parts
parseCmpExpr(StringPartScan, Map, Class, String, boolean, int)
for comparison expression parts
parseAddExpr(StringPartScan, Map, Class, String, int)
for summation expression parts
parseMultExpr(StringPartScan, Map, Class, String, int)
for multiplication / division expression parts
parseArgument(StringPartScan, Map, Class, String, int)
for the arguments.
sExpr
- For example "5.0*X" or "(X*X+1.5*X)"setExpr(String, String[])
protected void parseExpr(StringPartScan spExpr, java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables, java.lang.Class<?> reflData, java.lang.String startOperation, boolean bSpecialSyntax, int recursion) throws java.text.ParseException
spExpr
- given textual expressionnameVariables
- An operand can be given as name of a variable from this index.
Then for execution an array should be given as last argument of calcDataAccess(Map, Object...)
.reflData
- An operand can be given with access to this data via reflection.
Then for execution data with this reflection class should be given as argument of calcDataAccess(Map, Object...)
startOperation
- bSpecialSyntax
- true then ">" is not accepted (as compare operator).
It is for texts where the ">" has other meanings. The "gt" can be used to formulate "greater than" insteadrecursion
- throws on 1000, only for safetyjava.text.ParseException
protected void parseAndExpr(StringPartScan spExpr, java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables, java.lang.Class<?> reflData, java.lang.String startOperation, boolean bSpecialSyntax, int recursion) throws java.text.ParseException
java.text.ParseException
protected void parseCmpExpr(StringPartScan spExpr, java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables, java.lang.Class<?> reflData, java.lang.String startOperation, boolean bSpecialSyntax, int recursion) throws java.text.ParseException
parseAddExpr(StringPartScan, Map, Class, String, int)
to get the argument values.
==
:
!=
:
>=
:
<=
:
>
:
<
:
?ge
: "greater or equal" used instead >=
if >
is not possible in the environment.
?le
: "less or equal" used instead <=
if <
is not possible in the environment.
?gt
: "greater than" used instead >
if >
is not possible in the environment.
?lt
: "lesser than" used instead <
if <
is not possible in the environment.
?instanceof
:left operand: any object, right operand: object of type class, true if left operand is or inherits the class
?contains
: check whether the left string operand contains the right string
?starts
: check whether the left string operand starts with the right string
?ends
: check whether the left string operand ends with the right string
spExpr
- operation
- The first operation. On start operand it is "!" for set.java.text.ParseException
protected void parseAddExpr(StringPartScan spExpr, java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables, java.lang.Class<?> reflData, java.lang.String startOperation, int recursion) throws java.text.ParseException
#multExpr(StringPartScan, char)
to get the argument values.spExpr
- operation
- The first operation. On start operand it is "!" for set.java.text.ParseException
protected java.lang.String parseMultExpr(StringPartScan spExpr, java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables, java.lang.Class<?> reflData, java.lang.String startOperation, int recursion) throws java.text.ParseException
#parseArgument(StringPartScan, String, int)
to get the argument values.spExpr
- operation
- The first operation. On start operand it is "!" for set.java.text.ParseException
protected void parseArgument(StringPartScan spExpr, java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables, java.lang.Class<?> reflData, java.lang.String operation, int recursion) throws java.text.ParseException
#parseMultExpr(StringPartScan, String, int)
or maybe a #parseAddExpr(StringPartScan, String, int)
on absens of multiply operation.
#parseAddExpr(StringPartScan, String, int)
is invoked for the inner expression.
CalculatorExpr.SetExprBase.SetExpr
to use that.
Then an expression is parsed via ZBNF, used in the JZcmd script language.
spExpr
- operation
- recursion
- java.text.ParseException
public void setRpnExpr(java.lang.CharSequence sExpr, java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables, java.lang.Class<?> reflData) throws java.text.ParseException
sExpr
- String given, maybe also StringBuffer etc.
From that a StringPartScan.StringPartScan(CharSequence)
will be created
and setRpnExpr(StringPartScan, Map, Class)
is callednameVariables
- Some variables which can be used given on execution in an array.
See calcDataAccess(Data, Map, Object...)
reflData
- Access to fields via Reflection also possible. (not done yet).java.text.ParseException
public int setRpnExpr(StringPartScan sExpr, java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables, java.lang.Class<?> reflData) throws java.text.ParseException
setRpnExpr(CharSequence, Map, Class)
.
This is the working operation.sExpr
- Given as StringPartScan.nameVariables
- reflData
- java.text.ParseException
private void parseException(StringPartScan sExpr) throws java.text.ParseException
java.text.ParseException
public void addOperation(CalculatorExpr.Operation operation)
operation
- public java.util.List<CalculatorExpr.Operation> listOperations()
public CalculatorExpr.Operand isSimpleSetExpr()
public static CalculatorExpr.Operator getOperator(java.lang.String op)
op
- Any of "+", "-" etc.public double calc(double input)
calcDataAccess(Map, Object...)
but without a access Map.
It means it must not contain access to other data.input
- The only one input value.public float Oldcalc(float input)
input
- The only one input value (used for all variables, simple version).public float calc(float input)
calcDataAccess(Map, Object...)
but without a access Map.
It means it must not contain access to other data.input
- The only one input value.public long calcLong(long input)
calcDataAccess(Map, Object...)
but without a access Map.
It means it must not contain access to other data.input
- The only one input value.public long calcLong(int input)
calcDataAccess(Map, Object...)
but without a access Map.
It means it must not contain access to other data.input
- The only one input value.public float Oldcalc(int input)
input
- The only one input value (used for all variables, simple version).public CalculatorExpr.Value calc(java.lang.Object... args)
setExpr(String)
or setExpr(String, String[])
or via CalculatorExpr.SetExprBase.SetExpr
.
Calls then calcDataAccess(Data, Map, Object...)
see there for argument args.args
- Array of some inputspublic CalculatorExpr.Value calcDataAccess(java.util.Map<java.lang.String,DataAccess.Variable<java.lang.Object>> javaVariables, java.lang.Object... args) throws java.lang.Exception
CalculatorExpr.Data
for calculation and calls
calcDataAccess(Data, Map, Object...)
, see therejavaVariables
- args
- java.lang.Exception
public CalculatorExpr.Value calcDataAccess(CalculatorExpr.Data data, java.util.Map<java.lang.String,DataAccess.Variable<java.lang.Object>> javaVariables, java.lang.Object... args) throws java.lang.Exception
data
- re-used data instance (Stack and accu). InvokejavaVariables
- Any data which are access-able with its name. It is the first part of a datapath.args
- Some args given immediately. For example numerical args wrappend with Float etc or strings. Often not used.
It is also possible that args has member as array, often an (numeric) array.
Then it is simple to use values from the array.
The index of this arguments are related to the 2. argument nameVariables in setExpr(String, Map, Class)
.
Using this information the arguments have names.
The linear index of the arguments is split to the index of the sub arrays.
For example args has two sub arrays with 12 and 8 elements (of two different numerical types).
Then ix=11 is [0][11] and ix=12 is [1][0] etc.java.lang.Exception
- Any exception is possible. Especially NoSuchFieldException
or such
if the access via reflection is done.private CalculatorExpr.Value getValue(CalculatorExpr.Data data, CalculatorExpr.Operation oper, java.util.Map<java.lang.String,DataAccess.Variable<java.lang.Object>> javaVariables, java.lang.Object[] args) throws java.lang.Exception
java.lang.Exception
public java.lang.String toString()
toString
in class java.lang.Object
static void convertObj(CalculatorExpr.Value val2jar, java.lang.Object oval2)
int debug()