KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > xmlc > dom > generic > GenericLinkedDocument


1 package org.enhydra.xml.xmlc.dom.generic;
2
3 import org.enhydra.xml.dom.DOMOps;
4 import org.enhydra.xml.xmlc.XMLObject;
5 import org.enhydra.xml.xmlc.XMLObjectLink;
6 import org.w3c.dom.Attr JavaDoc;
7 import org.w3c.dom.CDATASection JavaDoc;
8 import org.w3c.dom.Comment JavaDoc;
9 import org.w3c.dom.DOMConfiguration JavaDoc;
10 import org.w3c.dom.DOMException JavaDoc;
11 import org.w3c.dom.DOMImplementation JavaDoc;
12 import org.w3c.dom.Document JavaDoc;
13 import org.w3c.dom.DocumentFragment JavaDoc;
14 import org.w3c.dom.DocumentType JavaDoc;
15 import org.w3c.dom.Element JavaDoc;
16 import org.w3c.dom.EntityReference JavaDoc;
17 import org.w3c.dom.NamedNodeMap JavaDoc;
18 import org.w3c.dom.Node JavaDoc;
19 import org.w3c.dom.NodeList JavaDoc;
20 import org.w3c.dom.ProcessingInstruction JavaDoc;
21 import org.w3c.dom.Text JavaDoc;
22 import org.w3c.dom.UserDataHandler JavaDoc;
23
24 /**
25  * This is a generic wrapper around {@link Document} that adds {@link
26  * XMLObjectLink} functionality.
27  */

