1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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, AdapterNode parent, NamedNodeMap nodes) {
41 this.nodes = nodes;
42 this.adapterFactory = factory;
43 this.parent = parent;
44 }
45
46 protected Node wrap(Node node) {
47 return adapterFactory.proxyNode(parent, node);
48 }
49
50 public int getLength() {
51 return nodes.getLength();
52 }
53
54 public Node item(int index) {
55 return wrap(nodes.item(index));
56 }
57
58 public Node getNamedItem(String name) {
59 return wrap(nodes.getNamedItem(name));
60 }
61
62 public Node removeNamedItem(String name) throws DOMException {
63 throw new UnsupportedOperationException();
64 }
65
66 public Node setNamedItem(Node arg) throws DOMException {
67 throw new UnsupportedOperationException();
68 }
69
70 public Node setNamedItemNS(Node arg) throws DOMException {
71 throw new UnsupportedOperationException();
72 }
73
74 public Node getNamedItemNS(String namespaceURI, String localName) {
75 return wrap(nodes.getNamedItemNS(namespaceURI, localName));
76 }
77
78 public Node removeNamedItemNS(String namespaceURI, String localName) throws DOMException {
79 throw new UnsupportedOperationException();
80 }
81 }