net.sourceforge.jstags.utils.template
Class TemplateUtils

java.lang.Object
  extended by net.sourceforge.jstags.utils.template.TemplateUtils

public class TemplateUtils
extends java.lang.Object

This class contains a set of methods to work with templates.

Every tag included in the library will generate a chunk of JavaScript code. Such code is generated by means of templates.

A template is just a text file that contains a collection of %VAR_NAME% elements representing variables to be replaced with the data used in every tag instance. Every time a tag is created, the JavaScript piece of code neeeded will be created. First of all, the template associated with the tag created will be retrieve. After that, the values of every %VAR_NAME% in that template will be replaced with the ones set in the tag. The code generated will contain the necessary logic to insert in the page

Since:
1.0
Author:
sschz@users.sourceforge.net

Field Summary
private static org.apache.log4j.Logger logger
          Logger for this class
 
Constructor Summary
TemplateUtils()
           
 
Method Summary
static java.lang.String getTemplateAsString(java.lang.String templateFileName)
          Locates templateFileName in TemplateConstants.TEMPLATES_FOLDER and returns its content
static java.lang.String replaceValuesInTemplate(java.lang.String template, java.util.Map<java.lang.String,java.lang.String> nameValuePairs)
          Given a template content, it replaces the variables in it returning the new content
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final org.apache.log4j.Logger logger
Logger for this class

Constructor Detail

TemplateUtils

public TemplateUtils()
Method Detail

getTemplateAsString

public static java.lang.String getTemplateAsString(java.lang.String templateFileName)
                                            throws TemplateException
Locates templateFileName in TemplateConstants.TEMPLATES_FOLDER and returns its content

Parameters:
templateFileName - name of the template to be retrieved
Returns:
a String with the templateFileName contents
Throws:
TemplateException

replaceValuesInTemplate

public static java.lang.String replaceValuesInTemplate(java.lang.String template,
                                                       java.util.Map<java.lang.String,java.lang.String> nameValuePairs)
Given a template content, it replaces the variables in it returning the new content

Parameters:
template - content to be used as a template
nameValuePairs - Map of (String, String) pairs representing the data to be replaced in the template. Every Map.Entry represents a variable name and its value
Returns:


Copyright © 2007. All Rights Reserved.