net.sf.zekr.engine.template
Class TemplateEngine

java.lang.Object
  extended by net.sf.zekr.engine.template.TemplateEngine

public class TemplateEngine
extends java.lang.Object

An adapter class for velocity template engine.
This class is not singleton due to thread-safety issues. A call to getInstance() simply returns a new instance.

Since:
Zekr 1.0
Author:
Mohsen Saboorian

Method Summary
static TemplateEngine getInstance()
           
 org.apache.velocity.Template getTemplate(java.lang.String name)
           
 java.lang.String getUpdated(java.lang.String name)
           
 void put(java.lang.String key, java.lang.Object value)
          Add a key-value pair to the template engine context.
 void putAll(java.util.Map map)
          Add a collection of key-value pairs to the template engine context.
 void putWrappedString(java.lang.String key, java.lang.String value)
          Add a key-value pair to the template engine context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static TemplateEngine getInstance()
Returns:
a new template engine instance.

getTemplate

public org.apache.velocity.Template getTemplate(java.lang.String name)
                                         throws java.lang.Exception
Parameters:
name - The file name of the desired template
Returns:
The associated Template object
Throws:
java.lang.Exception

put

public void put(java.lang.String key,
                java.lang.Object value)
Add a key-value pair to the template engine context.

Parameters:
key -
value -

putWrappedString

public void putWrappedString(java.lang.String key,
                             java.lang.String value)
Add a key-value pair to the template engine context. value should be of type String.

Parameters:
key -
value -

putAll

public void putAll(java.util.Map map)
Add a collection of key-value pairs to the template engine context. Keys should be of type String.


getUpdated

public java.lang.String getUpdated(java.lang.String name)
                            throws java.lang.Exception
Parameters:
name - the file name of the desired template
Returns:
the result String after the context map is merged (applied) into the source template file.
Throws:
java.lang.Exception