|
Java Card v2.2.2 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavacardx.framework.util.ArrayLogic
public final class ArrayLogic
The ArrayLogic class contains common utility functions for manipulating
arrays of primitive components - byte, short or int.
Some of the methods may be implemented as native functions for
performance reasons.
All the methods in ArrayLogic class are static methods.
Some methods of ArrayLogic, namely arrayCopyRepack(),
arrayCopyRepackNonAtomic() and arrayFillGenericNonAtomic(),
refer to the persistence of array objects. The term persistent means that
arrays and their values persist from one CAD session to the next, indefinitely.
The JCSystem class is used to control the persistence and transience of objects.
javacard.framework.JCSystem| Method Summary | |
|---|---|
static byte |
arrayCompareGeneric(Object src,
short srcOff,
Object dest,
short destOff,
short length)
Compares an array from the specified source array, beginning at the specified position, with the specified position of the destination array from left to right. |
static short |
arrayCopyRepack(Object src,
short srcOff,
short srcLen,
Object dest,
short destOff)
Copies data from the specified source array, beginning at the specified position, to the specified position of the destination array. |
static short |
arrayCopyRepackNonAtomic(Object src,
short srcOff,
short srcLen,
Object dest,
short destOff)
Non-atomically copies data from the specified source array, beginning at the specified position, to the specified position of the destination array. |
static short |
arrayFillGenericNonAtomic(Object theArray,
short off,
short len,
Object valArray,
short valOff)
Fills the array of primitive components(non-atomically) beginning at the specified position, for the specified length with the specified value. |
static short |
arrayFindGeneric(Object theArray,
short off,
byte[] valArray,
short valOff)
Finds the first occurrence of the specified value within the specified array. |
| Methods inherited from class java.lang.Object |
|---|
equals |
| Method Detail |
|---|
public static final short arrayCopyRepack(Object src,
short srcOff,
short srcLen,
Object dest,
short destOff)
throws ArrayIndexOutOfBoundsException,
NullPointerException,
TransactionException,
UtilException
Note:
srcLen
parameter is not a multiple of 2, an UtilException
exception is thrown.srcLen
parameter is not a multiple of 4, an UtilException
exception is thrown.srcLen
parameter is not a multiple of 2, an UtilException
exception is thrown.srcOff or destOff or srcLen parameter
is negative an ArrayIndexOutOfBoundsException exception is thrown.srcOff+srcLen is greater than src.length, the length
of the src array a ArrayIndexOutOfBoundsException exception is thrown
and no copy is performed.dest array would become greater than dest.length, the length
of the dest array during the copy operation ArrayIndexOutOfBoundsException exception is thrown
and no copy is performed.src or dest parameter is nullNullPointerException exception is thrown.
src and dest arguments refer to the same array object,
then the copying is performed as if the components at positions srcOff
through srcOff+srcLen-1 were first copied to a temporary array with srcLen components
and then the contents of the temporary array were copied into
positions destOff through destOff+srcLen-1 of the destination array.TransactionException
exception is thrown.
src - source array objectsrcOff - offset within source array to start copy fromsrcLen - number of source component values to be copied from the source arraydest - destination array objectdestOff - offset within destination array to start copy into
dest array where the last copy was performed
ArrayIndexOutOfBoundsException - if copying would cause access of data outside array bounds
NullPointerException - if either src or dest is null
TransactionException - if copying would cause the commit capacity to be exceeded
UtilException - with the following reason codes:UtilException.ILLEGAL_VALUE if src or dest is not an array of primitive components, or
if the srcLen parameter is incorrect
javacard.framework.JCSystem.getUnusedCommitCapacity()
public static final short arrayCopyRepackNonAtomic(Object src,
short srcOff,
short srcLen,
Object dest,
short destOff)
throws ArrayIndexOutOfBoundsException,
NullPointerException,
UtilException
This method does not use the transaction facility during the copy operation even if a transaction is in progress. Thus, this method is suitable for use only when the contents of the destination array can be left in a partially modified state in the event of a power loss in the middle of the copy operation.
Note:
srcLen
parameter is not a multiple of 2, an UtilException
exception is thrown.srcLen
parameter is not a multiple of 4, an UtilException
exception is thrown.srcLen
parameter is not a multiple of 2, an UtilException
exception is thrown.srcOff or destOff or srcLen parameter
is negative an ArrayIndexOutOfBoundsException exception is thrown.srcOff+srcLen is greater than src.length, the length
of the src array a ArrayIndexOutOfBoundsException exception is thrown
and no copy is performed.dest array would become greater than dest.length, the length
of the dest array during the copy operation ArrayIndexOutOfBoundsException exception is thrown
and no copy is performed.src or dest parameter is nullNullPointerException exception is thrown.
src and dest arguments refer to the same array object,
then the copying is performed as if the components at positions srcOff
through srcOff+srcLen-1 were first copied to a temporary array with srcLen components
and then the contents of the temporary array were copied into
positions destOff through destOff+srcLen-1 of the destination array.
src - source array objectsrcOff - offset within source array to start copy fromsrcLen - number of source component values to be copied from the source arraydest - destination array objectdestOff - offset within destination array to start copy into
dest array where the last copy was performed
ArrayIndexOutOfBoundsException - if copying would cause access of data outside array bounds
NullPointerException - if either src or dest is null
UtilException - with the following reason codes:UtilException.ILLEGAL_VALUE if src or dest is not an array of primitive components, or
if the srcLen parameter is incorrect
public static final short arrayFillGenericNonAtomic(Object theArray,
short off,
short len,
Object valArray,
short valOff)
throws ArrayIndexOutOfBoundsException,
NullPointerException,
UtilException
valArray) of the same
primitive component type at offset valOff.
This method does not use the transaction facility during the fill operation even if a transaction is in progress. Thus, this method is suitable for use only when the contents of the array can be left in a partially filled state in the event of a power loss in the middle of the fill operation.
The following code snippet shows how this method is typically used:
public short[] myArray = new short[10]; .. // Fill the entire array myArray of 10 short components with the value 0x1234 myArray[0] = (short)0x1234; ArrayLogic.arrayFillGenericNonAtomic(myArray, (short)0, (short)10, myArray, (short)0); ..
Note:
off or len or valOff parameter
is negative an ArrayIndexOutOfBoundsException exception is thrown.
off+len is greater than theArray.length, the length
of the theArray array an ArrayIndexOutOfBoundsException exception is thrown.
valOff is equal to or greater than valArray.length, the length
of the valArray array an ArrayIndexOutOfBoundsException exception is thrown.
theArray or valArray parameter is null
a NullPointerException exception is thrown.
len parameter is not constrained by the atomic commit capacity limitations.
theArray - the array objectoff - offset within array to start filling the specified valuelen - the number of component values to be filledvalArray - the array object containing the fill valuevalOff - the offset within the valArray array containing the fill value
off+len
ArrayIndexOutOfBoundsException - if the fill operation would cause access of data outside array bounds
NullPointerException - if theArray or valArray is null
UtilException - with the following reason codes:UtilException.ILLEGAL_VALUE if theArray or valArray is not an array of primitive components
UtilException.TYPE_MISMATCHED if the valArray parameter is not an array of
the same primitive component type as the theArray.
public static final byte arrayCompareGeneric(Object src,
short srcOff,
Object dest,
short destOff,
short length)
throws ArrayIndexOutOfBoundsException,
NullPointerException,
UtilException
Note:
srcOff or destOff or length parameter
is negative an ArrayIndexOutOfBoundsException exception is thrown.
srcOff+length is greater than src.length, the length
of the src array a ArrayIndexOutOfBoundsException exception is thrown.
destOff+length is greater than dest.length, the length
of the dest array an ArrayIndexOutOfBoundsException exception is thrown.
src or dest parameter is null
a NullPointerException exception is thrown.
src - source array objectsrcOff - offset within source array to start comparedest - destination array objectdestOff - offset within destination array to start comparelength - length to be compared
0 if identical-1 if the first miscomparing primitive component in source array is less than that in destination array1 if the first miscomparing primitive component in source array is greater than that in destination arrayArrayIndexOutOfBoundsException - if comparing all the components would cause access of data outside array bounds
NullPointerException - if either src or dest is null
UtilException - with the following reason codes:UtilException.ILLEGAL_VALUE if src or dest is not an array of primitive components, or
if the length parameter is incorrect
UtilException.TYPE_MISMATCHED if the dest parameter is not an array of
the same primitive component type.
public static final short arrayFindGeneric(Object theArray,
short off,
byte[] valArray,
short valOff)
throws ArrayIndexOutOfBoundsException,
NullPointerException,
UtilException
valOff in the byte array parameter valArray.
Note:
off or valOff parameter
is negative an ArrayIndexOutOfBoundsException exception is thrown.
off is greater than theArray.length, the length
of the theArray array an ArrayIndexOutOfBoundsException exception is thrown.
theArray or valArray parameter is null
a NullPointerException exception is thrown.
valOff in the valArray is used as
the search value. If valOff+1 is greater than valArray.length, the length
of the valArray array an ArrayIndexOutOfBoundsException exception is thrown.
valOff in the valArray are concatenated (high order byte
component first) to form
the search value. If valOff+2 is greater than valArray.length, the length
of the valArray array an ArrayIndexOutOfBoundsException exception is thrown.
valOff in the valArray are concatenated (high order byte
component first) to form
the search value. If valOff+4 is greater than valArray.length, the length
of the valArray array an ArrayIndexOutOfBoundsException exception is thrown.
theArray - the array object to searchoff - offset within the array to start serching for the specified valuevalArray - the array object containing the search valuevalOff - the offset within the valArray array containing the search value
ArrayIndexOutOfBoundsException - if the search operation would cause access of data outside array bounds
NullPointerException - if theArray is null
UtilException - with the following reason code:UtilException.ILLEGAL_VALUE if theArray is not an array of primitive components.
|
Java Card v2.2.2 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||