1 7 package org.enhydra.xml; 8 9 import java.util.Iterator ; 10 import java.util.List ; 11 12 import org.w3c.dom.DOMException ; 13 import org.w3c.dom.NamedNodeMap ; 14 import org.w3c.dom.Node ; 15 16 17 23 class NamedNodeMapImpl implements NamedNodeMap { 24 25 28 List nodes; 29 30 31 36 public NamedNodeMapImpl(List nodes) { 37 this.nodes = nodes; 38 } 39 40 45 public int getLength() { 46 return nodes.size(); 47 } 48 49 50 57 public Node getNamedItem(String name) { 58 Iterator iter = nodes.iterator(); 59 while (iter.hasNext()) { 60 Node node = (Node )iter.next(); 61 if (name.equals(node.getNodeName())) { 62 return node; 63 } 64 } 65 66 return null; 67 } 68 69 75 public Node item(int index) { 76 Node node = (Node ) nodes.get(index); 77 return node; 78 } 79 80 81 88 public Node removeNamedItem(java.lang.String name) { 89 throw new DOMException (DOMException.NO_MODIFICATION_ALLOWED_ERR, "This NamedNodeMap is read-only!"); 90 } 91 92 93 100 public Node setNamedItem(Node arg) { 101 throw new DOMException (DOMException.NO_MODIFICATION_ALLOWED_ERR, "This NamedNodeMap is read-only!"); 102 } 103 104 105 108 public Node getNamedItemNS(String namespaceURI, String localName) { 109 return getNamedItem(localName); 110 } 111 112 113 116 public Node setNamedItemNS(Node arg) { 117 return setNamedItem(arg); 118 } 119 120 121 124 public Node removeNamedItemNS(String namespaceURI, String localName) { 125 return removeNamedItem(localName); 126 } 127 128 } 129 | Popular Tags |