add
public void add(Node node)
add
public void add(NodeList list)
Add another node list to this one.
asString
public String asString()
contains
public boolean contains(Node node)
Check to see if the NodeList contains the supplied Node.
node
- The node to look for.
- True is the Node is in this NodeList.
copyToNodeArray
public void copyToNodeArray(Node[] array)
elementAt
public Node elementAt(int i)
extractAllNodesThatMatch
public NodeList extractAllNodesThatMatch(NodeFilter filter)
Filter the list with the given filter non-recursively.
filter
- The filter to use.
- 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.
filter
- The filter to use.recursive
- If true
digs into the children recursively.
- 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.
indexOf
public int indexOf(Node node)
Finds the index of the supplied Node.
node
- The node to look for.
- The index of the node in the list or -1 if it isn't found.
keepAllNodesThatMatch
public void keepAllNodesThatMatch(NodeFilter filter)
Remove nodes not matching the given filter non-recursively.
filter
- The filter to use.
keepAllNodesThatMatch
public void keepAllNodesThatMatch(NodeFilter filter,
boolean recursive)
Remove nodes not matching the given filter.
filter
- The filter to use.recursive
- If true
digs into the children recursively.
prepend
public void prepend(Node node)
Insert the given node at the head of the list.
node
- The new first element.
remove
public Node remove(int index)
Remove the node at index.
index
- The index of the node to remove.
- The node that was removed.
remove
public boolean remove(Node node)
Remove the supplied Node from the list.
node
- The node to remove.
- True if the node was found and removed from the list.
removeAll
public void removeAll()
toHtml
public String toHtml()
Convert this nodelist into the equivalent HTML.
- The contents of the list as HTML text.
toHtml
public String toHtml(boolean verbatim)
Convert this nodelist into the equivalent HTML.
verbatim
- If true
return as close to the original
page text as possible.
- The contents of the list as HTML text.
toNodeArray
public Node[] toNodeArray()
toString
public String toString()
Return the contents of the list as a string.
Suitable for debugging.
- A string representation of the list.
visitAllNodesWith
public void visitAllNodesWith(NodeVisitor visitor)
throws ParserException
Utility to apply a visitor to a node list.
Provides for a visitor to modify the contents of a page and get the
modified HTML as a string with code like this:
Parser parser = new Parser ("http://whatever");
NodeList list = parser.parse (null); // no filter
list.visitAllNodesWith (visitor);
System.out.println (list.toHtml ());