KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > tax > dom > NamedNodeMapImpl


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.tax.dom;
21
22 import org.w3c.dom.*;
23 import org.netbeans.tax.*;
24
25 /**
26  *
27  * @author Petr Kuzel
28  */

29 class NamedNodeMapImpl implements NamedNodeMap {
30
31     private final TreeNamedObjectMap peer;
32
33     /** Creates a new instance of AttrImpl */
34     public NamedNodeMapImpl(TreeNamedObjectMap peer) {
35         this.peer = peer;
36     }
37
38     /** The number of nodes in this map. The range of valid child node indices
39      * is <code>0</code> to <code>length-1</code> inclusive.
40      *
41      */

42     public int getLength() {
43         return peer.size();
44     }
45     
46     /** Retrieves a node specified by name.
47      * @param name The <code>nodeName</code> of a node to retrieve.
48      * @return A <code>Node</code> (of any type) with the specified
49      * <code>nodeName</code>, or <code>null</code> if it does not identify
50      * any node in this map.
51      *
52      */

53     public Node getNamedItem(String JavaDoc name) {
54         return Wrapper.wrap((TreeObject)peer.get(name));
55     }
56     
57     /** Retrieves a node specified by local name and namespace URI.
58      * <br>Documents which do not support the "XML" feature will permit only
59      * the DOM Level 1 calls for creating/setting elements and attributes.
60      * Hence, if you specify a non-null namespace URI, these DOMs will never
61      * find a matching node.
62      * @param namespaceURI The namespace URI of the node to retrieve.
63      * @param localName The local name of the node to retrieve.
64      * @return A <code>Node</code> (of any type) with the specified local
65      * name and namespace URI, or <code>null</code> if they do not
66      * identify any node in this map.
67      * @since DOM Level 2
68      *
69      */

70     public Node getNamedItemNS(String JavaDoc namespaceURI, String JavaDoc localName) {
71         throw new UOException();
72     }
73     
74     /** Returns the <code>index</code>th item in the map. If <code>index</code>
75      * is greater than or equal to the number of nodes in this map, this
76      * returns <code>null</code>.
77      * @param index Index into this map.
78      * @return The node at the <code>index</code>th position in the map, or
79      * <code>null</code> if that is not a valid index.
80      *
81      */

82     public Node item(int index) {
83         return Wrapper.wrap((TreeObject)peer.get(index));
84     }
85     
86     /** Removes a node specified by name. When this map contains the attributes
87      * attached to an element, if the removed attribute is known to have a
88      * default value, an attribute immediately appears containing the
89      * default value as well as the corresponding namespace URI, local name,
90      * and prefix when applicable.
91      * @param name The <code>nodeName</code> of the node to remove.
92      * @return The node removed from this map if a node with such a name
93      * exists.
94      * @exception DOMException
95      * NOT_FOUND_ERR: Raised if there is no node named <code>name</code> in
96      * this map.
97      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
98      *
99      */

100     public Node removeNamedItem(String JavaDoc name) throws DOMException {
101         throw new ROException();
102     }
103     
104     /** Removes a node specified by local name and namespace URI. A removed
105      * attribute may be known to have a default value when this map contains
106      * the attributes attached to an element, as returned by the attributes
107      * attribute of the <code>Node</code> interface. If so, an attribute
108      * immediately appears containing the default value as well as the
109      * corresponding namespace URI, local name, and prefix when applicable.
110      * <br>Documents which do not support the "XML" feature will permit only
111      * the DOM Level 1 calls for creating/setting elements and attributes.
112      * Hence, if you specify a non-null namespace URI, these DOMs will never
113      * find a matching node.
114      * @param namespaceURI The namespace URI of the node to remove.
115      * @param localName The local name of the node to remove.
116      * @return The node removed from this map if a node with such a local
117      * name and namespace URI exists.
118      * @exception DOMException
119      * NOT_FOUND_ERR: Raised if there is no node with the specified
120      * <code>namespaceURI</code> and <code>localName</code> in this map.
121      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
122      * @since DOM Level 2
123      *
124      */

125     public Node removeNamedItemNS(String JavaDoc namespaceURI, String JavaDoc localName) throws DOMException {
126         throw new ROException();
127     }
128     
129     /** Adds a node using its <code>nodeName</code> attribute. If a node with
130      * that name is already present in this map, it is replaced by the new
131      * one.
132      * <br>As the <code>nodeName</code> attribute is used to derive the name
133      * which the node must be stored under, multiple nodes of certain types
134      * (those that have a "special" string value) cannot be stored as the
135      * names would clash. This is seen as preferable to allowing nodes to be
136      * aliased.
137      * @param arg A node to store in this map. The node will later be
138      * accessible using the value of its <code>nodeName</code> attribute.
139      * @return If the new <code>Node</code> replaces an existing node the
140      * replaced <code>Node</code> is returned, otherwise <code>null</code>
141      * is returned.
142      * @exception DOMException
143      * WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a
144      * different document than the one that created this map.
145      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
146      * <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an
147      * <code>Attr</code> that is already an attribute of another
148      * <code>Element</code> object. The DOM user must explicitly clone
149      * <code>Attr</code> nodes to re-use them in other elements.
150      * <br>HIERARCHY_REQUEST_ERR: Raised if an attempt is made to add a node
151      * doesn't belong in this NamedNodeMap. Examples would include trying
152      * to insert something other than an Attr node into an Element's map
153      * of attributes, or a non-Entity node into the DocumentType's map of
154      * Entities.
155      *
156      */

157     public Node setNamedItem(Node arg) throws DOMException {
158         throw new ROException();
159     }
160     
161     /** Adds a node using its <code>namespaceURI</code> and
162      * <code>localName</code>. If a node with that namespace URI and that
163      * local name is already present in this map, it is replaced by the new
164      * one.
165      * @param arg A node to store in this map. The node will later be
166      * accessible using the value of its <code>namespaceURI</code> and
167      * <code>localName</code> attributes.
168      * @return If the new <code>Node</code> replaces an existing node the
169      * replaced <code>Node</code> is returned, otherwise <code>null</code>
170      * is returned.
171      * @exception DOMException
172      * WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a
173      * different document than the one that created this map.
174      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
175      * <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an
176      * <code>Attr</code> that is already an attribute of another
177      * <code>Element</code> object. The DOM user must explicitly clone
178      * <code>Attr</code> nodes to re-use them in other elements.
179      * <br>HIERARCHY_REQUEST_ERR: Raised if an attempt is made to add a node
180      * doesn't belong in this NamedNodeMap. Examples would include trying
181      * to insert something other than an Attr node into an Element's map
182      * of attributes, or a non-Entity node into the DocumentType's map of
183      * Entities.
184      * <br>NOT_SUPPORTED_ERR: Always thrown if the current document does not
185      * support the <code>"XML"</code> feature, since namespaces were
186      * defined by XML.
187      * @since DOM Level 2
188      *
189      */

190     public Node setNamedItemNS(Node arg) throws DOMException {
191         throw new ROException();
192     }
193     
194 }
195
Popular Tags