Package org.dom4j.io
Class DOMSAXContentHandler
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.dom4j.io.DOMSAXContentHandler
- All Implemented Interfaces:
ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
,LexicalHandler
SAXContentHandler
builds W3C DOM object via SAX events.
- Author:
- James Strachan , Todd Wolff
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addAttributes
(Element element, Attributes attributes) protected void
addDeclaredNamespaces
(Element element) protected String
attributeNameForNamespace
(Namespace namespace) void
characters
(char[] ch, int start, int end) void
comment
(char[] ch, int start, int end) protected void
protected Document
protected org.dom4j.io.ElementStack
void
endCDATA()
void
void
endDTD()
void
endElement
(String namespaceURI, String localName, String qName) void
void
endPrefixMapping
(String prefix) void
error
(SAXParseException exception) This method is called when an error is detected during parsing such as a validation error.void
fatalError
(SAXParseException exception) This method is called when a fatal error occurs during parsing.Retrieves w3c document object built via generated sax events.org.dom4j.io.ElementStack
boolean
Returns whether we should ignore comments or not.boolean
Returns whether adjacent text nodes should be merged together.boolean
Sets whether whitespace between element start and end tags should be ignoredvoid
processingInstruction
(String target, String data) void
setDocumentLocator
(Locator documentLocator) void
setElementStack
(org.dom4j.io.ElementStack elementStack) void
setEntityResolver
(EntityResolver entityResolver) void
setIgnoreComments
(boolean ignoreComments) Sets whether we should ignore comments or not.void
setInputSource
(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
void
void
void
startElement
(String namespaceURI, String localName, String qualifiedName, Attributes attributes) void
startEntity
(String name) void
startPrefixMapping
(String prefix, String uri) void
warning
(SAXParseException exception) This method is called when a warning occurs during the parsing of the document.Methods inherited from class org.xml.sax.helpers.DefaultHandler
ignorableWhitespace, notationDecl, resolveEntity, skippedEntity, unparsedEntityDecl
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.xml.sax.ContentHandler
declaration
-
Constructor Details
-
DOMSAXContentHandler
public DOMSAXContentHandler() -
DOMSAXContentHandler
-
-
Method Details
-
getDocument
Retrieves w3c document object built via generated sax events.- Returns:
- the document that has been or is being built
-
setDocumentLocator
- Specified by:
setDocumentLocator
in interfaceContentHandler
- Overrides:
setDocumentLocator
in classDefaultHandler
-
processingInstruction
- Specified by:
processingInstruction
in interfaceContentHandler
- Overrides:
processingInstruction
in classDefaultHandler
- Throws:
SAXException
-
startPrefixMapping
- Specified by:
startPrefixMapping
in interfaceContentHandler
- Overrides:
startPrefixMapping
in classDefaultHandler
- Throws:
SAXException
-
endPrefixMapping
- Specified by:
endPrefixMapping
in interfaceContentHandler
- Overrides:
endPrefixMapping
in classDefaultHandler
- Throws:
SAXException
-
startDocument
- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classDefaultHandler
- Throws:
SAXException
-
endDocument
- Specified by:
endDocument
in interfaceContentHandler
- Overrides:
endDocument
in classDefaultHandler
- Throws:
SAXException
-
startElement
public void startElement(String namespaceURI, String localName, String qualifiedName, Attributes attributes) throws SAXException - Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Throws:
SAXException
-
endElement
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Throws:
SAXException
-
characters
- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classDefaultHandler
- Throws:
SAXException
-
warning
This method is called when a warning occurs during the parsing of the document. This method does nothing.- Specified by:
warning
in interfaceErrorHandler
- Overrides:
warning
in classDefaultHandler
- Parameters:
exception
- DOCUMENT ME!- Throws:
SAXException
- DOCUMENT ME!
-
error
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 interfaceErrorHandler
- Overrides:
error
in classDefaultHandler
- Parameters:
exception
- DOCUMENT ME!- Throws:
SAXException
- DOCUMENT ME!
-
fatalError
This method is called when a fatal error occurs during parsing. This method rethrows the exception- Specified by:
fatalError
in interfaceErrorHandler
- Overrides:
fatalError
in classDefaultHandler
- Parameters:
exception
- DOCUMENT ME!- Throws:
SAXException
- DOCUMENT ME!
-
startDTD
- Specified by:
startDTD
in interfaceLexicalHandler
- Throws:
SAXException
-
endDTD
- Specified by:
endDTD
in interfaceLexicalHandler
- Throws:
SAXException
-
startEntity
- Specified by:
startEntity
in interfaceLexicalHandler
- Throws:
SAXException
-
endEntity
- Specified by:
endEntity
in interfaceLexicalHandler
- Throws:
SAXException
-
startCDATA
- Specified by:
startCDATA
in interfaceLexicalHandler
- Throws:
SAXException
-
endCDATA
- Specified by:
endCDATA
in interfaceLexicalHandler
- Throws:
SAXException
-
comment
- Specified by:
comment
in interfaceLexicalHandler
- Throws:
SAXException
-
getElementStack
public org.dom4j.io.ElementStack getElementStack() -
setElementStack
public void setElementStack(org.dom4j.io.ElementStack elementStack) -
getEntityResolver
-
setEntityResolver
-
getInputSource
-
setInputSource
-
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
-
addDeclaredNamespaces
-
addAttributes
-
createElementStack
protected org.dom4j.io.ElementStack createElementStack() -
attributeNameForNamespace
-