public class NodeList
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
NodeList() |
NodeList(Node node)
Create a one element node list.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Node node) |
void |
add(NodeList list)
Add another node list to this one.
|
java.lang.String |
asHtml()
Deprecated.
Use
toHtml() . |
java.lang.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(java.lang.Class classType)
Convenience method to search for nodes of the given type non-recursively.
|
NodeList |
searchFor(java.lang.Class classType,
boolean recursive)
Convenience method to search for nodes of the given type.
|
int |
size() |
java.lang.String |
toHtml()
Convert this nodelist into the equivalent HTML.
|
Node[] |
toNodeArray() |
java.lang.String |
toString()
Return the contents of the list as a string.
|
void |
visitAllNodesWith(NodeVisitor visitor)
Utility to apply a visitor to a node list.
|
public NodeList()
public NodeList(Node node)
node
- The initial node to add.public void add(Node node)
public void add(NodeList list)
list
- The list to add.public void prepend(Node node)
node
- The new first element.public int size()
public Node elementAt(int i)
public int getNumberOfAdjustments()
public SimpleNodeIterator elements()
public Node[] toNodeArray()
public void copyToNodeArray(Node[] array)
public java.lang.String asString()
public java.lang.String asHtml()
toHtml()
.public java.lang.String toHtml()
public Node remove(int index)
public void removeAll()
public java.lang.String toString()
toString
in class java.lang.Object
public NodeList extractAllNodesThatMatch(NodeFilter filter)
filter
- The filter to use.public NodeList extractAllNodesThatMatch(NodeFilter filter, boolean recursive)
filter
- The filter to use.recursive
- If true digs into the children recursively.
public void keepAllNodesThatMatch(NodeFilter filter)
filter
- The filter to use.public void keepAllNodesThatMatch(NodeFilter filter, boolean recursive)
filter
- The filter to use.recursive
- If true digs into the children recursively.
public NodeList searchFor(java.lang.Class classType)
classType
- The class to search for.public NodeList searchFor(java.lang.Class classType, boolean recursive)
classType
- The class to search for.recursive
- If true digs into the children recursively.
public void visitAllNodesWith(NodeVisitor visitor) throws ParserException
Parser parser = new Parser ("http://whatever"); NodeList list = parser.parse (null); // no filter list.visitAllNodesWith (visitor); System.out.println (list.toHtml ());
ParserException
HTML Parser is an open source library released under LGPL.