1
2
3
4
5
6
7
8
9
10 package org.dom4j.util;
11
12 import java.util.Map;
13
14 import org.dom4j.Attribute;
15 import org.dom4j.CDATA;
16 import org.dom4j.Comment;
17 import org.dom4j.Document;
18 import org.dom4j.DocumentFactory;
19 import org.dom4j.DocumentType;
20 import org.dom4j.Element;
21 import org.dom4j.Entity;
22 import org.dom4j.Namespace;
23 import org.dom4j.NodeFilter;
24 import org.dom4j.ProcessingInstruction;
25 import org.dom4j.QName;
26 import org.dom4j.Text;
27 import org.dom4j.XPath;
28 import org.dom4j.rule.Pattern;
29 import org.jaxen.VariableContext;
30
31 /*** <p><code>ProxyDocumentFactory</code> implements a proxy to a DocumentFactory
32 * which is useful for implementation inheritence, allowing the pipelining
33 * of various factory implementations. For example an EncodingDocumentFactory
34 * which takes care of encoding strings outside of allowable XML ranges
35 * could be used with a DatatypeDocumentFactory which is XML Schema Data Type
36 * aware.</p>
37 *
38 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
39 * @version $Revision: 1.11 $
40 */
41 public abstract class ProxyDocumentFactory {
42
43 private DocumentFactory proxy;
44
45 public ProxyDocumentFactory() {
46
47 this.proxy = DocumentFactory.getInstance();
48 }
49
50 public ProxyDocumentFactory(DocumentFactory proxy) {
51 this.proxy = proxy;
52 }
53
54
55
56
57 public Document createDocument() {
58 return proxy.createDocument();
59 }
60
61 public Document createDocument(Element rootElement) {
62 return proxy.createDocument(rootElement);
63 }
64
65 public DocumentType createDocType(String name, String publicId, String systemId) {
66 return proxy.createDocType(name, publicId, systemId);
67 }
68
69 public Element createElement(QName qname) {
70 return proxy.createElement(qname);
71 }
72
73 public Element createElement(String name) {
74 return proxy.createElement(name);
75 }
76
77
78 public Attribute createAttribute(Element owner, QName qname, String value) {
79 return proxy.createAttribute(owner, qname, value);
80 }
81
82 public Attribute createAttribute(Element owner, String name, String value) {
83 return proxy.createAttribute(owner, name, value);
84 }
85
86 public CDATA createCDATA(String text) {
87 return proxy.createCDATA(text);
88 }
89
90 public Comment createComment(String text) {
91 return proxy.createComment(text);
92 }
93
94 public Text createText(String text) {
95 return proxy.createText(text);
96 }
97
98
99 public Entity createEntity(String name, String text) {
100 return proxy.createEntity(name, text);
101 }
102
103 public Namespace createNamespace(String prefix, String uri) {
104 return proxy.createNamespace(prefix, uri);
105 }
106
107 public ProcessingInstruction createProcessingInstruction(String target, String data) {
108 return proxy.createProcessingInstruction(target, data);
109 }
110
111 public ProcessingInstruction createProcessingInstruction(String target, Map data) {
112 return proxy.createProcessingInstruction(target, data);
113 }
114
115 public QName createQName(String localName, Namespace namespace) {
116 return proxy.createQName(localName, namespace);
117 }
118
119 public QName createQName(String localName) {
120 return proxy.createQName(localName);
121 }
122
123 public QName createQName(String name, String prefix, String uri) {
124 return proxy.createQName(name, prefix, uri);
125 }
126
127 public QName createQName(String qualifiedName, String uri) {
128 return proxy.createQName(qualifiedName, uri);
129 }
130
131 public XPath createXPath(String xpathExpression) {
132 return proxy.createXPath(xpathExpression);
133 }
134
135 public XPath createXPath(String xpathExpression, VariableContext variableContext) {
136 return proxy.createXPath(xpathExpression, variableContext);
137 }
138
139 public NodeFilter createXPathFilter(String xpathFilterExpression, VariableContext variableContext) {
140 return proxy.createXPathFilter(xpathFilterExpression, variableContext);
141 }
142
143 public NodeFilter createXPathFilter(String xpathFilterExpression) {
144 return proxy.createXPathFilter(xpathFilterExpression);
145 }
146
147 public Pattern createPattern(String xpathPattern) {
148 return proxy.createPattern(xpathPattern);
149 }
150
151
152
153
154 protected DocumentFactory getProxy() {
155 return proxy;
156 }
157
158 protected void setProxy(DocumentFactory proxy) {
159 if ( proxy == null ) {
160
161 proxy = DocumentFactory.getInstance();
162 }
163 this.proxy = proxy;
164 }
165 }
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213