org.webmacro
Interface Template

All Superinterfaces:
Macro, Visitable
All Known Implementing Classes:
WMTemplate

public interface Template
extends Macro, Visitable


Method Summary
 java.lang.String getName()
           
 java.lang.Object getParam(java.lang.String name)
          A template may contain parameters, set by the #param directive.
 java.util.Map getParameters()
           
 void parse()
          Force the template to parse now.
 void setName(java.lang.String name)
           
 void setParam(java.lang.String key, java.lang.Object value)
          set a parameter.
 
Methods inherited from interface org.webmacro.Macro
evaluate, write
 
Methods inherited from interface org.webmacro.Visitable
accept
 

Method Detail

parse

public void parse()
           throws java.io.IOException,
                  TemplateException
Force the template to parse now. Normally the template will not parse the supplied file until the data is actually needed. However if you want to parse all of your templates at the start of the application to avoid incurring this call during an interactive session, you can call the parse() function at an appropriate time. Alternately, you could call this function to reparse a template if you know that it has changed.

Throws:
TemplateException - if the sytax was invalid and we could not recover
java.io.IOException - if we could not successfullly read the parseTool

getParam

public java.lang.Object getParam(java.lang.String name)
                          throws java.io.IOException,
                                 TemplateException
A template may contain parameters, set by the #param directive. These are statically evaluated during the parse phase of the template and shared between all users of the template. They are present so that the template can provide some meta information to its user as to what kind of data it expects to find in the Context, or other information about its use.

If the template has not already been parsed, it will be parsed. Thus this method may throw ParseException or IOException if there is some failure in accessing or parsing the template.

Throws:
java.io.IOException - if an error occurred reading the template
TemplateException - if an error occurred parsing the template

setParam

public void setParam(java.lang.String key,
                     java.lang.Object value)
set a parameter. Occasinally it's necessary to provide parameters externally. Although these might be considered of a different nature to those set by #param, they can be stored as such. One example might be the output character encoding which is needed when the template is played.

getParameters

public java.util.Map getParameters()

getName

public java.lang.String getName()

setName

public void setName(java.lang.String name)