Package com.saperion.rs.entityprovider
Class VelocityProvider
- java.lang.Object
-
- com.saperion.rs.entityprovider.VelocityProvider
-
public final class VelocityProvider extends java.lang.Object
This class creates and configures a static velocity instance.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
getContent(java.lang.String templateName, java.lang.String placeholderName, java.lang.Object contextObject)
Builds a String using the Velocity template engine with a template by the given templateName.static org.apache.velocity.Template
getTemplate(java.lang.String name)
Returns the Template by the given name if existing.static org.apache.velocity.VelocityContext
getVelocity()
Builds and returns an instance of the VelocityContext.
-
-
-
Method Detail
-
getVelocity
public static org.apache.velocity.VelocityContext getVelocity() throws java.lang.Exception
Builds and returns an instance of the VelocityContext.- Returns:
- an instance of the VelocityContext.
- Throws:
java.lang.Exception
- if an error occurs.
-
getTemplate
public static org.apache.velocity.Template getTemplate(java.lang.String name) throws java.lang.Exception
Returns the Template by the given name if existing.- Parameters:
name
- The filename of the template to get.- Returns:
- the required template instance.
- Throws:
java.lang.Exception
- if an error occurs or the template does not exist.
-
getContent
public static java.lang.String getContent(java.lang.String templateName, java.lang.String placeholderName, java.lang.Object contextObject) throws java.lang.Exception
Builds a String using the Velocity template engine with a template by the given templateName. The given contextObject will be put to the template context by the name of the given placeholderName.- Parameters:
templateName
- The name of the template to use.placeholderName
- The name of the placeholder to use.contextObject
- The context object to use.- Returns:
- the created String.
- Throws:
java.lang.Exception
- if an error occurs.
-
-