public final class BCDUtil extends Object
BCDUtil class contains common BCD(binary coded decimal)
related utility functions. This class supports Packed BCD format. All methods
in this class are static.
The BCDUtil class only supports unsigned numbers whose value
can are represented in hexadecimal format using an implementation specific
maximum number of bytes.
| Constructor and Description |
|---|
BCDUtil()
Intended to be package visible.
|
| Modifier and Type | Method and Description |
|---|---|
static short |
convertToBCD(byte[] hexArray,
short bOff,
short bLen,
byte[] bcdArray,
short outOff)
Converts the input hexadecimal data into BCD format.
|
static short |
convertToHex(byte[] bcdArray,
short bOff,
short bLen,
byte[] hexArray,
short outOff)
Converts the input BCD data into hexadecimal format.
|
static short |
getMaxBytesSupported()
This method returns the largest value that can be used with the BCD
utility functions.
|
static boolean |
isBCDFormat(byte[] bcdArray,
short bOff,
short bLen)
Checks if the input data is in BCD format.
|
public BCDUtil()
public static short getMaxBytesSupported()
public static short convertToHex(byte[] bcdArray,
short bOff,
short bLen,
byte[] hexArray,
short outOff)
Note:
bOff or bLen or outOff parameter
is negative an ArrayIndexOutOfBoundsException exception is thrown.
bOff+bLen is greater than bcdArray.length, the length
of the bcdArray array a ArrayIndexOutOfBoundsException exception is thrown
and no conversion is performed.
hexArray.length, the length
of the hexArray array an ArrayIndexOutOfBoundsException exception is thrown
and no conversion is performed.
bcdArray or hexArray parameter is null
a NullPointerException exception is thrown.
bcdArray and hexArray arguments refer to the same array object,
then the conversion is performed as if the components at positions bOff
through bOff+bLen-1 were first copied to a temporary array with bLen components
and then the contents of the temporary array were converted into
positions outOff onwards for the converted bytes of the output array.
bcdArray - input byte arraybOff - offset within byte array containing first byte (the high order
byte)bLen - byte length of input BCD datahexArray - output byte arrayoutOff - offset within hexArray where output data beginsArrayIndexOutOfBoundsException - if converting would cause access of data outside array
bounds or if bLen is negativeNullPointerException - if either bcdArray or hexArray
is nullArithmeticException - for the following conditions:
bLen is 0
public static short convertToBCD(byte[] hexArray,
short bOff,
short bLen,
byte[] bcdArray,
short outOff)
Note:
bOff or bLen or outOff parameter
is negative an ArrayIndexOutOfBoundsException exception is thrown.
bOff+bLen is greater than hexArray.length, the length
of the hexArray array a ArrayIndexOutOfBoundsException exception is thrown
and no conversion is performed.
bcdArray.length, the length
of the bcdArray array an ArrayIndexOutOfBoundsException exception is thrown
and no conversion is performed.
bcdArray or hexArray parameter is null
a NullPointerException exception is thrown.
bcdArray and hexArray arguments refer to the same array object,
then the conversion is performed as if the components at positions bOff
through bOff+bLen-1 were first copied to a temporary array with bLen components
and then the contents of the temporary array were converted into
positions outOff onwards for the converted bytes of the output array.
hexArray - input byte arraybOff - offset within byte array containing first byte (the high order
byte)bLen - byte length of input hex databcdArray - output byte arrayoutOff - offset within bcdArray where output data beginsArrayIndexOutOfBoundsException - if converting would cause access of data outside array
bounds or if bLen is negativeNullPointerException - if either bcdArray or hexArray
is nullArithmeticException - for the following conditions:
bLen is 0
public static boolean isBCDFormat(byte[] bcdArray,
short bOff,
short bLen)
bcdArray - input byte arraybOff - offset within byte array containing first byte (the high order
byte)bLen - byte length of input BCD dataArrayIndexOutOfBoundsException - if accessing the input array would cause access of data
outside array bounds or if bLen is negativeNullPointerException - if bcdArray is nullArithmeticException - if bLen is 0
Copyright © 1998, 2015, Oracle and/or its affiliates. All rights reserved.