|
|||||||||
| 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| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface freemarker.template.TemplateProcessor |
|---|
TemplateProcessor.ExitStatus |
| Field Summary | |
|---|---|
protected Cache |
cache
The Cache to which this template belongs (if any). |
| Constructor Summary | |
|---|---|
AbstractTemplate()
Constructs an empty unparsed template. |
|
AbstractTemplate(java.io.File file)
Constructs an unparsed template by compiling it from a file. |
|
AbstractTemplate(java.io.InputStream stream)
Constructs an unparsed template by compiling it from an InputStream. |
|
AbstractTemplate(java.io.Reader stream)
Constructs an unparsed template by compiling it from a Reader. |
|
AbstractTemplate(java.lang.String filePath)
Constructs an unparsed template by compiling it from a file. |
|
| Method Summary | |
|---|---|
java.lang.Object |
clone()
Clones the current template. |
void |
compileFromFile(java.io.File file)
Reads an unparsed template from a file, by getting the file's FileInputStream and using it to call
compileFromStream(java.io.InputStream),
using the platform's default character encoding. |
void |
compileFromFile(java.lang.String filePath)
Reads an unparsed template from a file, by getting the file's FileInputStream and using it to call
compileFromStream(java.io.InputStream),
using the platform's default character encoding. |
void |
compileFromStream(java.io.InputStream stream)
Reads the unparsed template from an InputStream, using the
platform's default character encoding. |
void |
compileFromStream(java.io.InputStream stream,
java.lang.String encoding)
Compiles the template from an InputStream, using the
specified character encoding. |
abstract void |
compileFromStream(java.io.Reader stream)
Compiles the template from a Reader. |
Cache |
getCache()
Retrieve the Cache that this object is stored in. |
abstract void |
process(TemplateModelRoot modelRoot,
java.io.Writer out)
Processes the template, using data from a template model, and outputs the resulting text to a Writer. |
abstract TemplateProcessor.ExitStatus |
process(TemplateModelRoot 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(java.lang.String filePath)
throws java.io.IOException
compileFromFile(String).
filePath - the absolute path of the template file
to be compiled.
java.io.IOException
public AbstractTemplate(java.io.File file)
throws java.io.IOException
compileFromFile(java.io.File).
file - a File representing the
template file to be compiled.
java.io.IOException
public AbstractTemplate(java.io.InputStream stream)
throws java.io.IOException
InputStream. Calls
compileFromStream(java.io.InputStream).
stream - an InputStream from which the
template can be read.
java.io.IOException
public AbstractTemplate(java.io.Reader stream)
throws java.io.IOException
Reader. Calls
compileFromStream(java.io.InputStream).
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
FileInputStream and using it to call
compileFromStream(java.io.InputStream),
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
FileInputStream and using it to call
compileFromStream(java.io.InputStream),
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
InputStream, using the
platform's default character encoding. If the template has
already been compiled, this method does nothing. Calls
compileFromStream(java.io.Reader) 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
InputStream, using the
specified character encoding. If the template has
already been compiled, this method does nothing. Calls
compileFromStream(java.io.Reader) 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 abstract void compileFromStream(java.io.Reader stream)
throws java.io.IOException
Reader. If the template
has already been compiled, this method does nothing.
stream - an Reader from which the
template can be read.
java.io.IOExceptionpublic 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 TemplateProcessor.ExitStatus process(TemplateModelRoot 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(TemplateModelRoot 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 | ||||||||