Package org.openxava.util
Class SimpleTemplater
- java.lang.Object
-
- org.openxava.util.SimpleTemplater
-
public class SimpleTemplater extends java.lang.Object
To process simple HTML templates. -- Usage -- SimpleTemplater.getInstance().buildOutputUsingStringTemplate(template, parameters); Replaces ${parameter_name} in the template by its value found in the (Map)parameters. -- Syntax -- Simple blocks can be processed. Blocks are surrounded by and $$for(parameter_name) will loop over the items of parameter_name of type Collection - Author:
- Laurent Wibaux
-
-
Constructor Summary
Constructors Constructor Description SimpleTemplater(boolean templateIsHTML)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
buildOutputUsingInputStreamTemplate(java.io.InputStream templateIS, java.util.Map<java.lang.String,java.lang.Object> parameters)
Returns the template with all fields replaced by their valuesjava.lang.String
buildOutputUsingResourceTemplate(java.lang.String templateName, java.util.Map<java.lang.String,java.lang.Object> parameters)
Returns the template with all fields replaced by their valuesjava.lang.String
buildOutputUsingStringTemplate(java.lang.String template, java.util.Map<java.lang.String,java.lang.Object> parameters)
Returns the template with all fields replaced by their valuesstatic SimpleTemplater
getInstance()
Returns an instance of SimpleTemplater which will not deal with HTMLstatic SimpleTemplater
getInstance(boolean templateIsHTML)
Returns an instance of SimpleTemplater which will or will not deal with HTMLstatic java.util.Collection<java.util.Map<java.lang.String,java.lang.Object>>
getSequence(java.lang.String indexName, int from, int to)
Returns a sequence of numbers going from 'from' to 'to', using indexName as key in the map this sequence can then be added to a Mapboolean
templateNameIsHTML(java.lang.String templateName)
-
-
-
Method Detail
-
getInstance
public static SimpleTemplater getInstance()
Returns an instance of SimpleTemplater which will not deal with HTML- Returns:
- SimpleTemplater
-
getInstance
public static SimpleTemplater getInstance(boolean templateIsHTML)
Returns an instance of SimpleTemplater which will or will not deal with HTML- Parameters:
templateIsHTML
- - set to true if the template that will be fed is HTML- Returns:
- SimpleTemplater
-
getSequence
public static java.util.Collection<java.util.Map<java.lang.String,java.lang.Object>> getSequence(java.lang.String indexName, int from, int to)
Returns a sequence of numbers going from 'from' to 'to', using indexName as key in the map this sequence can then be added to a Map- Parameters:
indexName
- - the name of the parameterfrom
- - start of the sequenceto
- - end of the sequence- Returns:
- a list of Map
-
buildOutputUsingResourceTemplate
public java.lang.String buildOutputUsingResourceTemplate(java.lang.String templateName, java.util.Map<java.lang.String,java.lang.Object> parameters)
Returns the template with all fields replaced by their values- Parameters:
templateName
- - the name of the template to be found in the code archiveparameters
- - Mapof the parameters - Returns:
- the result of the processing
- Throws:
SimpleTemplaterException
- - in case of an error in the template or in the passed parameters
-
buildOutputUsingInputStreamTemplate
public java.lang.String buildOutputUsingInputStreamTemplate(java.io.InputStream templateIS, java.util.Map<java.lang.String,java.lang.Object> parameters)
Returns the template with all fields replaced by their values- Parameters:
templateIS
- - an InputStreamparameters
- - Mapof the parameters - Returns:
- the result of the processing
- Throws:
SimpleTemplaterException
- - in case of an error in the template or in the passed parameters
-
buildOutputUsingStringTemplate
public java.lang.String buildOutputUsingStringTemplate(java.lang.String template, java.util.Map<java.lang.String,java.lang.Object> parameters)
Returns the template with all fields replaced by their values- Parameters:
template
- - a String containing the templateparameters
- - Mapof the parameters - Returns:
- the result of the processing
- Throws:
SimpleTemplaterException
- - in case of an error in the template or in the passed parameters
-
templateNameIsHTML
public boolean templateNameIsHTML(java.lang.String templateName)
-
-