[Dive4elements-commits] [PATCH] Add toString to httpclients XMLUtils
Wald Commits
scm-commit at wald.intevation.org
Fri May 31 15:17:33 CEST 2013
# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1370006200 -7200
# Node ID 21a7efe056b408b10876419c8c1f79cf42781082
# Parent e4a595d53a52c2033c7bf8b5a95bed49cd2f497c
Add toString to httpclients XMLUtils
Useful for debugging in the GWT Client
diff -r e4a595d53a52 -r 21a7efe056b4 src/main/java/org/dive4elements/artifacts/httpclient/utils/XMLUtils.java
--- a/src/main/java/org/dive4elements/artifacts/httpclient/utils/XMLUtils.java Tue May 28 16:01:41 2013 +0200
+++ b/src/main/java/org/dive4elements/artifacts/httpclient/utils/XMLUtils.java Fri May 31 15:16:40 2013 +0200
@@ -11,6 +11,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.StringWriter;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
@@ -316,5 +317,29 @@
}
return false;
}
+
+ public static String toString(Document document) {
+ try {
+ Transformer transformer =
+ TransformerFactory.newInstance().newTransformer();
+ DOMSource source = new DOMSource(document);
+ StringWriter out = new StringWriter();
+ StreamResult result = new StreamResult(out);
+ transformer.transform(source, result);
+ out.flush();
+ return out.toString();
+ }
+ catch (TransformerConfigurationException tce) {
+ logger.error(tce.getLocalizedMessage(), tce);
+ }
+ catch (TransformerFactoryConfigurationError tfce) {
+ logger.error(tfce.getLocalizedMessage(), tfce);
+ }
+ catch (TransformerException te) {
+ logger.error(te.getLocalizedMessage(), te);
+ }
+
+ return null;
+ }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
More information about the Dive4elements-commits
mailing list