Jadex 0.96-beta1

jadex.util
Class Base64

java.lang.Object
  extended by jadex.util.Base64

public final class Base64
extends Object

Base64
Contains lots of utilities for coding and decoding text and character arrays fore and back to the Base64 encoding. It is quite the fastest that I know.

Since:
Sep 8, 2005
Version:
1.1
Author:
Walczak

Constructor Summary
Base64()
           
 
Method Summary
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[] 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 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
equals, 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

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.
Both src and dest may be the same provided (sstart<=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

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.
The sequence may look like:

ABCDABCD\r\nABCDABCD or even ABCDABCD#####ABCD###ABCD#ABCD.

The array must be multiple of 4 + number of CRLF or illegal characters and the line length may vary.

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

Jadex 0.96-beta1

Submit a bug or feature
For further API reference and developer documentation, see the Jadex User Guide and the Jadex Tutorial. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, and working code examples.

Copyright (C) 2002-2007 Lars Braubach, Alexander Pokahr - University of Hamburg. Use is subject to license terms.