Provides a class for wrapping a list of JDOM objects primarily for use in template
engines and other kinds of text transformation tools.
It has a
toString()
method that will output the XML serialized form of the
nodes it contains - again focusing on template engine usage, as well as the
selectNodes(String)
method that helps selecting a different set of nodes
starting from the nodes in this list. The class also implements the
java.util.List
interface by simply delegating calls to the contained list (the
subList(int,int)
method is implemented by delegating to the contained list and wrapping the returned
sublist into a
NodeList
).
NodeList
public NodeList()
Creates an empty node list.
NodeList
public NodeList(Document document)
Creates a node list that holds a single Document
node.
NodeList
public NodeList(Element element)
Creates a node list that holds a single Element
node.
NodeList
public NodeList(List nodes)
Creates a node list that holds a list of nodes.
nodes
- the list of nodes this template should hold. The created
template will copy the passed nodes list, so changes to the passed list
will not affect the model.
NodeList
public NodeList(List nodes,
boolean copy)
Creates a node list that holds a list of nodes.
nodes
- the list of nodes this template should hold.copy
- if true, the created template will copy the passed nodes
list, so changes to the passed list will not affect the model. If false,
the model will reference the passed list and will sense changes in it,
altough no operations on the list will be synchronized.
NodeList
private NodeList(Object object)
add
public boolean add(Object o)
add
public void add(int index,
Object o)
addAll
public boolean addAll(Collection c)
addAll
public boolean addAll(int index,
Collection c)
clone
public Object clone()
throws CloneNotSupportedException
Returns a NodeList that contains the same nodes as this node list.
cloneNodes
private void cloneNodes()
throws CloneNotSupportedException
contains
public boolean contains(Object o)
containsAll
public boolean containsAll(Collection c)
equals
public boolean equals(Object o)
Tests for equality with another object.
o
- the object to test for equality
- true if the other object is also a NodeList and their contained
List
objects evaluate as equals.
get
public Object get(int index)
getList
public List getList()
Retrieves the underlying list used to store the nodes. Note however, that
you can fully use the underlying list through the List
interface
of this class itself. You would probably access the underlying list only for
synchronization purposes.
hashCode
public int hashCode()
Returns the hash code of the contained list.
indexOf
public int indexOf(Object o)
isEmpty
public boolean isEmpty()
iterator
public Iterator iterator()
lastIndexOf
public int lastIndexOf(Object o)
listIterator
public ListIterator listIterator()
listIterator
public ListIterator listIterator(int index)
remove
public boolean remove(Object o)
remove
public Object remove(int index)
removeAll
public boolean removeAll(Collection c)
retainAll
public boolean retainAll(Collection c)
selectNodes
public NodeList selectNodes(String xpathString)
Applies an XPath expression to the node list and returns the resulting
node list. In order for this method to work, your application must have
access to
werken.xpath library
classes. The implementation does cache the parsed format of XPath
expressions in a weak hash map, keyed by the string representation of
the XPath expression. As the string object passed as the argument is
usually kept in the parsed template, this ensures that each XPath
expression is parsed only once during the lifetime of the template that
first invoked it.
- a NodeList representing the nodes that are the result of
application of the XPath to the current node list. It can be empty.
set
public Object set(int index,
Object o)
subList
public List subList(int fromIndex,
int toIndex)
toArray
public Object[] toArray()
toArray
public Object[] toArray(Object[] a)
toString
public String toString()
This method returns the string resulting from concatenation of string
representations of its nodes. Each node is rendered using its XML
serialization format. This greatly simplifies creating XML-transformation
templates, as to output a node contained in variable x as XML fragment,
you simply write ${x} in the template (or whatever your template engine
uses as its expression syntax).