1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.struts2.views.xslt;
23
24 import org.w3c.dom.DOMException;
25 import org.w3c.dom.NamedNodeMap;
26 import org.w3c.dom.Node;
27
28 /***
29 * A NamedNodeMap that wraps the Nodes returned in their proxies.
30 *
31 * Note: Since maps have no guaranteed order we don't need to worry about identity
32 * here as we do with "child" adapters. In that case we need to preserve identity
33 * in order to support finding the next/previous siblings.
34 */
35 public class ProxyNamedNodeMap implements NamedNodeMap {
36
37 private NamedNodeMap nodes;
38 private AdapterFactory adapterFactory;
39 private AdapterNode parent;
40
41 public ProxyNamedNodeMap(AdapterFactory factory, 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) throws DOMException {
80 throw new UnsupportedOperationException();
81 }
82 }