You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@xml.apache.org by na...@apache.org on 2002/05/08 16:43:08 UTC

cvs commit: xml-soap/java/src/org/apache/soap/encoding/soapenc Base64.java

nagy        02/05/08 07:43:08

  Modified:    java/src/org/apache/soap/encoding/soapenc Base64.java
  Log:
  Fixed the documentation and code so that they match, and so that encode uses its len parameter correctly.
  For more info, see:
  http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4895
  Submitted by: Eric Hsiung (erich@bodymedia.com)
  Reviewed by: Bill Nagy (nagy@watson.ibm.com)
  
  Revision  Changes    Path
  1.2       +37 -7     xml-soap/java/src/org/apache/soap/encoding/soapenc/Base64.java
  
  Index: Base64.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/encoding/soapenc/Base64.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Base64.java	18 Aug 2000 16:27:29 -0000	1.1
  +++ Base64.java	8 May 2002 14:43:08 -0000	1.2
  @@ -70,7 +70,11 @@
       }
   
       /**
  -     *
  +     * Decode the base64 data.
  +     * @param data The base64 encoded data to be decoded
  +     * @param off The offset within the encoded data at which to start decoding
  +     * @param len The length of data to decode
  +     * @return The decoded data
        */
       public static byte[] decode(char[] data, int off, int len) {
           char[] ibuf = new char[4];
  @@ -96,7 +100,9 @@
       }
   
       /**
  -     *
  +     * Decode the base64 data.
  +     * @param data The base64 encoded data to be decoded
  +     * @return The decoded data
        */
       public static byte[] decode(String data) {
           char[] ibuf = new char[4];
  @@ -122,7 +128,12 @@
       }
   
       /**
  -     *
  +     * Decode the base64 data.
  +     * @param data The base64 encoded data to be decoded
  +     * @param off The offset within the encoded data at which to start decoding
  +     * @param len The length of data to decode
  +     * @param ostream The OutputStream to which the decoded data should be
  +     *                written
        */
       public static void decode(char[] data, int off, int len, OutputStream ostream) throws IOException {
           char[] ibuf = new char[4];
  @@ -143,7 +154,10 @@
       }
   
       /**
  -     *
  +     * Decode the base64 data.
  +     * @param data The base64 encoded data to be decoded
  +     * @param ostream The OutputStream to which the decoded data should be
  +     *                written
        */
       public static void decode(String data, OutputStream ostream) throws IOException {
           char[] ibuf = new char[4];
  @@ -165,6 +179,8 @@
   
       /**
        * Returns base64 representation of specified byte array.
  +     * @param data The data to be encoded
  +     * @return The base64 encoded data
        */
       public static String encode(byte[] data) {
           return encode(data, 0, data.length);
  @@ -172,13 +188,17 @@
   
       /**
        * Returns base64 representation of specified byte array.
  +     * @param data The data to be encoded
  +     * @param off The offset within the data at which to start encoding
  +     * @param len The length of the data to encode
  +     * @return The base64 encoded data
        */
       public static String encode(byte[] data, int off, int len) {
           if (len <= 0)  return "";
           char[] out = new char[len/3*4+4];
           int rindex = off;
           int windex = 0;
  -        int rest = len-off;
  +        int rest = len;
           while (rest >= 3) {
               int i = ((data[rindex]&0xff)<<16)
                   +((data[rindex+1]&0xff)<<8)
  @@ -208,12 +228,17 @@
   
       /**
        * Outputs base64 representation of the specified byte array to a byte stream.
  +     * @param data The data to be encoded
  +     * @param off The offset within the data at which to start encoding
  +     * @param len The length of the data to encode
  +     * @param ostream The OutputStream to which the encoded data should be
  +     *                written
        */
       public static void encode(byte[] data, int off, int len, OutputStream ostream) throws IOException {
           if (len <= 0)  return;
           byte[] out = new byte[4];
           int rindex = off;
  -        int rest = len-off;
  +        int rest = len;
           while (rest >= 3) {
               int i = ((data[rindex]&0xff)<<16)
                   +((data[rindex+1]&0xff)<<8)
  @@ -245,12 +270,17 @@
   
       /**
        * Outputs base64 representation of the specified byte array to a character stream.
  +     * @param data The data to be encoded
  +     * @param off The offset within the data at which to start encoding
  +     * @param len The length of the data to encode
  +     * @param writer The Writer to which the encoded data should be
  +     *               written
        */
       public static void encode(byte[] data, int off, int len, Writer writer) throws IOException {
           if (len <= 0)  return;
           char[] out = new char[4];
           int rindex = off;
  -        int rest = len-off;
  +        int rest = len;
           int output = 0;
           while (rest >= 3) {
               int i = ((data[rindex]&0xff)<<16)