1 16 package org.apache.axis2.saaj; 17 18 import org.w3c.dom.Node ; 19 import org.w3c.dom.NodeList ; 20 21 import java.util.ArrayList ; 22 import java.util.Collections ; 23 import java.util.List ; 24 25 31 public class NodeListImpl implements NodeList { 32 33 List mNodes; 34 35 public static final NodeList EMPTY_NODELIST = new NodeListImpl(Collections.EMPTY_LIST); 36 37 41 NodeListImpl() { 42 mNodes = new ArrayList (); 43 } 44 45 NodeListImpl(List nodes) { 46 this(); 47 mNodes.addAll(nodes); 48 } 49 50 void addNode(org.w3c.dom.Node node) { 51 mNodes.add(node); 52 } 53 54 void addNodeList(org.w3c.dom.NodeList nodes) { 55 for (int i = 0; i < nodes.getLength(); i++) { 56 mNodes.add(nodes.item(i)); 57 } 58 } 59 60 66 public Node item(int index) { 67 if (mNodes != null && mNodes.size() > index) { 68 return (Node ) mNodes.get(index); 69 } else { 70 return null; 71 } 72 } 73 74 public int getLength() { 75 return mNodes.size(); 76 } 77 78 } 79 | Popular Tags |