001
014
015 package com.liferay.portal.kernel.xml;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
020 import com.liferay.portal.kernel.util.GetterUtil;
021 import com.liferay.portal.kernel.util.PropsKeys;
022 import com.liferay.portal.kernel.util.PropsUtil;
023
024 import java.io.File;
025 import java.io.InputStream;
026 import java.io.Reader;
027
028 import java.net.MalformedURLException;
029 import java.net.URL;
030
031 import java.util.List;
032 import java.util.Map;
033
034
037 @ProviderType
038 public class SAXReaderUtil {
039
040 public static Attribute createAttribute(
041 Element element, QName qName, String value) {
042
043 return getSAXReader().createAttribute(element, qName, value);
044 }
045
046 public static Attribute createAttribute(
047 Element element, String name, String value) {
048
049 return getSAXReader().createAttribute(element, name, value);
050 }
051
052 public static Document createDocument() {
053 return getSAXReader().createDocument();
054 }
055
056 public static Document createDocument(Element rootElement) {
057 return getSAXReader().createDocument(rootElement);
058 }
059
060 public static Document createDocument(String encoding) {
061 return getSAXReader().createDocument(encoding);
062 }
063
064 public static Element createElement(QName qName) {
065 return getSAXReader().createElement(qName);
066 }
067
068 public static Element createElement(String name) {
069 return getSAXReader().createElement(name);
070 }
071
072 public static Entity createEntity(String name, String text) {
073 return getSAXReader().createEntity(name, text);
074 }
075
076 public static Namespace createNamespace(String uri) {
077 return getSAXReader().createNamespace(uri);
078 }
079
080 public static Namespace createNamespace(String prefix, String uri) {
081 return getSAXReader().createNamespace(prefix, uri);
082 }
083
084 public static ProcessingInstruction createProcessingInstruction(
085 String target, Map<String, String> data) {
086
087 return getSAXReader().createProcessingInstruction(target, data);
088 }
089
090 public static ProcessingInstruction createProcessingInstruction(
091 String target, String data) {
092
093 return getSAXReader().createProcessingInstruction(target, data);
094 }
095
096 public static QName createQName(String localName) {
097 return getSAXReader().createQName(localName);
098 }
099
100 public static QName createQName(String localName, Namespace namespace) {
101 return getSAXReader().createQName(localName, namespace);
102 }
103
104 public static Text createText(String text) {
105 return getSAXReader().createText(text);
106 }
107
108 public static XPath createXPath(String xPathExpression) {
109 return getSAXReader().createXPath(xPathExpression);
110 }
111
112 public static XPath createXPath(
113 String xPathExpression, Map<String, String> namespaceContextMap) {
114
115 return getSAXReader().createXPath(xPathExpression, namespaceContextMap);
116 }
117
118 public static XPath createXPath(
119 String xPathExpression, String prefix, String namespace) {
120
121 return getSAXReader().createXPath(xPathExpression, prefix, namespace);
122 }
123
124 public static SAXReader getSAXReader() {
125 PortalRuntimePermission.checkGetBeanProperty(SAXReaderUtil.class);
126
127 if (!_XML_SECURITY_ENABLED) {
128 return UnsecureSAXReaderUtil.getSAXReader();
129 }
130
131 return _saxReader;
132 }
133
134 public static Document read(File file) throws DocumentException {
135 return getSAXReader().read(file);
136 }
137
138 public static Document read(File file, boolean validate)
139 throws DocumentException {
140
141 return getSAXReader().read(file, validate);
142 }
143
144 public static Document read(InputStream is) throws DocumentException {
145 return getSAXReader().read(is);
146 }
147
148 public static Document read(InputStream is, boolean validate)
149 throws DocumentException {
150
151 return getSAXReader().read(is, validate);
152 }
153
154 public static Document read(Reader reader) throws DocumentException {
155 return getSAXReader().read(reader);
156 }
157
158 public static Document read(Reader reader, boolean validate)
159 throws DocumentException {
160
161 return getSAXReader().read(reader, validate);
162 }
163
164 public static Document read(String xml) throws DocumentException {
165 return getSAXReader().read(xml);
166 }
167
168 public static Document read(String xml, boolean validate)
169 throws DocumentException {
170
171 return getSAXReader().read(xml, validate);
172 }
173
174 public static Document read(String xml, XMLSchema xmlSchema)
175 throws DocumentException {
176
177 return getSAXReader().read(xml, xmlSchema);
178 }
179
180 public static Document read(URL url) throws DocumentException {
181 return getSAXReader().read(url);
182 }
183
184 public static Document read(URL url, boolean validate)
185 throws DocumentException {
186
187 return getSAXReader().read(url, validate);
188 }
189
190 public static Document readURL(String url)
191 throws DocumentException, MalformedURLException {
192
193 return getSAXReader().readURL(url);
194 }
195
196 public static Document readURL(String url, boolean validate)
197 throws DocumentException, MalformedURLException {
198
199 return getSAXReader().readURL(url, validate);
200 }
201
202 public static List<Node> selectNodes(
203 String xPathFilterExpression, List<Node> nodes) {
204
205 return getSAXReader().selectNodes(xPathFilterExpression, nodes);
206 }
207
208 public static List<Node> selectNodes(
209 String xPathFilterExpression, Node node) {
210
211 return getSAXReader().selectNodes(xPathFilterExpression, node);
212 }
213
214 public static void sort(List<Node> nodes, String xPathExpression) {
215 getSAXReader().sort(nodes, xPathExpression);
216 }
217
218 public static void sort(
219 List<Node> nodes, String xPathExpression, boolean distinct) {
220
221 getSAXReader().sort(nodes, xPathExpression, distinct);
222 }
223
224 public void setSAXReader(SAXReader saxReader) {
225 PortalRuntimePermission.checkSetBeanProperty(getClass());
226
227 _saxReader = saxReader;
228 }
229
230 private static final boolean _XML_SECURITY_ENABLED = GetterUtil.getBoolean(
231 PropsUtil.get(PropsKeys.XML_SECURITY_ENABLED));
232
233 private static SAXReader _saxReader;
234
235 }