View Javadoc
1 /* 2 Copyright (C) 2003 Together 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public 15 License along with this library; if not, write to the Free Software 16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 */ 18 19 package org.enhydra.xml; 20 21 import java.util.Iterator; 22 import java.util.List; 23 24 import org.w3c.dom.Document; 25 import org.w3c.dom.DOMException; 26 import org.w3c.dom.NamedNodeMap; 27 import org.w3c.dom.Node; 28 29 30 /*** 31 * 32 * @version 1.0 33 */ 34 class NamedNodeMapImpl implements NamedNodeMap { 35 36 /*** 37 * List of <code>Node</code>s. 38 */ 39 List nodes; 40 41 42 /*** 43 * Constructs new <code>NamedNodeMapImpl</code> with the given list of nodes. 44 * @param nodes list of nodes. 45 */ 46 public NamedNodeMapImpl(List nodes) { 47 this.nodes = nodes; 48 } 49 50 /*** 51 * Returns the count of nodes. 52 * 53 * @return the count of nodes. 54 */ 55 public int getLength() { 56 return nodes.size(); 57 } 58 59 60 /*** 61 * Returns the <code>Node</code> with the given name. 62 * 63 * @param name the node name. 64 * 65 * @return the <code>Node</code> with the given name. 66 */ 67 public Node getNamedItem(String name) { 68 Iterator iter = nodes.iterator(); 69 while (iter.hasNext()) { 70 Node node = (Node)iter.next(); 71 if (name.equals(node.getNodeName())) { 72 return node; 73 } 74 } 75 76 return null; 77 } 78 79 /*** 80 * Returns the <code>Node</code> with the given index. 81 * 82 * @param index index of a node. 83 * @return the <code>Node</code> with the given index. 84 */ 85 public Node item(int index) { 86 Node node = (Node) nodes.get(index); 87 return node; 88 } 89 90 public Node removeNamedItem(java.lang.String name) { 91 throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "This NamedNodeMap is read-only!"); 92 } 93 94 public Node setNamedItem(Node arg) { 95 throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "This NamedNodeMap is read-only!"); 96 } 97 98 public Node getNamedItemNS(String namespaceURI, String localName) { 99 return getNamedItem(localName); 100 } 101 102 103 /*** 104 * Equivalent to <code>setNamedItem(arg)</code>. 105 * @param arg is node 106 * @return node 107 */ 108 public Node setNamedItemNS(Node arg) { 109 return setNamedItem(arg); 110 } 111 112 113 /*** 114 * Equivalent to <code>removeNamedItem(localName)</code>. 115 * @param namespaceURI is name space 116 * @param localName is string 117 * @return node 118 */ 119 public Node removeNamedItemNS(String namespaceURI, String localName) { 120 return removeNamedItem(localName); 121 } 122 123 }

This page was automatically generated by Maven