public final class ZbnfJavaOutput
extends java.lang.Object
String
for String-results,
and int, float, double for value results. The numeric type is flexible.
component::=...
.
If such results should be stored using fields, a field of type List
should be exists with the semantic identifier
of the parse result. Than a new element of the List type will be created, that object will be filled with the
component's result and than add to the list.
set_Semantic(Type)
should be exist.
The Semantic
is the semantic identifier of the parse result. The Type
of the argument should follow
the type of the parse result. Thereby an integer parse result can be associated to one of the scalar number types,
a float or double result can associated to both a float or double parameter type. Any other result should be have a String
parameter. While accepting several parameter types, the architecture of the user methods can be adapted to the user's requirements.
Type new_semantic()
-method will be found, it is invoked to get an instance
for the syntax-components's content. It is possible, that this instance isn't a new instance, but it is a static allocated instance
which is reused temporary to hold the components data. Another way is to call a new
operator to get a new instance.
The return type of the Type new_semantic()
-method, or the field type of non-containers
or the generic-type of List
fields is used to search fields or methods for the component.
The types may be defined somewhere else in the Java-package-tree, but the classes have to be be public.
void add_semantic(Type)
or void set_semantic(Type)
is called to store the content. One of that methods have to be exist. Both method-variants, add_
or set_
have the same meaning for processing the data,
the name considers the meaning of the users action. add associates adding a content to a container, where set
means a simple setting of data. The implementation of this method can be store the reference of the instance, or it can evaluate
the content with special tests, copy in a special way etc. It is user-free.
new_Name(...)
may be a basic type or interface.
The implementation method is called of course. This concept enables a break of dependency between the classes, which are known
in context of storing a parse result and the really implementing classes. It is a application of the standard interface pattern.
org.apache.tools.ant.Task
called in ant
(http://ant.apache.org/manual/develop.html).
There are much more simple:
name
in the description below. For set- and get-methods
the name is used exactly like written in the ZBNF syntax script.
For searching field names the first character is converted to lower case.
set_name(Type)
- or add_name(Type)
-method
is searched and invoked, if found.
Type name
is searched.
If it is found, the type is tested.
For parse result elements, the type of fields must be java.lang.String or long, int, float or double.
To store instances for parse result components, the type of the field determines
the components class type.
SetLineColumn_ifc
. Then the column position, the line, the file
will be stored in the users instance. If only the column is necessary, only it will be stored. The effort to get the line
and the file will be higher, therefore it is not gotten if not necessary. The parser knows the column, line and file it is
parse result if the input allows to detect it. To capture the line number a StringPartFromFileLines
have to be used for input for the ZBNF parser, because only this class overrides the org.vishia.util.StringPart#getLineCt()
method with a really line number. This class reads a file line per line.
public int inputLine_
or a method set_inputLine_(int)
to store the line number of the input text, respectively public int inputColumn_
or a method set_inputColumn_(int)
if the input column of the parsed text should be stored. It will be checked whether that fields are existent,
then this information will be stored.
Modifier and Type | Class and Description |
---|---|
protected static class |
ZbnfJavaOutput.DstInstanceAndClass
Helper Instance to bundle a class to search methods or fields and the associated instance.
|
Modifier and Type | Field and Description |
---|---|
private boolean |
bExceptionIfnotFound
If it is set, an IllegalArgumentException is thrown, if a matching field or method are not found.
|
private boolean |
bNewFromType
True then create a dst instance of a component only from the given type name
and the found instance class.
|
private boolean |
bOnlyFields
If it is set, only fields are accepted, no methods.
|
private boolean |
bOnlyMethods
If it is set, only set_ or add_-methods and new_-methods are accepted,
no fields and no inner classes as container.
|
private java.lang.StringBuffer |
errors
Buffer to note errors during working.
|
ZbnfParser |
parser |
private LogMessage |
report |
static java.lang.String |
sVersion
Version, history and license.
|
Modifier | Constructor and Description |
---|---|
|
ZbnfJavaOutput()
Empty constructor.
|
|
ZbnfJavaOutput(LogMessage report)
Constructor with given log output.
|
private |
ZbnfJavaOutput(MainCmdLogging_ifc report,
boolean strict,
boolean methods) |
Modifier and Type | Method and Description |
---|---|
private ZbnfJavaOutput.DstInstanceAndClass |
getComponentsOutputField(java.lang.String semantic,
java.lang.reflect.Field element,
java.lang.Object outputInstance)
Gets the instance and class to write a components content into.
|
void |
init()
Sets the default settings and clears saved errors.
|
private void |
noteError(java.lang.CharSequence problem)
Adds an error.
|
java.lang.String |
parseFileAndFillJavaObject(java.lang.Class resultType,
java.lang.Object result,
java.io.File fInput,
java.io.File fSyntax)
Parses the given file with given syntax and fills the parsed result into the result object.
|
static java.lang.String |
parseFileAndFillJavaObject(java.lang.Class resultType,
java.lang.Object result,
java.io.File fInput,
java.io.File fSyntax,
MainCmdLogging_ifc report,
int msgRange)
Parses the given file with given syntax and fills the parsed result into the result object.
|
java.lang.String |
parseFileAndFillJavaObject(java.lang.Class resultType,
java.lang.Object result,
java.io.File fInput,
java.lang.String sSyntax)
Parses the given file with given syntax and fills the parsed result into the result object.
|
java.lang.String |
parseFileAndFillJavaObject(java.lang.Class resultType,
java.lang.Object result,
java.io.File fInput,
StringPartScan spSyntax) |
java.lang.String |
parseFileAndFillJavaObject(java.lang.Class resultType,
java.lang.Object result,
java.io.File fInput,
StringPartScan spSyntax,
java.io.File fSyntaxDir)
Parses the given file with given syntax and fills the parsed result into the result object.
|
java.lang.String |
parseFileAndFillJavaObject(java.lang.Class resultType,
java.lang.Object result,
StringPartScan spInput,
java.lang.String sFileInput) |
private java.lang.String |
parseFileAndFillJavaObject(java.lang.Class resultType,
java.lang.Object result,
StringPartScan spInput,
java.lang.String sFileInput,
StringPartScan spSyntax,
java.io.File fSyntaxDir)
Parses the given file with given syntax and fills the parsed result into the result object.
|
java.lang.String |
parseFileAndFillJavaObject(java.lang.Class resultType,
java.lang.Object result,
java.lang.String sInput,
java.lang.String sFileInput,
java.lang.String syntax,
java.io.File fSyntaxDir)
Parses the given String with given syntax and fills the parsed result into the result object.
|
java.lang.String |
parseFileAndFillJavaObject(java.lang.Object result,
java.io.File fInput)
Parses and fills to the result with given Syntax.
|
java.lang.String |
parseFileAndFillJavaObject(java.lang.Object result,
java.io.File fInput,
java.io.File fSyntax)
Parses the given file with given syntax and fills the parsed result into the result object.
|
java.lang.String |
parseFileAndFillJavaObject(java.lang.Object result,
java.io.File fInput,
java.lang.String sSyntax)
Parses the given file with given syntax and fills the parsed result into the result object.
|
private void |
problem(ZbnfJavaOutput.DstInstanceAndClass destComponent,
java.lang.String sProblem) |
private void |
searchAddMethodAndInvoke(java.lang.String semantic,
ZbnfJavaOutput.DstInstanceAndClass component,
ZbnfJavaOutput.DstInstanceAndClass componentsDestination)
Searches the
add_semantic(Object) -Method and invokes it. |
protected ZbnfJavaOutput.DstInstanceAndClass |
searchComponentsDestination(java.lang.String semantic,
ZbnfParseResultItem zbnfItem,
ZbnfJavaOutput.DstInstanceAndClass parentDst,
java.lang.Class<?> mainDstClass)
Searches a class and instance appropriate to the given semantic to store a component.
|
protected ZbnfJavaOutput.DstInstanceAndClass |
searchCreateMethod(java.lang.Class<?> inClazz,
java.lang.Object instance,
java.lang.String semantic,
ZbnfJavaOutput.DstInstanceAndClass parent,
ZbnfParseResultItem zbnfElement)
Searches a method with signature
new_ . |
protected ZbnfJavaOutput.DstInstanceAndClass |
searchCreateNew(java.lang.Class<?> mainDstClazz,
java.lang.Object instance,
java.lang.String semantic,
ZbnfJavaOutput.DstInstanceAndClass parent,
ZbnfParseResultItem zbnfElement)
Searches a method with signature
new_ . |
protected ZbnfJavaOutput.DstInstanceAndClass |
searchDestinationAndWriteResult(java.lang.String semanticRaw,
ZbnfJavaOutput.DstInstanceAndClass destComponent,
java.lang.Class<?> mainDstClass,
ZbnfParseResultItem resultItem)
searches the method or field matching to the semantic of the leaf resultItem (not a ZBNF-component)
and write the given content of resultItem into it,
|
private java.lang.reflect.Method |
searchMethod(int[] retVariant,
java.lang.Class<?> outputClass,
java.lang.String name,
java.lang.Class<?>[][] argTypesVariants)
Searches a method with given Name and given argument types in the class
or in its super-classes and interfaces.
|
java.lang.String |
setContent(java.lang.Class topLevelClass,
java.lang.Object topLevelInstance,
ZbnfParseResultItem resultItem)
This is the main method to set content (non-static variant).
|
void |
setFieldsOnly(boolean value)
Sets the association mode:
|
void |
setMethodsOnly(boolean value)
Sets the association mode:
|
void |
setNewFromType(boolean value) |
static void |
setOutput(java.lang.Object topLevelOutput,
ZbnfParseResultItem resultItem,
MainCmdLogging_ifc report) |
static void |
setOutput(java.lang.Object topLevelOutput,
ZbnfParseResultItem resultItem,
MainCmdLogging_ifc report,
boolean strict,
boolean bOnlyMethods,
boolean bNewFromType)
Writes the parsers result into a tree of Java objects using the reflection method.
|
static void |
setOutputFields(java.lang.Object topLevelOutput,
ZbnfParseResultItem resultItem,
MainCmdLogging_ifc report)
Writes the parsers result into a tree of Java objects using the reflection method.
|
static void |
setOutputStrict(java.lang.Object topLevelOutput,
ZbnfParseResultItem resultItem,
MainCmdLogging_ifc report)
Writes the parsers result into a tree of Java objects using the reflection method.
|
static void |
setOutputStrictNewFromType(java.lang.Object topLevelOutput,
ZbnfParseResultItem resultItem,
MainCmdLogging_ifc report)
Writes the parsers result into a tree of Java objects using the reflection method.
|
void |
setWeakErrors(boolean value)
Sets the behavior if no appropriate method or field is found for a parser result.
|
(package private) void |
stop()
It's a debug helper.
|
private void |
trySetInputColumn(java.lang.String semantic,
ZbnfJavaOutput.DstInstanceAndClass destComponent,
int column)
Tries if an field
inputColumn_semantic or a method
set_inputColumn_semantic exists and set resp. calls it. |
private boolean |
trySetInputInfo(ZbnfJavaOutput.DstInstanceAndClass destComponent,
int line,
int column,
java.lang.String sFile)
Tries if an field
inputLine_ or a method
set_inputInfo_ exists and set resp. calls it. |
private void |
writeInField(java.lang.reflect.Field element,
java.lang.Object outputInstance,
ZbnfParseResultItem resultItem)
Writes a value in a given field.
|
(package private) ZbnfJavaOutput.DstInstanceAndClass |
writeInMap(java.lang.String semantic,
ZbnfJavaOutput.DstInstanceAndClass destComponent,
ZbnfParseResultItem resultItem) |
protected void |
writeZbnfResult(ZbnfJavaOutput.DstInstanceAndClass dstArg,
ZbnfParseResultItem zbnfComponent,
java.lang.Class<?> mainDstClass,
int recursion)
Writes the content of one parse result component into the given outputInstance.
|
public static final java.lang.String sVersion
writeZbnfResult(DstInstanceAndClass, ZbnfParseResultItem, Class, int)
:
Store source of parsing if SetSrcInfo_ifc
is given on a destination class.
searchCreateNew(Class, Object, String, DstInstanceAndClass, ZbnfParseResultItem)
:
A construct as {<?*semantic>...
is also a syntax component and should be handled as such.
Some trouble for getting the name of the component. Solved.
bNewFromType
and setOutputStrictNewFromType(Object, ZbnfParseResultItem, MainCmdLogging_ifc)
writeZbnfResult(DstInstanceAndClass, ZbnfParseResultItem, Class, int)
with mainClass as argument for newfromType approach
searchCreateNew(Class, Object, String, DstInstanceAndClass, ZbnfParseResultItem)
as worker operation
searchAddMethodAndInvoke(String, DstInstanceAndClass, DstInstanceAndClass)
now checks also add_ and _set operations
with the super types of the argument, to find the correct operation with given super type.
GenZbnfJavaData
generates in some cases String variable instead boolean.
[<<cmpnSemantic/@text>
see documentation.
parser
is now a class variable and final public. Advantage: Accessible from outer to set some log things.
new_xyz
method is found for a non syntaxComponent, the return value
is a child instance to write into the next result items, till
. The last one switches back to the parent again.
new_semantic(ZbnfParseResultItem zbnfItem)
.
Then the parse result item is supplied. The application can evaluate both the ZbnfParseResultItem
or the ZbnfParseResultItem.syntaxItem()
for more informations. Especially the ZbnfSyntaxPrescript.getAttribute(String)
can be used.
parseFileAndFillJavaObject(Class, Object, String, String, String, File)
with simple string given input an syntax.
parseFileAndFillJavaObject(Class, Object, File, StringPartScan, File)
with the directory of scripts to include.
ZbnfJavaOutput.DstInstanceAndClass.clazz
and not the getClass() of the ZbnfJavaOutput.DstInstanceAndClass.instance
.
except the interface GetTypeToUse
is implemented by the returned instance of a new_()
.
This is documented now. The JZcmdScript (JbatScript) had used the property that the instance.getClass()
is the destination for overridden classes from DataAccess
, therefore this treatment was used
for all instances. But that is a poorly defined concept.
It is better to distinguish between the dst instance and the type where the information are searched.
Only in special cases, with the marker interface GetTypeToUse
an abbreviated type, usual the type of the instance
can be used.
SetLineColumn_ifc
. It is faster, because a method which does not exists often
should not be invoked. Only 'instanceof' is checked. This needs adaption of user classes
which uses the method set_inputColumn_(int).
trySetInputInfo(DstInstanceAndClass, int, int, String)
.
The destination class should provide boolean set_InputInfo_(int, int, String)
MainCmdLogging_ifc
for simple usage.
parseFileAndFillJavaObject(Object, File, String)
#trySetInputLine(DstInstanceAndClass, int)
. Uses DataAccess
first time.
there are some parallel functionality of this class and DataAccess. The DataAccess is the more universal one.
ZbnfJavaOutput.DstInstanceAndClass.clazz
is build from the instance instead from the
given clazz Argument. It means an derived instance can contain other set_, add_method.
writeInField(Field, Object, ZbnfParseResultItem)
supports a char field too,
it gets the first char of a parsed string or the numeric value converted in a char (ASCII, UTF-16).
MsgDispatchSystemOutErr
#writeZbnfResult(DstInstanceAndClass, ZbnfParseResultItem, int)
: check semantic, if empty, does nothing
private final LogMessage report
private boolean bOnlyMethods
private boolean bNewFromType
private boolean bOnlyFields
private boolean bExceptionIfnotFound
public final ZbnfParser parser
private java.lang.StringBuffer errors
setContent(Class, Object, ZbnfParseResultItem)
.public ZbnfJavaOutput()
MainCmdLogging_ifc
-output will be build with a MainCmdLoggingStream
if the MainCmd
is not used.public ZbnfJavaOutput(LogMessage report)
report
- for logging the process of associated, only LogMessage.fineDebug
will be used.private ZbnfJavaOutput(MainCmdLogging_ifc report, boolean strict, boolean methods)
public void setNewFromType(boolean value)
public void setMethodsOnly(boolean value)
value
- true, than fields aren't searched, only methods.public void setFieldsOnly(boolean value)
value
- true, than methods aren't searched, only fields. It may have some less calculation time.public void setWeakErrors(boolean value)
value
- true, than no exception is thrown in this case.
Instead the problem is noted in the returned String.
false, than an IllegalArguementException is throw in this case.
It is the standard behavior after init()
.public void init()
public java.lang.String setContent(java.lang.Class topLevelClass, java.lang.Object topLevelInstance, ZbnfParseResultItem resultItem) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.InstantiationException
topLevelClass
- The top level class, where methods and fields are searched.
It is able that it is an interface type.topLevelIntance
- The instance to output. It have to be instanceof topLevelClass
.resultItem
- The parsers result.java.lang.IllegalArgumentException
- Invoked if setWeakErrors(boolean)
is set with true.java.lang.IllegalAccessException
- Especially if fields and methods are non-public.java.lang.InstantiationException
- Especially if problems with methods exists.public static void setOutputStrictNewFromType(java.lang.Object topLevelOutput, ZbnfParseResultItem resultItem, MainCmdLogging_ifc report) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.InstantiationException
{*semantic:Typeclass>...
.
Invocation of new_semantic()
cannot decide
about the inner type sometimes if super component designation is used.
Then this output approach should be used.topLevelOutput
- The toplevel instanceresultItem
- The toplevel parse resultreport
- java.lang.IllegalAccessException
- if the field is found but it is not public.java.lang.IllegalArgumentException
java.lang.InstantiationException
- if a matching class is found but it can't be instanciated.public static void setOutputStrict(java.lang.Object topLevelOutput, ZbnfParseResultItem resultItem, MainCmdLogging_ifc report) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.InstantiationException
topLevelOutput
- The toplevel instanceresultItem
- The toplevel parse resultreport
- java.lang.IllegalAccessException
- if the field is found but it is not public.java.lang.IllegalArgumentException
java.lang.InstantiationException
- if a matching class is found but it can't be instanciated.public static void setOutputFields(java.lang.Object topLevelOutput, ZbnfParseResultItem resultItem, MainCmdLogging_ifc report) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.InstantiationException
topLevelOutput
- The toplevel instanceresultItem
- The toplevel parse resultreport
- java.lang.IllegalAccessException
- if the field is found but it is not public.java.lang.IllegalArgumentException
java.lang.InstantiationException
- if a matching class is found but it can't be instanciated.public static void setOutput(java.lang.Object topLevelOutput, ZbnfParseResultItem resultItem, MainCmdLogging_ifc report, boolean strict, boolean bOnlyMethods, boolean bNewFromType) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.InstantiationException
topLevelOutput
- The toplevel instanceresultItem
- The toplevel parse resultreport
- java.lang.IllegalAccessException
- if the field is found but it is not public.java.lang.IllegalArgumentException
java.lang.InstantiationException
- if a matching class is found but it can't be instanciated.public static void setOutput(java.lang.Object topLevelOutput, ZbnfParseResultItem resultItem, MainCmdLogging_ifc report) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.InstantiationException
topLevelOutput
- resultItem
- report
- java.lang.IllegalArgumentException
java.lang.IllegalAccessException
java.lang.InstantiationException
protected void writeZbnfResult(ZbnfJavaOutput.DstInstanceAndClass dstArg, ZbnfParseResultItem zbnfComponent, java.lang.Class<?> mainDstClass, int recursion) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.InstantiationException
SetLineColumn_ifc
.
If it does then the column, line and the file or stored with that in the dst instance.
#searchComponentsDestination(String, DstInstanceAndClass)
with the given semantic of the child and the given dst (calling argument) for this component.
With the child's dst this routine is invoked recursively.
If the dst needs an 'add_semantic' method then searchAddMethodAndInvoke(String, DstInstanceAndClass, DstInstanceAndClass)
is called after them for the child.
#searchDestinationAndWriteResult(String, DstInstanceAndClass, ZbnfParseResultItem)
is invoked for that child to store the content.
dstArg
- The class and instance to add children results.zbnfComponent
- The ZBNF parsers's result item which is either the top level result or any component.mainDstClass
- The main class to search instances for bNewFromType
recursion
- java.lang.IllegalAccessException
- if the field is not public.java.lang.IllegalArgumentException
java.lang.InstantiationException
- if a matching class is found but it can't be instantiated.private java.lang.reflect.Method searchMethod(int[] retVariant, java.lang.Class<?> outputClass, java.lang.String name, java.lang.Class<?>[][] argTypesVariants)
retVariant
- null or int[]. retVariant[0] will be set with the variant of argTypesVariants.outputClass
- name
- argTypesVariants
- A list (array) of possible arguments. If it contains Class>[0] it means no argument.protected ZbnfJavaOutput.DstInstanceAndClass searchCreateNew(java.lang.Class<?> mainDstClazz, java.lang.Object instance, java.lang.String semantic, ZbnfJavaOutput.DstInstanceAndClass parent, ZbnfParseResultItem zbnfElement) throws java.lang.IllegalAccessException
new_()
.inClazz
- class type where the method will be searched. The method won't be searched in super classes here.
Searching in super classes is organized in the routine #searchComponentsDestination(String, DstInstanceAndClass)
where this method is called.instance
- with them the found method will be invoked.semantic
- nameparent
- only used for parent in the return instance.ZbnfJavaOutput.DstInstanceAndClass.clazz
is the return type of the method.
That type is used to find out destinations for children of the component. It means the instance may be an derived type,
the special properties of the derived type are not used to store the parse result, only the return type is substantial.java.lang.IllegalAccessException
- if any error occurs in the found method.protected ZbnfJavaOutput.DstInstanceAndClass searchCreateMethod(java.lang.Class<?> inClazz, java.lang.Object instance, java.lang.String semantic, ZbnfJavaOutput.DstInstanceAndClass parent, ZbnfParseResultItem zbnfElement) throws java.lang.IllegalAccessException
new_()
.inClazz
- class type where the method will be searched. The method won't be searched in super classes here.
Searching in super classes is organized in the routine #searchComponentsDestination(String, DstInstanceAndClass)
where this method is called.instance
- with them the found method will be invoked.semantic
- nameparent
- only used for parent in the return instance.ZbnfJavaOutput.DstInstanceAndClass.clazz
is the return type of the method.
That type is used to find out destinations for children of the component. It means the instance may be an derived type,
the special properties of the derived type are not used to store the parse result, only the return type is substantial.java.lang.IllegalAccessException
- if any error occurs in the found method.private void searchAddMethodAndInvoke(java.lang.String semantic, ZbnfJavaOutput.DstInstanceAndClass component, ZbnfJavaOutput.DstInstanceAndClass componentsDestination) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException
add_semantic(Object)
-Method and invokes it.
This routine will be called after a ZBNF-components content is set into the destination Object.semantic
- The semantic from ZBNF.parentClass
- The class where the add_semantic(Object)
-Method should be declared
-or in its superclasses.parentInstance
- The instance with them the add_semantic(Object)
-Method
should be called.componentsDestination
- The Object where the content of the component is set.java.lang.IllegalArgumentException
- If the method isn't found and bExceptionIfnotFound
is true.java.lang.IllegalAccessException
- If the add_semantic(Object)
-Method isn't public.protected ZbnfJavaOutput.DstInstanceAndClass searchComponentsDestination(java.lang.String semantic, ZbnfParseResultItem zbnfItem, ZbnfJavaOutput.DstInstanceAndClass parentDst, java.lang.Class<?> mainDstClass) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.InstantiationException
new_semantic()
-method is found or a field with the given semantic
is found.
new_semantic()
-method is found, it is invoked.
The returned instance is the instance for the component. Note that the new_...()
method
don't need to create a new instance in any case. It is possible to returns any destination instance
which is used temporary till the add_...()
method (searchAddMethodAndInvoke(String, DstInstanceAndClass, DstInstanceAndClass)
).
The return type of the found method is the components class.
The method #searchCreateMethod(Class, Object, String)
is called for that.
null
, a new Object with the given type is created and set.
The object referenced to the field is returned.
List
, than a new Object with the generic type
of the List is created and added. See called method #getComponentsOutputField(Field, Object)
.
semantic
- The name of the new_-method or the field.parentDst
- The destination instance and class where the method or field is searched.ZbnfJavaOutput.DstInstanceAndClass.shouldAdd
is set true.
Because the add_-method should called also.java.lang.IllegalArgumentException
- If no method or field is found and bExceptionIfnotFound
is set.java.lang.IllegalAccessException
- If a problem with the field or method exists, especially the field or method should be public!java.lang.InstantiationException
- If a problem calling the new_-method exists.private ZbnfJavaOutput.DstInstanceAndClass getComponentsOutputField(java.lang.String semantic, java.lang.reflect.Field element, java.lang.Object outputInstance) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.InstantiationException
element
- The element (field) of the parent, which is matching to the semantic of the component.outputInstance
- The output instance where the element is located.java.lang.IllegalArgumentException
java.lang.IllegalAccessException
java.lang.InstantiationException
protected ZbnfJavaOutput.DstInstanceAndClass searchDestinationAndWriteResult(java.lang.String semanticRaw, ZbnfJavaOutput.DstInstanceAndClass destComponent, java.lang.Class<?> mainDstClass, ZbnfParseResultItem resultItem) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.InstantiationException
semanticRaw
- The semantic from ZBNF parse result item.
It may be a child destination: part1/part2
or may contain an @
to designate attributes if it will be stored in XML. If a child destination is given,
that destination is searched adequat to a destination for a component,
and than this method is called recursively with that destination and the right rest of semantic.
A @
as first char is ignored.destComponent
- The class where to found the method or field. and the instance to write into or invoke methods.
It should contain a matching public field or method.
A field matches, if its name is equal the semantic, but with lower case at first char.
A method matches, if it is named set_SEMANTIC, where SEMANTIC is the semantic of the zbnf item.
resultItem
- The semantic is determining the matching field or method.
The content is used if childOutputInstance is null.java.lang.IllegalAccessException
- if the element is not writeable especially not public.java.lang.IllegalArgumentException
java.lang.InstantiationException
- if the creation of a child instance fails.private void writeInField(java.lang.reflect.Field element, java.lang.Object outputInstance, ZbnfParseResultItem resultItem) throws java.lang.IllegalAccessException
element
- The fieldoutputInstance
- the associated instanceresultItem
- The ZBNF parser result.java.lang.IllegalAccessException
private boolean trySetInputInfo(ZbnfJavaOutput.DstInstanceAndClass destComponent, int line, int column, java.lang.String sFile) throws java.lang.IllegalAccessException, java.text.ParseException
inputLine_
or a method
set_inputInfo_
exists and set resp. calls it.
The method set_inputInfo_
have to return any object, not null, to detect whether it is existence.
Use boolean as return value.
If such a field or method isn't found, nothing is done. It is okay.semantic
- Name, it may be emtpy especially to search inputColumn_
for the component.destinationClass
- Class where searched.destinationInstance
- Associated instance where set or called.column
- The value of column. If it is negative, nothing is done. A negative value may indicate,
that no valid column is given to set.java.lang.IllegalAccessException
- If any problem with the set-method exists.java.text.ParseException
private void trySetInputColumn(java.lang.String semantic, ZbnfJavaOutput.DstInstanceAndClass destComponent, int column) throws java.lang.IllegalAccessException
inputColumn_semantic
or a method
set_inputColumn_semantic
exists and set resp. calls it.
If such a field or method isn't found, nothing is done. It is oksy.semantic
- Name, it may be emtpy especially to search inputColumn_
for the component.destinationClass
- Class where searched.destinationInstance
- Associated instance where set or called.column
- The value of column. If it is negative, nothing is done. A negative value may indicate,
that no valid column is given to set.java.lang.IllegalAccessException
- If any problem with the set-method exists.private void problem(ZbnfJavaOutput.DstInstanceAndClass destComponent, java.lang.String sProblem)
ZbnfJavaOutput.DstInstanceAndClass writeInMap(java.lang.String semantic, ZbnfJavaOutput.DstInstanceAndClass destComponent, ZbnfParseResultItem resultItem)
void stop()
public static java.lang.String parseFileAndFillJavaObject(java.lang.Class resultType, java.lang.Object result, java.io.File fInput, java.io.File fSyntax, MainCmdLogging_ifc report, int msgRange)
resultType
- The type or a interface or basic type of result. The fields and methods are searched in this type.result
- The instance, it have to be of type 'resultType', but may be derived.fInput
- The input file to parse.fSyntax
- The syntax file using ZBNFreport
- MainCmdLogging_ifc for parsing process and errorsmsgRange
- A start number of created messages in report.public java.lang.String parseFileAndFillJavaObject(java.lang.Object result, java.io.File fInput, java.io.File fSyntax)
resultType
- The type or a interface or basic type of result. The fields and methods are searched in this type.result
- The instance, it have to be of type 'resultType', but may be derived.fInput
- The input file to parse.fSyntax
- The syntax file using ZBNFpublic java.lang.String parseFileAndFillJavaObject(java.lang.Class resultType, java.lang.Object result, java.io.File fInput, java.io.File fSyntax)
resultType
- The type or a interface or basic type of result. The fields and methods are searched in this type.result
- The instance, it have to be of type 'resultType', but may be derived.fInput
- The input file to parse.fSyntax
- The syntax file using ZBNFpublic java.lang.String parseFileAndFillJavaObject(java.lang.Class resultType, java.lang.Object result, java.io.File fInput, java.lang.String sSyntax)
resultType
- The type or a interface or basic type of result. The fields and methods are searched in this type.result
- The instance, it have to be of type 'resultType', but may be derived.fInput
- The input file to parse.sSyntax
- The syntax using ZBNFpublic java.lang.String parseFileAndFillJavaObject(java.lang.Object result, java.io.File fInput, java.lang.String sSyntax)
result
- The instance to store the result.fInput
- The input file to parse.sSyntax
- The syntax using ZBNFpublic java.lang.String parseFileAndFillJavaObject(java.lang.Class resultType, java.lang.Object result, java.io.File fInput, StringPartScan spSyntax)
public java.lang.String parseFileAndFillJavaObject(java.lang.Class resultType, java.lang.Object result, java.io.File fInput, StringPartScan spSyntax, java.io.File fSyntaxDir)
resultType
- The type or a interface or basic type of result. The fields and methods are searched in this type.result
- The instance, it have to be of type 'resultType', but may be derived.fInput
- The input file to parse.spSyntax
- The ZBNF-syntax of the fInput, semantic should be proper to the resultType and result.fSyntaxDir
- directory which is used as base for import statements. It is the directory of the syntax file usually.
It may be null. The imports are not supported in the syntax.public java.lang.String parseFileAndFillJavaObject(java.lang.Class resultType, java.lang.Object result, java.lang.String sInput, java.lang.String sFileInput, java.lang.String syntax, java.io.File fSyntaxDir)
resultType
- The type or a interface or basic type of result. The fields and methods are searched in this type.result
- The instance, it have to be of type 'resultType', but may be derived.sInput
- Textual input may read from a file or given as constant, especially by using JZcmdsFileInput
- This String is used only for output messages on error. It may be ""syntax
- Textual given syntax in ZBNF format.fSyntaxDir
- directory which is used as base for import statements. It is the directory of the syntax file usually.
It may be null. The imports are not supported in the syntax.private java.lang.String parseFileAndFillJavaObject(java.lang.Class resultType, java.lang.Object result, StringPartScan spInput, java.lang.String sFileInput, StringPartScan spSyntax, java.io.File fSyntaxDir)
resultType
- The type or a interface or basic type of result. The fields and methods are searched in this type.result
- The instance, it have to be of type 'resultType', but may be derived.spInput
- sFileInput
- spSyntax
- fSyntaxDir
- directory which is used as base for import statements. It is the directory of the syntax file usually.
It may be null. The imports are not supported in the syntax.public java.lang.String parseFileAndFillJavaObject(java.lang.Class resultType, java.lang.Object result, StringPartScan spInput, java.lang.String sFileInput)
public java.lang.String parseFileAndFillJavaObject(java.lang.Object result, java.io.File fInput)
parserJava = new org.vishia.zbnf.ZbnfJavaOutput(logParser); parserJava.parser.setSyntax(sSyntax);
result
- Instance proper to syntax file for the result.
Hint: Use GenZbnfJavaData
to create the Java source proper to the syntax.fInput
- The input fileprivate void noteError(java.lang.CharSequence problem)
bExceptionIfnotFound
= false.problem
- The text.