Interface Serializer
-
- All Known Implementing Classes:
BaseMarkupSerializer,XMLSerializer
public interface SerializerInterface for a DOM serializer implementation, factory for DOM and SAX serializers, and static methods for serializing DOM documents.To serialize a document using SAX events, create a compatible serializer and pass it around as a
DocumentHandler. If an I/O error occurs while serializing, it will be thrown byDocumentHandler.endDocument(). The SAX serializer may also be used asDTDHandler,DeclHandlerandLexicalHandler.To serialize a DOM document or DOM element, create a compatible serializer and call it's
DOMSerializer.serialize(Document)orDOMSerializer.serialize(Element)methods. Both methods would produce a full XML document, to serizlie only the portion of the document useOutputFormat.setOmitXMLDeclaration(boolean)and specify no document type.The
OutputFormatdictates what underlying serialized is used to serialize the document based on the specified method. If the output format or method are missing, the default is an XML serializer with UTF-8 encoding and now indentation.- See Also:
DocumentHandler,ContentHandler,OutputFormat,DOMSerializer
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description org.xml.sax.ContentHandlerasContentHandler()Return aContentHandlerinterface into this serializer.org.xml.sax.DocumentHandlerasDocumentHandler()Return aDocumentHandlerinterface into this serializer.DOMSerializerasDOMSerializer()Return aDOMSerializerinterface into this serializer.voidsetOutputByteStream(java.io.OutputStream output)Specifies an output stream to which the document should be serialized.voidsetOutputCharStream(java.io.Writer output)Specifies a writer to which the document should be serialized.voidsetOutputFormat(OutputFormat format)Specifies an output format for this serializer.
-
-
-
Method Detail
-
setOutputByteStream
void setOutputByteStream(java.io.OutputStream output)
Specifies an output stream to which the document should be serialized. This method should not be called while the serializer is in the process of serializing a document.
-
setOutputCharStream
void setOutputCharStream(java.io.Writer output)
Specifies a writer to which the document should be serialized. This method should not be called while the serializer is in the process of serializing a document.
-
setOutputFormat
void setOutputFormat(OutputFormat format)
Specifies an output format for this serializer. It the serializer has already been associated with an output format, it will switch to the new format. This method should not be called while the serializer is in the process of serializing a document.- Parameters:
format- The output format to use
-
asDocumentHandler
org.xml.sax.DocumentHandler asDocumentHandler() throws java.io.IOExceptionReturn aDocumentHandlerinterface into this serializer. If the serializer does not support theDocumentHandlerinterface, it should return null.- Throws:
java.io.IOException
-
asContentHandler
org.xml.sax.ContentHandler asContentHandler() throws java.io.IOExceptionReturn aContentHandlerinterface into this serializer. If the serializer does not support theContentHandlerinterface, it should return null.- Throws:
java.io.IOException
-
asDOMSerializer
DOMSerializer asDOMSerializer() throws java.io.IOException
Return aDOMSerializerinterface into this serializer. If the serializer does not support theDOMSerializerinterface, it should return null.- Throws:
java.io.IOException
-
-