public abstract class StructRule
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static Position |
BOL
a default constant for defining a beginning of a line
|
static Position |
EMPTY_LINE
a default constant for defining an empty line
|
static Position |
EOB |
static Position |
EOL
a default constant for defining an end of a line
|
protected boolean |
m_attribute |
protected java.lang.Object |
m_out |
protected boolean |
m_terminate |
static Position |
SPACE
a default constant for defining a beginning a whitespace
|
| Constructor and Description |
|---|
StructRule() |
| Modifier and Type | Method and Description |
|---|---|
void |
addTransformat(Transformat format)
add a
Transformat to this rule |
protected abstract void |
clearBuffer()
general method to clear a buffer which an implementation
of a StructRule can implement to keep all data between
isFound() and isFinished(). |
StructGroup |
getParent()
get the parent group of which this rule is a part
|
java.util.List |
getTransformats()
get the List of Transformats applicable to this Rule.
|
void |
insertTransformat(int pos,
Transformat format) |
boolean |
isFinished()
check if the end of this rule is found in the input
|
boolean |
isFound()
check if the beginning of this rule is found.
|
boolean |
isTerminate() |
abstract void |
readline(java.lang.String line)
read a line from the parser for processing, without
tracking the line number
|
abstract void |
readline(java.lang.String line,
int lineno)
read a line from the parser for processing, with
tracking the line number
|
static int |
removeWhitespace(java.lang.String line,
int begin,
int end)
get the index within the line after detected whitespaces
between begin and end
|
void |
reset()
reset this rule to a state were the input
can be processed from the beginning.
|
protected void |
set(java.lang.Object objectId,
java.lang.String value)
set the value created from the input to the
Object created by the parent, identified within
that Object by objectId.
|
void |
setFinished(boolean finished)
set the indicator that the end of this rule is found in the input
|
void |
setFound(boolean found)
set the indicator that the beginning of this rule is found.
|
void |
setParent(StructGroup parent)
set the parent for this rule
|
public static final Position BOL
public static final Position EOL
public static final Position EMPTY_LINE
public static final Position SPACE
public static final Position EOB
protected java.lang.Object m_out
protected boolean m_attribute
protected boolean m_terminate
public abstract 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),
StructParserpublic abstract void 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 lineStructParserprotected abstract void clearBuffer()
isFound() and isFinished().
This method is called from reset to clear the buffer between two independant uses of this rule
reset()public void reset()
This method is called to reuse this rule for subsequent calls after a rule has finished clearing all data related to previous matching of this group.
After calling reset isFound() and isFinished()
will both be false and clearBuffer() will be called
public boolean isFinished()
isFound()public boolean isFound()
isFinished()public void setFinished(boolean finished)
finished - boolean, true if the end of the input is foundisFinished()public void setFound(boolean found)
found - boolean, true if the beginning of the group is foundisFound()public StructGroup getParent()
StructGrouppublic void setParent(StructGroup parent)
parent - StructGroup the parent to usepublic void insertTransformat(int pos,
Transformat format)
public static final int removeWhitespace(java.lang.String line,
int begin,
int end)
line - String, the line to testbegin - int, the begin index to test for whitespaceend - int, the end index to test for whitespacespublic void addTransformat(Transformat format)
Transformat to this rule
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
format - Transformatjava.lang.NullPointerException - if the transformat is nullpublic java.util.List getTransformats()
SimpleTransformats which are applicable to the StructGroup will also be applicable to this rule and thus will be returned by this function.
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
Transformatprotected void set(java.lang.Object objectId,
java.lang.String value)
objectId - Object, always a String but for reasons
of implementation of StructGroup supplied here as an Objectvalue - String, the value to set to the Objectpublic boolean isTerminate()