|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectfreemarker.template.AbstractTemplate
public abstract class AbstractTemplate
A base class from which Template implementations are subclassed. This
class implements all the interfaces required, and provides some of the basic
machinery required to compile and cache a Template.
Template,
UnparsedTemplate| Field Summary | |
|---|---|
protected Cache |
cache
The Cache to which this template belongs (if any). |
| Fields inherited from interface freemarker.template.TemplateProcessor |
|---|
BREAK, EXIT, OK, UNCOMPILED_TEMPLATE |
| Constructor Summary | |
|---|---|
AbstractTemplate()
Constructs an empty template. |
|
AbstractTemplate(java.io.File file)
Deprecated. use the InputSource contructor to supply source
streams to the template compiler |
|
AbstractTemplate(InputSource source)
Constructs a template by compiling it from an InputSource. |
|
AbstractTemplate(java.io.InputStream stream)
Deprecated. use the InputSource contructor to supply source
streams to the template compiler |
|
AbstractTemplate(java.io.Reader stream)
Deprecated. use the InputSource contructor to supply source
streams to the template compiler |
|
AbstractTemplate(java.lang.String filePath)
Deprecated. use the InputSource contructor to supply source
streams to the template compiler |
|
| Method Summary | |
|---|---|
java.lang.Object |
clone()
Clones the current template. |
abstract void |
compile(InputSource source)
Compiles the template from an InputSource. |
void |
compileFromFile(java.io.File file)
Deprecated. use the compile(freemarker.template.InputSource) method to supply source streams to
the template compiler |
void |
compileFromFile(java.lang.String filePath)
Deprecated. use the compile(freemarker.template.InputSource) method to supply source streams to
the template compiler |
void |
compileFromStream(java.io.InputStream stream)
Deprecated. use the compile(freemarker.template.InputSource) method to supply source streams to
the template compiler |
void |
compileFromStream(java.io.InputStream stream,
java.lang.String encoding)
Deprecated. use the compile(freemarker.template.InputSource) method to supply source streams to
the template compiler |
void |
compileFromStream(java.io.Reader stream)
Deprecated. use the compile(freemarker.template.InputSource) method to supply source streams to
the template compiler |
Cache |
getCache()
Retrieve the Cache that this object is
stored in. |
abstract void |
process(TemplateWriteableHashModel modelRoot,
java.io.Writer out)
Processes the template, using data from a template model, and outputs the resulting text to a Writer. |
abstract short |
process(TemplateWriteableHashModel modelRoot,
java.io.Writer out,
TemplateRuntimeHandler eventHandler)
Processes the template, using data from the template model, writing any events to the TemplateEventAdapter, and outputs the
resulting text to a Writer. |
abstract void |
process(java.io.Writer out)
Processes the template, using an empty data model, and outputs the resulting text to a Writer. |
void |
setCache(Cache cache)
Sets the Cache that this object is
stored in. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Cache cache
Cache to which this template belongs (if any).
| Constructor Detail |
|---|
public AbstractTemplate()
public AbstractTemplate(InputSource source)
throws java.io.IOException,
java.lang.IllegalArgumentException
InputSource.
Calls compile(InputSource).
source - an InputSource from which the template can be
read.
java.io.IOException
java.lang.IllegalArgumentException
public AbstractTemplate(java.lang.String filePath)
throws java.io.IOException
InputSource contructor to supply source
streams to the template compiler
compile(InputSource).
filePath - the absolute path of the template file to be compiled.
java.io.IOException
public AbstractTemplate(java.io.File file)
throws java.io.IOException
InputSource contructor to supply source
streams to the template compiler
compile(InputSource).
file - a File representing the template file to be
compiled.
java.io.IOException
public AbstractTemplate(java.io.InputStream stream)
throws java.io.IOException
InputSource contructor to supply source
streams to the template compiler
InputStream.
Calls compile(InputSource).
stream - an InputStream from which the template can be
read.
java.io.IOException
public AbstractTemplate(java.io.Reader stream)
throws java.io.IOException
InputSource contructor to supply source
streams to the template compiler
Reader. Calls
compile(InputSource).
stream - a Reader from which the template can be read.
java.io.IOException| Method Detail |
|---|
public void compileFromFile(java.lang.String filePath)
throws java.io.IOException
compile(freemarker.template.InputSource) method to supply source streams to
the template compiler
FileInputStream and using it to call
compile(InputSource), using the platform's default character
encoding.
filePath - the absolute path of the template file to be compiled.
java.io.IOException
public void compileFromFile(java.io.File file)
throws java.io.IOException
compile(freemarker.template.InputSource) method to supply source streams to
the template compiler
FileInputStream and using it to call
compile(InputSource), using the platform's default character
encoding.
file - a File representing the template file to be
compiled.
java.io.IOException
public void compileFromStream(java.io.InputStream stream)
throws java.io.IOException
compile(freemarker.template.InputSource) method to supply source streams to
the template compiler
InputStream, using the platform's
default character encoding. If the template has already been compiled,
this method does nothing. Calls compile(InputSource) to perform
parsing.
compileFromStream in interface Compileablestream - an InputStream from which the template can be
read.
java.io.IOException
public void compileFromStream(java.io.InputStream stream,
java.lang.String encoding)
throws java.io.IOException
compile(freemarker.template.InputSource) method to supply source streams to
the template compiler
InputStream, using the
specified character encoding. If the template has already been compiled,
this method does nothing. Calls compile(InputSource) to perform
parsing.
compileFromStream in interface Compileablestream - an InputStream from which the template can be
read.encoding - the character encoding of the input stream
java.io.IOException
public void compileFromStream(java.io.Reader stream)
throws java.io.IOException
compile(freemarker.template.InputSource) method to supply source streams to
the template compiler
Reader. If the template has
already been compiled, this method does nothing. Calls
compile(InputSource) to perform parsing.
stream - an Reader from which the template can be read.
java.io.IOException
public abstract void compile(InputSource source)
throws java.io.IOException,
java.lang.IllegalArgumentException
InputSource. If the template
has already been compiled, this method does nothing.
compile in interface Compileablesource - an InputSource from which the template can be
read.
java.io.IOException
java.lang.IllegalArgumentExceptionpublic void setCache(Cache cache)
Cache that this object is
stored in.
setCache in interface Cacheablecache - the Cache that this template belongs to.public Cache getCache()
Cache that this object is
stored in.
getCache in interface CacheableCache that this template belongs to.public java.lang.Object clone()
Clones the current template.
Cloning is used in Caches, whenever we
need to create a new template: rather than simply creating a new
Template, we ask a TemplateRegistry to
create one for us. TemplateRegistry uses the clone function
to take an existing template, copy it, and return the copy to the cache,
where it is then populated.
clone in interface Cacheableclone in class java.lang.Object
public abstract short process(TemplateWriteableHashModel modelRoot,
java.io.Writer out,
TemplateRuntimeHandler eventHandler)
throws java.io.IOException
TemplateEventAdapter, and outputs the
resulting text to a Writer.
process in interface TemplateProcessormodelRoot - the root node of the data model.out - a Writer to send the output to.eventHandler - a TemplateEventAdapter for handling any events
that occur during processing.
java.io.IOException - an IO error occurred during processing
public abstract void process(TemplateWriteableHashModel modelRoot,
java.io.Writer out)
throws java.io.IOException
Writer.
modelRoot - the root node of the data model. If null, an
empty data model is used.out - a Writer to output the text to.
java.io.IOException
public abstract void process(java.io.Writer out)
throws java.io.IOException
Writer.
out - a Writer to output the text to.
java.io.IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||