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

Hex encoder and decoder. More...

Inheritance diagram for Hex:
BinaryEncoder BinaryDecoder Encoder Decoder

Description

Since
1.1
Author
Apache Software Foundation
Version
Id
Hex.java,v 1.13 2004/04/18 18:22:33 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

byte[] decode (byte[] array) throws DecoderException
 Converts an array of character bytes representing hexidecimal values into an array of bytes of those same values. More...
 
Object decode (Object object) throws DecoderException
 Converts a String or an array of character bytes representing hexidecimal values into an array of bytes of those same values. More...
 
byte[] encode (byte[] array)
 Converts an array of bytes into an array of bytes for the characters representing the hexidecimal values of each byte in order. More...
 
Object encode (Object object) throws EncoderException
 Converts a String or an array of bytes into an array of characters representing the hexidecimal values of each byte in order. More...
 

Static Public Member Functions

static byte[] decodeHex (char[] data) throws DecoderException
 Converts an array of characters representing hexidecimal values into an array of bytes of those same values. More...
 
static char[] encodeHex (byte[] data)
 Converts an array of bytes into an array of characters representing the hexidecimal values of each byte in order. More...
 

Static Protected Member Functions

static int toDigit (char ch, int index) throws DecoderException
 Converts a hexadecimal character to an integer. More...
 

Member Function Documentation

◆ decodeHex()

static byte [] decodeHex ( char[]  data) throws DecoderException
static

The returned array will be half the length of the passed array, as it takes two characters to represent any given byte. An exception is thrown if the passed char array has an odd number of elements.

Parameters
dataAn array of characters containing hexidecimal digits
Returns
A byte array containing binary data decoded from the supplied char array.
Exceptions
DecoderExceptionThrown if an odd number or illegal of characters is supplied

◆ toDigit()

static int toDigit ( char  ch,
int  index 
) throws DecoderException
staticprotected
Parameters
chA character to convert to an integer digit
indexThe index of the character in the source
Returns
An integer
Exceptions
DecoderExceptionThrown if ch is an illegal hex character

◆ encodeHex()

static char [] encodeHex ( byte[]  data)
static

The returned array will be double the length of the passed array, as it takes two characters to represent any given byte.

Parameters
dataa byte[] to convert to Hex characters
Returns
A char[] containing hexidecimal characters

◆ decode() [1/2]

byte [] decode ( byte[]  array) throws DecoderException

The returned array will be half the length of the passed array, as it takes two characters to represent any given byte. An exception is thrown if the passed char array has an odd number of elements.

Parameters
arrayAn array of character bytes containing hexidecimal digits
Returns
A byte array containing binary data decoded from the supplied byte array (representing characters).
Exceptions
DecoderExceptionThrown if an odd number of characters is supplied to this function
See also
decodeHex(char[])

Implements BinaryDecoder.

◆ decode() [2/2]

Object decode ( Object  object) throws DecoderException

The returned array will be half the length of the passed String or array, as it takes two characters to represent any given byte. An exception is thrown if the passed char array has an odd number of elements.

Parameters
objectA String or, an array of character bytes containing hexidecimal digits
Returns
A byte array containing binary data decoded from the supplied byte array (representing characters).
Exceptions
DecoderExceptionThrown if an odd number of characters is supplied to this function or the object is not a String or char[]
See also
decodeHex(char[])

Implements Decoder.

◆ encode() [1/2]

byte [] encode ( byte[]  array)

The returned array will be double the length of the passed array, as it takes two characters to represent any given byte.

Parameters
arraya byte[] to convert to Hex characters
Returns
A byte[] containing the bytes of the hexidecimal characters
See also
encodeHex(byte[])

Implements BinaryEncoder.

◆ encode() [2/2]

Object encode ( Object  object) throws EncoderException

The returned array will be double the length of the passed String or array, as it takes two characters to represent any given byte.

Parameters
objecta String, or byte[] to convert to Hex characters
Returns
A char[] containing hexidecimal characters
Exceptions
EncoderExceptionThrown if the given object is not a String or byte[]
See also
encodeHex(byte[])

Implements Encoder.