jimm.twice.xml.dom
Class InlineFile
java.lang.Object
jimm.twice.xml.dom.Element
jimm.twice.xml.dom.Text
jimm.twice.xml.dom.InlineFile
- public class InlineFile
- extends Text
This element writes the contents of a file without reading the contents
into memory all at once. By default, it base64-encodes the file
contents. If the encoding is set to ENCODING_RAW
, then the
contents will be surrounded by "<![CDATA[" and "]]>" when output
as XML.
This is a subclass of Text
for type identification only;
the text instance variable is unused.
- Author:
- Jim Menard, jimm@io.com
Fields inherited from class jimm.twice.xml.dom.Text |
text |
Constructor Summary |
InlineFile(java.io.File f)
Constructor. |
InlineFile(java.io.File f,
int encoding)
Constructor. |
Method Summary |
protected void |
copyFileContents(java.io.InputStream in,
java.io.OutputStream out)
|
int |
getEncoding()
|
void |
setEncoding(int e)
|
void |
writeTo(java.io.OutputStream out,
int openOrClose)
Writes this element as an XML string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ENCODING_BASE64
public static final int ENCODING_BASE64
- See Also:
- Constant Field Values
ENCODING_RAW
public static final int ENCODING_RAW
- See Also:
- Constant Field Values
BUFSIZ
public static final int BUFSIZ
- See Also:
- Constant Field Values
file
protected java.io.File file
encoding
protected int encoding
InlineFile
public InlineFile(java.io.File f)
- Constructor. The file's contents will be base64 encoded.
- Parameters:
f
- a file
InlineFile
public InlineFile(java.io.File f,
int encoding)
- Constructor.
- Parameters:
f
- a fileencoding
- either ENCODING_BASE64
(the default)
or ENCODING_RAW
.
getEncoding
public int getEncoding()
setEncoding
public void setEncoding(int e)
writeTo
public void writeTo(java.io.OutputStream out,
int openOrClose)
throws java.io.IOException
- Description copied from class:
Element
- Writes this element as an XML string. The parameter
openOrClose
determines if the open tag
(OPEN_TAG
), close tag (CLOSE_TAG
), or both
(OPEN_AND_CLOSE_TAG
) should be returned.
- Overrides:
writeTo
in class Text
- Throws:
java.io.IOException
copyFileContents
protected void copyFileContents(java.io.InputStream in,
java.io.OutputStream out)
throws java.io.IOException
- Throws:
java.io.IOException