Package org.simpleframework.xml.core
Class Template
- java.lang.Object
-
- org.simpleframework.xml.core.Template
-
class Template extends java.lang.ObjectThis is primarily used to replace theStringBufferclass, as a way for theTemplateEngineto 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.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappend(char c)This will add acharto the end of the buffer.voidappend(char[] c, int off, int len)This will add acharto the end of the buffer.voidappend(java.lang.String str)This will add aStringto the end of the buffer.voidappend(java.lang.String str, int off, int len)This will add aStringto the end of the buffer.voidappend(Template text)This will add aTemplateto the end of this.voidappend(Template text, int off, int len)This will add aTemplateto the end of this.voidclear()This will empty theTemplateso that thetoStringparamater will returnnull.protected voidensureCapacity(int min)This ensure that there is enough space in the buffer to allow for more characters to be added.intlength()This will return the number of bytes that have been appended to theTemplate.java.lang.StringtoString()This will return the characters that have been appended to theTemplateas aStringobject.
-
-
-
Constructor Detail
-
Template
public Template()
Constructor forTemplate. The defaultTemplatestores 16 characters before aresizeis needed to append extra characters.
-
Template
public Template(int size)
This creates aTemplatewith a specific default size. The buffer will be created the with the length specified. TheTemplatecan grow to accomodate a collection of characters larger the the size spacified.- Parameters:
size- initial size of thisTemplate
-
-
Method Detail
-
append
public void append(char c)
This will add acharto the end of the buffer. The buffer will not overflow with repeated uses of theappend, it uses anensureCapacitymethod which will allow the buffer to dynamically grow in size to accomodate more characters.- Parameters:
c- thecharto be appended
-
append
public void append(java.lang.String str)
This will add aStringto the end of the buffer. The buffer will not overflow with repeated uses of theappend, it uses anensureCapacitymethod which will allow the buffer to dynamically grow in size to accomodate largeStringobjects.- Parameters:
str- theStringto be appended to this
-
append
public void append(Template text)
This will add aTemplateto the end of this. The buffer will not overflow with repeated uses of theappend, it uses anensureCapacitymethod which will allow the buffer to dynamically grow in size to accomodate largeTemplateobjects.- Parameters:
text- theTemplateto be appended
-
append
public void append(char[] c, int off, int len)This will add acharto the end of the buffer. The buffer will not overflow with repeated uses of theappend, it uses anensureCapacitymethod which will allow the buffer to dynamically grow in size to accomodate largechararrays.- Parameters:
c- thechararray to be appended to thisoff- the read offset for the arraylen- the number of characters to append to this
-
append
public void append(java.lang.String str, int off, int len)This will add aStringto the end of the buffer. The buffer will not overflow with repeated uses of theappend, it uses anensureCapacitymethod which will allow the buffer to dynamically grow in size to accomodate largeStringobjects.- Parameters:
str- theStringto be appended to thisoff- the read offset for theStringlen- the number of characters to append to this
-
append
public void append(Template text, int off, int len)
This will add aTemplateto the end of this. The buffer will not overflow with repeated uses of theappend, it uses anensureCapacitymethod which will allow the buffer to dynamically grow in size to accomodate largeTemplateobjects.- Parameters:
text- theTemplateto be appendedoff- the read offset for theTemplatelen- 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 theTemplateso that thetoStringparamater will returnnull. This is used so that the sameTemplatecan 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
public java.lang.String toString()
This will return the characters that have been appended to theTemplateas aStringobject. If theStringobject has been created before then a cachedStringobject will be returned. This method will returnnullafter clear is invoked.- Overrides:
toStringin classjava.lang.Object- Returns:
- the characters appended as a
String
-
-