HTML Parser Home Page

org.htmlparser.parserapplications.filterbuilder
Class HtmlTreeModel

java.lang.Object
  extended by org.htmlparser.parserapplications.filterbuilder.HtmlTreeModel
All Implemented Interfaces:
TreeModel

public class HtmlTreeModel
extends Object
implements TreeModel

Quick and dirty tree model for HTML nodes.


Field Summary
protected  Node mRoot
          The root Node.
protected  Vector mTreeListeners
          The list of tree listeners.
 
Constructor Summary
HtmlTreeModel(NodeList root)
          Create an HTML tree view.
 
Method Summary
 void addTreeModelListener(TreeModelListener l)
          Adds a listener for the TreeModelEvent posted after the tree changes.
 Object getChild(Object parent, int index)
          Returns the child of parent at index index in the parent's child array.
 int getChildCount(Object parent)
          Returns the number of children of parent.
 int getIndexOfChild(Object parent, Object child)
          Returns the index of child in parent.
 Object getRoot()
          Returns the root of the tree.
 boolean isLeaf(Object node)
          Returns true if node is a leaf.
 void removeTreeModelListener(TreeModelListener l)
          Removes a listener previously added with addTreeModelListener().
 void valueForPathChanged(TreePath path, Object newValue)
          Messaged when the user has altered the value for the item identified by path to newValue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mTreeListeners

protected Vector mTreeListeners
The list of tree listeners.


mRoot

protected Node mRoot
The root Node.

Constructor Detail

HtmlTreeModel

public HtmlTreeModel(NodeList root)
Create an HTML tree view.

Parameters:
root - The nodes at the root of the tree (the nodes are wrapped in an Html node that is never seen because it's the root, but this makes all downstream processing super-simple because every tree node is then a Node, not sometimes a NodeList at the root).
Method Detail

addTreeModelListener

public void addTreeModelListener(TreeModelListener l)
Adds a listener for the TreeModelEvent posted after the tree changes.

Specified by:
addTreeModelListener in interface TreeModel
Parameters:
l -

removeTreeModelListener

public void removeTreeModelListener(TreeModelListener l)
Removes a listener previously added with addTreeModelListener().

Specified by:
removeTreeModelListener in interface TreeModel
Parameters:
l -

getChild

public Object getChild(Object parent,
                       int index)
Returns the child of parent at index index in the parent's child array.

Specified by:
getChild in interface TreeModel
Parameters:
parent -
index -
Returns:

getChildCount

public int getChildCount(Object parent)
Returns the number of children of parent.

Specified by:
getChildCount in interface TreeModel
Parameters:
parent -
Returns:

getIndexOfChild

public int getIndexOfChild(Object parent,
                           Object child)
Returns the index of child in parent.

Specified by:
getIndexOfChild in interface TreeModel
Parameters:
parent -
child -
Returns:

getRoot

public Object getRoot()
Returns the root of the tree.

Specified by:
getRoot in interface TreeModel
Returns:

isLeaf

public boolean isLeaf(Object node)
Returns true if node is a leaf.

Specified by:
isLeaf in interface TreeModel
Parameters:
node -
Returns:

valueForPathChanged

public void valueForPathChanged(TreePath path,
                                Object newValue)
Messaged when the user has altered the value for the item identified by path to newValue.

Specified by:
valueForPathChanged in interface TreeModel
Parameters:
path -
newValue -

© 2006 Derrick Oswald
Sep 17, 2006

HTML Parser is an open source library released under Common Public License. SourceForge.net