01: /*
02: * Copyright (c) 2002-2006 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.webwork.views.xslt;
06:
07: import org.w3c.dom.DOMException;
08: import org.w3c.dom.Node;
09: import org.w3c.dom.NamedNodeMap;
10: import org.apache.commons.logging.Log;
11: import org.apache.commons.logging.LogFactory;
12:
13: /**
14: * A NamedNodeMap that wraps the Nodes returned in their proxies.
15: *
16: * @author Pat Niemeyer (pat@pat.net)
17: */
18: /*
19: Note: Since maps have no guaranteed order we don't need to worry about identity
20: here as we do with "child" adapters. In that case we need to preserve identity
21: in order to support finding the next/previous siblings.
22: */
23: public class ProxyNamedNodeMap implements NamedNodeMap {
24: private NamedNodeMap nodes;
25: private AdapterFactory adapterFactory;
26: private AdapterNode parent;
27: private Log log = LogFactory.getLog(this .getClass());
28:
29: public ProxyNamedNodeMap(AdapterFactory factory,
30: AdapterNode parent, NamedNodeMap nodes) {
31: this .nodes = nodes;
32: this .adapterFactory = factory;
33: this .parent = parent;
34: }
35:
36: protected Node wrap(Node node) {
37: return adapterFactory.proxyNode(parent, node);
38: }
39:
40: public int getLength() {
41: return nodes.getLength();
42: }
43:
44: public Node item(int index) {
45: return wrap(nodes.item(index));
46: }
47:
48: public Node getNamedItem(String name) {
49: return wrap((Node) nodes.getNamedItem(name));
50: }
51:
52: public Node removeNamedItem(String name) throws DOMException {
53: throw new UnsupportedOperationException();
54: }
55:
56: public Node setNamedItem(Node arg) throws DOMException {
57: throw new UnsupportedOperationException();
58: }
59:
60: public Node setNamedItemNS(Node arg) throws DOMException {
61: throw new UnsupportedOperationException();
62: }
63:
64: public Node getNamedItemNS(String namespaceURI, String localName) {
65: return wrap((Node) nodes
66: .getNamedItemNS(namespaceURI, localName));
67: }
68:
69: public Node removeNamedItemNS(String namespaceURI, String localName)
70: throws DOMException {
71: throw new UnsupportedOperationException();
72: }
73: }
|