Class BaseMarkupSerializer
- java.lang.Object
-
- org.apache.jackrabbit.vault.util.xml.serialize.BaseMarkupSerializer
-
- All Implemented Interfaces:
DOMSerializer
,Serializer
,ContentHandler
,DocumentHandler
,DTDHandler
,DeclHandler
,LexicalHandler
- Direct Known Subclasses:
XMLSerializer
@Deprecated(since="2021-09-01") public abstract class BaseMarkupSerializer extends Object implements ContentHandler, DocumentHandler, LexicalHandler, DTDHandler, DeclHandler, DOMSerializer, Serializer
Deprecated.Util Classes related to Xerces are removed in subsequent releases causing a major version change. As these utils are for internal use in Filevault the API is getting deprecated from public API surface.Base class for a serializer supporting both DOM and SAX pretty serializing of XML/HTML/XHTML documents. Derives classes perform the method-specific serializing, this class provides the common serializing mechanisms.The serializer must be initialized with the proper writer and output format before it can be used by calling
setOutputCharStream(java.io.Writer)
orsetOutputByteStream(java.io.OutputStream)
for the writer andsetOutputFormat(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.
- See Also:
Serializer
,LSSerializer
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ContentHandler
asContentHandler()
Deprecated.Return aContentHandler
interface into this serializer.DocumentHandler
asDocumentHandler()
Deprecated.Return aDocumentHandler
interface into this serializer.DOMSerializer
asDOMSerializer()
Deprecated.Return aDOMSerializer
interface into this serializer.void
attributeDecl(String eName, String aName, String type, String valueDefault, String value)
Deprecated.void
characters(char[] chars, int start, int length)
Deprecated.void
comment(char[] chars, int start, int length)
Deprecated.void
comment(String text)
Deprecated.void
elementDecl(String name, String model)
Deprecated.void
endCDATA()
Deprecated.void
endDocument()
Deprecated.Called at the end of the document to wrap it up.void
endDTD()
Deprecated.void
endEntity(String name)
Deprecated.void
endNonEscaping()
Deprecated.void
endPrefixMapping(String prefix)
Deprecated.void
endPreserving()
Deprecated.void
externalEntityDecl(String name, String publicId, String systemId)
Deprecated.void
ignorableWhitespace(char[] chars, int start, int length)
Deprecated.void
internalEntityDecl(String name, String value)
Deprecated.void
notationDecl(String name, String publicId, String systemId)
Deprecated.void
processingInstruction(String target, String code)
Deprecated.void
processingInstructionIO(String target, String code)
Deprecated.boolean
reset()
Deprecated.void
serialize(Document doc)
Deprecated.Serializes the DOM document using the previously specified writer and output format.void
serialize(DocumentFragment frag)
Deprecated.Serializes the DOM document fragmnt using the previously specified writer and output format.void
serialize(Element elem)
Deprecated.Serializes the DOM element using the previously specified writer and output format.void
setDocumentLocator(Locator locator)
Deprecated.void
setOutputByteStream(OutputStream output)
Deprecated.The specified stream will not be closed by this class.void
setOutputCharStream(Writer writer)
Deprecated.The specified writer will not be closed by this class.void
setOutputFormat(OutputFormat format)
Deprecated.Specifies an output format for this serializer.void
skippedEntity(String name)
Deprecated.void
startCDATA()
Deprecated.void
startDocument()
Deprecated.void
startDTD(String name, String publicId, String systemId)
Deprecated.void
startEntity(String name)
Deprecated.void
startNonEscaping()
Deprecated.void
startPrefixMapping(String prefix, String uri)
Deprecated.void
startPreserving()
Deprecated.void
unparsedEntityDecl(String name, String publicId, String systemId, String notationName)
Deprecated.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.xml.sax.ContentHandler
endElement, startElement
-
Methods inherited from interface org.xml.sax.DocumentHandler
endElement, startElement
-
-
-
-
Method Detail
-
asDocumentHandler
public DocumentHandler asDocumentHandler() throws IOException
Deprecated.Description copied from interface:Serializer
Return aDocumentHandler
interface into this serializer. If the serializer does not support theDocumentHandler
interface, it should return null.- Specified by:
asDocumentHandler
in interfaceSerializer
- Throws:
IOException
-
asContentHandler
public ContentHandler asContentHandler() throws IOException
Deprecated.Description copied from interface:Serializer
Return aContentHandler
interface into this serializer. If the serializer does not support theContentHandler
interface, it should return null.- Specified by:
asContentHandler
in interfaceSerializer
- Throws:
IOException
-
asDOMSerializer
public DOMSerializer asDOMSerializer() throws IOException
Deprecated.Description copied from interface:Serializer
Return aDOMSerializer
interface into this serializer. If the serializer does not support theDOMSerializer
interface, it should return null.- Specified by:
asDOMSerializer
in interfaceSerializer
- Throws:
IOException
-
setOutputByteStream
public void setOutputByteStream(OutputStream output)
Deprecated.The specified stream will not be closed by this class.
- Specified by:
setOutputByteStream
in interfaceSerializer
-
setOutputCharStream
public void setOutputCharStream(Writer writer)
Deprecated.The specified writer will not be closed by this class.
- Specified by:
setOutputCharStream
in interfaceSerializer
-
setOutputFormat
public void setOutputFormat(OutputFormat format)
Deprecated.Description copied from interface:Serializer
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.- Specified by:
setOutputFormat
in interfaceSerializer
- Parameters:
format
- The output format to use
-
reset
public boolean reset()
Deprecated.
-
serialize
public void serialize(Element elem) throws IOException
Deprecated.Serializes the DOM element using the previously specified writer and output format. Throws an exception only if an I/O exception occured while serializing.- Specified by:
serialize
in interfaceDOMSerializer
- Parameters:
elem
- The element to serialize- Throws:
IOException
- An I/O exception occured while serializing
-
serialize
public void serialize(DocumentFragment frag) throws IOException
Deprecated.Serializes the DOM document fragmnt using the previously specified writer and output format. Throws an exception only if an I/O exception occured while serializing.- Specified by:
serialize
in interfaceDOMSerializer
- Parameters:
frag
- The element to serialize- Throws:
IOException
- An I/O exception occured while serializing
-
serialize
public void serialize(Document doc) throws IOException
Deprecated.Serializes the DOM document using the previously specified writer and output format. Throws an exception only if an I/O exception occured while serializing.- Specified by:
serialize
in interfaceDOMSerializer
- Parameters:
doc
- The document to serialize- Throws:
IOException
- An I/O exception occured while serializing
-
startDocument
public void startDocument() throws SAXException
Deprecated.- Specified by:
startDocument
in interfaceContentHandler
- Specified by:
startDocument
in interfaceDocumentHandler
- Throws:
SAXException
-
characters
public void characters(char[] chars, int start, int length) throws SAXException
Deprecated.- Specified by:
characters
in interfaceContentHandler
- Specified by:
characters
in interfaceDocumentHandler
- Throws:
SAXException
-
ignorableWhitespace
public void ignorableWhitespace(char[] chars, int start, int length) throws SAXException
Deprecated.- Specified by:
ignorableWhitespace
in interfaceContentHandler
- Specified by:
ignorableWhitespace
in interfaceDocumentHandler
- Throws:
SAXException
-
processingInstruction
public final void processingInstruction(String target, String code) throws SAXException
Deprecated.- Specified by:
processingInstruction
in interfaceContentHandler
- Specified by:
processingInstruction
in interfaceDocumentHandler
- Throws:
SAXException
-
processingInstructionIO
public void processingInstructionIO(String target, String code) throws IOException
Deprecated.- Throws:
IOException
-
comment
public void comment(char[] chars, int start, int length) throws SAXException
Deprecated.- Specified by:
comment
in interfaceLexicalHandler
- Throws:
SAXException
-
comment
public void comment(String text) throws IOException
Deprecated.- Throws:
IOException
-
startCDATA
public void startCDATA()
Deprecated.- Specified by:
startCDATA
in interfaceLexicalHandler
-
endCDATA
public void endCDATA()
Deprecated.- Specified by:
endCDATA
in interfaceLexicalHandler
-
startNonEscaping
public void startNonEscaping()
Deprecated.
-
endNonEscaping
public void endNonEscaping()
Deprecated.
-
startPreserving
public void startPreserving()
Deprecated.
-
endPreserving
public void endPreserving()
Deprecated.
-
endDocument
public void endDocument() throws SAXException
Deprecated.Called at the end of the document to wrap it up. Will flush the output stream and throw an exception if any I/O error occured while serializing.- Specified by:
endDocument
in interfaceContentHandler
- Specified by:
endDocument
in interfaceDocumentHandler
- Throws:
SAXException
- An I/O exception occured during serializing
-
startEntity
public void startEntity(String name)
Deprecated.- Specified by:
startEntity
in interfaceLexicalHandler
-
endEntity
public void endEntity(String name)
Deprecated.- Specified by:
endEntity
in interfaceLexicalHandler
-
setDocumentLocator
public void setDocumentLocator(Locator locator)
Deprecated.- Specified by:
setDocumentLocator
in interfaceContentHandler
- Specified by:
setDocumentLocator
in interfaceDocumentHandler
-
skippedEntity
public void skippedEntity(String name) throws SAXException
Deprecated.- Specified by:
skippedEntity
in interfaceContentHandler
- Throws:
SAXException
-
startPrefixMapping
public void startPrefixMapping(String prefix, String uri) throws SAXException
Deprecated.- Specified by:
startPrefixMapping
in interfaceContentHandler
- Throws:
SAXException
-
endPrefixMapping
public void endPrefixMapping(String prefix) throws SAXException
Deprecated.- Specified by:
endPrefixMapping
in interfaceContentHandler
- Throws:
SAXException
-
startDTD
public final void startDTD(String name, String publicId, String systemId) throws SAXException
Deprecated.- Specified by:
startDTD
in interfaceLexicalHandler
- Throws:
SAXException
-
endDTD
public void endDTD()
Deprecated.- Specified by:
endDTD
in interfaceLexicalHandler
-
elementDecl
public void elementDecl(String name, String model) throws SAXException
Deprecated.- Specified by:
elementDecl
in interfaceDeclHandler
- Throws:
SAXException
-
attributeDecl
public void attributeDecl(String eName, String aName, String type, String valueDefault, String value) throws SAXException
Deprecated.- Specified by:
attributeDecl
in interfaceDeclHandler
- Throws:
SAXException
-
internalEntityDecl
public void internalEntityDecl(String name, String value) throws SAXException
Deprecated.- Specified by:
internalEntityDecl
in interfaceDeclHandler
- Throws:
SAXException
-
externalEntityDecl
public void externalEntityDecl(String name, String publicId, String systemId) throws SAXException
Deprecated.- Specified by:
externalEntityDecl
in interfaceDeclHandler
- Throws:
SAXException
-
unparsedEntityDecl
public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws SAXException
Deprecated.- Specified by:
unparsedEntityDecl
in interfaceDTDHandler
- Throws:
SAXException
-
notationDecl
public void notationDecl(String name, String publicId, String systemId) throws SAXException
Deprecated.- Specified by:
notationDecl
in interfaceDTDHandler
- Throws:
SAXException
-
-