NVelocity.NAnt.Anakia
Class NodeList

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 {@link #toString()} method that will output the XML serialized form of the nodes it contains - again focusing on template engine usage, as well as the {@link #selectNodes(String)} method that helps selecting a different set of nodes starting from the nodes in this list. The class also implements the {@link java.util.List} interface by simply delegating calls to the contained list (the {@link #subList(int, int)} method is implemented by delegating to the contained list and wrapping the returned sublist into a

NodeList
).

Constructor Summary
NodeList()
         Creates an empty node list.
NodeList(System.Xml.XmlDocument document)
         Creates a node list that holds a single {@link Document} node.
NodeList(System.Xml.XmlElement element)
         Creates a node list that holds a single {@link Element} node.
NodeList(object object_Renamed)
NodeList(System.Collections.IList nodes)
         Creates a node list that holds a list of nodes.
NodeList(System.Collections.IList nodes, bool copy)
         Creates a node list that holds a list of nodes.
NodeList(System.Xml.XmlNodeList list, bool copy)
NodeList(System.Xml.XmlAttributeCollection attributes)

Property Summary
int Count
bool IsFixedSize
bool IsReadOnly
bool IsSynchronized
object Item[int index]
System.Collections.IList List
         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.
object SyncRoot

Method Summary
int Add(object o)
void Clear()
object Clone()
         Returns a NodeList that contains the same nodes as this node list. @throws CloneNotSupportedException if the contained list's class does not have an accessible no-arg constructor.
bool Contains(object value)
void CopyTo(System.Array array, int index)
bool Equals(object o)
         Tests for equality with another object.
System.Collections.IEnumerator GetEnumerator()
int GetHashCode()
         Returns the hash code of the contained list.
int IndexOf(object value)
void Insert(int index, object value)
void Remove(object value)
void RemoveAt(int index)
NVelocity.NAnt.Anakia.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.
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).

Methods inherited from class System.Object
Finalize, GetType, MemberwiseClone


Constructor Detail

NodeList

public NodeList()

Creates an empty node list.


NodeList

public NodeList(System.Xml.XmlDocument document)

Creates a node list that holds a single {@link Document} node.


NodeList

public NodeList(System.Xml.XmlElement element)

Creates a node list that holds a single {@link Element} node.


NodeList

public NodeList(object object_Renamed)


NodeList

public NodeList(System.Collections.IList nodes)

Creates a node list that holds a list of nodes.

Parameters:
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(System.Collections.IList nodes,
                bool copy)

Creates a node list that holds a list of nodes.

Parameters:
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

public NodeList(System.Xml.XmlNodeList list,
                bool copy)


NodeList

public NodeList(System.Xml.XmlAttributeCollection attributes)

Property Detail

Count

public int Count


IsFixedSize

public bool IsFixedSize


IsReadOnly

public bool IsReadOnly


IsSynchronized

public bool IsSynchronized


Item

public object this[int index]


List

public System.Collections.IList List

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.


SyncRoot

public object SyncRoot

Method Detail

Add

public int Add(object o)


Clear

public void Clear()


Clone

public object Clone()

Returns a NodeList that contains the same nodes as this node list. @throws CloneNotSupportedException if the contained list's class does not have an accessible no-arg constructor.


Contains

public bool Contains(object value)


CopyTo

public void CopyTo(System.Array array,
                   int index)


Equals

public bool Equals(object o)

Tests for equality with another object.

Parameters:
o - the object to test for equality
Returns:
true if the other object is also a NodeList and their contained {@link List} objects evaluate as equals.

GetEnumerator

public System.Collections.IEnumerator GetEnumerator()


GetHashCode

public int GetHashCode()

Returns the hash code of the contained list.


IndexOf

public int IndexOf(object value)


Insert

public void Insert(int index,
                   object value)


Remove

public void Remove(object value)


RemoveAt

public void RemoveAt(int index)


selectNodes

public NVelocity.NAnt.Anakia.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.

Parameters:
xpathExpression - the XPath expression you wish to apply
Returns:
a NodeList representing the nodes that are the result of application of the XPath to the current node list. It can be empty.

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).