You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2011/07/14 23:52:35 UTC

svn commit: r1146909 - /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java

Author: veithen
Date: Thu Jul 14 21:52:34 2011
New Revision: 1146909

URL: http://svn.apache.org/viewvc?rev=1146909&view=rev
Log:
AXIOM-353: Clarify how charset encodings are specified with the new OMXMLBuilderFactory API.

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java?rev=1146909&r1=1146908&r2=1146909&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMXMLBuilderFactory.java Thu Jul 14 21:52:34 2011
@@ -81,6 +81,21 @@ public class OMXMLBuilderFactory {
     
     /**
      * Create an object model builder that reads a plain XML document from the provided input stream
+     * with the default parser configuration defined by {@link StAXParserConfiguration#DEFAULT}.
+     * 
+     * @param in
+     *            the input stream representing the XML document
+     * @param encoding
+     *            the charset encoding of the XML document or <code>null</code> if the parser should
+     *            determine the charset encoding
+     * @return the builder
+     */
+    public static OMXMLParserWrapper createOMBuilder(InputStream in, String encoding) {
+        return createOMBuilder(StAXParserConfiguration.DEFAULT, in, encoding);
+    }
+    
+    /**
+     * Create an object model builder that reads a plain XML document from the provided input stream
      * with a given parser configuration.
      * 
      * @param configuration
@@ -90,8 +105,27 @@ public class OMXMLBuilderFactory {
      * @return the builder
      */
     public static OMXMLParserWrapper createOMBuilder(StAXParserConfiguration configuration, InputStream in) {
+        return createOMBuilder(configuration, in, null);
+    }
+    
+    /**
+     * Create an object model builder that reads a plain XML document from the provided input stream
+     * with a given parser configuration.
+     * 
+     * @param configuration
+     *            the parser configuration to use
+     * @param in
+     *            the input stream representing the XML document
+     * @param encoding
+     *            the charset encoding of the XML document or <code>null</code> if the parser should
+     *            determine the charset encoding
+     * @return the builder
+     */
+    public static OMXMLParserWrapper createOMBuilder(StAXParserConfiguration configuration, InputStream in, String encoding) {
         OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory();
-        return metaFactory.createOMBuilder(metaFactory.getOMFactory(), configuration, new InputSource(in));
+        InputSource is = new InputSource(in);
+        is.setEncoding(encoding);
+        return metaFactory.createOMBuilder(metaFactory.getOMFactory(), configuration, is);
     }
     
     /**
@@ -233,7 +267,8 @@ public class OMXMLBuilderFactory {
      * @param in
      *            the input stream containing the SOAP message
      * @param encoding
-     *            the charset encoding
+     *            the charset encoding of the SOAP message or <code>null</code> if the parser should
+     *            determine the charset encoding
      * @return the builder
      */
     public static SOAPModelBuilder createSOAPModelBuilder(InputStream in, String encoding) {