1
22
23 package com.liferay.portal.kernel.xml;
24
25 import com.liferay.portal.kernel.log.Log;
26 import com.liferay.portal.kernel.log.LogFactoryUtil;
27
28 import java.io.File;
29 import java.io.InputStream;
30 import java.io.Reader;
31
32 import java.net.MalformedURLException;
33 import java.net.URL;
34
35 import java.util.List;
36 import java.util.Map;
37
38
43 public class SAXReaderUtil {
44
45 public static Attribute createAttribute(
46 Element element, QName qName, String value) {
47
48 return getSAXReader().createAttribute(element, qName, value);
49 }
50
51 public static Attribute createAttribute(
52 Element element, String name, String value) {
53
54 return getSAXReader().createAttribute(element, name, value);
55 }
56
57 public static Document createDocument() {
58 return getSAXReader().createDocument();
59 }
60
61 public static Document createDocument(Element rootElement) {
62 return getSAXReader().createDocument(rootElement);
63 }
64
65 public static Document createDocument(String encoding) {
66 return getSAXReader().createDocument(encoding);
67 }
68
69 public static Element createElement(QName qName) {
70 return getSAXReader().createElement(qName);
71 }
72
73 public static Element createElement(String name) {
74 return getSAXReader().createElement(name);
75 }
76
77 public static Entity createEntity(String name, String text) {
78 return getSAXReader().createEntity(name, text);
79 }
80
81 public static Namespace createNamespace(String uri) {
82 return getSAXReader().createNamespace(uri);
83 }
84
85 public static Namespace createNamespace(String prefix, String uri) {
86 return getSAXReader().createNamespace(prefix, uri);
87 }
88
89 public static ProcessingInstruction createProcessingInstruction(
90 String target, Map<String, String> data) {
91
92 return getSAXReader().createProcessingInstruction(target, data);
93 }
94
95 public static ProcessingInstruction createProcessingInstruction(
96 String target, String data) {
97
98 return getSAXReader().createProcessingInstruction(target, data);
99 }
100
101 public static QName createQName(String localName) {
102 return getSAXReader().createQName(localName);
103 }
104
105 public static QName createQName(String localName, Namespace namespace) {
106 return getSAXReader().createQName(localName, namespace);
107 }
108
109 public static Text createText(String text) {
110 return getSAXReader().createText(text);
111 }
112
113 public static XPath createXPath(String xpathExpression) {
114 return getSAXReader().createXPath(xpathExpression);
115 }
116
117 public static SAXReader getSAXReader() {
118 return _saxReader;
119 }
120
121 public static Document read(File file) throws DocumentException {
122 return getSAXReader().read(file);
123 }
124
125 public static Document read(File file, boolean validate)
126 throws DocumentException {
127
128 return getSAXReader().read(file, validate);
129 }
130
131 public static Document read(InputStream is) throws DocumentException {
132 return getSAXReader().read(is);
133 }
134
135 public static Document read(InputStream is, boolean validate)
136 throws DocumentException {
137
138 return getSAXReader().read(is, validate);
139 }
140
141 public static Document read(Reader reader) throws DocumentException {
142 return getSAXReader().read(reader);
143 }
144
145 public static Document read(Reader reader, boolean validate)
146 throws DocumentException {
147
148 return getSAXReader().read(reader, validate);
149 }
150
151 public static Document read(String xml) throws DocumentException {
152 return getSAXReader().read(xml);
153 }
154
155 public static Document read(String xml, boolean validate)
156 throws DocumentException {
157
158 return getSAXReader().read(xml, validate);
159 }
160
161 public static Document read(URL url) throws DocumentException {
162 return getSAXReader().read(url);
163 }
164
165 public static Document read(URL url, boolean validate)
166 throws DocumentException {
167
168 return getSAXReader().read(url, validate);
169 }
170
171 public static Document readURL(String url)
172 throws DocumentException, MalformedURLException {
173
174 return getSAXReader().readURL(url);
175 }
176
177 public static Document readURL(String url, boolean validate)
178 throws DocumentException, MalformedURLException {
179
180 return getSAXReader().readURL(url, validate);
181 }
182
183 public static List<Node> selectNodes(
184 String xpathFilterExpression, List<Node> nodes) {
185
186 return getSAXReader().selectNodes(xpathFilterExpression, nodes);
187 }
188
189 public static List<Node> selectNodes(
190 String xpathFilterExpression, Node node) {
191
192 return getSAXReader().selectNodes(xpathFilterExpression, node);
193 }
194
195 public static void sort(List<Node> nodes, String xpathExpression) {
196
197 getSAXReader().sort(nodes, xpathExpression);
198 }
199
200 public static void sort(
201 List<Node> nodes, String xpathExpression, boolean distinct) {
202
203 getSAXReader().sort(nodes, xpathExpression, distinct);
204 }
205
206 public void setSAXReader(SAXReader saxReader) {
207 _saxReader = saxReader;
208 }
209
210 private static Log _log = LogFactoryUtil.getLog(SAXReaderUtil.class);
211
212 private static SAXReader _saxReader;
213
214 }