• BlackBerry Dynamics
  • Runtime library for Android applications
  • 12.0.1.79
Base64 Class Reference

Provides Base64 encoding and decoding as defined by RFC 2045. More...

Inheritance diagram for Base64:
BinaryEncoder BinaryDecoder Encoder Decoder

Description

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

See also
RFC 2045
Author
Apache Software Foundation
Since
1.0-dev
Version
Id
Base64.java,v 1.20 2004/05/24 00:21:24 ggregory Exp

Notice

The following notice applies to the original API on which this API is based, and to its documentation. The documentation of this API has been revised from the original.

/*
 * Copyright (C) 2006 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

Public Member Functions

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

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. More...
 
static byte[] encodeBase64 (byte[] binaryData)
 Encodes binary data using the base64 algorithm but does not chunk the output. More...
 
static byte[] encodeBase64Chunked (byte[] binaryData)
 Encodes binary data using the base64 algorithm and chunks the encoded output into 76 character blocks. More...
 
static byte[] encodeBase64 (byte[] binaryData, boolean isChunked)
 Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks. More...
 
static byte[] decodeBase64 (byte[] base64Data)
 Decodes Base64 data into octects. More...
 

Member Function Documentation

◆ isArrayByteBase64()

static boolean isArrayByteBase64 ( byte[]  arrayOctect)
static
Parameters
arrayOctectbyte array to test
Returns
true if all bytes are valid characters in the Base64 alphabet or if the byte array is empty; false, otherwise

◆ encodeBase64() [1/2]

static byte [] encodeBase64 ( byte[]  binaryData)
static
Parameters
binaryDatabinary data to encode
Returns
Base64 characters

◆ encodeBase64Chunked()

static byte [] encodeBase64Chunked ( byte[]  binaryData)
static
Parameters
binaryDatabinary data to encode
Returns
Base64 characters chunked in 76 character blocks

◆ decode() [1/2]

Object decode ( Object  pObject) throws DecoderException

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
pObjectObject to decode
Returns
An object (of type byte[]) containing the binary data which corresponds to the byte[] supplied.
Exceptions
DecoderExceptionif the parameter supplied is not of type byte[]

Implements Decoder.

◆ decode() [2/2]

byte [] decode ( byte[]  pArray)
Parameters
pArrayA byte array containing Base64 character data
Returns
a byte array containing binary data

Implements BinaryDecoder.

◆ encodeBase64() [2/2]

static byte [] encodeBase64 ( byte[]  binaryData,
boolean  isChunked 
)
static
Parameters
binaryDataArray containing binary data to encode.
isChunkedif isChunked is true this encoder will chunk the base64 output into 76 character blocks
Returns
Base64-encoded data.

◆ decodeBase64()

static byte [] decodeBase64 ( byte[]  base64Data)
static
Parameters
base64DataByte array containing Base64 data
Returns
Array containing decoded data.

◆ encode() [1/2]

Object encode ( Object  pObject) throws EncoderException

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
pObjectObject to encode
Returns
An object (of type byte[]) containing the base64 encoded data which corresponds to the byte[] supplied.
Exceptions
EncoderExceptionif the parameter supplied is not of type byte[]

Implements Encoder.

◆ encode() [2/2]

byte [] encode ( byte[]  pArray)
Parameters
pArraya byte array containing binary data
Returns
A byte array containing only Base64 character data

Implements BinaryEncoder.