org.htmlparser.parserapplications.filterbuilder

Class HtmlTreeModel

public class HtmlTreeModel extends Object implements TreeModel

Quick and dirty tree model for HTML nodes.
Field Summary
protected NodemRoot
The root {@link Node}.
protected VectormTreeListeners
The list of tree listeners.
Constructor Summary
HtmlTreeModel(NodeList root)
Create an HTML tree view.
Method Summary
voidaddTreeModelListener(TreeModelListener l)
Adds a listener for the TreeModelEvent posted after the tree changes.
ObjectgetChild(Object parent, int index)
Returns the child of parent at index index in the parent's child array.
intgetChildCount(Object parent)
Returns the number of children of parent.
intgetIndexOfChild(Object parent, Object child)
Returns the index of child in parent.
ObjectgetRoot()
Returns the root of the tree.
booleanisLeaf(Object node)
Returns true if node is a leaf.
voidremoveTreeModelListener(TreeModelListener l)
Removes a listener previously added with addTreeModelListener().
voidvalueForPathChanged(TreePath path, Object newValue)
Messaged when the user has altered the value for the item identified by path to newValue.

Field Detail

mRoot

protected Node mRoot
The root {@link Node}.

mTreeListeners

protected Vector mTreeListeners
The list of tree listeners.

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 {@link Node}, not sometimes a {@link NodeList} at the root).

Method Detail

addTreeModelListener

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

Parameters: l {@inheritDoc}

getChild

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

Parameters: parent {@inheritDoc} index {@inheritDoc}

Returns: {@inheritDoc}

getChildCount

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

Parameters: parent {@inheritDoc}

Returns: {@inheritDoc}

getIndexOfChild

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

Parameters: parent {@inheritDoc} child {@inheritDoc}

Returns: {@inheritDoc}

getRoot

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

Returns: {@inheritDoc}

isLeaf

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

Parameters: node {@inheritDoc}

Returns: {@inheritDoc}

removeTreeModelListener

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

Parameters: l {@inheritDoc}

valueForPathChanged

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

Parameters: path {@inheritDoc} newValue {@inheritDoc}

HTML Parser is an open source library released under LGPL. SourceForge.net