comparison artifacts-common/src/main/java/org/dive4elements/artifacts/common/utils/XMLUtils.java @ 549:e781b847fdca 3.2.2

Added new File/NS-aware/Entity-Resolver signature for XMLUtils.parseDocument.
author Sascha L. Teichmann <teichmann@intevation.de>
date Mon, 22 Feb 2016 17:25:21 +0100
parents f099f0b22e62
children 584591f8203c
comparison
equal deleted inserted replaced
548:df7c3fb4b276 549:e781b847fdca
161 } // class ElementCreator 161 } // class ElementCreator
162 162
163 /** 163 /**
164 * Resolver for entities in artifacts configuration. 164 * Resolver for entities in artifacts configuration.
165 */ 165 */
166 private static final EntityResolver CONF_RESOLVER = new EntityResolver() { 166 public static final EntityResolver CONF_RESOLVER = new EntityResolver() {
167 @Override 167 @Override
168 public InputSource resolveEntity( 168 public InputSource resolveEntity(
169 String publicId, 169 String publicId,
170 String systemId 170 String systemId
171 ) throws SAXException, IOException { 171 ) throws SAXException, IOException {
251 InputStream inputStream, 251 InputStream inputStream,
252 Boolean namespaceAware 252 Boolean namespaceAware
253 ) { 253 ) {
254 return parseDocument( 254 return parseDocument(
255 inputStream, namespaceAware, CONF_RESOLVER); 255 inputStream, namespaceAware, CONF_RESOLVER);
256 }
257
258 public static final Document parseDocument(
259 File file,
260 Boolean namespaceAware,
261 EntityResolver entityResolver
262 ) {
263 InputStream inputStream = null;
264 try {
265 inputStream = new BufferedInputStream(new FileInputStream(file));
266 return parseDocument(inputStream, namespaceAware, entityResolver);
267 }
268 catch (IOException ioe) {
269 logger.error(ioe.getLocalizedMessage(), ioe);
270 }
271 finally {
272 if (inputStream != null) {
273 try { inputStream.close(); }
274 catch (IOException ioe) {}
275 }
276 }
277 return null;
256 } 278 }
257 279
258 public static final Document parseDocument( 280 public static final Document parseDocument(
259 InputStream inputStream, 281 InputStream inputStream,
260 Boolean namespaceAware, 282 Boolean namespaceAware,

http://dive4elements.wald.intevation.org