|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.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.NamespaceContextHandler |
contextStack |
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. |
void |
completeStartTag()
Closes the potentially open element start tag waiting to know by the following events if the tag is empty. |
void |
flush()
Flushes the user stream. |
boolean |
getAutoStreamClose()
Return the value set for stream automatic close feature. |
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 |
setGenerateEncodingDeclaration(boolean enable)
Enable encoding attribute generation in XML declaration on startDocument() event. |
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)
mode
- If true, ordering is performed following the
Canonical XML
W3C recommendation. If false, attributes are serialized as
passed by the SAX2 XMLReader.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
- XML Declaration is generated if true. Default is true.public void setGenerateEncodingDeclaration(boolean enable)
enable
- encoding declaration generation 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()
setAutoStreamClose(boolean).
public void completeStartTag()
public void flush()
public void reset()
public void close()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |