Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

org.apache.commons.codec.binary.Base64 Class Reference

Inheritance diagram for org.apache.commons.codec.binary.Base64:

org.apache.commons.codec.BinaryEncoder org.apache.commons.codec.BinaryDecoder org.apache.commons.codec.Encoder org.apache.commons.codec.Decoder List of all members.

Detailed Description

Provides Base64 encoding and decoding as defined by RFC 2045.

This class implements section <cite>6.8. Base64 Content-Transfer-Encoding</cite> from RFC 2045 <cite>Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies</cite> by Freed and Borenstein.

See also:
RFC 2045
Author:
Apache Software Foundation
Since:
1.0-dev
Version:
Id
Base64.java,v 1.1 2005/07/25 16:24:38 dev Exp

Definition at line 36 of file Base64.java.

Public Member Functions

Object decode (Object pObject) throws DecoderException
 Decodes an Object using the base64 algorithm.
byte[] decode (byte[] pArray)
 Decodes a byte[] containing containing characters in the Base64 alphabet.
Object encode (Object pObject) throws EncoderException
 Encodes an Object using the base64 algorithm.
byte[] encode (byte[] pArray)
 Encodes a byte[] containing binary data, into a byte[] containing characters in the Base64 alphabet.

Static Public Member Functions

static boolean isArrayByteBase64 (byte[] arrayOctect)
 Tests a given byte array to see if it contains only valid characters within the Base64 alphabet.
static byte[] encodeBase64 (byte[] binaryData)
 Encodes binary data using the base64 algorithm but does not chunk the output.
static byte[] encodeBase64Chunked (byte[] binaryData)
 Encodes binary data using the base64 algorithm and chunks the encoded output into 76 character blocks.
static byte[] encodeBase64 (byte[] binaryData, boolean isChunked)
 Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks.
static byte[] decodeBase64 (byte[] base64Data)
 Decodes Base64 data into octects.

Static Package Functions

static byte[] discardWhitespace (byte[] data)
 Discards any whitespace from a base-64 encoded block.
static byte[] discardNonBase64 (byte[] data)
 Discards any characters outside of the base64 alphabet, per the requirements on page 25 of RFC 2045 - "Any characters outside of the base64 alphabet are to be ignored in base64 encoded data.

Static Package Attributes

static final int CHUNK_SIZE = 76
 Chunk size per RFC 2045 section 6.8.
static final byte[] CHUNK_SEPARATOR = "\r\n".getBytes()
 Chunk separator per RFC 2045 section 2.1.
static final int BASELENGTH = 255
 The base length.
static final int LOOKUPLENGTH = 64
 Lookup length.
static final int EIGHTBIT = 8
 Used to calculate the number of bits in a byte.
static final int SIXTEENBIT = 16
 Used when encoding something which has fewer than 24 bits.
static final int TWENTYFOURBITGROUP = 24
 Used to determine how many bits data contains.
static final int FOURBYTE = 4
 Used to get the number of Quadruples.
static final int SIGN = -128
 Used to test the sign of a byte.
static final byte PAD = (byte) '='
 Byte used to pad output.


Member Function Documentation

byte [] org.apache.commons.codec.binary.Base64.decode byte[]  pArray  ) 
 

Decodes a byte[] containing containing characters in the Base64 alphabet.

Parameters:
pArray A byte array containing Base64 character data
Returns:
a byte array containing binary data

Implements org.apache.commons.codec.BinaryDecoder.

Definition at line 219 of file Base64.java.

References org.apache.commons.codec.binary.Base64.decodeBase64().

Object org.apache.commons.codec.binary.Base64.decode Object  pObject  )  throws DecoderException
 

Decodes an Object using the base64 algorithm.

This method is provided in order to satisfy the requirements of the Decoder interface, and will throw a DecoderException if the supplied object is not of type byte[].

Parameters:
pObject Object to decode
Returns:
An object (of type byte[]) containing the binary data which corresponds to the byte[] supplied.
Exceptions:
DecoderException if the parameter supplied is not of type byte[]

Implements org.apache.commons.codec.Decoder.

Definition at line 205 of file Base64.java.

static byte [] org.apache.commons.codec.binary.Base64.decodeBase64 byte[]  base64Data  )  [static]
 

Decodes Base64 data into octects.

Parameters:
base64Data Byte array containing Base64 data
Returns:
Array containing decoded data.

Definition at line 372 of file Base64.java.

References org.apache.commons.codec.binary.Base64.discardNonBase64(), org.apache.commons.codec.binary.Base64.FOURBYTE, and org.apache.commons.codec.binary.Base64.PAD.

Referenced by org.apache.commons.codec.binary.Base64.decode().

static byte [] org.apache.commons.codec.binary.Base64.discardNonBase64 byte[]  data  )  [static, package]
 

Discards any characters outside of the base64 alphabet, per the requirements on page 25 of RFC 2045 - "Any characters outside of the base64 alphabet are to be ignored in base64 encoded data.

