javacardx.framework.math

Class BCDUtil


public final class BCDUtilextends Object

The 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.

Since:

2.2.2 

Constructor Summary
BCDUtil ()           

 

Method Summary
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.

 

Methods inherited from class java.lang.Object
equals

 

Constructor Detail

BCDUtil

public BCDUtil()

Method Detail

getMaxBytesSupported

public static short getMaxBytesSupported()

This method returns the largest value that can be used with the BCD utility functions. This number represents the the byte length of the largest value in hex byte representation. All implementations must support at least 8 byte length usage capacity.

Returns:the byte length of the largest hex value supported


convertToHex

public static short convertToHex(byte[] bcdArray, short bOff, short bLen, byte[] hexArray, short outOff)

Converts the input BCD data into hexadecimal format. Note:






Parameters:bcdArray - input byte array

bOff - offset within byte array containing first byte (the high order byte)

bLen - byte length of input BCD data

hexArray - output byte array

outOff - offset within hexArray where output data begins

Returns:the byte length of the output hexadecimal data

Throws: ArrayIndexOutOfBoundsException - if converting would cause access of data outside array bounds or if bLen is negative

NullPointerException - if either bcdArray or hexArray is null

ArithmeticException - for the following conditions:





convertToBCD

public static short convertToBCD(byte[] hexArray, short bOff, short bLen, byte[] bcdArray, short outOff)

Converts the input hexadecimal data into BCD format. The output data is right justified. If the number of output BCD nibbles is odd, the first BCD nibble written is 0. Note:






Parameters:hexArray - input byte array

bOff - offset within byte array containing first byte (the high order byte)

bLen - byte length of input hex data

bcdArray - output byte array

outOff - offset within bcdArray where output data begins

Returns:the byte length of the output bcd formatted data

Throws: ArrayIndexOutOfBoundsException - if converting would cause access of data outside array bounds or if bLen is negative

NullPointerException - if either bcdArray or hexArray is null

ArithmeticException - for the following conditions:




isBCDFormat

public static boolean isBCDFormat(byte[] bcdArray, short bOff, short bLen)

Checks if the input data is in BCD format. Note that this method does not enforce an upper bound on the length of the input BCD value.

Parameters:bcdArray - input byte array

bOff - offset within byte array containing first byte (the high order byte)

bLen - byte length of input BCD data

Returns:true if input data is in BCD format, false otherwise

Throws: ArrayIndexOutOfBoundsException - if accessing the input array would cause access of data outside array bounds or if bLen is negative

NullPointerException - if bcdArray is null

ArithmeticException - if bLen is 0