|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectfreemarker.template.BinaryData
public class 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 Form| Field 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.
java.io.IOException
public BinaryData(java.io.File file)
throws java.io.IOException
compileFromFile().
file - a File representing the
binary file to be compiled.
java.io.IOException
public BinaryData(java.io.InputStream stream)
throws java.io.IOException
InputStream. Calls compileFromStream().
stream - an InputStream from which the
template can be read.
java.io.IOExceptionpublic BinaryData(BinaryData data)
BinaryData instance.
data - the BinaryData instance to be cloned| Method Detail |
|---|
public void compileFromFile(java.lang.String filePath)
throws java.io.IOException
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
file - a File representing the
template file to be compiled.
java.io.IOException
public void compileFromStream(java.io.InputStream stream)
throws java.io.IOException
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
compileFromStream in interface Compileablestream - an InputStream from which the
template can be read.encoding - the character encoding to use. For binary data,
this does nothing.
java.io.IOExceptionpublic 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 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()
BinaryData object.
clone in interface Cacheableclone in class java.lang.ObjectBinaryData
objectpublic java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||