Package org.dom4j.io
Class DOMSAXContentHandler
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.dom4j.io.DOMSAXContentHandler
-
- All Implemented Interfaces:
org.xml.sax.ContentHandler
,org.xml.sax.DTDHandler
,org.xml.sax.EntityResolver
,org.xml.sax.ErrorHandler
,org.xml.sax.ext.LexicalHandler
public class DOMSAXContentHandler extends org.xml.sax.helpers.DefaultHandler implements org.xml.sax.ext.LexicalHandler
SAXContentHandler
builds W3C DOM object via SAX events.
-
-
Constructor Summary
Constructors Constructor Description DOMSAXContentHandler()
DOMSAXContentHandler(DOMDocumentFactory documentFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addAttributes(Element element, org.xml.sax.Attributes attributes)
protected void
addDeclaredNamespaces(Element element)
protected java.lang.String
attributeNameForNamespace(Namespace namespace)
void
comment(char[] ch, int start, int end)
protected void
completeCurrentTextNode()
protected Document
createDocument()
protected org.dom4j.io.ElementStack
createElementStack()
void
endCDATA()
void
endDocument()
void
endDTD()
void
endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
void
endEntity(java.lang.String name)
void
endPrefixMapping(java.lang.String prefix)
void
error(org.xml.sax.SAXParseException exception)
This method is called when an error is detected during parsing such as a validation error.void
fatalError(org.xml.sax.SAXParseException exception)
This method is called when a fatal error occurs during parsing.org.w3c.dom.Document
getDocument()
Retrieves w3c document object built via generated sax events.org.dom4j.io.ElementStack
getElementStack()
org.xml.sax.EntityResolver
getEntityResolver()
org.xml.sax.InputSource
getInputSource()
void
characters(char[] ch, int start, int end)
boolean
isIgnoreComments()
Returns whether we should ignore comments or not.boolean
isMergeAdjacentText()
Returns whether adjacent text nodes should be merged together.boolean
isStripWhitespaceText()
Sets whether whitespace between element start and end tags should be ignoredvoid
processingInstruction(java.lang.String target, java.lang.String data)
void
setDocumentLocator(org.xml.sax.Locator documentLocator)
void
setElementStack(org.dom4j.io.ElementStack elementStack)
void
setEntityResolver(org.xml.sax.EntityResolver entityResolver)
void
setIgnoreComments(boolean ignoreComments)
Sets whether we should ignore comments or not.void
setInputSource(org.xml.sax.InputSource inputSource)
void
setMergeAdjacentText(boolean mergeAdjacentText)
Sets whether or not adjacent text nodes should be merged together when parsing.void
setStripWhitespaceText(boolean stripWhitespaceText)
Sets whether whitespace between element start and end tags should be ignored.void
startCDATA()
void
startDocument()
void
startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
void
startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qualifiedName, org.xml.sax.Attributes attributes)
void
startEntity(java.lang.String name)
void
startPrefixMapping(java.lang.String prefix, java.lang.String uri)
void
warning(org.xml.sax.SAXParseException exception)
This method is called when a warning occurs during the parsing of the document.
-
-
-
Constructor Detail
-
DOMSAXContentHandler
public DOMSAXContentHandler()
-
DOMSAXContentHandler
public DOMSAXContentHandler(DOMDocumentFactory documentFactory)
-
-
Method Detail
-
getDocument
public org.w3c.dom.Document getDocument()
Retrieves w3c document object built via generated sax events.- Returns:
- the document that has been or is being built
-
setDocumentLocator
public void setDocumentLocator(org.xml.sax.Locator documentLocator)
- Specified by:
setDocumentLocator
in interfaceorg.xml.sax.ContentHandler
- Overrides:
setDocumentLocator
in classorg.xml.sax.helpers.DefaultHandler
-
processingInstruction
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
- Specified by:
processingInstruction
in interfaceorg.xml.sax.ContentHandler
- Overrides:
processingInstruction
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
startPrefixMapping
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws org.xml.sax.SAXException
- Specified by:
startPrefixMapping
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startPrefixMapping
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
endPrefixMapping
public void endPrefixMapping(java.lang.String prefix) throws org.xml.sax.SAXException
- Specified by:
endPrefixMapping
in interfaceorg.xml.sax.ContentHandler
- Overrides:
endPrefixMapping
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
startDocument
public void startDocument() throws org.xml.sax.SAXException
- Specified by:
startDocument
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startDocument
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
endDocument
public void endDocument() throws org.xml.sax.SAXException
- Specified by:
endDocument
in interfaceorg.xml.sax.ContentHandler
- Overrides:
endDocument
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
startElement
public void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qualifiedName, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException
- Specified by:
startElement
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startElement
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
endElement
public void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException
- Specified by:
endElement
in interfaceorg.xml.sax.ContentHandler
- Overrides:
endElement
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
characters
public void characters(char[] ch, int start, int end) throws org.xml.sax.SAXException
- Specified by:
characters
in interfaceorg.xml.sax.ContentHandler
- Overrides:
characters
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
warning
public void warning(org.xml.sax.SAXParseException exception) throws org.xml.sax.SAXException
This method is called when a warning occurs during the parsing of the document. This method does nothing.- Specified by:
warning
in interfaceorg.xml.sax.ErrorHandler
- Overrides:
warning
in classorg.xml.sax.helpers.DefaultHandler
- Parameters:
exception
- DOCUMENT ME!- Throws:
org.xml.sax.SAXException
- DOCUMENT ME!
-
error
public void error(org.xml.sax.SAXParseException exception) throws org.xml.sax.SAXException
This method is called when an error is detected during parsing such as a validation error. This method rethrows the exception- Specified by:
error
in interfaceorg.xml.sax.ErrorHandler
- Overrides:
error
in classorg.xml.sax.helpers.DefaultHandler
- Parameters:
exception
- DOCUMENT ME!- Throws:
org.xml.sax.SAXException
- DOCUMENT ME!
-
fatalError
public void fatalError(org.xml.sax.SAXParseException exception) throws org.xml.sax.SAXException
This method is called when a fatal error occurs during parsing. This method rethrows the exception- Specified by:
fatalError
in interfaceorg.xml.sax.ErrorHandler
- Overrides:
fatalError
in classorg.xml.sax.helpers.DefaultHandler
- Parameters:
exception
- DOCUMENT ME!- Throws:
org.xml.sax.SAXException
- DOCUMENT ME!
-
startDTD
public void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
- Specified by:
startDTD
in interfaceorg.xml.sax.ext.LexicalHandler
- Throws:
org.xml.sax.SAXException
-
endDTD
public void endDTD() throws org.xml.sax.SAXException
- Specified by:
endDTD
in interfaceorg.xml.sax.ext.LexicalHandler
- Throws:
org.xml.sax.SAXException
-
startEntity
public void startEntity(java.lang.String name) throws org.xml.sax.SAXException
- Specified by:
startEntity
in interfaceorg.xml.sax.ext.LexicalHandler
- Throws:
org.xml.sax.SAXException
-
endEntity
public void endEntity(java.lang.String name) throws org.xml.sax.SAXException
- Specified by:
endEntity
in interfaceorg.xml.sax.ext.LexicalHandler
- Throws:
org.xml.sax.SAXException
-
startCDATA
public void startCDATA() throws org.xml.sax.SAXException
- Specified by:
startCDATA
in interfaceorg.xml.sax.ext.LexicalHandler
- Throws:
org.xml.sax.SAXException
-
endCDATA
public void endCDATA() throws org.xml.sax.SAXException
- Specified by:
endCDATA
in interfaceorg.xml.sax.ext.LexicalHandler
- Throws:
org.xml.sax.SAXException
-
comment
public void comment(char[] ch, int start, int end) throws org.xml.sax.SAXException
- Specified by:
comment
in interfaceorg.xml.sax.ext.LexicalHandler
- Throws:
org.xml.sax.SAXException
-
getElementStack
public org.dom4j.io.ElementStack getElementStack()
-
setElementStack
public void setElementStack(org.dom4j.io.ElementStack elementStack)
-
getEntityResolver
public org.xml.sax.EntityResolver getEntityResolver()
-
setEntityResolver
public void setEntityResolver(org.xml.sax.EntityResolver entityResolver)
-
getInputSource
public org.xml.sax.InputSource getInputSource()
-
setInputSource
public void setInputSource(org.xml.sax.InputSource inputSource)
-
isMergeAdjacentText
public boolean isMergeAdjacentText()
Returns whether adjacent text nodes should be merged together.- Returns:
- Value of property mergeAdjacentText.
-
setMergeAdjacentText
public void setMergeAdjacentText(boolean mergeAdjacentText)
Sets whether or not adjacent text nodes should be merged together when parsing.- Parameters:
mergeAdjacentText
- New value of property mergeAdjacentText.
-
isStripWhitespaceText
public boolean isStripWhitespaceText()
Sets whether whitespace between element start and end tags should be ignored- Returns:
- Value of property stripWhitespaceText.
-
setStripWhitespaceText
public void setStripWhitespaceText(boolean stripWhitespaceText)
Sets whether whitespace between element start and end tags should be ignored.- Parameters:
stripWhitespaceText
- New value of property stripWhitespaceText.
-
isIgnoreComments
public boolean isIgnoreComments()
Returns whether we should ignore comments or not.- Returns:
- boolean
-
setIgnoreComments
public void setIgnoreComments(boolean ignoreComments)
Sets whether we should ignore comments or not.- Parameters:
ignoreComments
- whether we should ignore comments or not.
-
completeCurrentTextNode
protected void completeCurrentTextNode()
-
createDocument
protected Document createDocument()
-
addDeclaredNamespaces
protected void addDeclaredNamespaces(Element element)
-
addAttributes
protected void addAttributes(Element element, org.xml.sax.Attributes attributes)
-
createElementStack
protected org.dom4j.io.ElementStack createElementStack()
-
attributeNameForNamespace
protected java.lang.String attributeNameForNamespace(Namespace namespace)
-
-