cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r749767 - /cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/Base64Type.java
Date Tue, 03 Mar 2009 21:39:30 GMT
Author: dkulp
Date: Tue Mar  3 21:39:29 2009
New Revision: 749767

URL: http://svn.apache.org/viewvc?rev=749767&view=rev
Log:
Fix aegis base64 types with different stax impls

Modified:
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/Base64Type.java

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/Base64Type.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/Base64Type.java?rev=749767&r1=749766&r2=749767&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/Base64Type.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/Base64Type.java
Tue Mar  3 21:39:29 2009
@@ -19,6 +19,8 @@
 package org.apache.cxf.aegis.type.basic;
 
 import java.io.ByteArrayOutputStream;
+import java.io.CharArrayWriter;
+import java.io.IOException;
 
 import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
@@ -80,20 +82,14 @@
                 return new byte[0];
             }
 
-            int length = reader.getTextLength();
-
-            char[] myBuffer = new char[length];
-            for (int sourceStart = 0;; sourceStart += length) {
-                int nCopied = reader.getTextCharacters(sourceStart, myBuffer, 0, length);
-
-                if (nCopied > 0) {
-                    Base64Utility.decode(myBuffer, 0, nCopied, bos);
-                }
-
-                if (nCopied < length) {
-                    break;
-                }
+            CharArrayWriter writer = new CharArrayWriter(2048);
+            while (reader.isCharacters()) {
+                writer.write(reader.getTextCharacters(),
+                             reader.getTextStart(),
+                             reader.getTextLength());
+                reader.next();
             }
+            Base64Utility.decode(writer.toCharArray(), 0, writer.size(), bos);
 
             while (reader.getEventType() != XMLStreamConstants.END_ELEMENT) {
                 reader.next();



Mime
View raw message