|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.Writer
java.io.FilterWriter
org.freecompany.xmlwriter.XmlWriter
public class XmlWriter
A Writer
for XML documents.
In concept, an XmlWriter
is a SAX ContentHandler
that simply writes the corresponding events as an XML document.
Field Summary | |
---|---|
protected int |
depth
|
protected java.lang.CharSequence |
encoding
|
protected boolean |
endElementGenerated
|
protected boolean |
indented
|
protected org.xml.sax.Locator |
locator
|
static int |
NO_AUTOFLUSH
A value for the autoflush threshold that disables the feature. |
protected java.util.Map<java.lang.String,java.lang.CharSequence> |
pending
|
protected java.util.Map<java.lang.String,java.lang.CharSequence> |
prefixes
|
protected java.lang.Boolean |
standalone
|
protected boolean |
startElementPending
State flags for internal use. |
protected int |
threshold
|
protected java.lang.CharSequence |
version
|
protected static java.lang.String |
XMLNS
|
Fields inherited from class java.io.FilterWriter |
---|
out |
Fields inherited from class java.io.Writer |
---|
lock |
Constructor Summary | |
---|---|
XmlWriter(java.io.Writer out)
Creates an XmlWriter that wraps another writer. |
Method Summary | |
---|---|
XmlWriter |
append(org.w3c.dom.Node root)
Writes a DOM subtree. |
XmlWriter |
appendInternal(char value)
Override to convert exception types to SAX. |
XmlWriter |
appendInternal(java.lang.CharSequence value)
Override to convert exception types to SAX. |
void |
cData(java.lang.CharSequence s)
Creates a CDATA section in the output. |
void |
characters(char[] characters,
int offset,
int length)
Writes text to the output. |
void |
characters(java.lang.CharSequence s)
Writes character data while performing escapes as defined in the XML 1.0 specification, section 2.4. |
void |
comment(char[] characters,
int offset,
int index)
|
void |
createElement(java.lang.CharSequence uri,
java.lang.CharSequence name)
Creates an empty element with no attributes. |
void |
createElement(java.lang.CharSequence uri,
java.lang.CharSequence name,
org.xml.sax.Attributes attrs)
Creates an empty element with the specified attributes. |
void |
createElement(java.lang.CharSequence uri,
java.lang.CharSequence name,
org.xml.sax.Attributes attrs,
java.lang.CharSequence content)
Creates an element with the specified attributes and text content. |
void |
createElement(java.lang.CharSequence uri,
java.lang.CharSequence name,
java.lang.CharSequence content)
Creates an element with no attributes and the specified text content. |
void |
createElement(javax.xml.namespace.QName qname)
Creates an empty element with no attributes. |
void |
createElement(javax.xml.namespace.QName qname,
org.xml.sax.Attributes attrs)
Creates an empty element with the specified attributes. |
void |
createElement(javax.xml.namespace.QName qname,
org.xml.sax.Attributes attrs,
java.lang.CharSequence content)
Creates an element with the specified attributes and text content. |
void |
createElement(javax.xml.namespace.QName qname,
java.lang.CharSequence content)
Creates an element with no attributes and the specified text content. |
void |
endCDATA()
Ends a CDATA section in the output. |
void |
endDocument()
|
void |
endDTD()
|
void |
endElement(javax.xml.namespace.QName qname)
Ends an element. |
void |
endElement(java.lang.String uri,
java.lang.String name)
Ends an element. |
void |
endElement(java.lang.String uri,
java.lang.String name,
java.lang.String qname)
Ends an element. |
void |
endEntity(java.lang.String name)
|
void |
endPrefixMapping(java.lang.String prefix)
Adds a set of namespace mappings to the current namespace context. |
protected void |
finishPendingStartElement()
|
protected void |
flushInternal()
|
int |
getAutoFlush()
Gets the autoflush threshold. |
int |
getDepth()
Gets the current output tree depth. |
java.lang.CharSequence |
getEncoding()
|
java.lang.Boolean |
getStandalone()
|
java.lang.CharSequence |
getVersion()
|
void |
ignorableWhitespace(char[] characters,
int offset,
int length)
|
protected void |
indent(int depth)
|
boolean |
isIndented()
|
void |
processingInstruction(java.lang.String target,
java.lang.String data)
|
void |
setAutoFlush(int threshold)
Sets the document depth at which the underlying writer is automatically flushed. |
void |
setDocumentLocator(org.xml.sax.Locator locator)
|
void |
setEncoding(java.lang.CharSequence encoding)
|
void |
setIndented(boolean indented)
|
void |
setStandalone(java.lang.Boolean standalone)
|
void |
setVersion(java.lang.CharSequence version)
|
void |
skippedEntity(java.lang.String name)
|
void |
startCDATA()
Starts a CDATA section in the output. |
void |
startDocument()
|
void |
startDTD(java.lang.String name,
java.lang.String publicid,
java.lang.String systemid)
|
void |
startElement(javax.xml.namespace.QName qname)
Start an element with no attributes. |
void |
startElement(javax.xml.namespace.QName qname,
org.xml.sax.Attributes attrs)
Start an element with the specified attributes. |
void |
startElement(java.lang.String uri,
java.lang.String name)
Start an element with no attributes. |
void |
startElement(java.lang.String uri,
java.lang.String name,
java.lang.String qname)
Start an element with no attributes. |
void |
startElement(java.lang.String uri,
java.lang.String name,
java.lang.String qname,
org.xml.sax.Attributes attrs)
Start an element with the specified attributes. |
void |
startEntity(java.lang.String name)
|
void |
startPrefixMapping(java.lang.String prefix,
java.lang.String uri)
Adds a namespace mapping to the current namespace context. |
protected void |
writeAttributes(org.xml.sax.Attributes attrs)
|
protected void |
writeNamespace(java.lang.CharSequence uri,
java.lang.CharSequence prefix)
|
protected void |
writeQName(java.lang.CharSequence uri,
java.lang.CharSequence name)
|
protected void |
writeWithEscapes(java.lang.CharSequence value,
java.lang.CharSequence charsToEscape)
|
Methods inherited from class java.io.FilterWriter |
---|
close, flush, write, write, write |
Methods inherited from class java.io.Writer |
---|
append, append, append, write, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int NO_AUTOFLUSH
protected static final java.lang.String XMLNS
protected final java.util.Map<java.lang.String,java.lang.CharSequence> prefixes
protected final java.util.Map<java.lang.String,java.lang.CharSequence> pending
protected org.xml.sax.Locator locator
protected java.lang.CharSequence version
protected java.lang.CharSequence encoding
protected java.lang.Boolean standalone
protected boolean indented
protected int threshold
protected boolean startElementPending
protected boolean endElementGenerated
protected int depth
Constructor Detail |
---|
public XmlWriter(java.io.Writer out)
XmlWriter
that wraps another writer.
out
- the wrapped writerMethod Detail |
---|
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
startPrefixMapping
in interface org.xml.sax.ContentHandler
uri
- the URI of the new namespaceprefix
- the prefix used when writing tags in the namespacepublic void endPrefixMapping(java.lang.String prefix)
endPrefixMapping
in interface org.xml.sax.ContentHandler
map
- a map of namespace URIs to prefixes.public void setAutoFlush(int threshold)
threshold
- the new threshold valuepublic int getAutoFlush()
public int getDepth()
public void startElement(javax.xml.namespace.QName qname) throws org.xml.sax.SAXException
qname
- the qualified name of the element
java.io.IOException
- when the underlying writer does
org.xml.sax.SAXException
public void startElement(javax.xml.namespace.QName qname, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXException
qname
- the qualified name of the elementattrs
- the attribute names mapped to their corresponding values
java.io.IOException
- when the underlying writer does
org.xml.sax.SAXException
public void startElement(java.lang.String uri, java.lang.String name) throws org.xml.sax.SAXException
uri
- the namespace URI of the elementname
- the local name of the element
java.io.IOException
- when the underlying writer does
org.xml.sax.SAXException
public void startElement(java.lang.String uri, java.lang.String name, java.lang.String qname) throws org.xml.sax.SAXException
uri
- the namespace URI of the elementname
- the local name of the element
java.io.IOException
- when the underlying writer does
org.xml.sax.SAXException
public void startElement(java.lang.String uri, java.lang.String name, java.lang.String qname, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXException
startElement
in interface org.xml.sax.ContentHandler
uri
- the namespace URI of the elementname
- the local name of the elementattrs
- the attribute names mapped to their corresponding values
java.io.IOException
- when the underlying writer does
org.xml.sax.SAXException
protected void indent(int depth) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void endElement(javax.xml.namespace.QName qname) throws org.xml.sax.SAXException
qname
- the qualified name of the element
java.io.IOException
- when the underlying writer does
org.xml.sax.SAXException
public void endElement(java.lang.String uri, java.lang.String name) throws org.xml.sax.SAXException
uri
- the namespace URI of the elementname
- the local name of the element
java.io.IOException
- when the underlying writer does
org.xml.sax.SAXException
public void endElement(java.lang.String uri, java.lang.String name, java.lang.String qname) throws org.xml.sax.SAXException
endElement
in interface org.xml.sax.ContentHandler
uri
- the namespace URI of the elementname
- the local name of the element
java.io.IOException
- when the underlying writer does
org.xml.sax.SAXException
protected void finishPendingStartElement() throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void createElement(javax.xml.namespace.QName qname) throws org.xml.sax.SAXException
qname
- the qualified name of the element
java.io.IOException
- when the underlying writer does
org.xml.sax.SAXException
public void createElement(javax.xml.namespace.QName qname, java.lang.CharSequence content) throws org.xml.sax.SAXException
qname
- the qualified name of the elementcontent
- the text value of the element
java.io.IOException
- when the underlying writer does
org.xml.sax.SAXException
public void createElement(javax.xml.namespace.QName qname, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXException
qname
- the qualified name of the elementattrs
- the attribute names mapped to their corresponding values
java.io.IOException
- when the underlying writer does
org.xml.sax.SAXException
public void createElement(javax.xml.namespace.QName qname, org.xml.sax.Attributes attrs, java.lang.CharSequence content) throws org.xml.sax.SAXException
qname
- the qualified name of the elementattrs
- the attribute names mapped to their corresponding valuescontent
- the text value of the element
java.io.IOException
- when the underlying writer does
org.xml.sax.SAXException
public void createElement(java.lang.CharSequence uri, java.lang.CharSequence name) throws org.xml.sax.SAXException
uri
- the namespace URI of the elementname
- the local name of the element
java.io.IOException
- when the underlying writer does
org.xml.sax.SAXException
public void createElement(java.lang.CharSequence uri, java.lang.CharSequence name, java.lang.CharSequence content) throws org.xml.sax.SAXException
uri
- the namespace URI of the elementname
- the local name of the elementcontent
- the text value of the element
java.io.IOException
- when the underlying writer does
org.xml.sax.SAXException
public void createElement(java.lang.CharSequence uri, java.lang.CharSequence name, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXException
uri
- the namespace URI of the elementname
- the local name of the elementattrs
- the attribute names mapped to their corresponding values
java.io.IOException
- when the underlying writer does
org.xml.sax.SAXException
public void createElement(java.lang.CharSequence uri, java.lang.CharSequence name, org.xml.sax.Attributes attrs, java.lang.CharSequence content) throws org.xml.sax.SAXException
uri
- the namespace URI of the elementname
- the local name of the elementattrs
- the attribute names mapped to their corresponding valuescontent
- the text value of the element
java.io.IOException
- when the underlying writer does
org.xml.sax.SAXException
protected void writeQName(java.lang.CharSequence uri, java.lang.CharSequence name) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected void writeNamespace(java.lang.CharSequence uri, java.lang.CharSequence prefix) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected void writeAttributes(org.xml.sax.Attributes attrs) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected void writeWithEscapes(java.lang.CharSequence value, java.lang.CharSequence charsToEscape) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public XmlWriter append(org.w3c.dom.Node root) throws org.xml.sax.SAXException
root
- the root of the DOM subtree
java.io.IOException
- when the underlying writer does
org.xml.sax.SAXException
protected void flushInternal() throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void startCDATA() throws org.xml.sax.SAXException
startCDATA
in interface org.xml.sax.ext.LexicalHandler
java.io.IOException
- when the underlying writer does
org.xml.sax.SAXException
public void endCDATA() throws org.xml.sax.SAXException
endCDATA
in interface org.xml.sax.ext.LexicalHandler
java.io.IOException
- when the underlying writer does
org.xml.sax.SAXException
public void cData(java.lang.CharSequence s) throws org.xml.sax.SAXException
java.io.IOException
- when the underlying writer does
org.xml.sax.SAXException
public void comment(char[] characters, int offset, int index) throws org.xml.sax.SAXException
comment
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
public void startDocument() throws org.xml.sax.SAXException
startDocument
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
public void endDocument()
endDocument
in interface org.xml.sax.ContentHandler
public void setDocumentLocator(org.xml.sax.Locator locator)
setDocumentLocator
in interface org.xml.sax.ContentHandler
public void ignorableWhitespace(char[] characters, int offset, int length) throws org.xml.sax.SAXException
ignorableWhitespace
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
processingInstruction
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
public void skippedEntity(java.lang.String name)
skippedEntity
in interface org.xml.sax.ContentHandler
public void startEntity(java.lang.String name)
startEntity
in interface org.xml.sax.ext.LexicalHandler
public void endEntity(java.lang.String name)
endEntity
in interface org.xml.sax.ext.LexicalHandler
public void startDTD(java.lang.String name, java.lang.String publicid, java.lang.String systemid)
startDTD
in interface org.xml.sax.ext.LexicalHandler
public void endDTD()
endDTD
in interface org.xml.sax.ext.LexicalHandler
public void characters(char[] characters, int offset, int length) throws org.xml.sax.SAXException
characters
in interface org.xml.sax.ContentHandler
java.io.IOException
- when the underlying writer does
org.xml.sax.SAXException
public void characters(java.lang.CharSequence s) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void setVersion(java.lang.CharSequence version)
public java.lang.CharSequence getVersion()
public void setEncoding(java.lang.CharSequence encoding)
public java.lang.CharSequence getEncoding()
public void setStandalone(java.lang.Boolean standalone)
public java.lang.Boolean getStandalone()
public void setIndented(boolean indented)
public boolean isIndented()
public XmlWriter appendInternal(char value) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public XmlWriter appendInternal(java.lang.CharSequence value) throws org.xml.sax.SAXException
org.xml.sax.SAXException
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |