org.webmacro.engine
Class StreamTemplate
java.lang.Object
|
+--org.webmacro.engine.WMTemplate
|
+--org.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.
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
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 templatein
- 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 templatein
- input stream to read template fromencoding
- encoding of input stream- Throws:
java.io.IOException
- if encoding is unsupported
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.
- Overrides:
getReader
in class WMTemplate
- Following copied from class:
org.webmacro.engine.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.
- Overrides:
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()
- 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.
- Overrides:
setName
in class WMTemplate
main
public static void main(java.lang.String[] arg)
- Simple test