Author: richard.opalka(a)jboss.com
Date: 2010-02-18 09:04:50 -0500 (Thu, 18 Feb 2010)
New Revision: 11610
Modified:
common/trunk/src/main/java/org/jboss/wsf/common/DOMUtils.java
common/trunk/src/main/java/org/jboss/wsf/test/JBossWSTest.java
Log:
refactoring helper methods from JBossWSTest to DOMUtils
Modified: common/trunk/src/main/java/org/jboss/wsf/common/DOMUtils.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/DOMUtils.java 2010-02-18 13:43:49 UTC
(rev 11609)
+++ common/trunk/src/main/java/org/jboss/wsf/common/DOMUtils.java 2010-02-18 14:04:50 UTC
(rev 11610)
@@ -25,7 +25,9 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.PrintWriter;
import java.io.Reader;
+import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
@@ -820,4 +822,46 @@
return retElement;
}
+
+ /**
+ * Converts XML node in pretty mode using UTF-8 encoding to string.
+ *
+ * @param node XML document or element
+ * @return XML string
+ * @throws Exception if some error occurs
+ */
+ public static String node2String(final Node node) throws UnsupportedEncodingException
+ {
+ return node2String(node, true, Constants.DEFAULT_XML_CHARSET);
+ }
+
+ /**
+ * Converts XML node in specified pretty mode using UTF-8 encoding to string.
+ *
+ * @param node XML document or element
+ * @param prettyPrint whether XML have to be pretty formated
+ * @return XML string
+ * @throws Exception if some error occurs
+ */
+ public static String node2String(final Node node, boolean prettyPrint) throws
UnsupportedEncodingException
+ {
+ return node2String(node, prettyPrint, Constants.DEFAULT_XML_CHARSET);
+ }
+
+ /**
+ * Converts XML node in specified pretty mode and encoding to string.
+ *
+ * @param node XML document or element
+ * @param prettyPrint whether XML have to be pretty formated
+ * @param encoding to use
+ * @return XML string
+ * @throws UnsupportedEncodingException
+ */
+ public static String node2String(final Node node, boolean prettyPrint, String
encoding) throws UnsupportedEncodingException
+ {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ new DOMWriter(new PrintWriter(baos),
encoding).setPrettyprint(prettyPrint).print(node);
+ return baos.toString(encoding);
+ }
+
}
Modified: common/trunk/src/main/java/org/jboss/wsf/test/JBossWSTest.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/test/JBossWSTest.java 2010-02-18 13:43:49 UTC
(rev 11609)
+++ common/trunk/src/main/java/org/jboss/wsf/test/JBossWSTest.java 2010-02-18 14:04:50 UTC
(rev 11610)
@@ -21,11 +21,9 @@
*/
package org.jboss.wsf.test;
-import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
-import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -45,7 +43,6 @@
import junit.framework.TestCase;
import org.jboss.logging.Logger;
-import org.jboss.ws.Constants;
import org.jboss.wsf.common.DOMWriter;
import org.jboss.wsf.common.concurrent.CopyJob;
import org.w3c.dom.Element;
@@ -73,47 +70,6 @@
}
/**
- * Prints XML in pretty mode in UTF-8 encoding.
- *
- * @param node XML document or element
- * @return XML string
- * @throws Exception if some error occurs
- */
- public static String getXML(final Node node) throws Exception
- {
- return getXML(node, true, Constants.DEFAULT_XML_CHARSET);
- }
-
- /**
- * Prints XML in specified pretty mode in UTF-8 encoding.
- *
- * @param node XML document or element
- * @param prettyPrint whether XML have to be pretty formated
- * @return XML string
- * @throws Exception if some error occurs
- */
- public static String getXML(final Node node, boolean prettyPrint) throws Exception
- {
- return getXML(node, prettyPrint, Constants.DEFAULT_XML_CHARSET);
- }
-
- /**
- * Prints XML in specified encoding and pretty mode.
- *
- * @param node XML document or element
- * @param prettyPrint whether XML have to be pretty formated
- * @param encoding to use
- * @return XML string
- * @throws Exception if some error occurs
- */
- public static String getXML(final Node node, boolean prettyPrint, String encoding)
throws Exception
- {
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- new DOMWriter(new PrintWriter(baos),
encoding).setPrettyprint(prettyPrint).print(node);
- return baos.toString(encoding);
- }
-
- /**
* Execute <b>command</b> in separate process.
* @param command command to execute
* @throws IOException if I/O error occurs
Show replies by date