Author: dims
Date: Fri Feb 23 09:27:14 2007
New Revision: 511026

URL: http://svn.apache.org/viewvc?view=rev&rev=511026
Log:
Fix for WSCOMMONS-123 - Improvements for OMTextImpl Methods getText(..) and 
getTextAsQName(..)

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

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/Base64.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/Base64.java?view=diff&rev=511026&r1=511025&r2=511026
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/Base64.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/Base64.java
 Fri Feb 23 09:27:14 2007
@@ -210,6 +210,46 @@
     }
 
     /**
+     * Outputs base64 representation of the specified byte array to the 
specified String Buffer
+     */
+    public static void encode(byte[] data, int off, int len, StringBuffer 
buffer) {
+        if (len <= 0) {
+            return;
+        }
+
+        char[] out = new char[4];
+        int rindex = off;
+        int rest = len - off;
+        while (rest >= 3) {
+            int i = ((data[rindex] & 0xff) << 16)
+                    + ((data[rindex + 1] & 0xff) << 8)
+                    + (data[rindex + 2] & 0xff);
+            out[0] = S_BASE64CHAR[i >> 18];
+            out[1] = S_BASE64CHAR[(i >> 12) & 0x3f];
+            out[2] = S_BASE64CHAR[(i >> 6) & 0x3f];
+            out[3] = S_BASE64CHAR[i & 0x3f];
+            buffer.append(out);
+            rindex += 3;
+            rest -= 3;
+        }
+        if (rest == 1) {
+            int i = data[rindex] & 0xff;
+            out[0] = S_BASE64CHAR[i >> 2];
+            out[1] = S_BASE64CHAR[(i << 4) & 0x3f];
+            out[2] = S_BASE64PAD;
+            out[3] = S_BASE64PAD;
+            buffer.append(out);
+        } else if (rest == 2) {
+            int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
+            out[0] = S_BASE64CHAR[i >> 10];
+            out[1] = S_BASE64CHAR[(i >> 4) & 0x3f];
+            out[2] = S_BASE64CHAR[(i << 2) & 0x3f];
+            out[3] = S_BASE64PAD;
+            buffer.append(out);
+        }
+    }
+
+    /**
      * Outputs base64 representation of the specified byte array to a byte
      * stream.
      */

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/TextHelper.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/TextHelper.java?view=diff&rev=511026&r1=511025&r2=511026
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/TextHelper.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/TextHelper.java
 Fri Feb 23 09:27:14 2007
@@ -28,7 +28,7 @@
             data = new byte[1023];
             int len;
             while ((len = inStream.read(data)) > 0) {
-                text.append(Base64.encode(data, 0, len));
+                Base64.encode(data, 0, len, text);
             }
         } while (inStream.available() > 0);
         return text.toString();



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to