org.dom4j.io
Class DOMSAXContentHandler

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended byorg.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.

Author:
James Strachan , Todd Wolff


Constructor Summary
DOMSAXContentHandler()
           
DOMSAXContentHandler(DOMDocumentFactory documentFactory)
           
 
Method Summary
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 ignored
 void 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 interface ContentHandler

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Specified by:
processingInstruction in interface ContentHandler
Throws:
SAXException

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException
Specified by:
startPrefixMapping in interface ContentHandler
Throws:
SAXException

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws SAXException
Specified by:
endPrefixMapping in interface ContentHandler
Throws:
SAXException

startDocument

public void startDocument()
                   throws SAXException
Specified by:
startDocument in interface ContentHandler
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
Specified by:
endDocument in interface ContentHandler
Throws:
SAXException

startElement

public void startElement(String namespaceURI,
                         String localName,
                         String qualifiedName,
                         Attributes attributes)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Throws:
SAXException

endElement

public void endElement(String namespaceURI,
                       String localName,
                       String qName)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Throws:
SAXException

characters

public void characters(char[] ch,
                       int start,
                       int end)
                throws SAXException
Specified by:
characters in interface ContentHandler
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 interface ErrorHandler
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 interface ErrorHandler
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 interface ErrorHandler
Parameters:
exception - DOCUMENT ME!
Throws:
SAXException - DOCUMENT ME!

startDTD

public void startDTD(String name,
                     String publicId,
                     String systemId)
              throws SAXException
Specified by:
startDTD in interface LexicalHandler
Throws:
SAXException

endDTD

public void endDTD()
            throws SAXException
Specified by:
endDTD in interface LexicalHandler
Throws:
SAXException

startEntity

public void startEntity(String name)
                 throws SAXException
Specified by:
startEntity in interface LexicalHandler
Throws:
SAXException

endEntity

public void endEntity(String name)
               throws SAXException
Specified by:
endEntity in interface LexicalHandler
Throws:
SAXException

startCDATA

public void startCDATA()
                throws SAXException
Specified by:
startCDATA in interface LexicalHandler
Throws:
SAXException

endCDATA

public void endCDATA()
              throws SAXException
Specified by:
endCDATA in interface LexicalHandler
Throws:
SAXException

comment

public void comment(char[] ch,
                    int start,
                    int end)
             throws SAXException
Specified by:
comment in interface LexicalHandler
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()

attributeNameForNamespace

protected String attributeNameForNamespace(Namespace namespace)


Copyright © 2001-2006 MetaStuff Ltd.. All Rights Reserved.