public abstract class BaseMarkupSerializer extends Object implements ContentHandler, DocumentHandler, LexicalHandler, DTDHandler, DeclHandler, DOMSerializer, Serializer
The serializer must be initialized with the proper writer and
output format before it can be used by calling setOutputCharStream(java.io.Writer)
or setOutputByteStream(java.io.OutputStream) for the writer and setOutputFormat(org.apache.jackrabbit.vault.util.xml.serialize.OutputFormat)
for the output format.
The serializer can be reused any number of times, but cannot be used concurrently by two threads.
If an output stream is used, the encoding is taken from the output format (defaults to UTF-8). If a writer is used, make sure the writer uses the same encoding (if applies) as specified in the output format.
The serializer supports both DOM and SAX. DOM serializing is done
by calling serialize(Document) and SAX serializing is done by firing
SAX events and using the serializer as a document handler.
This also applies to derived class.
If an I/O exception occurs while serializing, the serializer
will not throw an exception directly, but only throw it
at the end of serializing (either DOM or SAX's DocumentHandler.endDocument().
For elements that are not specified as whitespace preserving, the serializer will potentially break long text lines at space boundaries, indent lines, and serialize elements on separate lines. Line terminators will be regarded as spaces, and spaces at beginning of line will be stripped.
When indenting, the serializer is capable of detecting seemingly element content, and serializing these elements indented on separate lines. An element is serialized indented when it is the first or last child of an element, or immediate following or preceding another element.
Serializer,
LSSerializer| Modifier and Type | Method and Description |
|---|---|
ContentHandler |
asContentHandler()
Return a
ContentHandler interface into this serializer. |
DocumentHandler |
asDocumentHandler()
Return a
DocumentHandler interface into this serializer. |
DOMSerializer |
asDOMSerializer()
Return a
DOMSerializer interface into this serializer. |
void |
attributeDecl(String eName,
String aName,
String type,
String valueDefault,
String value) |
void |
characters(char[] chars,
int start,
int length) |
void |
comment(char[] chars,
int start,
int length) |
void |
comment(String text) |
void |
elementDecl(String name,
String model) |
void |
endCDATA() |
void |
endDocument()
Called at the end of the document to wrap it up.
|
void |
endDTD() |
void |
endEntity(String name) |
void |
endNonEscaping() |
void |
endPrefixMapping(String prefix) |
void |
endPreserving() |
void |
externalEntityDecl(String name,
String publicId,
String systemId) |
void |
ignorableWhitespace(char[] chars,
int start,
int length) |
void |
internalEntityDecl(String name,
String value) |
void |
notationDecl(String name,
String publicId,
String systemId) |
void |
processingInstruction(String target,
String code) |
void |
processingInstructionIO(String target,
String code) |
boolean |
reset() |
void |
serialize(Document doc)
Serializes the DOM document using the previously specified
writer and output format.
|
void |
serialize(DocumentFragment frag)
Serializes the DOM document fragmnt using the previously specified
writer and output format.
|
void |
serialize(Element elem)
Serializes the DOM element using the previously specified
writer and output format.
|
void |
setDocumentLocator(Locator locator) |
void |
setOutputByteStream(OutputStream output)
The specified stream will not be closed by this class.
|
void |
setOutputCharStream(Writer writer)
The specified writer will not be closed by this class.
|
void |
setOutputFormat(OutputFormat format)
Specifies an output format for this serializer.
|
void |
skippedEntity(String name) |
void |
startCDATA() |
void |
startDocument() |
void |
startDTD(String name,
String publicId,
String systemId) |
void |
startEntity(String name) |
void |
startNonEscaping() |
void |
startPrefixMapping(String prefix,
String uri) |
void |
startPreserving() |
void |
unparsedEntityDecl(String name,
String publicId,
String systemId,
String notationName) |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitendElement, startElementendElement, startElementpublic DocumentHandler asDocumentHandler() throws IOException
SerializerDocumentHandler interface into this serializer.
If the serializer does not support the DocumentHandler
interface, it should return null.asDocumentHandler in interface SerializerIOExceptionpublic ContentHandler asContentHandler() throws IOException
SerializerContentHandler interface into this serializer.
If the serializer does not support the ContentHandler
interface, it should return null.asContentHandler in interface SerializerIOExceptionpublic DOMSerializer asDOMSerializer() throws IOException
SerializerDOMSerializer interface into this serializer.
If the serializer does not support the DOMSerializer
interface, it should return null.asDOMSerializer in interface SerializerIOExceptionpublic void setOutputByteStream(OutputStream output)
The specified stream will not be closed by this class.
setOutputByteStream in interface Serializerpublic void setOutputCharStream(Writer writer)
The specified writer will not be closed by this class.
setOutputCharStream in interface Serializerpublic void setOutputFormat(OutputFormat format)
SerializersetOutputFormat in interface Serializerformat - The output format to usepublic boolean reset()
public void serialize(Element elem) throws IOException
serialize in interface DOMSerializerelem - The element to serializeIOException - An I/O exception occured while
serializingpublic void serialize(DocumentFragment frag) throws IOException
serialize in interface DOMSerializerfrag - The element to serializeIOException - An I/O exception occured while
serializingpublic void serialize(Document doc) throws IOException
serialize in interface DOMSerializerdoc - The document to serializeIOException - An I/O exception occured while
serializingpublic void startDocument()
throws SAXException
startDocument in interface ContentHandlerstartDocument in interface DocumentHandlerSAXExceptionpublic void characters(char[] chars,
int start,
int length)
throws SAXException
characters in interface ContentHandlercharacters in interface DocumentHandlerSAXExceptionpublic void ignorableWhitespace(char[] chars,
int start,
int length)
throws SAXException
ignorableWhitespace in interface ContentHandlerignorableWhitespace in interface DocumentHandlerSAXExceptionpublic final void processingInstruction(String target, String code) throws SAXException
processingInstruction in interface ContentHandlerprocessingInstruction in interface DocumentHandlerSAXExceptionpublic void processingInstructionIO(String target, String code) throws IOException
IOExceptionpublic void comment(char[] chars,
int start,
int length)
throws SAXException
comment in interface LexicalHandlerSAXExceptionpublic void comment(String text) throws IOException
IOExceptionpublic void startCDATA()
startCDATA in interface LexicalHandlerpublic void endCDATA()
endCDATA in interface LexicalHandlerpublic void startNonEscaping()
public void endNonEscaping()
public void startPreserving()
public void endPreserving()
public void endDocument()
throws SAXException
endDocument in interface ContentHandlerendDocument in interface DocumentHandlerSAXException - An I/O exception occured during
serializingpublic void startEntity(String name)
startEntity in interface LexicalHandlerpublic void endEntity(String name)
endEntity in interface LexicalHandlerpublic void setDocumentLocator(Locator locator)
setDocumentLocator in interface ContentHandlersetDocumentLocator in interface DocumentHandlerpublic void skippedEntity(String name) throws SAXException
skippedEntity in interface ContentHandlerSAXExceptionpublic void startPrefixMapping(String prefix, String uri) throws SAXException
startPrefixMapping in interface ContentHandlerSAXExceptionpublic void endPrefixMapping(String prefix) throws SAXException
endPrefixMapping in interface ContentHandlerSAXExceptionpublic final void startDTD(String name, String publicId, String systemId) throws SAXException
startDTD in interface LexicalHandlerSAXExceptionpublic void endDTD()
endDTD in interface LexicalHandlerpublic void elementDecl(String name, String model) throws SAXException
elementDecl in interface DeclHandlerSAXExceptionpublic void attributeDecl(String eName, String aName, String type, String valueDefault, String value) throws SAXException
attributeDecl in interface DeclHandlerSAXExceptionpublic void internalEntityDecl(String name, String value) throws SAXException
internalEntityDecl in interface DeclHandlerSAXExceptionpublic void externalEntityDecl(String name, String publicId, String systemId) throws SAXException
externalEntityDecl in interface DeclHandlerSAXExceptionpublic void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws SAXException
unparsedEntityDecl in interface DTDHandlerSAXExceptionpublic void notationDecl(String name, String publicId, String systemId) throws SAXException
notationDecl in interface DTDHandlerSAXExceptionCopyright © 2010 - 2020 Adobe. All Rights Reserved