public static class DataAccess.DatapathElement
extends java.lang.Object
ZbnfJavaOutput
to fill from a parse result.
Therefore some methods have a special naming which matches to the semantic of the used parser script.
fnArgs
and indices
:DataAccess#access(Object, boolean, boolean)
or DataAccess#access(DatapathElement, Object, boolean, boolean, boolean, Dst)
is called.
The calculation of the arguments and indices should be done outside of the class before usage with adequate operations.
To set the results setActualArgumentArray(Object[])
or setActualArguments(Object...)
should be used.
set(String)
: Textual parsing of the path. Its capability was enhanced in 2019-06: Before, the usage of DataAccess
was usually related to the ZBNF parser and the JZtxtcmd
, which uses
the derived class DataAccess.SetDatapathElement
and the set_ident(String)
etc. from the parse result.
The other possibility, set the path immediately only from a given text, was necessary with the OutTextPreparer
and it may be proper from user level. That possibility supports only simple argument names stored in #argNames
,
String literal arguments stored immediately in fnArgs
and numeric literal indices stored in indices
Modifier and Type | Field and Description |
---|---|
private CalculatorExpr.Operand[] |
args
It is is a method call, contains the argument calculation rules.
|
protected java.lang.Object[] |
fnArgs
Deprecated.
because it is a violation of the principle that this class stores only data of construction or set, not for current access.
It is used yet (2019-08) especially in
JZtxtcmdExecuter . |
protected java.lang.String |
ident
Name of the element or method in any instance.
|
(package private) int[] |
indices
Numerical values to access elements of the given variable.
|
(package private) int |
ixData
Idf >=0 then the data should be accessed simple from a given List or array with this index.
|
private boolean |
operation_
true then an operation call, false: a variable access.
|
(package private) java.lang.reflect.Member |
reflAccess
If set the source class is already .
|
protected char |
whatisit
Kind of element
'$': An environment variable.
|
Modifier | Constructor and Description |
---|---|
protected |
DatapathElement()
Creates an empty element.
|
|
DatapathElement(java.lang.String path)
Creates a datapath element.
|
|
DatapathElement(StringPartScan path,
java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables,
java.lang.Class<?> reflData)
Creates a datapath element. see
set(String) |
|
DatapathElement(StringPartScan path,
java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables,
java.lang.Class<?> reflData,
boolean bFirst)
Creates a datapath element. see
set(String) also for details of the arguments. |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
argName(int ix)
Returns the name for the argument start variable.
|
java.lang.String |
ident() |
boolean |
isOperation() |
int |
nrArgNames() |
(package private) CalculatorExpr.Operand[] |
parseArgumentExpr(StringPartScan sArgs,
java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables,
java.lang.Class<?> reflData)
Parses an argument String with expressions
|
void |
set_ident(java.lang.String text) |
void |
set_operation()
Invoked from
ZbnfJavaOutput or other via reflection. |
void |
set_operation(boolean val)
Invoked from
ZbnfJavaOutput or other via reflection. |
void |
set_whatisit(java.lang.String text) |
void |
set(java.lang.String path)
Creates a datapath element, for general purpose.
|
void |
set(StringPartScan path,
java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables,
java.lang.Class<?> reflData,
boolean bFirst)
Creates the first datapath element, which can also access to the variable pool and a reflData class
or create further elements but supports the first element for operations arguments.
|
void |
setActualArgumentArray(java.lang.Object[] args)
Adds any argument with its value.
|
void |
setActualArguments(java.lang.Object... args)
Adds any argument with its value.
|
void |
setIdent(java.lang.String ident) |
java.lang.String |
toString()
For debugging.
|
void |
writeAccessString(java.lang.Appendable wr)
Writes a String which should show the originally text given access.
|
void |
writeStruct(java.lang.Appendable out) |
protected java.lang.String ident
protected char whatisit
fnArgs
fnArgs
fnArgs
.
DataAccess.Variable
with that given type using DataAccess#storeValue(List, Map, Object, boolean)
.@Deprecated protected java.lang.Object[] fnArgs
JZtxtcmdExecuter
.DataAccess.invokeMethod(DatapathElement, Class, Object, boolean, Object[], boolean)
.private CalculatorExpr.Operand[] args
CalculatorExpr.Operand.textOrVar
contains the name of the start variable if given.java.lang.reflect.Member reflAccess
int ixData
int[] indices
args
maybe with const values.private boolean operation_
protected DatapathElement()
public DatapathElement(java.lang.String path) throws java.text.ParseException
descr
- see set(String)
java.text.ParseException
public DatapathElement(StringPartScan path, java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables, java.lang.Class<?> reflData, boolean bFirst) throws java.text.ParseException
set(String)
also for details of the arguments.path
- nameVariables
- association between name and index. This will be enhanced with not stored variables on the fly.reflData
- bFirst
- java.text.ParseException
public DatapathElement(StringPartScan path, java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables, java.lang.Class<?> reflData) throws java.text.ParseException
set(String)
path
- nameVariables
- see DataAccess.DataAccess(StringPartScan, Map, Class, char)
The nameVariables will be completed by unknown but necessary variables. On execution then all variables are known.reflData
- see DataAccess.DataAccess(StringPartScan, Map, Class, char)
java.text.ParseException
public void set_operation(boolean val)
ZbnfJavaOutput
or other via reflection.public void set_operation()
ZbnfJavaOutput
or other via reflection.public boolean isOperation()
public int nrArgNames()
public java.lang.String argName(int ix)
DataAccess.invokeMethod(DatapathElement, Class, Object, boolean, Object[], boolean)
public void set(java.lang.String path) throws java.text.ParseException
whatisit
.
If the name contains a '(' it is a method call. Elsewhere it is the name of a field.
If it is a method call, the following rules are taken for evaluating parameters:
CalculatorExpr.setExpr(String)
.
path
- java.text.ParseException
public void set(StringPartScan path, java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables, java.lang.Class<?> reflData, boolean bFirst) throws java.text.ParseException
whatisit
.
ident
whatisit
is marked as '(' for an non static operation
or remains '% for a static operation. operation_
= true.
The arguemnts are parsed, stored in args
.
indices
whatisit
.
ixData
is set and whatisit
= '@'. ident()
= the parsed indetifier.
indices
may be set, as access to array elements in the variable.
All other elements are null and false. This is a simple access to a variable.
reflAccess
is set to use on access.
operation(arg, ...)
then it is marked as Operation call.
If the operation name is found unique in the given reflData, then reflAccess
is set with this operation,
so the access can use it. If the operation is not found or it is not unique (overridden arguments),
then the reflAccess
is not set, the operation should be searched on access with the current data.
array[indices]
the index values are parsed with CalculatorExpr#setExpr(StringPartScan)
.
Usual they are only integer literal constants, then the value is stored immediately.
path
- It is used to parse this one element from the whole datapath.
After this operation the current position is the position after.
It means either a '.' for a next element of the following stuff after the path.nameVariables
- If bFirst is set, it is primary checked whether the path element will be found there.
Then ixData is set to access the correct element in varValues, last argument of DataAccess.access(Object, boolean, boolean, Map, Object[])
see DataAccess.DataAccess(StringPartScan, Map, Class, char)
reflData
- If bFirst is set, it is secondary checked whether the path element will be found there.bFirst
- ==true for the first element. It can be start with a member of nameVariables or in reflData.
if bFirst== false, nameVariables and refldata are not used for this element,
but they are necessary for arguments of an operation call.java.text.ParseException
CalculatorExpr.Operand[] parseArgumentExpr(StringPartScan sArgs, java.util.Map<java.lang.String,DataAccess.IntegerIx> nameVariables, java.lang.Class<?> reflData) throws java.text.ParseException
sArgs
- The starting "(" is parsed already, by previous check. A following ")" is not read.
It means the sArgs can contain the argument String without ().
After parsing the sArgs is set before ")" if exist, after the args.
The Syntax of any arg is determined by functionality of CalculatorExpr#CalculatorExpr(StringPartScan, Map, Class)
.nameVariables
- Map of variables
The nameVariables will be completed by unknown but necessary variables. On execution then all variables are known.reflData
- java.text.ParseException
public void set_ident(java.lang.String text)
public void set_whatisit(java.lang.String text)
public java.lang.String ident()
public void setIdent(java.lang.String ident)
public void setActualArguments(java.lang.Object... args)
public void setActualArgumentArray(java.lang.Object[] args)
public void writeStruct(java.lang.Appendable out) throws java.io.IOException
java.io.IOException
public void writeAccessString(java.lang.Appendable wr) throws java.io.IOException
CalculatorExpr.Operand.textOrVar
for the textual representation of the arguments,
because this field should store the originally used textual input.wr
- to outputjava.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object