org.webmacro.engine
Class StreamTemplate

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

public class StreamTemplate
extends WMTemplate

StreamTempaltes are constructed with a stream from which they read their data. They can only read the stream once, and after that will throw an exception. Mostly they are useful for testing WebMacro directives on the command line, since a main() is provided which reads the template on standard input.


Field Summary
 
Fields inherited from class org.webmacro.engine.WMTemplate
_broker, _content, _log
 
Constructor Summary
StreamTemplate(Broker broker, java.io.InputStream in)
          Instantiate a template based on the specified stream Will use webmacro's default encoding.
StreamTemplate(Broker broker, java.io.InputStream in, java.lang.String encoding)
          Instantiate a template based on the specified stream If encoding is null, webmacro's default encoding will be used.
StreamTemplate(Broker broker, java.io.Reader inStream)
          Instantiate a template based on the specified stream
 
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.
static void main(java.lang.String[] arg)
          Simple test
 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

StreamTemplate

public StreamTemplate(Broker broker,
                      java.io.Reader inStream)
Instantiate a template based on the specified stream


StreamTemplate

public StreamTemplate(Broker broker,
                      java.io.InputStream in)
               throws java.io.IOException
Instantiate a template based on the specified stream Will use webmacro's default encoding.

Parameters:
broker - broker for this template
in - input stream to read template from
Throws:
java.io.IOException - if default encoding is unsupported

StreamTemplate

public StreamTemplate(Broker broker,
                      java.io.InputStream in,
                      java.lang.String encoding)
               throws java.io.IOException
Instantiate a template based on the specified stream If encoding is null, webmacro's default encoding will be used.

Parameters:
broker - broker for this template
in - input stream to read template from
encoding - encoding of input stream
Throws:
java.io.IOException - if encoding is unsupported
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

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

main

public static void main(java.lang.String[] arg)
Simple test