| java.lang.Object org.apache.velocity.anakia.NodeList
NodeList | public class NodeList implements List,Cloneable(Code) | | 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
NodeList.toString() method that will output the XML serialized form of the
nodes it contains - again focusing on template engine usage, as well as the
NodeList.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
NodeList.subList(int,int) method is implemented by delegating to the contained list and wrapping the returned
sublist into a NodeList ).
author: Attila Szegedi version: $Id: NodeList.java 463298 2006-10-12 16:10:32Z henning $ |
Constructor Summary | |
public | NodeList() Creates an empty node list. | public | NodeList(Document document) Creates a node list that holds a single
Document node. | public | NodeList(Element element) Creates a node list that holds a single
Element node. | public | NodeList(List nodes) Creates a node list that holds a list of nodes.
Parameters: nodes - the list of nodes this template should hold. | public | NodeList(List nodes, boolean copy) Creates a node list that holds a list of nodes.
Parameters: nodes - the list of nodes this template should hold. Parameters: copy - if true, the created template will copy the passed nodeslist, so changes to the passed list will not affect the model. |
NodeList | public NodeList()(Code) | | Creates an empty node list.
|
NodeList | public NodeList(Document document)(Code) | | Creates a node list that holds a single
Document node.
Parameters: document - |
NodeList | public NodeList(Element element)(Code) | | Creates a node list that holds a single
Element node.
Parameters: element - |
NodeList | public NodeList(List nodes)(Code) | | Creates a node list that holds a list of nodes.
Parameters: nodes - the list of nodes this template should hold. The createdtemplate will copy the passed nodes list, so changes to the passed listwill not affect the model. |
NodeList | public NodeList(List nodes, boolean copy)(Code) | | Creates a node list that holds a list of nodes.
Parameters: nodes - the list of nodes this template should hold. Parameters: copy - if true, the created template will copy the passed nodeslist, 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. |
equals | public boolean equals(Object o)(Code) | | Tests for equality with another object.
Parameters: o - the object to test for equality true if the other object is also a NodeList and their containedList objects evaluate as equals. |
getList | public List getList()(Code) | | 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.
The internal node List. |
hashCode | public int hashCode()(Code) | | Returns the hash code of the contained list.
The hashcode of the list. |
selectNodes | public NodeList selectNodes(String xpathString)(Code) | | 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.
Parameters: xpathString - the XPath expression you wish to apply a NodeList representing the nodes that are the result ofapplication of the XPath to the current node list. It can be empty. |
toString | public String toString()(Code) | | 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).
The Nodelist as printable object. |
|
|