cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r825241 - in /cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf: helpers/XMLUtils.java staxutils/FragmentStreamReader.java staxutils/StaxUtils.java
Date Wed, 14 Oct 2009 19:51:54 GMT
Author: dkulp
Date: Wed Oct 14 19:51:53 2009
New Revision: 825241

URL: http://svn.apache.org/viewvc?rev=825241&view=rev
Log:
Port some minor fixes

Modified:
    cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java
    cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/FragmentStreamReader.java
    cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java

Modified: cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java?rev=825241&r1=825240&r2=825241&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java
(original)
+++ cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/XMLUtils.java
Wed Oct 14 19:51:53 2009
@@ -25,6 +25,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.StringWriter;
 import java.io.Writer;
 import java.util.Collections;
 import java.util.List;
@@ -199,7 +200,7 @@
     }
 
     public static String toString(Source source, Properties props) throws TransformerException,
IOException {
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        StringWriter bos = new StringWriter();
         StreamResult sr = new StreamResult(bos);
         Transformer trans = newTransformer();
         if (props == null) {

Modified: cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/FragmentStreamReader.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/FragmentStreamReader.java?rev=825241&r1=825240&r2=825241&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/FragmentStreamReader.java
(original)
+++ cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/FragmentStreamReader.java
Wed Oct 14 19:51:53 2009
@@ -23,7 +23,7 @@
 import javax.xml.stream.XMLStreamReader;
 
 /**
- * Wraps a XMLStreamReader and provides START_DOCUMENT and END_DOCUMENT events.
+ * Wraps a XMLStreamReader and provides optional START_DOCUMENT and END_DOCUMENT events.
  * 
  * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
  */
@@ -32,6 +32,7 @@
     private boolean startElement;
     private boolean middle = true;
     private boolean endDoc;
+    private boolean doDocEvents = true;
 
     private int depth;
     private int current = -1;
@@ -41,6 +42,17 @@
     public FragmentStreamReader(XMLStreamReader reader) {
         super(reader);
     }    
+    public FragmentStreamReader(XMLStreamReader reader, boolean doDocEvents) {
+        super(reader);
+        this.doDocEvents = doDocEvents;
+        if (!doDocEvents) {
+            startDoc = true;
+            
+            depth = getDepth();
+            current = reader.getEventType();
+            startElement = true;
+        }
+    }    
    
     public int getEventType() {
         return current;
@@ -58,7 +70,7 @@
         return reader.hasNext();
     }
     
-    public int next() throws XMLStreamException {
+    public final int next() throws XMLStreamException {
         if (!startDoc) {
             startDoc = true;
             current = START_DOCUMENT;
@@ -82,6 +94,9 @@
 
             if (current == END_ELEMENT && getDepth() < depth) {
                 middle = false;
+                if (!doDocEvents) {
+                    endDoc = true;
+                }
             }
         } else if (!endDoc) {
             // Move past the END_ELEMENT token.

Modified: cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=825241&r1=825240&r2=825241&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
(original)
+++ cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
Wed Oct 14 19:51:53 2009
@@ -356,6 +356,7 @@
                     throw new XMLStreamException(e);
                 }
             }
+       
         }
         
         XMLStreamReader reader = createXMLStreamReader(source);
@@ -930,6 +931,13 @@
                 if (null != el) {
                     return new W3CDOMStreamReader(el);
                 }
+            } else if ("javax.xml.transform.stax.StAXSource".equals(source.getClass().getName()))
{
+                try {
+                    return (XMLStreamReader)source.getClass()
+                        .getMethod("getXMLStreamReader").invoke(source);
+                } catch (Exception ex) {
+                    //ignore
+                }
             }
             
             XMLInputFactory factory = getXMLInputFactory();



Mime
View raw message