ds.ov2.util
Class APDU_short_array

java.lang.Object
  extended by ds.ov2.util.Serializable_array
      extended by ds.ov2.util.APDU_short_array
All Implemented Interfaces:
APDU_Serializable

public class APDU_short_array
extends Serializable_array
implements APDU_Serializable

APDU_Serializable wrapper around a short array. Provides get and set methods for accessing the array. Relies on Serializable_array for the APDU_Serializable functionality. This is not terribly effient, but good enough as long as this is only used for setting the sizes of Resizable_buffer's in the tests of the OV-chip protocol layer.

CPP Preprocessing
This class uses the following cpp defines: PACKAGE, PUBLIC, JAVACARD_APPLET
Execution Environment:
host, card
To Do:
Could be made more efficient by using a short array internally instead of an APDU_short array. The latter is of course much more convenient in the to/from_byte methods.
Author:
Hendrik Tews
Version:
$Revision: 1.10 $
Last Commit:
$Date: 2009-03-26 15:51:31 $ by $Author: tews $

Field Summary
private  APDU_short[] a
          The internal array with the data.
 
Constructor Summary
APDU_short_array(int[] int_array)
          Convenience initializing constructor.
APDU_short_array(short len)
          Noninitializing constructor.
APDU_short_array(short len, int[] int_array)
          Initializing constructor for the IDL compiler.
 
Method Summary
 void copy(int[] int_array)
          Reinitialize this array from an int array.
protected  APDU_Serializable[] get_array()
          Return the short array a in support for abstract Serializable_array.
 int[] get_int_array()
          Return the contents as int array.
 short get(short i)
          Array read access.
 boolean is_compatible_with(Object o)
          Compatibility check for the OV-chip protocol layer.
 void set(short i, short v)
          Array write access.
 short size()
          Size in bytes of this array.
 
Methods inherited from class ds.ov2.util.Serializable_array
from_byte_array, get_length, to_byte_array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ds.ov2.util.APDU_Serializable
from_byte_array, to_byte_array
 

Field Detail

a

private APDU_short[] a
The internal array with the data.

Constructor Detail

APDU_short_array

public APDU_short_array(short len)
Noninitializing constructor.

Parameters:
len - length of the short array to create

APDU_short_array

public APDU_short_array(int[] int_array)
Convenience initializing constructor. Create a short array with the same data as int_array. Asserts that all elements of int_array fit into a short.

Only available if JAVACARD_APPLET is undefined.

Parameters:
int_array - provides length and data for the new short array.

APDU_short_array

public APDU_short_array(short len,
                        int[] int_array)
Initializing constructor for the IDL compiler. The len argument is redundant here, but the IDL compiler is not smart enough to leave it out. This constructor is the same as the convenience initializing constructor. It only additionally asserts that len equals the int_array length.

Parameters:
len - length of the new array
int_array - data for the new array
Method Detail

get_int_array

public int[] get_int_array()
Return the contents as int array. Convenient in the host driver.

Only available if JAVACARD_APPLET is undefined.

Returns:
contents of this array as int array of the same size

copy

public void copy(int[] int_array)
Reinitialize this array from an int array. Asserts that the length of int_array equals the length of this array and that all elements of int_array fit into a short.

Only available if JAVACARD_APPLET is undefined.

Parameters:
int_array - new data for this array

get

public short get(short i)
Array read access.

Parameters:
i - index
Returns:
ith element of this array
Throws:
ArrayIndexOutOfBoundsException - if the index i is invalid

set

public void set(short i,
                short v)
Array write access. Store a value at an index.

Parameters:
i - index
v - new value.
Throws:
ArrayIndexOutOfBoundsException - if the index i is invalid

get_array

protected APDU_Serializable[] get_array()
Return the short array a in support for abstract Serializable_array.

Specified by:
get_array in class Serializable_array
Returns:
array of objects to (de-)serialize

size

public short size()
Size in bytes of this array. Necessary for the OV-chip protocol layer, see APDU_Serializable.size(). Overriden here with a more efficient method to compute the size.

Specified by:
size in interface APDU_Serializable
Overrides:
size in class Serializable_array
Returns:
size in bytes

is_compatible_with

public boolean is_compatible_with(Object o)
Compatibility check for the OV-chip protocol layer. See the compatibility check explanations and also APDU_Serializable.is_compatible_with.

This object is compatible with instances of this class with the same array length.

Specified by:
is_compatible_with in interface APDU_Serializable
Overrides:
is_compatible_with in class Serializable_array
Parameters:
o - actual argument or result
Returns:
true if o is an instance of APDU_short_array with the same length