public interface StructGroup
A StructGroup is basically a StructRule which can contain rules itself (including other Groups) that apply only to the content which is part of this group.
To make this a bit more concrete, say we are reading a java method itself:
public int getInt() {
return m_int;
}
a StructGroup would be defined to read public to }.
Rules to this group can be set to read the content of the method, say from
return to ;
A Group further has the task to maintain the Object (XML|PROPERTIES)
to which the results of individual rules are written to. The result of a finished
group isFinished() == true (all input read until the end and all rules applied) can be gotten from
getObject()
| Modifier and Type | Field and Description |
|---|---|
static int |
MAP
constant for defining the output as Property or Map
|
static int |
XML
constant for defining the output as XML
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(StructRule rule)
add a rule to this Group.
|
java.lang.Object |
getObject()
get the Object created as a result of the input matching
this group.
|
int |
getOutputType()
the type of output
getObject() will deliver if the
rules are matched to the output |
java.util.List |
getTransformats()
get the List of Transformats added to this Group.
|
boolean |
isFinished()
check if the end of this group is found in the input
|
boolean |
isFound()
check if the beginning of this group is found.
|
void |
readline(java.lang.String line)
read a line from the parser for processing, without
tracking the line number
|
void |
readline(java.lang.String line,
int lineno)
read a line from the parser for processing, with
tracking the line number
|
void |
reset()
reset this group to a state were the input
can be processed from the beginning.
|
void |
setParent(StructGroup group)
set the parent for this Group
|
static final int XML
static final int MAP
boolean isFinished()
isFound()boolean isFound()
All input will be processed inside this group as long as isFinished is false
isFinished()void readline(java.lang.String line)
The StructParser supplies the input line for line. This
does not limit the rules to one line. This is only dependant
on isFound() and isFinished()
This method calls readline(String, int) with lineno=-1
and will ignore lineno for information purposes
line - String, the line to be readreadline(String, int),
StructParservoid readline(java.lang.String line,
int lineno)
The StructParser supplies the input line for line. This
does not limit the rules to one line. This is only dependant
on isFound() and isFinished()
line - String, the line to be readlineno - int, the linenumber of this lineStructParservoid add(StructRule rule)
isFound() is true and until isFinished()
is true.rule - StructRule, the rule to add to this groupjava.lang.Object getObject()
isFound() is never true
for this group and might not be correctly set if isFinished() never is trueint getOutputType()
getObject() will deliver if the
rules are matched to the outputjava.util.List getTransformats()
A transformater is a class which will be called to
format the values from an input to a value for the output.
With an implementation one can do simple transformations
SimpleTransformat like trimming whitespaces or
setting the value to uppercase or do complex transformations
ComplexTransformat changing multiple values
in a resulting Object
For SimpleTransformat adding this to the group
will mean this rule will be applied to all rules added to
this group
Transformatvoid reset()
This method is called to reuse this Group for subsequent calls after a group has finished clearing all data related to previous matching of this group.
After calling reset isFound() and isFinished()
should both be false and getObject() should return null
void setParent(StructGroup group)
group - StructGroup the parent to use