| java.lang.Object simple.util.parse.ParseBuffer
All known Subclasses: simple.page.translate.TokenBuffer, simple.page.translate.Parser, simple.util.parse.PropertyBuffer,
ParseBuffer | public class ParseBuffer implements Serializable(Code) | | 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.
author: Niall Gallagher |
Field Summary | |
protected char[] | buf The char 's this buffer accumulated. | protected String | cache This is used to quicken toString . | protected int | count This is the number of char 's stored. |
Constructor Summary | |
public | ParseBuffer() Constructor for ParseBuffer . | public | ParseBuffer(int size) This creates a ParseBuffer with a specific
default size. |
Method Summary | |
public void | append(char c) This will add a char to the end of the buffer. | public void | append(String str) This will add a String to the end of the buffer. | public void | append(ParseBuffer text) This will add a ParseBuffer to the end of this. | public void | append(char[] c, int off, int len) This will add a char to the end of the buffer. | public void | append(String str, int off, int len) This will add a String to the end of the buffer. | public void | append(ParseBuffer text, int off, int len) This will add a ParseBuffer to the end of this. | public 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. | public int | length() This will return the number of bytes that have been appended
to the ParseBuffer . | public String | toString() This will return the characters that have been appended to the
ParseBuffer as a String object.
If the String object has been created before then
a cached String object will be returned. |
buf | protected char[] buf(Code) | | The char 's this buffer accumulated.
|
cache | protected String cache(Code) | | This is used to quicken toString .
|
count | protected int count(Code) | | This is the number of char 's stored.
|
ParseBuffer | public ParseBuffer()(Code) | | Constructor for ParseBuffer . The default
ParseBuffer stores 16 char 's
before a resize is needed to accomodate
extra characters.
|
ParseBuffer | public ParseBuffer(int size)(Code) | | This creates a 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.
Parameters: size - initial size of this ParseBuffer |
append | public void append(char c)(Code) | | This will add a 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.
Parameters: c - the char to be appended |
append | public void append(String str)(Code) | | This will add a 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.
Parameters: str - the String to be appended to this |
append | public void append(ParseBuffer text)(Code) | | This will add a 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.
Parameters: text - the ParseBuffer to be appended |
append | public void append(char[] c, int off, int len)(Code) | | This will add a 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.
Parameters: c - the char array to be appended to this Parameters: off - the read offset for the array Parameters: len - the number of char 's to add |
append | public void append(String str, int off, int len)(Code) | | This will add a 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.
Parameters: str - the String to be appended to this Parameters: off - the read offset for the String Parameters: len - the number of char 's to add |
append | public void append(ParseBuffer text, int off, int len)(Code) | | This will add a 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.
Parameters: text - the ParseBuffer to be appended Parameters: off - the read offset for the ParseBuffer Parameters: len - the number of char 's to add |
clear | public void clear()(Code) | | This will empty the ParseBuffer so that the
toString paramater will return null .
This is used so that the same ParseBuffer can be
recycled for different tokens.
|
ensureCapacity | protected void ensureCapacity(int min)(Code) | | This ensure that there is enough space in the buffer to
allow for more char 's to be added. If
the buffer is already larger than min then the buffer
will not be expanded at all.
Parameters: min - the minimum size needed |
length | public int length()(Code) | | This will return the number of bytes that have been appended
to the ParseBuffer . This will return zero after
the clear method has been invoked.
the number of char 's within the buffer |
toString | public String toString()(Code) | | This will return the characters that have been appended to the
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.
the char 's appended as a String |
|
|