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
public class DOMSAXContentHandler extends DefaultHandler implements 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, 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
completeCurrentTextNode()
protected Document
createDocument()
protected org.dom4j.io.ElementStack
createElementStack()
void
endCDATA()
void
endDocument()
void
endDTD()
void
endElement(String namespaceURI, String localName, String qName)
void
endEntity(String name)
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.Document
getDocument()
Retrieves w3c document object built via generated sax events.org.dom4j.io.ElementStack
getElementStack()
EntityResolver
getEntityResolver()
InputSource
getInputSource()
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(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
startCDATA()
void
startDocument()
void
startDTD(String name, String publicId, String systemId)
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
-
-
-
-
Constructor Detail
-
DOMSAXContentHandler
public DOMSAXContentHandler()
-
DOMSAXContentHandler
public DOMSAXContentHandler(DOMDocumentFactory documentFactory)
-
-
Method Detail
-
getDocument
public 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(Locator documentLocator)
- Specified by:
setDocumentLocator
in interfaceContentHandler
- Overrides:
setDocumentLocator
in classDefaultHandler
-
processingInstruction
public void processingInstruction(String target, String data) throws SAXException
- Specified by:
processingInstruction
in interfaceContentHandler
- Overrides:
processingInstruction
in classDefaultHandler
- Throws:
SAXException
-
startPrefixMapping
public void startPrefixMapping(String prefix, String uri) throws SAXException
- Specified by:
startPrefixMapping
in interfaceContentHandler
- Overrides:
startPrefixMapping
in classDefaultHandler
- Throws:
SAXException
-
endPrefixMapping
public void endPrefixMapping(String prefix) throws SAXException
- Specified by:
endPrefixMapping
in interfaceContentHandler
- Overrides:
endPrefixMapping
in classDefaultHandler
- Throws:
SAXException
-
startDocument
public void startDocument() throws SAXException
- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classDefaultHandler
- Throws:
SAXException
-
endDocument
public void endDocument() throws SAXException
- 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
public void endElement(String namespaceURI, String localName, String qName) throws SAXException
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Throws:
SAXException
-
characters
public void characters(char[] ch, int start, int end) throws SAXException
- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classDefaultHandler
- Throws:
SAXException
-
warning
public void warning(SAXParseException exception) throws SAXException
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
public void error(SAXParseException exception) throws 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 interfaceErrorHandler
- Overrides:
error
in classDefaultHandler
- Parameters:
exception
- DOCUMENT ME!- Throws:
SAXException
- DOCUMENT ME!
-
fatalError
public void fatalError(SAXParseException exception) throws SAXException
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
public void startDTD(String name, String publicId, String systemId) throws SAXException
- Specified by:
startDTD
in interfaceLexicalHandler
- Throws:
SAXException
-
endDTD
public void endDTD() throws SAXException
- Specified by:
endDTD
in interfaceLexicalHandler
- Throws:
SAXException
-
startEntity
public void startEntity(String name) throws SAXException
- Specified by:
startEntity
in interfaceLexicalHandler
- Throws:
SAXException
-
endEntity
public void endEntity(String name) throws SAXException
- Specified by:
endEntity
in interfaceLexicalHandler
- Throws:
SAXException
-
startCDATA
public void startCDATA() throws SAXException
- Specified by:
startCDATA
in interfaceLexicalHandler
- Throws:
SAXException
-
endCDATA
public void endCDATA() throws SAXException
- Specified by:
endCDATA
in interfaceLexicalHandler
- Throws:
SAXException
-
comment
public void comment(char[] ch, int start, int end) throws SAXException
- Specified by:
comment
in interfaceLexicalHandler
- Throws:
SAXException
-
getElementStack
public org.dom4j.io.ElementStack getElementStack()
-
setElementStack
public void setElementStack(org.dom4j.io.ElementStack elementStack)
-
getEntityResolver
public EntityResolver getEntityResolver()
-
setEntityResolver
public void setEntityResolver(EntityResolver entityResolver)
-
getInputSource
public InputSource getInputSource()
-
setInputSource
public void setInputSource(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, Attributes attributes)
-
createElementStack
protected org.dom4j.io.ElementStack createElementStack()
-
-