|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.ricebridge.xmlman.in.XmlWriter
Outputs well-formed XML to an OutputStream, using a specified encoding.
You can subclass this class to customize the creation of XML text by
XML Manager. Call the XmlManagerStore.setXmlWriterClass(java.lang.Class) method
to set the class of your own XmlWriter. Note that subclasses are
required to have a empty constructor, so that new instances can be created
from the class object.
XmlOutputHandler| Field Summary | |
protected boolean |
iClose
|
protected boolean |
iFirstElement
|
protected boolean |
iFlush
|
protected boolean |
iIndent
|
protected int |
iIndentCount
|
protected int |
iIndentOfText
|
protected String |
iIndentString
|
protected String |
iLastElement
|
protected int |
iNumIndentSpaces
|
protected OutputStreamWriter |
iOutputStreamWriter
|
protected boolean |
iVerbatimText
|
| Constructor Summary | |
XmlWriter()
Create a new XmlWriter instance. |
|
| Method Summary | |
static String |
encodeAttr(String pText)
Encode XML attribute content. |
static String |
encodeText(String pText)
Encode XML text content. |
void |
endDocument(String pFooter)
End XML document by flushing and closing stream. |
void |
endElement(String pQName)
Output the end tag of an element. |
protected void |
flush()
Flush output, and handle exceptions. |
String |
formatAttrs(List pAttrPairs)
Create XML attribute content. |
String |
formatNamespaces(Map pNamespaceMap)
Create XML Namespace declaration attributes. |
protected String |
indent()
Make current indent string. |
protected String |
indentText(String pText)
Indent XML text content so that it is aligned with start tag. |
void |
setClose(boolean pClose)
Close the OutputStream specified with setOutput(java.io.OutputStream, java.lang.String) when finished. |
void |
setFlush(boolean pFlush)
Flush output after the start and end of each element, and after outputting text. |
void |
setIndent(boolean pIndent)
Indent XML so that it is human readable. |
void |
setOutput(OutputStream pOutputStream,
String pCharsetName)
Set the OutputStream and character encoding to use. |
void |
startDocument(String pHeader)
Start XML document by outputting header. |
void |
startElement(String pQName,
List pAttrPairs,
Map pNamespaceMap)
Output the start tag of an element, including attributes and namespace declarations, if present. |
void |
text(String pText)
Output XML text content for current tag. |
protected String |
trimContent(String pContent)
Trim text content to a small example extract for error reporting. |
protected void |
write(String pContent)
Write content to output, and handle exceptions. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected OutputStreamWriter iOutputStreamWriter
protected boolean iFlush
protected boolean iVerbatimText
protected boolean iIndent
protected boolean iClose
protected boolean iFirstElement
protected String iLastElement
protected int iNumIndentSpaces
protected int iIndentOfText
protected int iIndentCount
protected String iIndentString
| Constructor Detail |
public XmlWriter()
| Method Detail |
public void setOutput(OutputStream pOutputStream,
String pCharsetName)
OutputStream and character encoding to use.
The OutputStream is wrapped in a OutputStreamWriter
which uses the specified character encoding to create the correct
stream of output bytes. See the documentation for Charset for a
discussion of Java character encoding. Note that XML should generally be encoding as
UTF-8 or UTF-16 for guaranteed interoperability.
pOutputStream - OutputStream to recieve XML contentpCharsetName - character encoding for the XML contentpublic void setFlush(boolean pFlush)
pFlush - flush OutputStream after each elementXmlSpec.setFlush(boolean)public void setIndent(boolean pIndent)
If the XML is not indented, then it is output in a compact format with no newlines or unnecessary whitespace.
pIndent - indent outputXmlSpec.setIndent(boolean)public void setClose(boolean pClose)
OutputStream specified with setOutput(java.io.OutputStream, java.lang.String) when finished.
pClose - close OutputStreampublic void startDocument(String pHeader)
pHeader - header contentpublic void endDocument(String pFooter)
public void startElement(String pQName,
List pAttrPairs,
Map pNamespaceMap)
Note that the list of attributes is a flat list with even elements as names and odd elements as values.
pQName - prefix qualified name of elementpAttrPairs - list of attr, value elements, may be nullpNamespaceMap - prefix to uri mappings, may be nullpublic String formatNamespaces(Map pNamespaceMap)
pNamespaceMap - prefix to uri mappingspublic String formatAttrs(List pAttrPairs)
pAttrPairs - list of name, value elementspublic void text(String pText)
pText - text content to outputpublic void endElement(String pQName)
pQName - prefix qualified name of elementpublic static String encodeText(String pText)
pText - text contentpublic static String encodeAttr(String pText)
pText - attribute contentprotected String indent()
protected String indentText(String pText)
pText - text contentprotected void write(String pContent)
pContent - content to outputprotected void flush()
protected String trimContent(String pContent)
pContent - text content
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||