jimm.twice.ice
Class XMLTextData
java.lang.Object
jimm.twice.ice.XMLTextData
- public class XMLTextData
- extends java.lang.Object
Manages XML text data, large or small. Since large amounts of content
may be delivered inline, we want to avoid keeping all that text in
memory. If the text given to us exceeds a certain size, we store the
data in a temp file on disk. The text data is retrievable as a string
or as an InputStream
.
Behavior is undefined if you retrieve data using
getTextDataInputStream
and then continue to add data by
calling append
.
It would be trivial to keep track of how big the data is and provide
a method to return that value, or a boolean method that indicates
if the data is on disk or in memory, but we don't need them yet.
- Author:
- Jim Menard, jimm@io.com
Method Summary |
void |
append(char[] ch,
int start,
int length)
|
void |
cleanup()
|
protected void |
finalize()
|
java.lang.String |
getTextData()
Returns the text we are holding, or null if
there is no data. |
java.io.InputStream |
getTextDataInputStream()
Returns an input stream on the text we are holding, or null
if there is no data. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
IN_MEMORY_MAX_SIZE
protected static final int IN_MEMORY_MAX_SIZE
- See Also:
- Constant Field Values
BUFSIZ
protected static final int BUFSIZ
- See Also:
- Constant Field Values
TEMP_FILE_PREFIX
protected static final java.lang.String TEMP_FILE_PREFIX
- See Also:
- Constant Field Values
TEMP_FILE_SUFFIX
protected static final java.lang.String TEMP_FILE_SUFFIX
- See Also:
- Constant Field Values
LOGGER_PREFIX
protected static final java.lang.String LOGGER_PREFIX
- See Also:
- Constant Field Values
textBuffer
protected java.lang.StringBuffer textBuffer
tempFile
protected java.io.File tempFile
tempFileWriter
protected java.io.FileWriter tempFileWriter
XMLTextData
public XMLTextData()
append
public void append(char[] ch,
int start,
int length)
getTextData
public java.lang.String getTextData()
- Returns the text we are holding, or
null
if
there is no data. If the data is being stored in a temp file, that text
is read into memory.
- Returns:
- an input stream on our text; may be
null
getTextDataInputStream
public java.io.InputStream getTextDataInputStream()
- Returns an input stream on the text we are holding, or
null
if there is no data.
- Returns:
- a reader on our text; may be
null
finalize
protected void finalize()
throws java.lang.Throwable
- Throws:
java.lang.Throwable
cleanup
public void cleanup()
toString
public java.lang.String toString()