public class TemplateProcessor
extends java.lang.Object
implements java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
private static int |
BROWSER_IE
The browser type value for Microsoft Internet Explorer.
|
private static java.util.Properties |
cvConfig
The velocity configuration properties.
|
private static java.lang.Class<?> |
cvFmtClass
The class for the configured template formatter.
|
private static java.lang.String |
NO_CACHE
The html meta tag that denotes no caching of the html file.
|
private static long |
serialVersionUID
The class' serialization version id.
|
| Constructor and Description |
|---|
TemplateProcessor() |
| Modifier and Type | Method and Description |
|---|---|
private static void |
addTemplateData(org.apache.velocity.VelocityContext data)
Adds additional template data that is common to all templates, such as
the
StringEncoder class and the Util class. |
static java.lang.String |
doTemplate(java.io.File template,
org.apache.velocity.VelocityContext data,
boolean bodyonly)
Processes the given template file and context data and returns the results
as a string.
|
static void |
doTemplate(javax.servlet.http.HttpServletResponse response,
java.lang.String template,
org.apache.velocity.VelocityContext data,
int browser)
Processes the given template name and context data and writes the results
to the given response object.
|
private static java.lang.String |
doTemplate(java.lang.String template,
java.lang.String logref,
org.apache.velocity.VelocityContext data)
Processes the given template content and context data and returns the
results as a string.
|
static java.lang.String |
doTemplate(java.lang.String template,
org.apache.velocity.VelocityContext data)
Processes the given template name and context data and returns the results
as a string.
|
private static void |
doTemplate(java.lang.String template,
org.apache.velocity.VelocityContext data,
java.io.PrintWriter pw)
Processes the given template name and context data and writes the results
to the given writer.
|
static void |
dumpPropertiesToFile()
Dumps a sorted list of the processor's configuration property keys and
values to a file named "_properties.velocity.txt" in the application's
log folder.
|
static java.util.ArrayList<java.lang.String> |
dumpPropertiesToList()
Returns a sorted list of the processor's configuration property keys and
values.
|
static void |
dumpResultsToFile(java.io.File template,
org.apache.velocity.VelocityContext data)
Dumps the results of template processing to a log file in the log folder.
|
static void |
dumpResultsToFile(java.lang.String template,
org.apache.velocity.VelocityContext data)
Dumps the results of template processing to a log file in the log folder.
|
static java.lang.String |
getTemplateExtension(java.lang.String template)
Returns the file extension for a template file name.
|
static java.lang.String |
getTemplateFolder()
Returns the file path for the defined folder for template files.
|
private static java.lang.String |
getTemplateName(java.io.File template)
Extracts and returns the template file name from the given file by
removing the template folder root path from the beginning of the file's
absolute path.
|
static boolean |
isHtmlTemplate(java.lang.String template)
Answers if a template is an html template based on the template name's
file extension.
|
static boolean |
isTextTemplate(java.lang.String template)
Answers if a template is a text template based on the template name's
file extension.
|
static boolean |
isXmlTemplate(java.lang.String template)
Answers if a template is an xml template based on the template name's
file extension.
|
static java.lang.String |
nocacheComponents(org.apache.velocity.VelocityContext data,
java.lang.String results)
Appends a version number to the end of style, script and image URLs that
are found within a processed template in an attempt to prevent web browsers
from using cached copies of the files.
|
static void |
setTemplateEncoder(int type,
org.apache.velocity.VelocityContext data)
Sets the template encoder to be used during Velocity template processing.
|
static void |
setTemplateEncoder(java.lang.String template,
org.apache.velocity.VelocityContext data)
Sets the template encoder to be used during Velocity template processing.
|
private static void |
setTemplateFolder()
Sets the file path for the defined folder for template files.
|
private static final long serialVersionUID
private static java.util.Properties cvConfig
private static java.lang.Class<?> cvFmtClass
private static final java.lang.String NO_CACHE
private static final int BROWSER_IE
private static void addTemplateData(org.apache.velocity.VelocityContext data)
StringEncoder class and the Util class.data - (VelocityContext) The template data to add to.public static void doTemplate(javax.servlet.http.HttpServletResponse response,
java.lang.String template,
org.apache.velocity.VelocityContext data,
int browser)
throws java.lang.Exception
BaseServlet.response - (HttpServletResponse) The calling servlet's outgoing
response object.template - (String) The name of the template file to process.data - (VelocityContext) The data to use for substitutions.browser - (int) The type of browser that will receive the sent
response. Must be one of the defined browser types.java.lang.Exception - - if an error occurs while processing the
template and data.public static java.lang.String doTemplate(java.io.File template,
org.apache.velocity.VelocityContext data,
boolean bodyonly)
throws java.lang.Exception
MailMessage class when processing email templates.template - (File) The file containing the template to process.data - (VelocityContext) The data to use for substitutions.bodyonly - (boolean) true if the source file is an
html file and only the body portion of the html file is to be
included in the results, otherwise false. This
parameter is ignored for all non-html file types.java.lang.Exception - - if an error occurs while processing the
template and data.public static java.lang.String doTemplate(java.lang.String template,
org.apache.velocity.VelocityContext data)
throws java.lang.Exception
template - (String) The name of the template file to process.data - (VelocityContext) The data to use for substitutions.java.lang.Exception - - if an error occurs while processing the
template and data.private static void doTemplate(java.lang.String template,
org.apache.velocity.VelocityContext data,
java.io.PrintWriter pw)
throws java.lang.Exception
template - (String) The name of the template file to process.data - (VelocityContext) The data to use for substitutions.pw - (PrintWriter) The writer where the processed results are
to be written.java.lang.Exception - - if an error occurs while processing the
template and data.private static java.lang.String doTemplate(java.lang.String template,
java.lang.String logref,
org.apache.velocity.VelocityContext data)
throws java.lang.Exception
template - (String) The content for the template to process.logref - (String) A meaningful reference description. This value
is written to the log if any template processing problems occur.data - (VelocityContext) The data to use for substitutions.java.lang.Exception - - if an error occurs while processing the
template and data.public static void dumpPropertiesToFile()
public static java.util.ArrayList<java.lang.String> dumpPropertiesToList()
public static void dumpResultsToFile(java.io.File template,
org.apache.velocity.VelocityContext data)
throws java.lang.Exception
template - (File) The file containing the template to process.data - (VelocityContext) The data to use for substitutions.java.lang.Exception - - if an error occurs while processing the
template and data.public static void dumpResultsToFile(java.lang.String template,
org.apache.velocity.VelocityContext data)
throws java.lang.Exception
template - (String) The name of the template file to process.data - (VelocityContext) The data to use for substitutions.java.lang.Exception - - if an error occurs while processing the
template and data.public static java.lang.String getTemplateExtension(java.lang.String template)
template - (String) A template file name.public static java.lang.String getTemplateFolder()
private static void setTemplateFolder()
Profile.SITE_PATH.private static java.lang.String getTemplateName(java.io.File template)
template - (File) The template file to process.public static boolean isHtmlTemplate(java.lang.String template)
template - (String) A template file name.true if the template is an html template,
otherwise false.public static boolean isTextTemplate(java.lang.String template)
template - (String) A template file name.true if the template is a text template,
otherwise false.public static boolean isXmlTemplate(java.lang.String template)
template - (String) A template file name.true if the template is an xml template,
otherwise false.public static java.lang.String nocacheComponents(org.apache.velocity.VelocityContext data,
java.lang.String results)
data - (VelocityContext) The data used for template substitutions.results - (String) The processed template results. This should be
the processed results that are about to be sent to the browser.public static void setTemplateEncoder(int type,
org.apache.velocity.VelocityContext data)
type - (int) The type of template file being processed. Must
be one of the TYPE_* constants defined in the TemplateEncoder
class.data - (VelocityContext) The Velocity template data (the data for
substitutions).public static void setTemplateEncoder(java.lang.String template,
org.apache.velocity.VelocityContext data)
template - (String) The name of the template file being processed.data - (VelocityContext) The Velocity template data (the data for
substitutions).