1 57 58 package com.sun.org.apache.xerces.internal.impl.xs.opti; 59 60 import org.w3c.dom.Node ; 61 import org.w3c.dom.Attr ; 62 import org.w3c.dom.NamedNodeMap ; 63 64 import org.w3c.dom.DOMException ; 65 66 67 72 public class NamedNodeMapImpl implements NamedNodeMap { 73 74 Attr [] attrs; 75 76 public NamedNodeMapImpl(Attr [] attrs) { 77 this.attrs = attrs; 78 } 79 80 public Node getNamedItem(String name) { 81 for (int i=0; i<attrs.length; i++) { 82 if (attrs[i].getName().equals(name)) { 83 return attrs[i]; 84 } 85 } 86 return null; 87 } 88 89 public Node item(int index) { 90 if (index < 0 && index > getLength()) { 91 return null; 92 } 93 return attrs[index]; 94 } 95 96 public int getLength() { 97 return attrs.length; 98 } 99 100 public Node getNamedItemNS(String namespaceURI, String localName) { 101 for (int i=0; i<attrs.length; i++) { 102 if (attrs[i].getName().equals(localName) && attrs[i].getNamespaceURI().equals(namespaceURI)) { 103 return attrs[i]; 104 } 105 } 106 return null; 107 } 108 109 public Node setNamedItemNS(Node arg) throws DOMException { 110 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, "Method not supported"); 111 } 112 113 public Node setNamedItem(Node arg) throws DOMException { 114 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, "Method not supported"); 115 } 116 117 public Node removeNamedItem(String name) throws DOMException { 118 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, "Method not supported"); 119 } 120 121 public Node removeNamedItemNS(String namespaceURI, String localName) throws DOMException { 122 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, "Method not supported"); 123 } 124 } 125 126 | Popular Tags |