1 19 20 package org.netbeans.modules.xml.xdm.nodes; 21 22 import java.util.ArrayList ; 23 import java.util.HashMap ; 24 import java.util.List ; 25 import java.util.Map ; 26 import org.netbeans.modules.xml.spi.dom.ROException; 27 import org.w3c.dom.NamedNodeMap ; 28 import org.w3c.dom.Node ; 29 30 37 public final class NamedNodeMapImpl implements NamedNodeMap { 38 39 private List <Attribute> attributes; 40 41 42 public static final NamedNodeMap EMPTY = 43 new NamedNodeMapImpl(new ArrayList (0)); 44 45 49 public NamedNodeMapImpl(List <Attribute> attributes) { 50 if (attributes == null) throw new NullPointerException (); 51 this.attributes = new ArrayList (attributes); 52 } 53 54 public int getLength() { 55 return attributes.size(); 56 } 57 58 public org.w3c.dom.Node removeNamedItem(String str) 59 throws org.w3c.dom.DOMException { 60 throw new ROException(); 61 } 62 63 public org.w3c.dom.Node setNamedItemNS(org.w3c.dom.Node node) 64 throws org.w3c.dom.DOMException { 65 throw new ROException(); 66 } 67 68 public org.w3c.dom.Node setNamedItem(org.w3c.dom.Node node) 69 throws org.w3c.dom.DOMException { 70 throw new ROException(); 71 } 72 73 public org.w3c.dom.Node getNamedItemNS(String uri, String local) { 74 String key = (String )createKey(uri, local); 75 if(key == null) return null; 76 return getNode(key); 77 } 78 79 public org.w3c.dom.Node item(int param) { 80 if(param < attributes.size()) 81 return (org.w3c.dom.Node ) attributes.get(param); 82 return null; 83 } 84 85 public org.w3c.dom.Node getNamedItem(String str) { 86 String key = (String )createKey(str); 87 if(key == null) return null; 88 return getNode(key); 89 } 90 91 public org.w3c.dom.Node removeNamedItemNS(String str, String str1) 92 throws org.w3c.dom.DOMException { 93 throw new ROException(); 94 } 95 96 private Node getNode(String key) { 97 assert(key != null); 98 for(Attribute attr: attributes) { 99 if(key.equals(attr.getName())) { 100 return attr; 101 } 102 } 103 return null; 104 } 105 106 109 public static Object createKey(String qname) { 110 return qname; 111 } 112 113 116 public static Object createKey(String uri, String local) { 117 return uri + ":" + local; } 119 120 } | Popular Tags |