jimm.twice.xml.dom
Class InlineFile

java.lang.Object
  extended byjimm.twice.xml.dom.Element
      extended byjimm.twice.xml.dom.Text
          extended byjimm.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

Field Summary
static int BUFSIZ
           
protected  int encoding
           
static int ENCODING_BASE64
           
static int ENCODING_RAW
           
protected  java.io.File file
           
 
Fields inherited from class jimm.twice.xml.dom.Text
text
 
Fields inherited from class jimm.twice.xml.dom.Element
CLOSE_TAG, OPEN_AND_CLOSE_TAG, OPEN_TAG
 
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 jimm.twice.xml.dom.Element
writeTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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
Constructor Detail

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 file
encoding - either ENCODING_BASE64 (the default) or ENCODING_RAW.
Method Detail

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