Enhydra 5.1 API

org.w3c.tidy
Class NodeHandlerStore

java.lang.Object
  |
  +--org.w3c.tidy.NodeHandlerStore

public class NodeHandlerStore
extends java.lang.Object

Provides a method for non-Tidy classes to register external handlers to extend the core HTML parsing. Provides NodeHandler implementations with access to each node as it is parsed and provides a facility for adding dynamic content.

Author:
Ryan Breen (ryan@porivo.com)
See Also:
NodeHandler, Node.insertNodeAtEnd(org.w3c.tidy.Node, org.w3c.tidy.Node), StreamInImpl.readCharFromStream()

Method Summary
 void addNewHandler(NodeHandler handler)
          Register a new NodeHandler implementation with the NodeHandlerStore.
 int getDynamicInput()
          Iterates through the registered NodeHandlers, calling the getDynamicContent method on each, until the list is exhausted or one of the handlers returns a non -1 value.
 java.util.List getHandlers()
          Returns the list of registered NodeHandler implementations.
static NodeHandlerStore getInstance()
          Singleton accessor method, returns the global instance of the NodeHandlerStore.
 Node handleNode(Node element, Node node)
          Submits the element and node to the handleNode method of each NodeHandler implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static NodeHandlerStore getInstance()
Singleton accessor method, returns the global instance of the NodeHandlerStore.


addNewHandler

public void addNewHandler(NodeHandler handler)
Register a new NodeHandler implementation with the NodeHandlerStore. NodeHandlers will be stored and queried in the order in which they are added.

Parameters:
handler - A new NodeHandler implementation to register as active.

getHandlers

public java.util.List getHandlers()
Returns the list of registered NodeHandler implementations.


handleNode

public Node handleNode(Node element,
                       Node node)
Submits the element and node to the handleNode method of each NodeHandler implementation. These calls are made serially with each NodeHandler being queried in the order in whcih they were added through calls to addNewHandler. This call is made from the Node.insertNodeAtEnd method, so the input element and node variables represent the parent element and the node that is being appended.

Parameters:
element - Parent element for the new node element
node - Node to be inserted into the DOM under the parent element
Returns:
The node to be appended to the DOM, after being inspected and potentially manipulated by each NodeHandler.

getDynamicInput

public int getDynamicInput()
                    throws java.io.IOException
Iterates through the registered NodeHandlers, calling the getDynamicContent method on each, until the list is exhausted or one of the handlers returns a non -1 value.

Returns:
-1 if there is no dynamic input in any of the NodeHandlers or the first byte of dynamic content available.
java.io.IOException

Enhydra 5.1 API