Package org.simpleframework.xml.core
Class Template
java.lang.Object
org.simpleframework.xml.core.Template
This is primarily used to replace the
StringBuffer
class, as a way for the TemplateEngine
to store the
data for a specific region within the parse data that constitutes
a desired value. The methods are not synchronized so it enables
the characters to be taken quicker than the string buffer class.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
append
(char c) This will add achar
to the end of the buffer.void
append
(char[] c, int off, int len) This will add achar
to the end of the buffer.void
This will add aString
to the end of the buffer.void
This will add aString
to the end of the buffer.void
This will add aTemplate
to the end of this.void
This will add aTemplate
to the end of this.void
clear()
This will empty theTemplate
so that thetoString
paramater will returnnull
.protected void
ensureCapacity
(int min) This ensure that there is enough space in the buffer to allow for more characters to be added.int
length()
This will return the number of bytes that have been appended to theTemplate
.toString()
This will return the characters that have been appended to theTemplate
as aString
object.
-
Field Details
-
cache
This is used to quickentoString
. -
buf
protected char[] bufThe characters that this buffer has accumulated. -
count
protected int countThis is the number of characters this has stored.
-
-
Constructor Details
-
Template
public Template()Constructor forTemplate
. The defaultTemplate
stores 16 characters before aresize
is needed to append extra characters. -
Template
public Template(int size) This creates aTemplate
with a specific default size. The buffer will be created the with the length specified. TheTemplate
can grow to accomodate a collection of characters larger the the size spacified.- Parameters:
size
- initial size of thisTemplate
-
-
Method Details
-
append
public void append(char c) This will add achar
to the end of the buffer. The buffer will not overflow with repeated uses of theappend
, it uses anensureCapacity
method which will allow the buffer to dynamically grow in size to accomodate more characters.- Parameters:
c
- thechar
to be appended
-
append
This will add aString
to the end of the buffer. The buffer will not overflow with repeated uses of theappend
, it uses anensureCapacity
method which will allow the buffer to dynamically grow in size to accomodate largeString
objects.- Parameters:
str
- theString
to be appended to this
-
append
This will add aTemplate
to the end of this. The buffer will not overflow with repeated uses of theappend
, it uses anensureCapacity
method which will allow the buffer to dynamically grow in size to accomodate largeTemplate
objects.- Parameters:
text
- theTemplate
to be appended
-
append
public void append(char[] c, int off, int len) This will add achar
to the end of the buffer. The buffer will not overflow with repeated uses of theappend
, it uses anensureCapacity
method which will allow the buffer to dynamically grow in size to accomodate largechar
arrays.- Parameters:
c
- thechar
array to be appended to thisoff
- the read offset for the arraylen
- the number of characters to append to this
-
append
This will add aString
to the end of the buffer. The buffer will not overflow with repeated uses of theappend
, it uses anensureCapacity
method which will allow the buffer to dynamically grow in size to accomodate largeString
objects.- Parameters:
str
- theString
to be appended to thisoff
- the read offset for theString
len
- the number of characters to append to this
-
append
This will add aTemplate
to the end of this. The buffer will not overflow with repeated uses of theappend
, it uses anensureCapacity
method which will allow the buffer to dynamically grow in size to accomodate largeTemplate
objects.- Parameters:
text
- theTemplate
to be appendedoff
- the read offset for theTemplate
len
- the number of characters to append to this
-
ensureCapacity
protected void ensureCapacity(int min) This ensure that there is enough space in the buffer to allow for more characters 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 for this buffer
-
clear
public void clear()This will empty theTemplate
so that thetoString
paramater will returnnull
. This is used so that the sameTemplate
can be recycled for different tokens. -
length
public int length()This will return the number of bytes that have been appended to theTemplate
. This will return zero after the clear method has been invoked.- Returns:
- the number of characters within this buffer object
-
toString
This will return the characters that have been appended to theTemplate
as aString
object. If theString
object has been created before then a cachedString
object will be returned. This method will returnnull
after clear is invoked.
-