KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > impl > xs > opti > NamedNodeMapImpl


1 /*
2  * Copyright 2001, 2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.xerces.impl.xs.opti;
18
19 import org.w3c.dom.Node JavaDoc;
20 import org.w3c.dom.Attr JavaDoc;
21 import org.w3c.dom.NamedNodeMap JavaDoc;
22
23 import org.w3c.dom.DOMException JavaDoc;
24
25
26 /**
27  * @xerces.internal
28  *
29  * @author Rahul Srivastava, Sun Microsystems Inc.
30  *
31  * @version $Id: NamedNodeMapImpl.java,v 1.4 2004/10/06 15:14:49 mrglavas Exp $
32  */

33 public class NamedNodeMapImpl implements NamedNodeMap JavaDoc {
34
35     Attr JavaDoc[] attrs;
36     
37     public NamedNodeMapImpl(Attr JavaDoc[] attrs) {
38         this.attrs = attrs;
39     }
40     
41     public Node JavaDoc getNamedItem(String JavaDoc 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 JavaDoc 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 JavaDoc getNamedItemNS(String JavaDoc namespaceURI, String JavaDoc 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 JavaDoc setNamedItemNS(Node JavaDoc arg) throws DOMException JavaDoc {
71         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
72     }
73     
74     public Node JavaDoc setNamedItem(Node JavaDoc arg) throws DOMException JavaDoc {
75         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
76     }
77     
78     public Node JavaDoc removeNamedItem(String JavaDoc name) throws DOMException JavaDoc {
79         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
80     }
81
82     public Node JavaDoc removeNamedItemNS(String JavaDoc namespaceURI, String JavaDoc localName) throws DOMException JavaDoc {
83         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
84     }
85 }
Popular Tags