Package org.simpleframework.xml.core
Class TemplateEngine
- java.lang.Object
-
- org.simpleframework.xml.core.TemplateEngine
-
class TemplateEngine extends java.lang.Object
TheTemplateEngine
object is used to create strings which have system variable names replaced with their values. This is used by theSource
context object to ensure that values taken from an XML element or attribute can be values values augmented with system or environment variable values.tools=${java.home}/lib/tools.jar
Above is an example of the use of an system variable that has been inserted into a plain Java properties file. This will be converted to the full path to tools.jar when the system variable "java.home" is replaced with the matching value.
-
-
Field Summary
Fields Modifier and Type Field Description private Filter
filter
This is the filter used to replace templated variables.private Template
name
This is used to accumulate the bytes for the variable name.private int
off
This is used to keep track of the buffer seek offset.private Template
source
This is used to store the text that are to be processed.private Template
text
This is used to accumulate the transformed text value.
-
Constructor Summary
Constructors Constructor Description TemplateEngine(Filter filter)
Constructor for theTemplateEngine
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
This method is used to clear the contents of the buffer.private void
name()
This method is used to extract text from the property value that matches the pattern "${ *TEXT }".private void
parse()
This extracts the value from the Java properties text.java.lang.String
process(java.lang.String value)
This method is used to append the provided text and then it converts the buffered text to return the corrosponding text.private void
replace()
This will replace the accumulated for an system variable name with the value of that system variable.private void
replace(java.lang.String name)
This will replace the accumulated for an system variable name with the value of that system variable.private void
replace(Template name)
This will replace the accumulated for an system variable name with the value of that system variable.
-
-
-
Field Detail
-
source
private Template source
This is used to store the text that are to be processed.
-
name
private Template name
This is used to accumulate the bytes for the variable name.
-
text
private Template text
This is used to accumulate the transformed text value.
-
filter
private Filter filter
This is the filter used to replace templated variables.
-
off
private int off
This is used to keep track of the buffer seek offset.
-
-
Constructor Detail
-
TemplateEngine
public TemplateEngine(Filter filter)
Constructor for theTemplateEngine
object. This is used to create a parsing buffer, which can be used to replace filter variable names with their corrosponding values.- Parameters:
filter
- this is the filter used to provide replacements
-
-
Method Detail
-
process
public java.lang.String process(java.lang.String value)
This method is used to append the provided text and then it converts the buffered text to return the corrosponding text. The contents of the buffer remain unchanged after the value is buffered. It must be cleared if used as replacement only.- Parameters:
value
- this is the value to append to the buffer- Returns:
- returns the value of the buffer after the append
-
parse
private void parse()
This extracts the value from the Java properties text. This will basically ready any text up to the first occurance of an equal of a terminal. If a terminal character is read this returns without adding the terminal to the value.
-
name
private void name()
This method is used to extract text from the property value that matches the pattern "${ *TEXT }". Such patterns within the properties file are considered to be system variables, this will replace instances of the text pattern with the matching system variable, if a matching variable does not exist the value remains unmodified.
-
replace
private void replace()
This will replace the accumulated for an system variable name with the value of that system variable. If a value does not exist for the variable name, then the name is put into the value so that the value remains unmodified.
-
replace
private void replace(Template name)
This will replace the accumulated for an system variable name with the value of that system variable. If a value does not exist for the variable name, then the name is put into the value so that the value remains unmodified.- Parameters:
name
- this is the name of the system variable
-
replace
private void replace(java.lang.String name)
This will replace the accumulated for an system variable name with the value of that system variable. If a value does not exist for the variable name, then the name is put into the value so that the value remains unmodified.- Parameters:
name
- this is the name of the system variable
-
clear
public void clear()
This method is used to clear the contents of the buffer. This includes the contents of all buffers used to transform the value of the buffered text with system variable values. Once invoked the instance can be reused as a clean buffer.
-
-