|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.virtuosotechnologies.lib.xml.XMLUnparser
Helper for XML unparsing. This creates an indented tree representation of the elements. Elements may be single-line or multi-line. Single-line elements may only contain text or other single-line elements. Multi-line elements may contain text or any other element. Output inside a multi-line element is indented.
This class is not thread-safe. Access should be serialized into one thread.
Constructor Summary | |
XMLUnparser(Writer writer,
int indent,
boolean escape16BitChars)
Constructor |
Method Summary | |
void |
addAttribute(String name,
String value)
Add an attribute to the current element. |
void |
addString(String value)
Add a string to the current element |
protected String |
createIndentString(int indent)
Create an indent string given an indent level. |
void |
endElement(String element)
End the innermost element. |
Writer |
getWriter()
Returns the writer being written to |
boolean |
isDefunct()
Returns true if the unparser is defunct. |
void |
makeDefunct()
Finish the unparser. |
void |
startMultiLineElement(String element)
Start a multi-line element. |
void |
startSingleLineElement(String element)
Start a single-line element. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public XMLUnparser(Writer writer, int indent, boolean escape16BitChars) throws IOException
writer
- writer to write toindent
- base indentescape16BitChars
- true to generate escape sequences for 16-bit charactersMethod Detail |
protected String createIndentString(int indent)
indent
- number of indents
public Writer getWriter()
public boolean isDefunct()
public void makeDefunct() throws IOException
IOException
- i/o error
IllegalStateException
- there are unterminated elements or unparser is already defunctpublic void startMultiLineElement(String element) throws IOException
element
- element name
IOException
- i/o error
IllegalStateException
- Surrounding element is a single-line element or unparser is defunct
IllegalArgumentException
- Element name is illegalpublic void startSingleLineElement(String element) throws IOException
element
- element name
IOException
- i/o error
IllegalStateException
- unparser is defunct
IllegalArgumentException
- Element name is illegalpublic void endElement(String element) throws IOException
element
- element name, which must match the current element name
IOException
- i/o error
IllegalStateException
- no current element or unparser is defunct
IllegalArgumentException
- element name mismatchpublic void addAttribute(String name, String value) throws IOException
name
- attribute namevalue
- attribute value
IOException
- i/o error
IllegalStateException
- no current element, the current element has
already had subelements or strings added, or unparser is defunct
IllegalArgumentException
- attribute name is illegalpublic void addString(String value) throws IOException
value
- string to add
IOException
- i/o error
IllegalStateException
- unparser is defunct
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |