Class Base64Decoder

java.lang.Object
org.castor.core.util.Base64Decoder

public final class Base64Decoder extends Object
Class decodes a Base64 encoded string back into the original byte representation that can be read as byte array.
Since:
0.9.9
Version:
$Revision: 6907 $ $Date: 2005-08-05 13:58:36 -0600 (Fri, 05 Aug 2005) $
Author:
Ralf Joachim
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a default Base64Decoder waiting on calls to its translate() method.
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    Decode given string into a decoded byte array.
    byte[]
    Get all decoded octets as byte array.
    void
    translate(String string)
    Translate every base64 character from given string into a sextet byte value by using above translation array.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Base64Decoder

      public Base64Decoder()
      Construct a default Base64Decoder waiting on calls to its translate() method.
  • Method Details

    • decode

      public static byte[] decode(String str)
      Decode given string into a decoded byte array.
      Parameters:
      str - Base64 String to be decoded.
      Returns:
      All decoded octets as byte array.
    • translate

      public void translate(String string)
      Translate every base64 character from given string into a sextet byte value by using above translation array. The sextets are then shiftet into an buffer until the buffer contains 4 sextets which are then decoded into 3 octets. The translate and decode process is continued until all characters of given string are evaluated. If there are remaing sextets in the buffer they also will be converted into octets at the end. All the converted octets are added to the list for later read.
      Parameters:
      string - Base64 String to be decoded.
    • getByteArray

      public byte[] getByteArray()
      Get all decoded octets as byte array.
      Returns:
      All decoded octets as byte array.