1 16 17 package org.apache.xerces.impl.xs.opti; 18 19 import org.w3c.dom.Node ; 20 import org.w3c.dom.Attr ; 21 import org.w3c.dom.NamedNodeMap ; 22 23 import org.w3c.dom.DOMException ; 24 25 26 33 public class NamedNodeMapImpl implements NamedNodeMap { 34 35 Attr [] attrs; 36 37 public NamedNodeMapImpl(Attr [] attrs) { 38 this.attrs = attrs; 39 } 40 41 public Node getNamedItem(String name) { 42 for (int i=0; i<attrs.length; i++) { 43 if (attrs[i].getName().equals(name)) { 44 return attrs[i]; 45 } 46 } 47 return null; 48 } 49 50 public Node item(int index) { 51 if (index < 0 && index > getLength()) { 52 return null; 53 } 54 return attrs[index]; 55 } 56 57 public int getLength() { 58 return attrs.length; 59 } 60 61 public Node getNamedItemNS(String namespaceURI, String localName) { 62 for (int i=0; i<attrs.length; i++) { 63 if (attrs[i].getName().equals(localName) && attrs[i].getNamespaceURI().equals(namespaceURI)) { 64 return attrs[i]; 65 } 66 } 67 return null; 68 } 69 70 public Node setNamedItemNS(Node arg) throws DOMException { 71 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, "Method not supported"); 72 } 73 74 public Node setNamedItem(Node arg) throws DOMException { 75 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, "Method not supported"); 76 } 77 78 public Node removeNamedItem(String name) throws DOMException { 79 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, "Method not supported"); 80 } 81 82 public Node removeNamedItemNS(String namespaceURI, String localName) throws DOMException { 83 throw new DOMException (DOMException.NOT_SUPPORTED_ERR, "Method not supported"); 84 } 85 } | Popular Tags |