1
2
3
4
5
6
7
8 package org.dom4j.util;
9
10 import java.util.Map;
11
12 import org.dom4j.Attribute;
13 import org.dom4j.CDATA;
14 import org.dom4j.Comment;
15 import org.dom4j.Document;
16 import org.dom4j.DocumentFactory;
17 import org.dom4j.DocumentType;
18 import org.dom4j.Element;
19 import org.dom4j.Entity;
20 import org.dom4j.Namespace;
21 import org.dom4j.NodeFilter;
22 import org.dom4j.ProcessingInstruction;
23 import org.dom4j.QName;
24 import org.dom4j.Text;
25 import org.dom4j.XPath;
26 import org.dom4j.rule.Pattern;
27
28 import org.jaxen.VariableContext;
29
30 /***
31 * <p>
32 * <code>ProxyDocumentFactory</code> implements a proxy to a DocumentFactory
33 * which is useful for implementation inheritence, allowing the pipelining of
34 * various factory implementations. For example an EncodingDocumentFactory which
35 * takes care of encoding strings outside of allowable XML ranges could be used
36 * with a DatatypeDocumentFactory which is XML Schema Data Type aware.
37 * </p>
38 *
39 * @author <a href="mailto:jstrachan@apache.org">James Strachan </a>
40 * @version $Revision: 1.13 $
41 */
42 public abstract class ProxyDocumentFactory {
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 public Document createDocument() {
57 return proxy.createDocument();
58 }
59
60 public Document createDocument(Element rootElement) {
61 return proxy.createDocument(rootElement);
62 }
63
64 public DocumentType createDocType(String name, String publicId,
65 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 public Attribute createAttribute(Element owner, QName qname, String value) {
78 return proxy.createAttribute(owner, qname, value);
79 }
80
81 public Attribute createAttribute(Element owner, String name, String value) {
82 return proxy.createAttribute(owner, name, value);
83 }
84
85 public CDATA createCDATA(String text) {
86 return proxy.createCDATA(text);
87 }
88
89 public Comment createComment(String text) {
90 return proxy.createComment(text);
91 }
92
93 public Text createText(String text) {
94 return proxy.createText(text);
95 }
96
97 public Entity createEntity(String name, String text) {
98 return proxy.createEntity(name, text);
99 }
100
101 public Namespace createNamespace(String prefix, String uri) {
102 return proxy.createNamespace(prefix, uri);
103 }
104
105 public ProcessingInstruction createProcessingInstruction(String target,
106 String data) {
107 return proxy.createProcessingInstruction(target, data);
108 }
109
110 public ProcessingInstruction createProcessingInstruction(String target,
111 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,
136 VariableContext variableContext) {
137 return proxy.createXPath(xpathExpression, variableContext);
138 }
139
140 public NodeFilter createXPathFilter(String xpathFilterExpression,
141 VariableContext variableContext) {
142 return proxy.createXPathFilter(xpathFilterExpression, variableContext);
143 }
144
145 public NodeFilter createXPathFilter(String xpathFilterExpression) {
146 return proxy.createXPathFilter(xpathFilterExpression);
147 }
148
149 public Pattern createPattern(String xpathPattern) {
150 return proxy.createPattern(xpathPattern);
151 }
152
153
154
155 protected DocumentFactory getProxy() {
156 return proxy;
157 }
158
159 protected void setProxy(DocumentFactory proxy) {
160 if (proxy == null) {
161
162 proxy = DocumentFactory.getInstance();
163 }
164
165 this.proxy = proxy;
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