public class VelocityTemplateEngine extends Object
Velocity tools supported (See http://velocity.apache.org/tools/devel/generic.html}:
Examples:$dateTool:$dateTool.get('yyyy-M-d H:m:s') -> 2003-10-19 21:54:50
$dateComparisonTool:$dateComparisonTool.difference('2005-07-04','2007-02-15').abbr -> 1 yr
$mathTool:$mathTool.toNumber($value) -> Converts java.lang.String $value to a java.lang.Number
$numberTool:$numberTool.currency($myNumber) -> $13.55
$sortTool:$sorter.sort($collection, "name:asc") -> Sorts $collection with property 'name' in ascending order
Constructor and Description |
---|
VelocityTemplateEngine()
Constructs a velocity template engine.
|
VelocityTemplateEngine(Map<String,Object> config)
Constructs a velocity template engine with velocity tools configurations.
|
Modifier and Type | Method and Description |
---|---|
String |
evaluate(Map<String,Object> mapContext,
Reader template)
Evaluates a template with a map of objects.
|
String |
evaluate(Map<String,Object> contextMap,
String template)
Evaluates a template with a map of objects.
|
void |
setLogFile()
Sets the Velocity Log File to the default location.
|
void |
setLogFile(String logfile)
Sets the Velocity Log File.
|
void |
setLogging(boolean enableLogging)
Sets logging on or off.
|
public VelocityTemplateEngine()
public VelocityTemplateEngine(Map<String,Object> config)
config
- Velocity tools configurationspublic void setLogging(boolean enableLogging)
enableLogging
- True enables logging; false disables loggingpublic void setLogFile()
{catalina.base}/velocity.log
or target/velocity.log
.public void setLogFile(String logfile)
logFile
- the path and filename for velocity loggingpublic String evaluate(Map<String,Object> contextMap, String template) throws org.apache.velocity.exception.VelocityException
contextMap
can
be null if no keys/tokens are referenced in the template
contextMap
- Map of objects to be used in the templatetemplate
- Velocity Templateorg.apache.velocity.exception.VelocityException
public String evaluate(Map<String,Object> mapContext, Reader template) throws org.apache.velocity.exception.VelocityException
mapContext
- Map of Objects to be used in the templatetemplate
- Velocity Templateorg.apache.velocity.exception.VelocityException
Copyright © 2005–2015 The Kuali Foundation. All rights reserved.