|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--freemarker.template.BinaryData
An application or servlet can instantiate a BinaryData
to retrieve a binary file.
You can pass the filename of the binary file to the constructor, in which case it is read in immediately.
To retrive the binary data, call the process(java.io.OutputStream)
method.
To facilitate multithreading, BinaryData
objects are
immutable; if you need to reload a binary file, you must make a new
BinaryData
object. In most cases, it will be sufficient
to let a Cache
do this for you.
FileTemplateCache
, Serialized FormField Summary | |
protected Cache |
cache
The cache to which this binary data object belongs (if any). |
protected byte[] |
dataArray
The binary data held by this object. |
Constructor Summary | |
BinaryData()
Constructs an empty binary object. |
|
BinaryData(BinaryData data)
Clones an existing BinaryData instance. |
|
BinaryData(java.io.File file)
Constructs a BinaryData object by compiling it from a file. |
|
BinaryData(java.io.InputStream stream)
Constructs a template by compiling it from an InputStream . |
|
BinaryData(java.lang.String filePath)
Constructs a binary data object by compiling it from a file. |
Method Summary | |
java.lang.Object |
clone()
Clones the current BinaryData object. |
void |
compileFromFile(java.io.File file)
Reads and compiles a template from a file, by getting the file's FileInputStream and using it to call compileFromStream(), using the platform's default character encoding. |
void |
compileFromFile(java.lang.String filePath)
Reads and compiles a template from a file, by getting the file's FileInputStream and using it to call compileFromStream(), using the platform's default character encoding. |
void |
compileFromStream(java.io.InputStream stream)
Compiles the 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. |
Cache |
getCache()
Retrieve the Cache that this object is stored in. |
void |
process(java.io.OutputStream out)
Processes the binary data file, and output the resulting binary data to an OutputStream. |
void |
setCache(Cache cache)
Sets the Cache that this object is stored in. |
java.lang.String |
toString()
Returns a string representation of the object. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected byte[] dataArray
protected transient Cache cache
Constructor Detail |
public BinaryData()
public BinaryData(java.lang.String filePath) throws java.io.IOException
compileFromFile()
.filePath
- the absolute path of the binary file
to be compiled.public BinaryData(java.io.File file) throws java.io.IOException
compileFromFile()
.file
- a File
representing the
binary file to be compiled.public BinaryData(java.io.InputStream stream) throws java.io.IOException
InputStream
. Calls compileFromStream()
.stream
- an InputStream
from which the
template can be read.public BinaryData(BinaryData data)
BinaryData
instance.data
- the BinaryData
instance to be clonedMethod Detail |
public void compileFromFile(java.lang.String filePath) throws java.io.IOException
filePath
- the absolute path of the template file
to be compiled.public void compileFromFile(java.io.File file) throws java.io.IOException
file
- a File representing the
template file to be compiled.public void compileFromStream(java.io.InputStream stream) throws java.io.IOException
compileFromStream
in interface Compileable
stream
- an InputStream from which the
template can be read.public void compileFromStream(java.io.InputStream stream, java.lang.String encoding) throws java.io.IOException
compileFromStream
in interface Compileable
stream
- an InputStream from which the
template can be read.encoding
- the character encoding to use. For binary data,
this does nothing.public void process(java.io.OutputStream out)
out
- an OutputStream to output the HTML to.public void setCache(Cache cache)
Cache
that this object is stored in.
IncludeInstruction objects will be able to request this
Cache
at run-time.setCache
in interface Cacheable
cache
- the Cache
that this template belongs to.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()
BinaryData
object.clone
in interface Cacheable
clone
in class java.lang.Object
BinaryData
objectpublic java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |