package rath.libxml;

import java.util.*;

/**
 * 
 * User: rath
 * Date: 04/11/2013
 * Time: 17:42
 * 
 */
public class NodeSet implements Iterable<Node> {
	private final long p;
	private int size;
	private List<Node> nodes = new ArrayList<Node>();

	NodeSet(long p) {
		this.p = p;
	}

	public int getSize() {
		return this.size;
	}

	public Node getFirstNode() {
		return nodes.get(0);
	}

	/**
	 * Called by JNI
	 * @param node
	 */
	void addNode(Node node) {
		nodes.add(node);
	}

	public List<Node> getNodes() {
		return this.nodes;
	}

	public Node getNodeAt(int index) {
		return nodes.get(index);
	}

	@Override
	public Iterator<Node> iterator() {
		return nodes.iterator();
	}

	public String toString() {
		return "[NodeSet] size=" + this.size + ", items=" + nodes.toString();
	}
}

@@ -334,36 +334,194 @@
 %7D%0A%0A%09
-public Node getFirstNode() %7B
+/**%0A%09 * Convenience method for a set containing only one node.%0A%09 * @return first node, null if this set is empty.%0A%09 */%0A%09public Node getFirstNode() %7B%0A%09%09if(nodes.size()==0)%0A%09%09%09return null;
 %0A%09%09r

NodeSet.getFirstNode() can return null