View Javadoc
1 /* 2 * @(#)HashMapNode.java 1.36 02/03/21 3 * 4 * Copyright 2002 Sun Microsystems, Inc. All rights reserved. 5 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 6 */ 7 package org.enhydra.xml; 8 9 import java.util.Iterator; 10 import java.util.List; 11 12 import org.w3c.dom.Document; 13 import org.w3c.dom.DOMException; 14 import org.w3c.dom.NamedNodeMap; 15 import org.w3c.dom.Node; 16 17 18 /*** 19 * 20 * @version 1.0 21 */ 22 class NamedNodeMapImpl implements NamedNodeMap { 23 24 /*** 25 * List of <code>Node</code>s. 26 */ 27 List nodes; 28 29 30 /*** 31 * Constructs new <code>NamedNodeMapImpl</code> with the given list of nodes. 32 * @param nodes list of nodes. 33 */ 34 public NamedNodeMapImpl(List nodes) { 35 this.nodes = nodes; 36 } 37 38 /*** 39 * Returns the count of nodes. 40 * 41 * @return the count of nodes. 42 */ 43 public int getLength() { 44 return nodes.size(); 45 } 46 47 48 /*** 49 * Returns the <code>Node</code> with the given name. 50 * 51 * @param name the node name. 52 * 53 * @return the <code>Node</code> with the given name. 54 */ 55 public Node getNamedItem(String name) { 56 Iterator iter = nodes.iterator(); 57 while (iter.hasNext()) { 58 Node node = (Node)iter.next(); 59 if (name.equals(node.getNodeName())) { 60 return node; 61 } 62 } 63 64 return null; 65 } 66 67 /*** 68 * Returns the <code>Node</code> with the given index. 69 * 70 * @param index index of a node. 71 * @return the <code>Node</code> with the given index. 72 */ 73 public Node item(int index) { 74 Node node = (Node) nodes.get(index); 75 return node; 76 } 77 78 public Node removeNamedItem(java.lang.String name) { 79 throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "This NamedNodeMap is read-only!"); 80 } 81 82 public Node setNamedItem(Node arg) { 83 throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "This NamedNodeMap is read-only!"); 84 } 85 86 public Node getNamedItemNS(String namespaceURI, String localName) { 87 return getNamedItem(localName); 88 } 89 90 91 /*** 92 * Equivalent to <code>setNamedItem(arg)</code>. 93 */ 94 public Node setNamedItemNS(Node arg) { 95 return setNamedItem(arg); 96 } 97 98 99 /*** 100 * Equivalent to <code>removeNamedItem(localName)</code>. 101 */ 102 public Node removeNamedItemNS(String namespaceURI, String localName) { 103 return removeNamedItem(localName); 104 } 105 106 }

This page automatically generated by Maven