|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsimple.util.parse.ParseBuffer
public class ParseBuffer
This is primarily used to replace the StringBuffer
class, as a way for the Parser
to store the char's
for a specific region within the parse data that constitutes a
desired value. The methods are not synchronized so it enables
the char
's to be taken quicker than the
StringBuffer
class.
Field Summary | |
---|---|
protected char[] |
buf
The char 's this buffer accumulated. |
protected java.lang.String |
cache
This is used to quicken toString . |
protected int |
count
This is the number of char 's stored. |
Constructor Summary | |
---|---|
ParseBuffer()
Constructor for ParseBuffer . |
|
ParseBuffer(int size)
This creates a ParseBuffer with a specific
default size. |
Method Summary | |
---|---|
void |
append(char c)
This will add a char to the end of the buffer. |
void |
append(char[] c,
int off,
int len)
This will add a char to the end of the buffer. |
void |
append(ParseBuffer text)
This will add a ParseBuffer to the end of this. |
void |
append(ParseBuffer text,
int off,
int len)
This will add a ParseBuffer to the end of this. |
void |
append(java.lang.String str)
This will add a String to the end of the buffer. |
void |
append(java.lang.String str,
int off,
int len)
This will add a String to the end of the buffer. |
void |
clear()
This will empty the ParseBuffer so that the
toString paramater will return null . |
protected void |
ensureCapacity(int min)
This ensure that there is enough space in the buffer to allow for more char 's to be added. |
int |
length()
This will return the number of bytes that have been appended to the ParseBuffer . |
java.lang.String |
toString()
This will return the characters that have been appended to the ParseBuffer as a String object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.lang.String cache
toString
.
protected char[] buf
char
's this buffer accumulated.
protected int count
char
's stored.
Constructor Detail |
---|
public ParseBuffer()
ParseBuffer
. The default
ParseBuffer
stores 16 char
's
before a resize
is needed to accomodate
extra characters.
public ParseBuffer(int size)
ParseBuffer
with a specific
default size. The buffer will be created the with the
length specified. The ParseBuffer
can grow
to accomodate a collection of char
's larger
the the size spacified.
size
- initial size of this ParseBuffer
Method Detail |
---|
public void append(char c)
char
to the end of the buffer.
The buffer will not overflow with repeated uses of the
append
, it uses an ensureCapacity
method which will allow the buffer to dynamically grow in
size to accomodate more char
's.
c
- the char
to be appendedpublic void append(java.lang.String str)
String
to the end of the buffer.
The buffer will not overflow with repeated uses of the
append
, it uses an ensureCapacity
method which will allow the buffer to dynamically grow in
size to accomodate large String
objects.
str
- the String
to be appended to thispublic void append(ParseBuffer text)
ParseBuffer
to the end of this.
The buffer will not overflow with repeated uses of the
append
, it uses an ensureCapacity
method which will allow the buffer to dynamically grow in
size to accomodate large ParseBuffer
objects.
text
- the ParseBuffer
to be appendedpublic void append(char[] c, int off, int len)
char
to the end of the buffer.
The buffer will not overflow with repeated uses of the
append
, it uses an ensureCapacity
method which will allow the buffer to dynamically grow in
size to accomodate large char
arrays.
c
- the char
array to be appended to thisoff
- the read offset for the arraylen
- the number of char
's to addpublic void append(java.lang.String str, int off, int len)
String
to the end of the buffer.
The buffer will not overflow with repeated uses of the
append
, it uses an ensureCapacity
method which will allow the buffer to dynamically grow in
size to accomodate large String
objects.
str
- the String
to be appended to thisoff
- the read offset for the String
len
- the number of char
's to addpublic void append(ParseBuffer text, int off, int len)
ParseBuffer
to the end of this.
The buffer will not overflow with repeated uses of the
append
, it uses an ensureCapacity
method which will allow the buffer to dynamically grow in
size to accomodate large ParseBuffer
objects.
text
- the ParseBuffer
to be appendedoff
- the read offset for the ParseBuffer
len
- the number of char
's to addprotected 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 neededpublic void clear()
ParseBuffer
so that the
toString
paramater will return null
.
This is used so that the same ParseBuffer
can be
recycled for different tokens.
public int length()
ParseBuffer
. This will return zero after
the clear method has been invoked.
char
's within the bufferpublic java.lang.String toString()
ParseBuffer
as a String
object.
If the String
object has been created before then
a cached String
object will be returned. This
method will return null
after clear is invoked.
toString
in class java.lang.Object
char
's appended as a String
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |