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

Translates between byte arrays and strings of "0"s and "1"s. More...

Inheritance diagram for BinaryCodec:
BinaryDecoder BinaryEncoder Decoder Encoder

Description

TODO: may want to add more bit vector functions like and/or/xor/nand. TODO: also might be good to generate boolean[] from byte[] et. cetera.

Author
Apache Software Foundation
Since
1.3
Version
$Id $

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

byte[] encode (byte[] raw)
 Converts an array of raw binary data into an array of ascii 0 and 1 characters. More...
 
Object encode (Object raw) throws EncoderException
 Converts an array of raw binary data into an array of ascii 0 and 1 chars. More...
 
Object decode (Object ascii) throws DecoderException
 Decodes a byte array where each byte represents an ascii '0' or '1'. More...
 
byte[] decode (byte[] ascii)
 Decodes a byte array where each byte represents an ascii '0' or '1'. More...
 
byte[] toByteArray (String ascii)
 Decodes a String where each char of the String represents an ascii '0' or '1'. More...
 

Static Public Member Functions

static byte[] fromAscii (char[] ascii)
 Decodes a byte array where each char represents an ascii '0' or '1'. More...
 
static byte[] fromAscii (byte[] ascii)
 Decodes a byte array where each byte represents an ascii '0' or '1'. More...
 
static byte[] toAsciiBytes (byte[] raw)
 Converts an array of raw binary data into an array of ascii 0 and 1 character bytes - each byte is a truncated char. More...
 
static char[] toAsciiChars (byte[] raw)
 Converts an array of raw binary data into an array of ascii 0 and 1 characters. More...
 
static String toAsciiString (byte[] raw)
 Converts an array of raw binary data into a String of ascii 0 and 1 characters. More...
 

Member Function Documentation

◆ encode() [1/2]

byte [] encode ( byte[]  raw)
Parameters
rawthe raw binary data to convert
Returns
0 and 1 ascii character bytes one for each bit of the argument
See also
org.apache.commons.codec.BinaryEncoder::encode(byte[])

Implements BinaryEncoder.

◆ encode() [2/2]

Object encode ( Object  raw) throws EncoderException
Parameters
rawthe raw binary data to convert
Returns
0 and 1 ascii character chars one for each bit of the argument
Exceptions
EncoderExceptionif the argument is not a byte[]
See also
org.apache.commons.codec.Encoder::encode(java.lang.Object)

Implements Encoder.

◆ decode() [1/2]

Object decode ( Object  ascii) throws DecoderException
Parameters
asciieach byte represents an ascii '0' or '1'
Returns
the raw encoded binary where each bit corresponds to a byte in the byte array argument
Exceptions
DecoderExceptionif argument is not a byte[], char[] or String
See also
org.apache.commons.codec.Decoder::decode(java.lang.Object)

Implements Decoder.

◆ decode() [2/2]

byte [] decode ( byte[]  ascii)
Parameters
asciieach byte represents an ascii '0' or '1'
Returns
the raw encoded binary where each bit corresponds to a byte in the byte array argument
See also
org.apache.commons.codec.Decoder::decode(Object)

Implements BinaryDecoder.

◆ toByteArray()

byte [] toByteArray ( String  ascii)
Parameters
asciiString of '0' and '1' characters
Returns
the raw encoded binary where each bit corresponds to a byte in the byte array argument
See also
org.apache.commons.codec.Decoder::decode(Object)

◆ fromAscii() [1/2]

static byte [] fromAscii ( char[]  ascii)
static
Parameters
asciieach char represents an ascii '0' or '1'
Returns
the raw encoded binary where each bit corresponds to a char in the char array argument

◆ fromAscii() [2/2]

static byte [] fromAscii ( byte[]  ascii)
static
Parameters
asciieach byte represents an ascii '0' or '1'
Returns
the raw encoded binary where each bit corresponds to a byte in the byte array argument

◆ toAsciiBytes()

static byte [] toAsciiBytes ( byte[]  raw)
static
Parameters
rawthe raw binary data to convert
Returns
an array of 0 and 1 character bytes for each bit of the argument
See also
org.apache.commons.codec.BinaryEncoder::encode(byte[])

◆ toAsciiChars()

static char [] toAsciiChars ( byte[]  raw)
static
Parameters
rawthe raw binary data to convert
Returns
an array of 0 and 1 characters for each bit of the argument
See also
org.apache.commons.codec.BinaryEncoder::encode(byte[])

◆ toAsciiString()

static String toAsciiString ( byte[]  raw)
static
Parameters
rawthe raw binary data to convert
Returns
a String of 0 and 1 characters representing the binary data
See also
org.apache.commons.codec.BinaryEncoder::encode(byte[])