|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.simpleframework.util.parse.Parser
public abstract class Parser
This Parser
object is to be used as a simple template
for parsing uncomplicated expressions. This object is used to parse
a String
. This provides a few methods that can be used
to store and track the reading of data from a buffer. There are two
abstract methods provided to allow this to be subclassed to create
a Parser
for a given String
.
Field Summary | |
---|---|
protected char[] |
buf
This is the buffer that is being parsed. |
protected int |
count
This represents the length of the buffer. |
protected int |
off
This represents the current read offset. |
Constructor Summary | |
---|---|
protected |
Parser()
This is a no argument constructor for the Parser . |
Method Summary | |
---|---|
protected boolean |
digit(char c)
This is used to determine wheather or not a given character is a digit character. |
protected void |
ensureCapacity(int min)
This ensure that there is enough space in the buffer to allow for more char 's to be added. |
protected abstract void |
init()
This will initialize the Parser when it is ready
to parse a new String . |
protected abstract void |
parse()
This is the method that should be implemented to read the buf. |
void |
parse(java.lang.String text)
This is used to parse the String given to it. |
protected boolean |
skip(java.lang.String text)
This is used to skip an arbitrary String within the
char buf. |
protected boolean |
space(char c)
This is used to determine if a given ISO-8859-1 character is a space character. |
protected char |
toLower(char c)
This takes a unicode character and assumes an encoding of ISO-8859-1. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected char[] buf
protected int off
protected int count
Constructor Detail |
---|
protected Parser()
Parser
.
This will be invoked by each subclass of this object. It will
set the buffer to a zero length buffer so that when the
ensureCapacity
method is used the buf's
length can be checked.
Method Detail |
---|
public void parse(java.lang.String text)
String
given to it. This
will ensure that the char
buffer has enough space
to contain the characters from the String
. This
will firstly ensure that the buffer is resized if nessecary. The
second step in this parse
method is to initialize
the Parser
object so that multiple parse invokations
can be made. The init
method will reset this to an
prepared state. Then finally the parse
method is
called to parse the char
buffer.
text
- the String
to be parsed with this
Parser
protected void ensureCapacity(int min)
char
's to be added. If the buffer is
already larger than min then the buffer will not be expanded
at all.
min
- the minimum size needed to accomodate the charactersprotected boolean space(char c)
c
- the character that is being determined by this
protected boolean digit(char c)
c
- the character being determined by this method
protected char toLower(char c)
c
- the char
to be converted to lowercase
protected boolean skip(java.lang.String text)
String
within the
char
buf. It checks the length of the String
first to ensure that it will not go out of bounds. A comparison
is then made with the buffers contents and the String
if the reigon in the buffer matched the String
then the
offset within the buffer is increased by the String
's
length so that it has effectively skipped it.
text
- this is the String
value to be skipped
String
was skippedprotected abstract void init()
Parser
when it is ready
to parse a new String
. This will reset the
Parser
to a ready state. The init
method is invoked by the Parser
when the
parse
method is invoked.
protected abstract void parse()
init
method is invoked.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |