1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.struts2.views.xslt;
19
20 import org.w3c.dom.DOMException;
21 import org.w3c.dom.NamedNodeMap;
22 import org.w3c.dom.Node;
23
24 /***
25 * A NamedNodeMap that wraps the Nodes returned in their proxies.
26 *
27 * Note: Since maps have no guaranteed order we don't need to worry about identity
28 * here as we do with "child" adapters. In that case we need to preserve identity
29 * in order to support finding the next/previous siblings.
30 */
31 public class ProxyNamedNodeMap implements NamedNodeMap {
32
33 private NamedNodeMap nodes;
34 private AdapterFactory adapterFactory;
35 private AdapterNode parent;
36
37 public ProxyNamedNodeMap(AdapterFactory factory, AdapterNode parent, NamedNodeMap nodes) {
38 this.nodes = nodes;
39 this.adapterFactory = factory;
40 this.parent = parent;
41 }
42
43 protected Node wrap(Node node) {
44 return adapterFactory.proxyNode(parent, node);
45 }
46
47 public int getLength() {
48 return nodes.getLength();
49 }
50
51 public Node item(int index) {
52 return wrap(nodes.item(index));
53 }
54
55 public Node getNamedItem(String name) {
56 return wrap(nodes.getNamedItem(name));
57 }
58
59 public Node removeNamedItem(String name) throws DOMException {
60 throw new UnsupportedOperationException();
61 }
62
63 public Node setNamedItem(Node arg) throws DOMException {
64 throw new UnsupportedOperationException();
65 }
66
67 public Node setNamedItemNS(Node arg) throws DOMException {
68 throw new UnsupportedOperationException();
69 }
70
71 public Node getNamedItemNS(String namespaceURI, String localName) {
72 return wrap(nodes.getNamedItemNS(namespaceURI, localName));
73 }
74
75 public Node removeNamedItemNS(String namespaceURI, String localName) throws DOMException {
76 throw new UnsupportedOperationException();
77 }
78 }