View Javadoc

1   package org.tinyjee.maven.dim.utils;
2   
3   import org.w3c.dom.Node;
4   import org.w3c.dom.NodeList;
5   
6   import java.util.AbstractList;
7   
8   /**
9    * Adapts NodeList to Java Collections.
10   *
11   * @author Juergen_Kellerer, 2011-10-30
12   */
13  public class NodeListAdapter extends AbstractList<Node> {
14  
15  	private final NodeList nodeList;
16  
17  	public NodeListAdapter(NodeList nodeList) {
18  		this.nodeList = nodeList;
19  	}
20  
21  	@Override
22  	public Node get(int index) {
23  		return nodeList.item(index);
24  	}
25  
26  	@Override
27  	public int size() {
28  		return nodeList == null ? 0 : nodeList.getLength();
29  	}
30  }