28 public class GenericLinkedDocument implements Document JavaDoc, XMLObjectLink {
29     /** Delegate document */
30     protected final Document JavaDoc DELEGATE;
31
32     /** The {@link XMLObject instance} */
33     private XMLObject objectLink;
34
35     /**
36      * Constructor.
37      * @param inner the document to be wrapped.
38      */

39     public GenericLinkedDocument(Document JavaDoc inner) {
40         DELEGATE = inner;
41     }
42     
43     /**
44      * @see XMLObjectLink#setXMLObject
45      */

46     public void setXMLObject(XMLObject xmlObject) {
47         objectLink = xmlObject;
48     }
49
50     /**
51      * @see XMLObjectLink#getXMLObject
52      */

53     public XMLObject getXMLObject() {
54         return objectLink;
55     }
56
57     /** @see Node#cloneNode */
58     public Node JavaDoc cloneNode(boolean deep) {
59     // Make sure the cloned document is an object link as well,
60
// and points back to the same object...
61
GenericLinkedDocument clone =
62         new GenericLinkedDocument((Document JavaDoc)DELEGATE.cloneNode(deep));
63     clone.setXMLObject(getXMLObject());
64     return clone;
65     }
66
67     // Everything below here simply passes all calls through to the
68
// wrapped object...
69

70     // DOM Level 2, org.w3c.dom.Document
71
public DocumentType JavaDoc getDoctype() {
72         return DELEGATE.getDoctype();
73     }
74     public DOMImplementation JavaDoc getImplementation() {
75         return DELEGATE.getImplementation();
76     }
77     public Element JavaDoc getDocumentElement() {
78         return DELEGATE.getDocumentElement();
79     }
80     public Element JavaDoc createElement(String JavaDoc tagName) throws DOMException JavaDoc {
81         return DELEGATE.createElement(tagName);
82     }
83     public DocumentFragment JavaDoc createDocumentFragment() {
84         return DELEGATE.createDocumentFragment();
85     }
86     public Text JavaDoc createTextNode(String JavaDoc data) {
87         return DELEGATE.createTextNode(data);
88     }
89     public Comment JavaDoc createComment(String JavaDoc data) {
90         return DELEGATE.createComment(data);
91     }
92     public CDATASection JavaDoc createCDATASection(String JavaDoc data) throws DOMException JavaDoc {
93         return DELEGATE.createCDATASection(data);
94     }
95     public ProcessingInstruction JavaDoc createProcessingInstruction(String JavaDoc target, String JavaDoc data) throws DOMException JavaDoc {
96         return DELEGATE.createProcessingInstruction(target, data);
97     }
98     public Attr JavaDoc createAttribute(String JavaDoc name) throws DOMException JavaDoc {
99         return DELEGATE.createAttribute(name);
100     }
101     public EntityReference JavaDoc createEntityReference(String JavaDoc name) throws DOMException JavaDoc {
102         return DELEGATE.createEntityReference(name);
103     }
104     public NodeList JavaDoc getElementsByTagName(String JavaDoc tagname) {
105         return DELEGATE.getElementsByTagName(tagname);
106     }
107     public Node JavaDoc importNode(Node JavaDoc importedNode, boolean deep) throws DOMException JavaDoc {
108         return DELEGATE.importNode(importedNode, deep);
109     }
110     public Element JavaDoc createElementNS(String JavaDoc namespaceURI, String JavaDoc qualifiedName) throws DOMException JavaDoc {
111         return DELEGATE.createElementNS(namespaceURI, qualifiedName);
112     }
113     public Attr JavaDoc createAttributeNS(String JavaDoc namespaceURI, String JavaDoc qualifiedName) throws DOMException JavaDoc {
114         return DELEGATE.createAttributeNS(namespaceURI, qualifiedName);
115     }
116     public NodeList JavaDoc getElementsByTagNameNS(String JavaDoc namespaceURI, String JavaDoc localName) {
117         return DELEGATE.getElementsByTagNameNS(namespaceURI, localName);
118     }
119     public Element JavaDoc getElementById(String JavaDoc elementId) {
120         return DELEGATE.getElementById(elementId);
121     }
122     
123     // org.w3c.dom.Node
124

125     public String JavaDoc getNodeName() {
126         return DELEGATE.getNodeName();
127     }
128     public String JavaDoc getNodeValue() throws DOMException JavaDoc {
129         return DELEGATE.getNodeValue();
130     }
131     public void setNodeValue(String JavaDoc nodeValue) throws DOMException JavaDoc {
132         DELEGATE.setNodeValue(nodeValue);
133     }
134
135     public short getNodeType() {
136         return DELEGATE.getNodeType();
137     }
138     public Node JavaDoc getParentNode() {
139         return DELEGATE.getParentNode();
140     }
141     public NodeList JavaDoc getChildNodes() {
142         return DELEGATE.getChildNodes();
143     }
144     public Node JavaDoc getFirstChild() {
145         return DELEGATE.getFirstChild();
146     }
147     public Node JavaDoc getLastChild() {
148         return DELEGATE.getLastChild();
149     }
150     public Node JavaDoc getPreviousSibling() {
151         return DELEGATE.getPreviousSibling();
152     }
153     public Node JavaDoc getNextSibling() {
154         return DELEGATE.getNextSibling();
155     }
156     public NamedNodeMap JavaDoc getAttributes() {
157         return DELEGATE.getAttributes();
158     }
159     public Document JavaDoc getOwnerDocument() {
160         return DELEGATE.getOwnerDocument();
161     }
162     public Node JavaDoc insertBefore(Node JavaDoc newChild, Node JavaDoc refChild) throws DOMException JavaDoc {
163         return DELEGATE.insertBefore(newChild, refChild);
164     }
165     public Node JavaDoc replaceChild(Node JavaDoc newChild, Node JavaDoc oldChild) throws DOMException JavaDoc {
166         return DELEGATE.replaceChild(newChild, oldChild);
167     }
168     public Node JavaDoc removeChild(Node JavaDoc oldChild) throws DOMException JavaDoc {
169         return DELEGATE.removeChild(oldChild);
170     }
171     public Node JavaDoc appendChild(Node JavaDoc newChild) throws DOMException JavaDoc {
172         return DELEGATE.appendChild(newChild);
173     }
174     public boolean hasChildNodes() {
175         return DELEGATE.hasChildNodes();
176     }
177     public void normalize() {
178         DELEGATE.normalize();
179     }
180     public boolean isSupported(String JavaDoc feature, String JavaDoc version) {
181         return DELEGATE.isSupported(feature, version);
182     }
183     public String JavaDoc getNamespaceURI() {
184         return DELEGATE.getNamespaceURI();
185     }
186     public String JavaDoc getPrefix() {
187         return DELEGATE.getPrefix();
188     }
189     public void setPrefix(String JavaDoc prefix) throws DOMException JavaDoc {
190         DELEGATE.setPrefix(prefix);
191     }
192     public String JavaDoc getLocalName() {
193         return DELEGATE.getLocalName();
194     }
195     public boolean hasAttributes() {
196         return DELEGATE.hasAttributes();
197     }
198
199     // DOM level 3, org.w3c.dom.Document. This API may change as the
200
// specification settles....
201
public String JavaDoc getEncoding() {
202         return DOMOps.getEncoding(DELEGATE);
203     }
204     public void setEncoding(String JavaDoc encoding) {
205         DOMOps.setEncoding(DELEGATE, encoding);
206     }
207
208     public boolean getStandalone() {
209         return DOMOps.getStandalone(DELEGATE);
210     }
211     public void setStandalone(boolean standalone) {
212         DOMOps.setStandalone(DELEGATE, standalone);
213     }
214
215     public boolean getStrictErrorChecking() {
216         return DOMOps.getStrictErrorChecking(DELEGATE);
217     }
218     public void setStrictErrorChecking(boolean strictErrorChecking) {
219         DOMOps.setStrictErrorChecking(DELEGATE, strictErrorChecking);
220     }
221
222     public String JavaDoc getVersion() {
223         return DOMOps.getVersion(DELEGATE);
224     }
225     public void setVersion(String JavaDoc version) {
226         DOMOps.setVersion(DELEGATE, version);
227     }
228
229     public Node JavaDoc adoptNode(Node JavaDoc source) throws DOMException JavaDoc {
230         return DOMOps.adoptNode(DELEGATE, source);
231     }
232
233
234 //Below are DOM3 methods. adoptNode() above is DOM3, but was used experimentally previously, so leaving as is. There is a similar situation for getEncoding(), however the DOM3 method is getInputEncoding(). Leaving getEncoding() as is.
235

236     public String JavaDoc getInputEncoding() {
237         return DELEGATE.getInputEncoding();
238     }
239
240     public String JavaDoc getXmlEncoding() {
241         return DELEGATE.getXmlEncoding();
242     }
243
244     public boolean getXmlStandalone() {
245         return DELEGATE.getXmlStandalone();
246     }
247
248     public void setXmlStandalone(boolean xmlStandalone) throws DOMException JavaDoc {
249         DELEGATE.setXmlStandalone(xmlStandalone);
250     }
251
252     public String JavaDoc getXmlVersion() {
253         return DELEGATE.getXmlVersion();
254     }
255
256     public void setXmlVersion(String JavaDoc xmlVersion) throws DOMException JavaDoc {
257         DELEGATE.setXmlVersion(xmlVersion);
258     }
259
260     public String JavaDoc getDocumentURI() {
261         return DELEGATE.getDocumentURI();
262     }
263
264     public void setDocumentURI(String JavaDoc documentURI) {
265         DELEGATE.setDocumentURI(documentURI);
266     }
267
268     public DOMConfiguration JavaDoc getDomConfig() {
269         return DELEGATE.getDomConfig();
270     }
271
272     public void normalizeDocument() {
273         DELEGATE.normalizeDocument();
274     }
275
276     public Node JavaDoc renameNode(Node JavaDoc n, String JavaDoc namespaceURI, String JavaDoc qualifiedName) throws DOMException JavaDoc {
277         return DELEGATE.renameNode(n, namespaceURI, qualifiedName);
278     }
279
280     public String JavaDoc getBaseURI() {
281         return DELEGATE.getBaseURI();
282     }
283
284     public short compareDocumentPosition(Node JavaDoc other) throws DOMException JavaDoc {
285         return DELEGATE.compareDocumentPosition(other);
286     }
287
288     public String JavaDoc getTextContent() throws DOMException JavaDoc {
289         return DELEGATE.getTextContent();
290     }
291
292     public void setTextContent(String JavaDoc textContent) throws DOMException JavaDoc {
293         DELEGATE.setTextContent(textContent);
294     }
295
296     public boolean isSameNode(Node JavaDoc other) {
297         return DELEGATE.isSameNode(other);
298     }
299
300     public String JavaDoc lookupPrefix(String JavaDoc namespaceURI) {
301         return DELEGATE.lookupPrefix(namespaceURI);
302     }
303
304     public boolean isDefaultNamespace(String JavaDoc namespaceURI) {
305         return DELEGATE.isDefaultNamespace(namespaceURI);
306     }
307
308     public String JavaDoc lookupNamespaceURI(String JavaDoc prefix) {
309         return DELEGATE.lookupNamespaceURI(prefix);
310     }
311
312     public boolean isEqualNode(Node JavaDoc arg) {
313         return DELEGATE.isEqualNode(arg);
314     }
315
316     public Object JavaDoc getFeature(String JavaDoc feature, String JavaDoc version) {
317         return DELEGATE.getFeature(feature, version);
318     }
319
320     public Object JavaDoc setUserData(String JavaDoc key, Object JavaDoc data, UserDataHandler JavaDoc handler) {
321         return DELEGATE.setUserData(key, data, handler);
322     }
323
324     public Object JavaDoc getUserData(String JavaDoc key) {
325         return DELEGATE.getUserData(key);
326     }
327 }
328
Popular Tags