Mercurial > dive4elements > framework
comparison artifacts-common/src/main/java/de/intevation/artifacts/common/utils/XMLUtils.java @ 135:a48882c9e096
Added a convinience method to transform an document into a byte array.
artifacts/trunk@1360 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 02 Mar 2011 10:30:27 +0000 |
parents | 1282cf96d3eb |
children | 9a64e0c1c737 |
comparison
equal
deleted
inserted
replaced
134:19267b9960c3 | 135:a48882c9e096 |
---|---|
6 * or visit http://www.gnu.org/licenses/ if it does not exist. | 6 * or visit http://www.gnu.org/licenses/ if it does not exist. |
7 */ | 7 */ |
8 | 8 |
9 package de.intevation.artifacts.common.utils; | 9 package de.intevation.artifacts.common.utils; |
10 | 10 |
11 import java.io.ByteArrayOutputStream; | |
11 import java.io.File; | 12 import java.io.File; |
12 import java.io.IOException; | 13 import java.io.IOException; |
13 import java.io.OutputStream; | 14 import java.io.OutputStream; |
14 | 15 |
15 import javax.xml.namespace.NamespaceContext; | 16 import javax.xml.namespace.NamespaceContext; |
305 logger.error(te.getLocalizedMessage(), te); | 306 logger.error(te.getLocalizedMessage(), te); |
306 } | 307 } |
307 | 308 |
308 return false; | 309 return false; |
309 } | 310 } |
311 | |
312 /** | |
313 * Transforms an XML document into a byte array. | |
314 * @param document The document to be streamed out. | |
315 * @return the byte array or null if operation failed or | |
316 * document is null. | |
317 */ | |
318 public static byte [] toByteArray(Document document) { | |
319 if (document == null) { | |
320 return null; | |
321 } | |
322 ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |
323 return toStream(document, baos) | |
324 ? baos.toByteArray() | |
325 : null; | |
326 } | |
310 } | 327 } |
311 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 328 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |