01: /*
02: * $Id: ProxyNamedNodeMap.java 471756 2006-11-06 15:01:43Z husted $
03: *
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. 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,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21: package org.apache.struts2.views.xslt;
22:
23: import org.w3c.dom.DOMException;
24: import org.w3c.dom.NamedNodeMap;
25: import org.w3c.dom.Node;
26:
27: /**
28: * A NamedNodeMap that wraps the Nodes returned in their proxies.
29: *
30: * Note: Since maps have no guaranteed order we don't need to worry about identity
31: * here as we do with "child" adapters. In that case we need to preserve identity
32: * in order to support finding the next/previous siblings.
33: */
34: public class ProxyNamedNodeMap implements NamedNodeMap {
35:
36: private NamedNodeMap nodes;
37: private AdapterFactory adapterFactory;
38: private AdapterNode parent;
39:
40: public ProxyNamedNodeMap(AdapterFactory factory,
41: AdapterNode parent, NamedNodeMap nodes) {
42: this .nodes = nodes;
43: this .adapterFactory = factory;
44: this .parent = parent;
45: }
46:
47: protected Node wrap(Node node) {
48: return adapterFactory.proxyNode(parent, node);
49: }
50:
51: public int getLength() {
52: return nodes.getLength();
53: }
54:
55: public Node item(int index) {
56: return wrap(nodes.item(index));
57: }
58:
59: public Node getNamedItem(String name) {
60: return wrap(nodes.getNamedItem(name));
61: }
62:
63: public Node removeNamedItem(String name) throws DOMException {
64: throw new UnsupportedOperationException();
65: }
66:
67: public Node setNamedItem(Node arg) throws DOMException {
68: throw new UnsupportedOperationException();
69: }
70:
71: public Node setNamedItemNS(Node arg) throws DOMException {
72: throw new UnsupportedOperationException();
73: }
74:
75: public Node getNamedItemNS(String namespaceURI, String localName) {
76: return wrap(nodes.getNamedItemNS(namespaceURI, localName));
77: }
78:
79: public Node removeNamedItemNS(String namespaceURI, String localName)
80: throws DOMException {
81: throw new UnsupportedOperationException();
82: }
83: }
|