Class Base64Encoder

java.lang.Object
org.simpleframework.common.encode.Base64Encoder

public class Base64Encoder extends Object
The Base64Encoder is used to encode and decode base64 content. The implementation used here provides a reasonably fast memory efficient encoder for use with input and output streams. It is possible to achieve higher performance, however, ease of use and convenience are the priorities with this implementation. This can only decode complete blocks.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final char[]
    This contains the base64 alphabet used for encoding.
    private static final int[]
    This maintains reference data used to fast decoding.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    decode(char[] text)
    This is used to decode the provide base64 data back in to an array of binary data.
    static byte[]
    decode(char[] text, int off, int len)
    This is used to decode the provide base64 data back in to an array of binary data.
    static char[]
    encode(byte[] buf)
    This method is used to encode the specified byte array of binary data in to base64 data.
    static char[]
    encode(byte[] buf, int off, int len)
    This method is used to encode the specified byte array of binary data in to base64 data.

    Methods inherited from class java.lang.Object

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

    • REFERENCE

      private static final int[] REFERENCE
      This maintains reference data used to fast decoding.
    • ALPHABET

      private static final char[] ALPHABET
      This contains the base64 alphabet used for encoding.
  • Constructor Details

    • Base64Encoder

      public Base64Encoder()
  • Method Details

    • encode

      public static char[] encode(byte[] buf)
      This method is used to encode the specified byte array of binary data in to base64 data. The block is complete and must be decoded as a complete block.
      Parameters:
      buf - this is the binary data to be encoded
      Returns:
      this is the base64 encoded value of the data
    • encode

      public static char[] encode(byte[] buf, int off, int len)
      This method is used to encode the specified byte array of binary data in to base64 data. The block is complete and must be decoded as a complete block.
      Parameters:
      buf - this is the binary data to be encoded
      off - this is the offset to read the binary data from
      len - this is the length of data to encode from the array
      Returns:
      this is the base64 encoded value of the data
    • decode

      public static byte[] decode(char[] text)
      This is used to decode the provide base64 data back in to an array of binary data. The data provided here must be a full block of base 64 data in order to be decoded.
      Parameters:
      text - this is the base64 text to be decoded
      Returns:
      this returns the resulting byte array
    • decode

      public static byte[] decode(char[] text, int off, int len)
      This is used to decode the provide base64 data back in to an array of binary data. The data provided here must be a full block of base 64 data in order to be decoded.
      Parameters:
      text - this is the base64 text to be decoded
      off - this is the offset to read the text data from
      len - this is the length of data to decode from the text
      Returns:
      this returns the resulting byte array