org.webmacro.engine
Class StringTemplate

java.lang.Object
  extended byorg.webmacro.engine.WMTemplate
      extended byorg.webmacro.engine.StringTemplate
All Implemented Interfaces:
Macro, Template, Visitable

public class StringTemplate
extends WMTemplate

StringTemplate objects read their template data from a string. They do not need an encoding since strings are already converted to utf by java.

Author:
Brian Goetz

Field Summary
 
Fields inherited from class org.webmacro.engine.WMTemplate
_broker, _content, _log
 
Constructor Summary
StringTemplate(Broker broker, java.lang.String templateText)
          Instantiate a template.
StringTemplate(Broker broker, java.lang.String templateText, java.lang.String name)
          Instantiate a template.
 
Method Summary
 java.lang.String getName()
          Return a name for this template.
protected  java.io.Reader getReader()
          Get the stream the template should be read from.
 void setName(java.lang.String name)
          Set the name for this template.
 java.lang.String toString()
          Return a name for this template.
 
Methods inherited from class org.webmacro.engine.WMTemplate
accept, evaluate, getDefaultEncoding, getMacros, getParam, getParameters, getParser, parse, setParam, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringTemplate

public StringTemplate(Broker broker,
                      java.lang.String templateText)
Instantiate a template. Encoding information is not needed, as strings are already converted to utf in java.


StringTemplate

public StringTemplate(Broker broker,
                      java.lang.String templateText,
                      java.lang.String name)
Instantiate a template. Encoding information is not needed, as strings are already converted to utf in java.

Parameters:
name - name of string template to display in error messages and logs
Method Detail

setName

public void setName(java.lang.String name)
Description copied from class: WMTemplate
Set the name for this template. Default implementation does nothing.

Specified by:
setName in interface Template
Overrides:
setName in class WMTemplate

getName

public java.lang.String getName()
Description copied from class: WMTemplate
Return a name for this template. If not overridden, uses toString()

Specified by:
getName in interface Template
Overrides:
getName in class WMTemplate

getReader

protected java.io.Reader getReader()
                            throws java.io.IOException
Get the stream the template should be read from. Parse will call this method in order to locate a stream.

Specified by:
getReader in class WMTemplate
Throws:
java.io.IOException - if unable to read template

toString

public java.lang.String toString()
Return a name for this template. For example, if the template reads from a file you might want to mention which it is--will be used to produce error messages describing which template had a problem.

Specified by:
toString in class WMTemplate