public static class CalculatorExpr.Operand
extends java.lang.Object
CalculatorExpr.Operation
.Modifier and Type | Field and Description |
---|---|
DataAccess |
dataAccess
Set if the value uses reflection.
|
java.lang.Object |
dataConst
Set for constant data.
|
CalculatorExpr |
expr
If not null the operand is calculated with an expression itself.
|
int |
ixValue
Index of the value contained in a given array on execution, -1 if not used.
|
java.lang.String |
textOrVar
The String literal or the given sDatapath.
|
Constructor and Description |
---|
Operand(CalculatorExpr expr) |
Operand(int ixValue,
DataAccess dataAccess,
java.lang.Object dataConst,
java.lang.String textOrVar)
Constructs
|
Operand(java.lang.Object value)
Creates an operator which is a single data instance.
|
Operand(java.lang.String text)
A ValueAccess without value, only a constant text literal, especially for Text Cmd.
|
Operand(java.lang.String sDatapath,
java.util.Map<java.lang.String,DataAccess.IntegerIx> variables,
java.lang.Class<?> reflData,
java.util.Map<java.lang.String,java.lang.Object> idxConstData)
Creates an Operand from the textual given datapath and the given enviromments.
|
Operand(StringPartScan sDatapath,
java.util.Map<java.lang.String,DataAccess.IntegerIx> variables,
java.lang.Class<?> reflData,
boolean bSpecialSyntax)
See
Operand#Operand(StringPartScan, Map, Class, Map, boolean)
but without the idxConstData |
Operand(StringPartScan sDatapath,
java.util.Map<java.lang.String,DataAccess.IntegerIx> variables,
java.lang.Class<?> reflData,
java.util.Map<java.lang.String,java.lang.Object> idxConstData,
boolean bSpecialSyntax)
See
Operand#Operand(String, Map, Class, Map) but with StringPartScan for the sDatapath |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
calc(java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables,
java.lang.Object[] varValues)
Accesses or calculates and returns the value of this operand.
|
java.lang.String |
toString() |
public int ixValue
public final DataAccess dataAccess
public final java.lang.Object dataConst
public final java.lang.String textOrVar
public final CalculatorExpr expr
public Operand(java.lang.String text)
text
- public Operand(CalculatorExpr expr)
public Operand(int ixValue, DataAccess dataAccess, java.lang.Object dataConst, java.lang.String textOrVar)
ixValue
- -1 if no variable is useddataAccess
- maybe null, the access inside a given variable if ixValue >=0dataConst
- textOrVar
- Name of the variabe if ixValue >=0, constant text if ixValue <0public Operand(java.lang.Object value)
CalculatorExpr.Value
, for numeric values.
This is checked on evaluation of the data. Then numeric operations are possible.
But value can be any Object, evaluated often with Object.toString()
to get the string content
or also evaluated with a DataAccess expression.value
- public Operand(java.lang.String sDatapath, java.util.Map<java.lang.String,DataAccess.IntegerIx> variables, java.lang.Class<?> reflData, java.util.Map<java.lang.String,java.lang.Object> idxConstData) throws java.lang.Exception
dataConst
as value of the operand. All other are null.
ixValue
, the rest describes the access operation.
expr
as expression to execute is null.
expr
. The fields dataConst
and dataAccess
remains null.
sDatapath
- textual given value. It is either a literal, a simple variable ...TODO docuvariables
- Container with some variable names associated to indices in a value array.reflData
- type wich can contain a static member with the required name in sDatapath if the name is not found in variablesidxConstData
- If this is not null, then it is first used to find dataConst
with sDatapath as key.java.lang.Exception
Operand#Operand(Object, StringPartScan, Map, Class, boolean)
public Operand(StringPartScan sDatapath, java.util.Map<java.lang.String,DataAccess.IntegerIx> variables, java.lang.Class<?> reflData, boolean bSpecialSyntax) throws java.text.ParseException
Operand#Operand(StringPartScan, Map, Class, Map, boolean)
but without the idxConstDatasDatapath
- variables
- The variables will be completed by unknown but necessary variables. On execution then all variables are known.reflData
- bSpecialSyntax
- java.text.ParseException
public Operand(StringPartScan sDatapath, java.util.Map<java.lang.String,DataAccess.IntegerIx> variables, java.lang.Class<?> reflData, java.util.Map<java.lang.String,java.lang.Object> idxConstData, boolean bSpecialSyntax) throws java.text.ParseException
Operand#Operand(String, Map, Class, Map)
but with StringPartScan
for the sDatapathsDatapath
- variables
- The variables will be completed by unknown but necessary variables. On execution then all variables are known.reflData
- idxConstData
- bSpecialSyntax
- java.text.ParseException
public java.lang.Object calc(java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables, java.lang.Object[] varValues) throws java.lang.Exception
ixValue
addresses the possible value or start value for access.
dataConst
is given, contains the value.
If dataConst
is instance of CalculatorExpr.Value
, the stored value in CalculatorExpr.Value
is used.
expr
is given, it is used to calculate the value, using the 'varValues'
If the result is instanceof CalculatorExpr.Value
, the stored value in CalculatorExpr.Value
is used.
dataAccess
is given, calculates a static value (start with null as instance).
textOrVar
dataAccess
is given, it accesses the data with the start path
from dataConst
, expr
or just null (static data access).
dataConst
or the given expr
with data Access,
whereby combination with expr
is only sensible if it returns an Object.
This can be an array access expression or also a function call.
dataAccess
is not given, the value, at least the textOrVar
is returned.
nameVariables
- see DataAccess.access(List, Object, boolean, boolean, Map, Object[], boolean, org.vishia.util.DataAccess.Dst)
necessary on indirect access to variable via String, construct such as <&&(path)>varValues
- Array of possible values proper to the given ixValue
dataAccess
is given, it accesses with the given start Objectjava.lang.Exception
public java.lang.String toString()
toString
in class java.lang.Object