org.apache.cocoon.xml.dom
Class DOMBuilder

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLoggable
        |
        +--org.apache.cocoon.xml.AbstractXMLProducer
              |
              +--org.apache.cocoon.xml.AbstractXMLPipe
                    |
                    +--org.apache.cocoon.xml.dom.DOMBuilder
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler, org.apache.avalon.framework.logger.Loggable, org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable, XMLConsumer, XMLPipe, XMLProducer

public class DOMBuilder
extends AbstractXMLPipe

The DOMBuilder is a utility class that will generate a W3C DOM Document from SAX events.

Version:
CVS $Id: DOMBuilder.java,v 1.7.2.1 2002/11/21 15:06:49 sylvain Exp $
Author:
Carsten Ziegeler

Inner Class Summary
static interface DOMBuilder.Listener
          The Listener interface must be implemented by those objects willing to be notified of a successful DOM tree generation.
 
Field Summary
protected static javax.xml.transform.sax.SAXTransformerFactory factory
          The transformer factory shared by all instances
protected  DOMBuilder.Listener listener
          The listener
protected  org.w3c.dom.Node parentNode
          The parentNode
protected  javax.xml.transform.dom.DOMResult result
          The result
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, lexicalHandler, xmlConsumer
 
Constructor Summary
DOMBuilder()
          Construct a new instance of this TreeGenerator.
DOMBuilder(DOMBuilder.Listener listener)
          Construct a new instance of this TreeGenerator.
DOMBuilder(DOMBuilder.Listener listener, org.w3c.dom.Node parentNode)
          Construct a new instance of this TreeGenerator.
DOMBuilder(DOMFactory factory)
          Deprecated. Use DOMBuilder() instead.
DOMBuilder(DOMFactory factory, DOMBuilder.Listener listener)
          Deprecated. Use DOMBuilder(listener) instead.
DOMBuilder(DOMFactory domFactory, DOMBuilder.Listener listener, org.w3c.dom.Node parentNode)
          Deprecated. Use DOMBuilder(listener, parentNode) instead.
DOMBuilder(org.w3c.dom.Node parentNode)
          Constructs a new instance that appends nodes to the given parent node.
Note : you cannot use a Listener when appending to a Node, because the notification occurs at endDocument() which does not happen here.
 
Method Summary
 void endDocument()
          Receive notification of the beginning of a document.
 org.w3c.dom.Document getDocument()
          Return the newly built Document.
protected  void notifyListener()
          Receive notification of a successfully completed DOM tree generation.
 void recycle()
          Recycling
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
characters, comment, endCDATA, endDTD, endElement, endEntity, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startCDATA, startDocument, startDTD, startElement, startEntity, startPrefixMapping
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setConsumer, setContentHandler, setLexicalHandler
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable
getLogger, setLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
 

Field Detail

factory

protected static final javax.xml.transform.sax.SAXTransformerFactory factory
The transformer factory shared by all instances

listener

protected DOMBuilder.Listener listener
The listener

result

protected javax.xml.transform.dom.DOMResult result
The result

parentNode

protected org.w3c.dom.Node parentNode
The parentNode
Constructor Detail

DOMBuilder

public DOMBuilder()
Construct a new instance of this TreeGenerator.

DOMBuilder

public DOMBuilder(DOMFactory factory)
Deprecated. Use DOMBuilder() instead.

Construct a new instance of this TreeGenerator.

DOMBuilder

public DOMBuilder(DOMBuilder.Listener listener)
Construct a new instance of this TreeGenerator.

DOMBuilder

public DOMBuilder(DOMFactory factory,
                  DOMBuilder.Listener listener)
Deprecated. Use DOMBuilder(listener) instead.

Construct a new instance of this TreeGenerator.

DOMBuilder

public DOMBuilder(DOMFactory domFactory,
                  DOMBuilder.Listener listener,
                  org.w3c.dom.Node parentNode)
Deprecated. Use DOMBuilder(listener, parentNode) instead.

Construct a new instance of this TreeGenerator.

DOMBuilder

public DOMBuilder(DOMBuilder.Listener listener,
                  org.w3c.dom.Node parentNode)
Construct a new instance of this TreeGenerator.

DOMBuilder

public DOMBuilder(org.w3c.dom.Node parentNode)
Constructs a new instance that appends nodes to the given parent node.
Note : you cannot use a Listener when appending to a Node, because the notification occurs at endDocument() which does not happen here.
Method Detail

recycle

public void recycle()
Recycling
Overrides:
recycle in class AbstractXMLProducer

getDocument

public org.w3c.dom.Document getDocument()
Return the newly built Document.

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Receive notification of the beginning of a document.
Overrides:
endDocument in class AbstractXMLPipe
Throws:
org.xml.sax.SAXException - If this method was not called appropriately.

notifyListener

protected void notifyListener()
                       throws org.xml.sax.SAXException
Receive notification of a successfully completed DOM tree generation.


Copyright � 1999-2002 Apache Software Foundation. All Rights Reserved.