View Javadoc
1   /*
2    * reserved comment block
3    * DO NOT REMOVE OR ALTER!
4    */
5   /*
6    * Copyright 2001, 2002,2004 The Apache Software Foundation.
7    *
8    * Licensed under the Apache License, Version 2.0 (the "License");
9    * you may not use this file except in compliance with the License.
10   * You may obtain a copy of the License at
11   *
12   *      http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  
21  package com.sun.org.apache.xerces.internal.impl.xs.opti;
22  
23  import org.w3c.dom.Node;
24  import org.w3c.dom.Attr;
25  import org.w3c.dom.NamedNodeMap;
26  
27  import org.w3c.dom.DOMException;
28  
29  
30  /**
31   * @xerces.internal
32   *
33   * @author Rahul Srivastava, Sun Microsystems Inc.
34   *
35   */
36  public class NamedNodeMapImpl implements NamedNodeMap {
37  
38          Attr[] attrs;
39  
40          public NamedNodeMapImpl(Attr[] attrs) {
41                  this.attrs = attrs;
42          }
43  
44          public Node getNamedItem(String name) {
45                  for (int i=0; i<attrs.length; i++) {
46                          if (attrs[i].getName().equals(name)) {
47                                  return attrs[i];
48                          }
49                  }
50                  return null;
51          }
52  
53          public Node item(int index) {
54                  if (index < 0 && index > getLength()) {
55                          return null;
56                  }
57                  return attrs[index];
58          }
59  
60          public int getLength() {
61                  return attrs.length;
62          }
63  
64          public Node getNamedItemNS(String namespaceURI, String localName) {
65                  for (int i=0; i<attrs.length; i++) {
66                          if (attrs[i].getName().equals(localName) && attrs[i].getNamespaceURI().equals(namespaceURI)) {
67                                  return attrs[i];
68                          }
69                  }
70                  return null;
71          }
72  
73          public Node setNamedItemNS(Node arg) throws DOMException {
74                  throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
75          }
76  
77          public Node setNamedItem(Node arg) throws DOMException {
78                  throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
79          }
80  
81          public Node removeNamedItem(String name) throws DOMException {
82                  throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
83          }
84  
85          public Node removeNamedItemNS(String namespaceURI, String localName) throws DOMException {
86                  throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
87          }
88  }