MXQuery 0.6.0 API Documentation - Copyright 2006-2009 ETH Zurich

ch.ethz.mxquery.util
Class Base64

java.lang.Object
  extended by ch.ethz.mxquery.util.Base64

public class Base64
extends java.lang.Object

Encodes and decodes to and from Base64 notation.

Homepage: http://iharder.net/base64.

I am placing this code in the Public Domain. Do with it as you will. This software comes with no guarantees or warranties but with plenty of well-wishing instead! Please visit http://iharder.net/base64 periodically to check for updates or to contribute improvements.

Version:
2.2.1 modified for MXQuery by Rokas Tamosevicius

Field Summary
static int DONT_BREAK_LINES
          Don't break lines when encoding (violates strict Base64 specification)
 
Method Summary
static byte[] decode(byte[] source, int off, int len)
          Very low-level access to decoding ASCII characters in the form of a byte array.
static byte[] decode(java.lang.String s)
          Decodes data from Base64 notation
static java.lang.String encodeBytes(byte[] source)
          Encodes a byte array into Base64 notation.
static java.lang.String encodeBytes(byte[] source, int off, int len)
          Encodes a byte array into Base64 notation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DONT_BREAK_LINES

public static final int DONT_BREAK_LINES
Don't break lines when encoding (violates strict Base64 specification)

See Also:
Constant Field Values
Method Detail

encodeBytes

public static java.lang.String encodeBytes(byte[] source)
Encodes a byte array into Base64 notation.

Parameters:
source - The data to convert
Since:
1.4

encodeBytes

public static java.lang.String encodeBytes(byte[] source,
                                           int off,
                                           int len)
Encodes a byte array into Base64 notation.

Valid options:

   DONT_BREAK_LINES: don't break lines at 76 characters
     Note: Technically, this makes your encoding non-compliant.
 

Example: encodeBytes( myData, Base64.GZIP ) or

Example: encodeBytes( myData, Base64.GZIP | Base64.DONT_BREAK_LINES )

Parameters:
source - The data to convert
off - Offset in array where conversion should begin
len - Length of data to convert
Returns:
the encoded content as string
Since:
2.0

decode

public static byte[] decode(byte[] source,
                            int off,
                            int len)
                     throws MXQueryException
Very low-level access to decoding ASCII characters in the form of a byte array.

Parameters:
source - The Base64 encoded data
off - The offset of where to begin decoding
len - The length of characters to decode
Returns:
decoded data
Throws:
MXQueryException
Since:
1.3

decode

public static byte[] decode(java.lang.String s)
                     throws MXQueryException
Decodes data from Base64 notation

Parameters:
s - the string to decode
Returns:
the decoded data
Throws:
MXQueryException
Since:
1.4

MXQuery 0.6.0 API Documentation - Copyright 2006-2009 ETH Zurich

MXQuery 0.6.0 API Documentation - Copyright 2006-2009 ETH Zurich