Class VelocityTemplateEngine
java.lang.Object
org.kuali.rice.krms.impl.repository.language.VelocityTemplateEngine
Velocity template engine.
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 Summary
ConstructorsConstructorDescriptionConstructs a velocity template engine.VelocityTemplateEngine(Map<String, Object> config) Constructs a velocity template engine with velocity tools configurations. -
Method Summary
Modifier and TypeMethodDescriptionEvaluates a template with a map of objects.Evaluates a template with a map of objects.voidSets the Velocity Log File to the default location.voidsetLogFile(String logfile) Sets the Velocity Log File.voidsetLogging(boolean enableLogging) Sets logging on or off.
-
Constructor Details
-
VelocityTemplateEngine
public VelocityTemplateEngine()Constructs a velocity template engine. -
VelocityTemplateEngine
Constructs a velocity template engine with velocity tools configurations.- Parameters:
config- Velocity tools configurations
-
-
Method Details
-
setLogging
public void setLogging(boolean enableLogging) Sets logging on or off.- Parameters:
enableLogging- True enables logging; false disables logging
-
setLogFile
public void setLogFile()Sets the Velocity Log File to the default location. Either{catalina.base}/velocity.logortarget/velocity.log. -
setLogFile
Sets the Velocity Log File.- Parameters:
logFile- the path and filename for velocity logging
-
evaluate
public String evaluate(Map<String, Object> contextMap, String template) throws org.apache.velocity.exception.VelocityExceptionEvaluates a template with a map of objects.contextMapcan be null if no keys/tokens are referenced in thetemplate- Parameters:
contextMap- Map of objects to be used in the templatetemplate- Velocity Template- Returns:
- Evaluated template
- Throws:
org.apache.velocity.exception.VelocityException
-
evaluate
public String evaluate(Map<String, Object> mapContext, Reader template) throws org.apache.velocity.exception.VelocityExceptionEvaluates a template with a map of objects.- Parameters:
mapContext- Map of Objects to be used in the templatetemplate- Velocity Template- Returns:
- Evaluated template
- Throws:
org.apache.velocity.exception.VelocityException
-