"

Parameters:
data The base-64 encoded data to groom
Returns:
The data, less non-base64 characters (see RFC 2045).

Definition at line 473 of file Base64.java.

Referenced by org.apache.commons.codec.binary.Base64.decodeBase64().

static byte [] org.apache.commons.codec.binary.Base64.discardWhitespace byte[]  data  )  [static, package]
 

Discards any whitespace from a base-64 encoded block.

Parameters:
data The base-64 encoded data to discard the whitespace from.
Returns:
The data, less whitespace (see RFC 2045).

Definition at line 441 of file Base64.java.

Referenced by org.apache.commons.codec.binary.Base64.isArrayByteBase64().

byte [] org.apache.commons.codec.binary.Base64.encode byte[]  pArray  ) 
 

Encodes a byte[] containing binary data, into a byte[] containing characters in the Base64 alphabet.

Parameters:
pArray a byte array containing binary data
Returns:
A byte array containing only Base64 character data

Implements org.apache.commons.codec.BinaryEncoder.

Definition at line 520 of file Base64.java.

References org.apache.commons.codec.binary.Base64.encodeBase64().

Object org.apache.commons.codec.binary.Base64.encode Object  pObject  )  throws EncoderException
 

Encodes an Object using the base64 algorithm.

This method is provided in order to satisfy the requirements of the Encoder interface, and will throw an EncoderException if the supplied object is not of type byte[].

Parameters:
pObject Object to encode
Returns:
An object (of type byte[]) containing the base64 encoded data which corresponds to the byte[] supplied.
Exceptions:
EncoderException if the parameter supplied is not of type byte[]

Implements org.apache.commons.codec.Encoder.

Definition at line 505 of file Base64.java.

static byte [] org.apache.commons.codec.binary.Base64.encodeBase64 byte[]  binaryData,
boolean  isChunked
[static]
 

Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks.

Parameters:
binaryData Array containing binary data to encode.
isChunked if isChunked is true this encoder will chunk the base64 output into 76 character blocks
Returns:
Base64-encoded data.

Definition at line 232 of file Base64.java.

References org.apache.commons.codec.binary.Base64.CHUNK_SEPARATOR, org.apache.commons.codec.binary.Base64.CHUNK_SIZE, org.apache.commons.codec.binary.Base64.EIGHTBIT, org.apache.commons.codec.binary.Base64.PAD, org.apache.commons.codec.binary.Base64.SIGN, org.apache.commons.codec.binary.Base64.SIXTEENBIT, and org.apache.commons.codec.binary.Base64.TWENTYFOURBITGROUP.

static byte [] org.apache.commons.codec.binary.Base64.encodeBase64 byte[]  binaryData  )  [static]
 

Encodes binary data using the base64 algorithm but does not chunk the output.

Parameters:
binaryData binary data to encode
Returns:
Base64 characters

Definition at line 177 of file Base64.java.

Referenced by org.apache.commons.codec.binary.Base64.encode(), and org.apache.commons.codec.binary.Base64.encodeBase64Chunked().

static byte [] org.apache.commons.codec.binary.Base64.encodeBase64Chunked byte[]  binaryData  )  [static]
 

Encodes binary data using the base64 algorithm and chunks the encoded output into 76 character blocks.

Parameters:
binaryData binary data to encode
Returns:
Base64 characters chunked in 76 character blocks

Definition at line 188 of file Base64.java.

References org.apache.commons.codec.binary.Base64.encodeBase64().

static boolean org.apache.commons.codec.binary.Base64.isArrayByteBase64 byte[]  arrayOctect  )  [static]
 

Tests a given byte array to see if it contains only valid characters within the Base64 alphabet.

Parameters:
arrayOctect byte array to test
Returns:
true if all bytes are valid characters in the Base64 alphabet or if the byte array is empty; false, otherwise

Definition at line 152 of file Base64.java.

References org.apache.commons.codec.binary.Base64.discardWhitespace().


Member Data Documentation

final byte [] org.apache.commons.codec.binary.Base64.CHUNK_SEPARATOR = "\r\n".getBytes() [static, package]
 

Chunk separator per RFC 2045 section 2.1.

See also:
RFC 2045 section 2.1

Definition at line 53 of file Base64.java.

Referenced by org.apache.commons.codec.binary.Base64.encodeBase64().

final int org.apache.commons.codec.binary.Base64.CHUNK_SIZE = 76 [static, package]
 

Chunk size per RFC 2045 section 6.8.

The {} character limit does not count the trailing CRLF, but counts all other characters, including any equal signs.

See also:
RFC 2045 section 6.8

Definition at line 46 of file Base64.java.

Referenced by org.apache.commons.codec.binary.Base64.encodeBase64().


The documentation for this class was generated from the following file:
Generated on Wed Dec 14 21:05:37 2005 for OpenMobileIS by  doxygen 1.4.4