Package jadex.commons

Class Base64


  • public final class Base64
    extends java.lang.Object
    Base64
    • Constructor Summary

      Constructors 
      Constructor Description
      Base64()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] decode​(byte[] code)
      This is a wrapper to decode(final byte[] code, final int from, final int len)
      static byte[] decode​(byte[] src, int from, int len)
      a copy of the char part
      static byte[] decode​(char[] code)
      This is a wrapper to decode(final char[] code, final int from, final int len)
      static byte[] decode​(char[] code, int from, int len)
      This will decode base64 data without line feeds.
      static byte[] decode76​(char[] code)
      decodeCRLF(code, 0, code.length, 76)
      static byte[] decodeCRLF​(char[] code, int from, int len)
      This will decode base64 data with CRLF at 4 character boundary.
      static byte[] decodeCRLF​(char[] code, int from, int len, int llen)
      This will decode base64 data.
      static byte[] decodeFailSafe​(char[] code)  
      static byte[] decodeFailSafe​(char[] code, int from, int len)
      This removes all bad characters from the char array.
      static byte[] decodeNoPadding​(byte[] code)
      Decode without padding.
      static byte[] encode​(byte[] text)  
      static byte[] encode​(byte[] text, int llen)
      This will encode the text.
      static byte[] encode​(byte[] text, int from, int len)
      This will encode the text without line feeds added
      static int encode​(byte[] src, int sstart, int len, byte[] dest, int dstart)
      This will encode the text without line feeds added.
      static byte[] encodeNoPadding​(byte[] text)
      Encode and omit padding.
      static char[] toCharArray​(byte[] text)
      This is a wrapper to toCharArray(final byte[] text, final int from, final int len)
      static char[] toCharArray​(byte[] text, int llen)
      This will encode the text.
      static char[] toCharArray​(byte[] text, int from, int len)
      This will encode the text without line feeds added
      • Methods inherited from class java.lang.Object

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

      • Base64

        public Base64()
    • Method Detail

      • toCharArray

        public static final char[] toCharArray​(byte[] text)
        This is a wrapper to toCharArray(final byte[] text, final int from, final int len)
        Parameters:
        text -
        Returns:
        an encoded char array from the text
      • toCharArray

        public static final char[] toCharArray​(byte[] text,
                                               int from,
                                               int len)
        This will encode the text without line feeds added
        Parameters:
        text -
        from - where to start
        len - how long is the byte array
        Returns:
        an encoded char array from the text
      • encodeNoPadding

        public static final byte[] encodeNoPadding​(byte[] text)
        Encode and omit padding.
        Parameters:
        text -
        Returns:
        encoded text
      • encode

        public static final byte[] encode​(byte[] text)
        Parameters:
        text -
        Returns:
        encoded text
      • encode

        public static final byte[] encode​(byte[] text,
                                          int from,
                                          int len)
        This will encode the text without line feeds added
        Parameters:
        text -
        from - where to start
        len - how long is the byte array
        Returns:
        an encoded byte array from the text
      • encode

        public static final int encode​(byte[] src,
                                       int sstart,
                                       int len,
                                       byte[] dest,
                                       int dstart)
        This will encode the text without line feeds added. It will write all output to the dest buffer begining from dstart.
        Parameters:
        src -
        sstart - where to start
        len - how long is the byte array
        dest -
        dstart -
        Returns:
        index to the buffer byte ofter the text
      • toCharArray

        public static final char[] toCharArray​(byte[] text,
                                               int llen)
        This will encode the text. The CRLF comes after lb characters.
        Parameters:
        text -
        llen - the length of line (without CRLF) must be a multiple of 4
        Returns:
        an encoded char array from the text
      • encode

        public static final byte[] encode​(byte[] text,
                                          int llen)
        This will encode the text. The CRLF comes after lb characters.
        Parameters:
        text -
        llen - the length of line (without CRLF) must be a multiple of 4
        Returns:
        an encoded byte array from the text
      • decode

        public static final byte[] decode​(char[] code)
        This is a wrapper to decode(final char[] code, final int from, final int len)
        Parameters:
        code -
        Returns:
        a byte array holding encoded char data
      • decode

        public static final byte[] decode​(char[] code,
                                          int from,
                                          int len)
        This will decode base64 data without line feeds. The char array should be multiple of 4 in length.
        Parameters:
        code -
        from - start position in code
        len - length of the part
        Returns:
        the decoded sequence of text
      • decodeNoPadding

        public static final byte[] decodeNoPadding​(byte[] code)
        Decode without padding.
        Parameters:
        code -
        Returns:
        a byte array holding encoded char data
      • decode

        public static final byte[] decode​(byte[] code)
        This is a wrapper to decode(final byte[] code, final int from, final int len)
        Parameters:
        code -
        Returns:
        a byte array holding encoded char data
      • decode

        public static final byte[] decode​(byte[] src,
                                          int from,
                                          int len)
        a copy of the char part
        Parameters:
        src -
        from -
        len -
        Returns:
        decoded byte array
      • decode76

        public static final byte[] decode76​(char[] code)
        decodeCRLF(code, 0, code.length, 76)
        Parameters:
        code -
        Returns:
        the encoded text;
      • decodeCRLF

        public static final byte[] decodeCRLF​(char[] code,
                                              int from,
                                              int len,
                                              int llen)
        This will decode base64 data. The starting point and length must be accurate. The data must end on a multiple of 4 boundary and must include the '=' padding, if any.
        Parameters:
        code -
        from -
        len - the length of data
        llen - the line length of this base64 (without CRLF)
        Returns:
        the decoded sequence of text
      • decodeCRLF

        public static final byte[] decodeCRLF​(char[] code,
                                              int from,
                                              int len)
        This will decode base64 data with CRLF at 4 character boundary.
        Parameters:
        code -
        from -
        len -
        Returns:
        the decoded sequence of text
      • decodeFailSafe

        public static final byte[] decodeFailSafe​(char[] code)
        Parameters:
        code -
        Returns:
        the decoded array
      • decodeFailSafe

        public static final byte[] decodeFailSafe​(char[] code,
                                                  int from,
                                                  int len)
        This removes all bad characters from the char array. It modifies the array in the scope of the process !!! Than simply calls decode;
        Parameters:
        code -
        from -
        len -
        Returns:
        decoded text