|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfreemarker.template.AbstractTemplate
freemarker.template.UnparsedTemplate
public class UnparsedTemplate
An UnparsedTemplate
consists only of text. No logic
beyond simple outputting is performed.
You can pass the filename of the template to the constructor, in which case it is read immediately. Once read, the unparsed template is stored in an an character array for later use.
To process the unparsed template, call the process(freemarker.template.TemplateWriteableHashModel, java.io.Writer, freemarker.template.TemplateRuntimeHandler)
method,
which takes an optional tree of TemplateModel
objects as its
data model. The root node of the tree must be a TemplateWriteableHashModel
.
Any error messages will be included as HTML comments in the output.
To facilitate multithreading, UnparsedTemplate
objects are
immutable; if you need to recompile a template, you must make a new
UnparsedTemplate
object. In most cases, it will be sufficient
to let a TemplateCache
do this for you.
TemplateCache
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from interface freemarker.template.TemplateProcessor |
---|
TemplateProcessor.ExitStatus |
Field Summary | |
---|---|
protected char[] |
templateText
The unparsed template text. |
Fields inherited from class freemarker.template.AbstractTemplate |
---|
cache |
Constructor Summary | |
---|---|
UnparsedTemplate()
Constructs an empty unparsed template. |
|
UnparsedTemplate(java.io.File file)
Deprecated. use the InputSource contructor to supply
source streams to the template compiler |
|
UnparsedTemplate(InputSource source)
Constructs an unparsed template by compiling it from an InputSource. |
|
UnparsedTemplate(java.io.InputStream stream)
Deprecated. use the InputSource contructor to supply
source streams to the template compiler |
|
UnparsedTemplate(java.io.Reader stream)
Deprecated. use the InputSource contructor to supply
source streams to the template compiler |
|
UnparsedTemplate(java.lang.String filePath)
Deprecated. use the InputSource contructor to supply
source streams to the template compiler |
Method Summary | |
---|---|
void |
compile(InputSource source)
Compiles the template from an InputSource . |
boolean |
equals(java.lang.Object o)
Tests this object for equality with the given object. |
int |
hashCode()
Retrieve the hash code for this object |
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 . |
TemplateProcessor.ExitStatus |
process(TemplateWriteableHashModel modelRoot,
java.io.Writer out,
TemplateRuntimeHandler eventHandler)
Processes the contents of this UnparsedTemplate and
outputs the resulting text to a Writer . |
void |
process(java.io.Writer out)
Processes the template, using an empty data model, and outputs the resulting text to a Writer . |
java.lang.String |
toString()
Return the String value of this object |
Methods inherited from class freemarker.template.AbstractTemplate |
---|
clone, compileFromFile, compileFromFile, compileFromStream, compileFromStream, compileFromStream, getCache, setCache |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected char[] templateText
Constructor Detail |
---|
public UnparsedTemplate()
public UnparsedTemplate(InputSource source) throws java.io.IOException
compile()
.
source
- the source of the template file
to be compiled.
java.io.IOException
@Deprecated public UnparsedTemplate(java.lang.String filePath) throws java.io.IOException
InputSource
contructor to supply
source streams to the template compiler
compileFromFile()
.
filePath
- the absolute path of the template file
to be compiled.
java.io.IOException
@Deprecated public UnparsedTemplate(java.io.File file) throws java.io.IOException
InputSource
contructor to supply
source streams to the template compiler
compileFromFile()
.
file
- a File
representing the template file
to be compiled.
java.io.IOException
@Deprecated public UnparsedTemplate(java.io.InputStream stream) throws java.io.IOException
InputSource
contructor to supply
source streams to the template compiler
InputStream
. Calls compileFromStream()
.
stream
- an InputStream
from which the
template can be read.
java.io.IOException
@Deprecated public UnparsedTemplate(java.io.Reader stream) throws java.io.IOException
InputSource
contructor to supply
source streams to the template compiler
Reader
. Calls compileFromStream()
.
stream
- a Reader
from which the
template can be read.
java.io.IOException
Method Detail |
---|
public void compile(InputSource source) throws java.io.IOException, java.lang.IllegalArgumentException
InputSource
. If the template
has already been compiled, this method does nothing. Calls
AbstractTemplate.compileFromStream(java.io.Reader)
to perform parsing.
compile
in interface Compileable
compile
in class AbstractTemplate
source
- an InputSource
from which the
template can be read.
java.io.IOException
java.lang.IllegalArgumentException
public TemplateProcessor.ExitStatus process(TemplateWriteableHashModel modelRoot, java.io.Writer out, TemplateRuntimeHandler eventHandler) throws java.io.IOException
UnparsedTemplate
and
outputs the resulting text to a Writer
.
process
in interface TemplateProcessor
process
in class AbstractTemplate
modelRoot
- 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 with the Writer
during processingpublic void process(TemplateWriteableHashModel modelRoot, java.io.Writer out) throws java.io.IOException
Writer
.
process
in class AbstractTemplate
modelRoot
- the root node of the data model.out
- a Writer
to output the text to.
java.io.IOException
public void process(java.io.Writer out) throws java.io.IOException
Writer
.
process
in class AbstractTemplate
out
- a Writer
to output the text to.
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- the object to be compared against
true
if the two objects are equal, otherwise
false
public int hashCode()
hashCode
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |