public final class VelocityExtensions extends Object
VelocityExtensions provides methods for create velocity template engines and
templates.| Modifier and Type | Field and Description |
|---|---|
static String |
CLASSPATH_VALUE
The Constant for the value of property 'resource.loader'.
|
static String |
KEY_CLASSPATH_RESOURCE_LOADER_CLASS
The Constant for the key of property 'classpath.resource.loader.class'.
|
static String |
VELOCITY_TEMPLATE_FILE_EXTENSION
The Constant VELOCITY_TEMPLATE_FILE_EXTENSION.
|
| Constructor and Description |
|---|
VelocityExtensions() |
| Modifier and Type | Method and Description |
|---|---|
static org.apache.velocity.app.VelocityEngine |
getClasspathResourceLoaderVelocityEngine()
Gets the velocity template engine that load resources from the class path.
|
static org.apache.velocity.Template |
getTemplate(String templateAsString)
Gets a velocity template from the given String.
|
static org.apache.velocity.Template |
getTemplate(String templateAsString,
String templateName)
Gets a velocity template from the given String.
|
static org.apache.velocity.Template |
getTemplate(String templateAsString,
String templateName,
String encoding)
Gets a velocity template from the given String.
|
static org.apache.velocity.Template |
getTemplate(org.apache.velocity.app.VelocityEngine ve,
String path,
String templateName)
Gets the velocity template with default encoding "UTF-8".
|
static org.apache.velocity.Template |
getTemplate(org.apache.velocity.app.VelocityEngine ve,
String path,
String templateName,
String encoding)
Gets the velocity template.
|
static String |
merge(org.apache.velocity.VelocityContext context,
Properties velocityProperties,
String logTag,
String templateAsString)
Merges the given context with the given template that is a String object and returns the
result.
|
static String |
merge(org.apache.velocity.VelocityContext context,
String templateAsString)
Merges the given context with the given template that is a String object and returns the
result.
|
static String |
merge(org.apache.velocity.VelocityContext context,
String logTag,
String templateAsString)
Merges the given context with the given template that is a String object and returns the
result.
|
static void |
mergeToContext(org.apache.velocity.app.VelocityEngine ve,
org.apache.velocity.VelocityContext context,
String templateFileName,
String fileName)
Merges the given template file to the given file in the given velocity context.
|
static void |
mergeToContext(org.apache.velocity.app.VelocityEngine ve,
org.apache.velocity.VelocityContext context,
String path,
String templateName,
String fileName,
String encoding)
Merges the given template file to the given file in the given velocity context.
|
static org.apache.velocity.VelocityContext |
newVelocityContext()
Factory method for create a new
VelocityContext. |
public static final String CLASSPATH_VALUE
public static final String KEY_CLASSPATH_RESOURCE_LOADER_CLASS
public static final String VELOCITY_TEMPLATE_FILE_EXTENSION
public static org.apache.velocity.app.VelocityEngine getClasspathResourceLoaderVelocityEngine()
public static org.apache.velocity.Template getTemplate(String templateAsString) throws org.apache.velocity.runtime.parser.ParseException
templateAsString - the template as stringorg.apache.velocity.runtime.parser.ParseException - the parse exceptionpublic static org.apache.velocity.Template getTemplate(String templateAsString, String templateName) throws org.apache.velocity.runtime.parser.ParseException
templateAsString - the template as stringtemplateName - the template nameorg.apache.velocity.runtime.parser.ParseException - the parse exceptionpublic static org.apache.velocity.Template getTemplate(String templateAsString, String templateName, String encoding) throws org.apache.velocity.runtime.parser.ParseException
templateAsString - the template as stringtemplateName - the template nameencoding - the encodingorg.apache.velocity.runtime.parser.ParseException - the parse exceptionpublic static org.apache.velocity.Template getTemplate(org.apache.velocity.app.VelocityEngine ve,
String path,
String templateName)
ve - the velocity template enginepath - the pathtemplateName - the template namepublic static org.apache.velocity.Template getTemplate(org.apache.velocity.app.VelocityEngine ve,
String path,
String templateName,
String encoding)
ve - the velocity template enginepath - the pathtemplateName - the template nameencoding - the encodingpublic static String merge(org.apache.velocity.VelocityContext context, Properties velocityProperties, String logTag, String templateAsString)
context - the contextvelocityProperties - the velocity propertieslogTag - to be used as the template name for log messagestemplateAsString - the template as stringpublic static String merge(org.apache.velocity.VelocityContext context, String templateAsString)
context - the contexttemplateAsString - the template as stringpublic static String merge(org.apache.velocity.VelocityContext context, String logTag, String templateAsString)
context - the contextlogTag - to be used as the template name for log messagestemplateAsString - the template as stringpublic static void mergeToContext(org.apache.velocity.app.VelocityEngine ve,
org.apache.velocity.VelocityContext context,
String templateFileName,
String fileName)
throws IOException
ve - the velocity template enginecontext - the velocity contexttemplateFileName - the file name of the template filefileName - the file name that will be createdIOException - Signals that an I/O exception has occurred.public static void mergeToContext(org.apache.velocity.app.VelocityEngine ve,
org.apache.velocity.VelocityContext context,
String path,
String templateName,
String fileName,
String encoding)
throws IOException
ve - the velocity template enginecontext - the velocity contextpath - the pathtemplateName - the template namefileName - the file name that will be createdencoding - the encodingIOException - Signals that an I/O exception has occurred.public static org.apache.velocity.VelocityContext newVelocityContext()
VelocityContext.VelocityContextCopyright © 2015–2018 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.