HTML Parser Home Page

org.htmlparser.util
Class NodeList

java.lang.Object
  extended byorg.htmlparser.util.NodeList
All Implemented Interfaces:
Serializable

public class NodeList
extends Object
implements Serializable

See Also:
Serialized Form

Constructor Summary
NodeList()
           
NodeList(Node node)
          Create a one element node list.
 
Method Summary
 void add(Node node)
           
 void add(NodeList list)
          Add another node list to this one.
 String asHtml()
           
 String asString()
           
 void copyToNodeArray(Node[] array)
           
 Node elementAt(int i)
           
 SimpleNodeIterator elements()
           
 NodeList extractAllNodesThatMatch(NodeFilter filter)
          Filter the list with the given filter non-recursively.
 NodeList extractAllNodesThatMatch(NodeFilter filter, boolean recursive)
          Filter the list with the given filter.
 int getNumberOfAdjustments()
           
 void keepAllNodesThatMatch(NodeFilter filter)
          Remove nodes not matching the given filter non-recursively.
 void keepAllNodesThatMatch(NodeFilter filter, boolean recursive)
          Remove nodes not matching the given filter.
 void prepend(Node node)
          Insert the given node at the head of the list.
 Node remove(int index)
           
 void removeAll()
           
 NodeList searchFor(Class classType)
          Convenience method to search for nodes of the given type non-recursively.
 NodeList searchFor(Class classType, boolean recursive)
          Convenience method to search for nodes of the given type.
 int size()
           
 Node[] toNodeArray()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NodeList

public NodeList()

NodeList

public NodeList(Node node)
Create a one element node list.

Parameters:
node - The initial node to add.
Method Detail

add

public void add(Node node)

add

public void add(NodeList list)
Add another node list to this one.

Parameters:
list - The list to add.

prepend

public void prepend(Node node)
Insert the given node at the head of the list.

Parameters:
node - The new first element.

size

public int size()

elementAt

public Node elementAt(int i)

getNumberOfAdjustments

public int getNumberOfAdjustments()

elements

public SimpleNodeIterator elements()

toNodeArray

public Node[] toNodeArray()

copyToNodeArray

public void copyToNodeArray(Node[] array)

asString

public String asString()

asHtml

public String asHtml()

remove

public Node remove(int index)

removeAll

public void removeAll()

toString

public String toString()

extractAllNodesThatMatch

public NodeList extractAllNodesThatMatch(NodeFilter filter)
Filter the list with the given filter non-recursively.

Parameters:
filter - The filter to use.
Returns:
A new node array containing the nodes accepted by the filter. This is a linear list and preserves the nested structure of the returned nodes only.

extractAllNodesThatMatch

public NodeList extractAllNodesThatMatch(NodeFilter filter,
                                         boolean recursive)
Filter the list with the given filter.

Parameters:
filter - The filter to use.
recursive - If true digs into the children recursively.
Returns:
A new node array containing the nodes accepted by the filter. This is a linear list and preserves the nested structure of the returned nodes only.

keepAllNodesThatMatch

public void keepAllNodesThatMatch(NodeFilter filter)
Remove nodes not matching the given filter non-recursively.

Parameters:
filter - The filter to use.

keepAllNodesThatMatch

public void keepAllNodesThatMatch(NodeFilter filter,
                                  boolean recursive)
Remove nodes not matching the given filter.

Parameters:
filter - The filter to use.
recursive - If true digs into the children recursively.

searchFor

public NodeList searchFor(Class classType)
Convenience method to search for nodes of the given type non-recursively.

Parameters:
classType - The class to search for.

searchFor

public NodeList searchFor(Class classType,
                          boolean recursive)
Convenience method to search for nodes of the given type.

Parameters:
classType - The class to search for.
recursive - If true digs into the children recursively.

© 2004 Somik Raha
Mar 14, 2004

HTML Parser is an open source library released under LGPL.