org.webmacro
Interface Template
- All Superinterfaces:
- Macro, Visitable
- All Known Implementing Classes:
- WMTemplate
- public interface Template
- extends Macro, Visitable
Method Summary |
java.util.Map |
getMacros()
Get a Map containing all #macros defined for this template. |
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. |
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. Once a template has
been parsed, subsequent calls to this method do not have an effect. If
you want to reparse the template, because you know, it has been changed, you
have to create a new Template object and leave this one to the garbage collector.
- Throws:
TemplateException
- if the sytax was invalid and we could not recoverjava.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 templateTemplateException
- 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)
getMacros
public java.util.Map getMacros()
- Get a Map containing all #macros defined for this template.
The returned Map can be
null
if this Template
does not contain Macros, or if this Template has not been
parsed yet.
- Returns:
-