01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.xerces.impl.xs.opti;
19:
20: import org.w3c.dom.Node;
21: import org.w3c.dom.Attr;
22: import org.w3c.dom.NamedNodeMap;
23:
24: import org.w3c.dom.DOMException;
25:
26: /**
27: * @xerces.internal
28: *
29: * @author Rahul Srivastava, Sun Microsystems Inc.
30: *
31: * @version $Id: NamedNodeMapImpl.java 446728 2006-09-15 20:43:46Z mrglavas $
32: */
33: public class NamedNodeMapImpl implements NamedNodeMap {
34:
35: Attr[] attrs;
36:
37: public NamedNodeMapImpl(Attr[] attrs) {
38: this .attrs = attrs;
39: }
40:
41: public Node getNamedItem(String 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 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 getNamedItemNS(String namespaceURI, String localName) {
62: for (int i = 0; i < attrs.length; i++) {
63: if (attrs[i].getName().equals(localName)
64: && attrs[i].getNamespaceURI().equals(namespaceURI)) {
65: return attrs[i];
66: }
67: }
68: return null;
69: }
70:
71: public Node setNamedItemNS(Node arg) throws DOMException {
72: throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
73: "Method not supported");
74: }
75:
76: public Node setNamedItem(Node arg) throws DOMException {
77: throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
78: "Method not supported");
79: }
80:
81: public Node removeNamedItem(String name) throws DOMException {
82: throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
83: "Method not supported");
84: }
85:
86: public Node removeNamedItemNS(String namespaceURI, String localName)
87: throws DOMException {
88: throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
89: "Method not supported");
90: }
91: }
|