org.apache.cocoon.xml.dom
Class DOMBuilder

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.xml.AbstractXMLProducer
          extended by org.apache.cocoon.xml.AbstractXMLPipe
              extended by org.apache.cocoon.xml.dom.DOMBuilder
All Implemented Interfaces:
Poolable, Recyclable, LogEnabled, XMLPipe, XMLProducer, XMLConsumer, ContentHandler, LexicalHandler

public class DOMBuilder
extends AbstractXMLPipe

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

Version:
$Id: DOMBuilder.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Carsten Ziegeler

Nested 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  SAXTransformerFactory factory
          The transformer factory
protected static SAXTransformerFactory FACTORY
          The default transformer factory shared by all instances
protected  DOMBuilder.Listener listener
          The listener
protected  Node parentNode
          The parentNode
protected  DOMResult result
          The result
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
 
Constructor Summary
DOMBuilder()
          Construct a new instance of this DOMBuilder.
DOMBuilder(DOMBuilder.Listener listener)
          Construct a new instance of this DOMBuilder.
DOMBuilder(DOMBuilder.Listener listener, Node parentNode)
          Construct a new instance of this DOMBuilder.
DOMBuilder(DOMFactory factory)
          Deprecated. Use DOMBuilder() instead.
DOMBuilder(DOMFactory factory, DOMBuilder.Listener listener)
          Deprecated. Use DOMBuilder(listener) instead.
DOMBuilder(DOMFactory domFactory, DOMBuilder.Listener listener, Node parentNode)
          Deprecated. Use DOMBuilder(listener, parentNode) instead.
DOMBuilder(Node parentNode)
          Constructs a new instance that appends nodes to the given parent node.
DOMBuilder(SAXTransformerFactory factory)
          Construct a new instance of this DOMBuilder.
DOMBuilder(SAXTransformerFactory factory, DOMBuilder.Listener listener, Node parentNode)
          Construct a new instance of this DOMBuilder.
 
Method Summary
 void endDocument()
          Receive notification of the end of a document.
 Document getDocument()
          Return the newly built Document.
protected  void notifyListener()
          Receive notification of a successfully completed DOM tree generation.
 void recycle()
          Recycle this builder, prepare for re-use.
 
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.AbstractLogEnabled
enableLogging, getLogger, 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 SAXTransformerFactory FACTORY
The default transformer factory shared by all instances


factory

protected SAXTransformerFactory factory
The transformer factory


listener

protected DOMBuilder.Listener listener
The listener


result

protected DOMResult result
The result


parentNode

protected Node parentNode
The parentNode

Constructor Detail

DOMBuilder

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


DOMBuilder

public DOMBuilder(SAXTransformerFactory factory)
Construct a new instance of this DOMBuilder.


DOMBuilder

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

Construct a new instance of this DOMBuilder.


DOMBuilder

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


DOMBuilder

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

Construct a new instance of this DOMBuilder.


DOMBuilder

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

Construct a new instance of this DOMBuilder.


DOMBuilder

public DOMBuilder(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.


DOMBuilder

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


DOMBuilder

public DOMBuilder(SAXTransformerFactory factory,
                  DOMBuilder.Listener listener,
                  Node parentNode)
Construct a new instance of this DOMBuilder.

Method Detail

recycle

public void recycle()
Recycle this builder, prepare for re-use.

Specified by:
recycle in interface Recyclable
Overrides:
recycle in class AbstractXMLProducer

getDocument

public Document getDocument()
Return the newly built Document.


endDocument

public void endDocument()
                 throws SAXException
Receive notification of the end of a document.

Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in class AbstractXMLPipe
Throws:
SAXException - If this method was not called appropriately.

notifyListener

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

Throws:
SAXException


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.