|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.bristle.javalib.xml.XMLWriter
public class XMLWriter
This class writes formatted XML strings to a Writer. It is a class, rather than just a collection of routines, to make the calling code simpler. As a class, it can use instance variables to store things like the Writer, which would otherwise have to be passed on each method call.
Usage: - The following is a typical scenario for using this class: XMLWriter writer = new XMLWriter(writerOut); writer.writeStartTag("abcd"); writer.write("some text in the abcd tag"); writer.writeEndTag("abcd"); Assumptions: Effects: - None. Anticipated Changes: Notes: Implementation Notes: Portability Issues: Revision History: $Log$
Nested Class Summary | |
---|---|
static class |
XMLWriter.Tester
Each class contains a Tester inner class with a main() for easier unit testing. |
Field Summary | |
---|---|
static boolean |
blnWITH_NEWLINE
|
static boolean |
m_blnFORCE_LOG
|
Constructor Summary | |
---|---|
XMLWriter(Writer writer)
Constructor. |
Method Summary | |
---|---|
boolean |
checkError()
Check for errors in the nested Writer, if it's a PrintWriter. |
String |
getNewLineString()
Get the newline String. |
boolean |
logProgressAndCheckError(Logger logger,
int intCount)
Log the progress of the calling routine in generating its data stream, and check for errors that have occurred when the calling routine wrote to this XMLWriter. |
boolean |
logProgressAndCheckError(Logger logger,
int intCount,
boolean blnForceLog)
Log the progress of the calling routine in generating its data stream, and check for errors that have occurred when the calling routine wrote to its XMLWriter. |
void |
setNewLineString(String strNew)
Set the newline String. |
void |
write(String strText)
Write the line of text to the Writer. |
void |
writeEndTag(String strTag)
Write the end version of the specified XML tag to the Writer, followed by a newline. |
void |
writeEndTag(String strTag,
boolean blnNewLine)
Write the end version of the specified XML tag to the Writer, optionally followed by a newline. |
void |
writeln()
Write a newline to the Writer. |
void |
writeln(String strText)
Write the line of text to the Writer, followed by a newline. |
void |
writeStartTag(String strTag)
Write the start version of the specified XML tag to the Writer, followed by a newline. |
void |
writeStartTag(String strTag,
boolean blnNewLine)
Write the start version of the specified XML tag to the Writer, optionally followed by a newline. |
void |
writeStartTagAndAttributes(String strTag,
String strAttributes)
Write the start version of the specified XML tag to the Writer, including a string containing one or more attributes, followed by a newline. |
void |
writeStartTagAndAttributes(String strTag,
String strAttributes,
boolean blnNewLine)
Write the start version of the specified XML tag to the Writer, including a string containing one or more attributes, optionally followed by a newline. |
void |
writeTagAndValue(String strTag,
String strValue)
Write the specified value, enclosed in the start and end versions of the specified XML tag, to the Writer, followed by a newline. |
void |
writeTagAndValue(String strTag,
String strValue,
boolean blnNewLine)
Write the specified value, enclosed in the start and end versions of the specified XML tag, to the Writer, optionally followed by a newline. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final boolean m_blnFORCE_LOG
public static final boolean blnWITH_NEWLINE
Constructor Detail |
---|
public XMLWriter(Writer writer)
writer
- The Writer to write the XML to.Method Detail |
---|
public void setNewLineString(String strNew)
strNew
- The new value.public String getNewLineString()
public void write(String strText) throws IOException
strText
- String of text.
IOException
- When an error occurs writing to the Writer.public void writeln() throws IOException
IOException
- When an error occurs writing to the Writer.public void writeln(String strText) throws IOException
strText
- String of text.
IOException
- When an error occurs writing to the Writer.public void writeStartTag(String strTag, boolean blnNewLine) throws IOException
strTag
- XML tag (without angle brackets).blnNewLine
- Boolean flag indicating whether to write a newline
after the tag.
IOException
- When an error occurs writing to the Writer.public void writeStartTag(String strTag) throws IOException
strTag
- XML tag (without angle brackets).
IOException
- When an error occurs writing to the Writer.public void writeStartTagAndAttributes(String strTag, String strAttributes, boolean blnNewLine) throws IOException
strTag
- XML tag (without angle brackets).strAttributes
- Attributes to be included in the start tagblnNewLine
- Boolean flag indicating whether to write a
newline after the tag.
IOException
- When an error occurs writing to the Writer.public void writeStartTagAndAttributes(String strTag, String strAttributes) throws IOException
strTag
- XML tag (without angle brackets).strAttributes
- Attributes to be included in the start tag
IOException
- When an error occurs writing to the Writer.public void writeEndTag(String strTag, boolean blnNewLine) throws IOException
strTag
- XML tag (without angle brackets or slash).blnNewLine
- Boolean flag indicating whether to write a newline
after the tag.
IOException
- When an error occurs writing to the Writer.public void writeEndTag(String strTag) throws IOException
strTag
- XML tag (without angle brackets).
IOException
- When an error occurs writing to the Writer.public void writeTagAndValue(String strTag, String strValue, boolean blnNewLine) throws IOException
strTag
- XML tag (without angle brackets).strValue
- String value to enclose in XML tags.blnNewLine
- Boolean flag indicating whether to write a newline
after the formatted XML.
IOException
- When an error occurs writing to the Writer.public void writeTagAndValue(String strTag, String strValue) throws IOException
strTag
- XML tag (without angle brackets).strValue
- String value to enclose in XML tags.
IOException
- When an error occurs writing to the Writer.public boolean checkError()
public boolean logProgressAndCheckError(Logger logger, int intCount, boolean blnForceLog)
logger
- Logger to log progress messages.intCount
- Count of times called (used internally to decide
whether to bother with periodic tasks).blnForceLog
- Flag to force logging at this call, instead of just
periodically. Useful to log the final data row.
public boolean logProgressAndCheckError(Logger logger, int intCount)
logger
- Logger to log progress messages.intCount
- Count of times called (used internally to decide
whether to bother with periodic tasks).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |