org.apache.commons.codec.binary
Class Base64

java.lang.Object
  |
  +--org.apache.commons.codec.binary.Base64
All Implemented Interfaces:
BinaryDecoder, BinaryEncoder, Decoder, Encoder

public class Base64
extends java.lang.Object
implements BinaryEncoder, BinaryDecoder

This class provides encode/decode for RFC 2045 Base64 as defined by RFC 2045, N. Freed and N. Borenstein. RFC 2045: Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies. Reference 1996

Since:
1.0-dev
Author:
Jeffrey Rodriguez, Daniel Rall, Martin Redington

Constructor Summary
Base64()
           
 
Method Summary
 byte[] decode(byte[] pArray)
          Decode a byte array and return the results of the decode as a byte array.
 java.lang.Object decode(java.lang.Object pObject)
          Decode an "encoded" Object and return a "decoded" Object.
static byte[] decodeBase64(byte[] base64Data)
          Decodes Base64 data into octects
 byte[] encode(byte[] pArray)
          Encode a byte array and return the encoded data as a byte array.
 java.lang.Object encode(java.lang.Object pObject)
          encode an Object
static byte[] encodeBase64(byte[] binaryData)
           
static byte[] encodeBase64(byte[] binaryData, boolean isChunked)
          Encodes hex octects into Base64.
static byte[] encodeBase64Chunked(byte[] binaryData)
           
static boolean isArrayByteBase64(byte[] arrayOctect)
           
 
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

isArrayByteBase64

public static boolean isArrayByteBase64(byte[] arrayOctect)

encodeBase64

public static byte[] encodeBase64(byte[] binaryData)

encodeBase64Chunked

public static byte[] encodeBase64Chunked(byte[] binaryData)

decode

public java.lang.Object decode(java.lang.Object pObject)
                        throws DecoderException
Description copied from interface: Decoder
Decode an "encoded" Object and return a "decoded" Object. Note that the implementation of this interface will try to cast the Object parameter to the specific type expected by a particular Decoder implementation. If a ClassCastException occurs this decode method will throw a DecoderException.

Specified by:
decode in interface Decoder
Parameters:
pObject - an object to "decode"
Returns:
a 'decoded" object
Throws:
DecoderException - a decoder exception can be thrown for any number of reasons. Some good candidates are that the parameter passed to this method is null, a param cannot be cast to the appropriate type for a specific encoder.

decode

public byte[] decode(byte[] pArray)
              throws DecoderException
Description copied from interface: BinaryDecoder
Decode a byte array and return the results of the decode as a byte array.

Specified by:
decode in interface BinaryDecoder
Parameters:
pArray - A byte array which has been encoded with the appropriate encoder
Returns:
a byte array that contains decoded content
Throws:
DecoderException - A decoder exception is thrown if a Decoder encounters a failure condition during the decode process.

encodeBase64

public static byte[] encodeBase64(byte[] binaryData,
                                  boolean isChunked)
Encodes hex octects into Base64.

Parameters:
binaryData - Array containing binary data to encode.
Returns:
Base64-encoded data.

decodeBase64

public static byte[] decodeBase64(byte[] base64Data)
Decodes Base64 data into octects

Returns:
Array containing decoded data.

encode

public java.lang.Object encode(java.lang.Object pObject)
                        throws EncoderException
encode an Object

Specified by:
encode in interface Encoder
Parameters:
pObject - An object ot encode
Returns:
An "encoded" Object
Throws:
EncoderException - an encoder exception is thrown if the encoder experiences a failure condition during the encoding process.

encode

public byte[] encode(byte[] pArray)
              throws EncoderException
Description copied from interface: BinaryEncoder
Encode a byte array and return the encoded data as a byte array.

Specified by:
encode in interface BinaryEncoder
Parameters:
pArray - Data to be encoded
Returns:
A byte array containing the encoded data
Throws:
EncoderException - thrown if the Encoder encounters a failure condition during the encoding process.


Copyright © 2002-2003 Apache Software Foundation. All Rights Reserved.