|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnu.xom.Serializer
nu.xom.samples.TextSerializer
public class TextSerializer
This Serializer
subclass outputs raw, unescaped text
from the text nodes, but no markup of any kind. In essence, it
converts XML into plain text.
Constructor Summary | |
---|---|
TextSerializer(java.io.OutputStream out)
Create a new text serializer that uses the UTF-8 encoding. |
|
TextSerializer(java.io.OutputStream out,
java.lang.String encoding)
Create a new serializer that uses a specified encoding. |
Method Summary | |
---|---|
static void |
main(java.lang.String[] args)
|
protected void |
write(nu.xom.Comment comment)
Writes a comment onto the output stream using the current options. |
protected void |
write(nu.xom.DocType doctype)
Writes a DocType object
onto the output stream using the current options. |
protected void |
write(nu.xom.ProcessingInstruction instruction)
Writes a processing instruction onto the output stream using the current options. |
protected void |
writeEmptyElementTag(nu.xom.Element element)
Writes an empty-element tag for the element including all its namespace declarations and attributes. |
protected void |
writeEndTag(nu.xom.Element element)
Writes the end-tag for an element in the form </name> . |
protected void |
writeStartTag(nu.xom.Element element)
Writes the start-tag for the element including all its namespace declarations and attributes. |
protected void |
writeText(nu.xom.Text text)
|
protected void |
writeXMLDeclaration()
Writes the XML declaration onto the output stream, followed by a line break. |
Methods inherited from class nu.xom.Serializer |
---|
breakLine, flush, getColumnNumber, getEncoding, getIndent, getLineSeparator, getMaxLength, getPreserveBaseURI, getUnicodeNormalizationFormC, setIndent, setLineSeparator, setMaxLength, setOutputStream, setPreserveBaseURI, setUnicodeNormalizationFormC, write, write, write, write, writeAttributes, writeAttributeValue, writeChild, writeEscaped, writeNamespaceDeclaration, writeNamespaceDeclarations, writeRaw |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TextSerializer(java.io.OutputStream out)
Create a new text serializer that uses the UTF-8 encoding.
out
- the output stream to write the document on
java.lang.NullPointerException
- if out is nullpublic TextSerializer(java.io.OutputStream out, java.lang.String encoding) throws java.io.UnsupportedEncodingException
Create a new serializer that uses a specified encoding. The encoding must be recognized by the Java virtual machine.
out
- the output stream to write the document onencoding
- the character encoding for the serialization
java.lang.NullPointerException
- if out
or encoding
is null
java.io.UnsupportedEncodingException
- if the VM does not
support the requested encodingMethod Detail |
---|
protected void writeStartTag(nu.xom.Element element)
nu.xom.Serializer
Writes the start-tag for the element including all its namespace declarations and attributes.
The writeAttributes
method is called to write
all the non-namespace-declaration attributes.
The writeNamespaceDeclarations
method
is called to write all the namespace declaration attributes.
writeStartTag
in class nu.xom.Serializer
element
- the element whose start-tag is writtenprotected void writeEmptyElementTag(nu.xom.Element element)
nu.xom.Serializer
Writes an empty-element tag for the element including all its namespace declarations and attributes.
The writeAttributes
method is called to write
all the non-namespace-declaration attributes.
The writeNamespaceDeclarations
method
is called to write all the namespace declaration attributes.
If subclasses don't wish empty-element tags to be used,
they can override this method to simply invoke
writeStartTag
followed by
writeEndTag
.
writeEmptyElementTag
in class nu.xom.Serializer
element
- the element whose empty-element tag is writtenprotected void writeEndTag(nu.xom.Element element)
nu.xom.Serializer
Writes the end-tag for an element in the form
</name>
.
writeEndTag
in class nu.xom.Serializer
element
- the element whose end-tag is writtenprotected void writeXMLDeclaration()
nu.xom.Serializer
Writes the XML declaration onto the output stream, followed by a line break.
writeXMLDeclaration
in class nu.xom.Serializer
protected void write(nu.xom.Comment comment)
nu.xom.Serializer
Writes a comment onto the output stream using the current options. Since character and entity references are not resolved in comments, comments can only be serialized when all characters they contain are available in the current encoding.
write
in class nu.xom.Serializer
comment
- the Comment
to serializeprotected void write(nu.xom.ProcessingInstruction instruction)
nu.xom.Serializer
Writes a processing instruction onto the output stream using the current options. Since character and entity references are not resolved in processing instructions, processing instructions can only be serialized when all characters they contain are available in the current encoding.
write
in class nu.xom.Serializer
instruction
- the ProcessingInstruction
to serializeprotected void write(nu.xom.DocType doctype)
nu.xom.Serializer
Writes a DocType
object
onto the output stream using the current options.
write
in class nu.xom.Serializer
doctype
- the document type declaration to serializeprotected void writeText(nu.xom.Text text) throws java.io.IOException
java.io.IOException
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |