|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.xquark.util.HandlerDecorator
org.xquark.util.NamespaceContextHandler
org.xquark.util.NSPrefixDecorator
org.xquark.serialize.XMLSerializer
A simple SAX2 XML serializer implementing SAX ContentHandler and
LexicalHandler.
Warning:Default behavior is to perform automatic indentation and to
ignore ignorable whitespace generated by the XML processor.
IMPORTANT: SAX2 XMLReader
http://xml.org/sax/features/namespaces
feature is
supposed to be set to true which is the default.
Field Summary |
Fields inherited from class org.xquark.util.NSPrefixDecorator |
NS_PREFIX, XML_PREFIX |
Fields inherited from class org.xquark.util.HandlerDecorator |
contentHandler, errorHandler, lexicalHandler |
Fields inherited from interface org.xquark.util.SAXConstants |
FRAGMENT_FEATURE, SAX_DECLARATION_PROPERTY, SAX_LEXICAL_PROPERTY, SAX_NAMESPACE_FEATURE, SAX_PREFIX_FEATURE, SAX_VALIDATION_FEATURE, TRACE_FEATURE, XMLNS_PREFIX, XMLNS_URI |
Constructor Summary | |
XMLSerializer(java.io.OutputStream out)
Creates a new XMLSerializer |
|
XMLSerializer(java.io.OutputStream out,
java.lang.String encoding)
Creates a new XMLSerializer |
|
XMLSerializer(java.lang.String encoding,
boolean indent)
Creates a new XMLSerializer |
|
XMLSerializer(java.io.Writer out)
Creates a new XMLSerializer |
|
XMLSerializer(java.io.Writer out,
java.lang.String encoding)
Creates a new XMLSerializer |
Method Summary | |
void |
close()
Closes the user stream. |
boolean |
getAutoStreamClose()
Enable automatic close of the output user stream on endDocument() event. |
boolean |
getCanonicalOutput()
Accessor to the current ordering mode for attributes. |
java.lang.String |
getEncoding()
Accessor to the current character encoding in use. |
boolean |
getGenerateXMLDeclaration()
Accessor to the current flag for XML declaration generation. |
boolean |
getIndent()
Accessor to the current indenting mode. |
boolean |
getUseIgnorableWhitespaces()
Accessor to the current the status of the use of ignorable whitespace by the serializer. |
void |
reset()
Reset internal state before reuse. |
void |
setAutoStreamClose(boolean close)
Enable automatic close of the output user stream on endDocument() event. |
void |
setCanonicalOutput(boolean mode)
Set the ordering mode for attributes. |
void |
setEncoding(java.lang.String encoding)
Set the character encoding. |
void |
setGenerateXMLDeclaration(boolean enable)
Enable XML declaration generation on startDocument() event. |
void |
setIndent(boolean indent)
Set the indenting mode. |
void |
setOutputStream(java.io.OutputStream out)
Set the OutputStream where the serializer writes bytes. |
void |
setUseIgnorableWhitespaces(boolean use)
turn on or off the use of ignorable whitespace for indentation. |
void |
setWriter(java.io.Writer out)
Set the Writer where the serializer writes characters. |
Methods inherited from class org.xquark.util.NSPrefixDecorator |
endElement, isEnabled, setEnabled, startElement |
Methods inherited from class org.xquark.util.NamespaceContextHandler |
endPrefixMapping, getDeclaredPrefixes, getNamespaceContext, getNamespaceURI, getNamespaceURIs, getPrefix, getPrefixes, getPrefixes, startPrefixMapping |
Methods inherited from class org.xquark.util.HandlerDecorator |
characters, comment, endCDATA, endDocument, endDTD, endEntity, error, fatalError, getContentHandler, getLexicalHandler, getPluggedErrorHandler, ignorableWhitespace, processingInstruction, setContentHandler, setDocumentLocator, setErrorHandler, setLexicalHandler, skippedEntity, startCDATA, startDocument, startDTD, startEntity, warning |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public XMLSerializer(java.io.OutputStream out) throws java.io.UnsupportedEncodingException
out
- the OutputStream where the serializer writes bytes. For
instance a FileOutputStream. The Unicode character encoding used will be
the platform default.
java.io.UnsupportedEncodingException
- if the UTF-8 encoding is not supported
by the JAVA platformpublic XMLSerializer(java.io.OutputStream out, java.lang.String encoding) throws java.io.UnsupportedEncodingException
out
- the OutputStream where the serializer writes bytes. For
instance a FileOutputStream.encoding
- a string specifying the character encoding, which must be supported by the
JDK. Example: UTF-8, ISO-8859-1
java.io.UnsupportedEncodingException
- if the provided encoding is not supported
by the JAVA platformOutputStream
public XMLSerializer(java.io.Writer out)
out
- the writer where the serializer writes characters. For
instance a FileWriter.public XMLSerializer(java.io.Writer out, java.lang.String encoding)
out
- the writer where the serializer writes characters. For
instance a FileWriter.encoding
- a string specifying the character encoding (must be compatible with
the encoding used by the writer). This value is used to generate the encoding information
at the beginning of the XML fileOutputStream
public XMLSerializer(java.lang.String encoding, boolean indent)
encoding
- a string for the character encoding (must be supported by the
JDK used). Example: UTF-8, ISO-8859-1indent
- if true, tabs are used at the beginning of lines to indent the output file.Method Detail |
public void setOutputStream(java.io.OutputStream out) throws java.io.UnsupportedEncodingException
out
- the OutputStream where the serializer writes bytes. For
instance a FileOutputStream.
java.io.UnsupportedEncodingException
- if the provided encoding is not supported
by the JAVA platformpublic void setWriter(java.io.Writer out)
out
- the writer where the serializer writes characters.public void setIndent(boolean indent)
indent
- if true, tabs are used at the beginning of lines to indent the output file.public void setCanonicalOutput(boolean mode)
public void setUseIgnorableWhitespaces(boolean use)
use
- if true (the default), ignorable whitespace are used for
indentation unless automatic indentation is on.public void setEncoding(java.lang.String encoding)
encoding
- a string specifying the character encoding, which must be supported by the
JDK. Example: UTF-8, ISO-8859-1.public void setGenerateXMLDeclaration(boolean enable)
enable
- Declaration is geenrated if true. Default is true.public void setAutoStreamClose(boolean close)
close
- Output stream will be closed if true. Default is false.public boolean getIndent()
public boolean getCanonicalOutput()
public boolean getUseIgnorableWhitespaces()
public java.lang.String getEncoding()
public boolean getGenerateXMLDeclaration()
public boolean getAutoStreamClose()
public void reset()
public void close()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |