org.webmacro.engine
Class FileTemplate

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

public class FileTemplate
extends WMTemplate

FileTemplate objects read their template data from a text file.


Field Summary
 
Fields inherited from class org.webmacro.engine.WMTemplate
_broker, _content, _log
 
Constructor Summary
FileTemplate(Broker broker, java.io.File templateFile)
          Instantiate a template based on the specified file using the default encoding from WebMacro.properties (TemplateEncoding), if not specified there then the UTF-8 encoding.
FileTemplate(Broker broker, java.io.File tmplFile, java.lang.String encoding)
          Instantiate a template based on the specified file using the specified encoding to read the template.
FileTemplate(Broker broker, java.lang.String filename)
          Instantiate a template based on the specified filename using the default encoding from WebMacro.properties (TemplateEncoding), or if not specified there then the UTF-8 encoding.
 
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.
 java.lang.String toString()
          Return a name for this template.
 
Methods inherited from class org.webmacro.engine.WMTemplate
accept, evaluateAsBytes, evaluateAsString, getDefaultEncoding, getMacros, getParam, getParameters, getParser, parse, setName, setParam, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileTemplate

public FileTemplate(Broker broker,
                    java.lang.String filename)
Instantiate a template based on the specified filename using the default encoding from WebMacro.properties (TemplateEncoding), or if not specified there then the UTF-8 encoding.


FileTemplate

public FileTemplate(Broker broker,
                    java.io.File templateFile)
Instantiate a template based on the specified file using the default encoding from WebMacro.properties (TemplateEncoding), if not specified there then the UTF-8 encoding.


FileTemplate

public FileTemplate(Broker broker,
                    java.io.File tmplFile,
                    java.lang.String encoding)
Instantiate a template based on the specified file using the specified encoding to read the template.

Method Detail

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

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


Copyright © 1999-2006 WebMacro. All Rights Reserved.