|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object freemarker.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 | |
---|---|
protected |
AbstractTemplate()
|
|
AbstractTemplate(java.io.Reader reader)
Constructs a template by compiling it from a Reader . |
|
AbstractTemplate(java.io.Reader reader,
Cache cache)
Constructs a template by compiling it from a Reader . |
Method Summary | |
---|---|
java.lang.Object |
clone()
Clones the current template. |
protected abstract void |
compile(java.io.Reader reader)
Compiles the template from a Reader . |
Cache |
getCache()
Retrieve the Cache that this object
is stored in. |
protected static java.lang.String |
getTemplateText(java.io.Reader reader)
Takes the given Reader, reads it until the end of the stream, and accumulates the contents in a String. |
abstract TemplateProcessor.ExitStatus |
process(TemplateProcessorParameters p)
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(TemplateWriteableHashModel modelRoot,
java.io.Writer out)
Processes the template, using data from a template model, 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 . |
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 |
---|
protected AbstractTemplate()
public AbstractTemplate(java.io.Reader reader) throws java.io.IOException, java.lang.IllegalArgumentException
Reader
.
reader
- a Reader
from which the
template can be read.
java.io.IOException
java.lang.IllegalArgumentException
public AbstractTemplate(java.io.Reader reader, Cache cache) throws java.io.IOException, java.lang.IllegalArgumentException
Reader
.
reader
- a Reader
from which the
template can be read.
java.io.IOException
java.lang.IllegalArgumentException
Method Detail |
---|
protected abstract void compile(java.io.Reader reader) throws java.io.IOException, java.lang.IllegalArgumentException
Reader
. If the template
has already been compiled, this method does nothing.
reader
- an Reader
from which the
template can be read.
java.io.IOException
java.lang.IllegalArgumentException
public Cache getCache()
Cache
that this object
is stored in.
getCache
in interface Cacheable
Cache
that this template belongs to.public java.lang.Object clone()
Clones the current template.
Cloning is used in Cache
s,
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 class java.lang.Object
public abstract TemplateProcessor.ExitStatus process(TemplateProcessorParameters p) throws java.io.IOException
TemplateEventAdapter
, and outputs
the resulting text to a Writer
.
process
in interface TemplateProcessor
p
- template processing parameters
java.io.IOException
- an IO error occurred during processingpublic 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
protected static java.lang.String getTemplateText(java.io.Reader reader) throws java.io.IOException
reader
- the reader to be turned into a String
java.io.IOException
- something went wrong while processing the stream
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |