ds.ov2.util
Class APDU_byte_array

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

public class APDU_byte_array
extends Object
implements APDU_Serializable

APDU_Serializable wrapper around a fixed size byte array.

CPP Preprocessing
This class uses the following cpp defines: PACKAGE, PUBLIC, ASSERT
Execution Environment:
host, card
Author:
Hendrik Tews
Version:
$Revision: 1.9 $
Last Commit:
$Date: 2009-05-28 15:17:03 $ by $Author: tews $

Field Summary
 byte[] buf
          The byte array.
 
Constructor Summary
APDU_byte_array(byte[] buf)
          Create a APDU_byte_array by wrapping an existing byte array.
APDU_byte_array(short size)
          Create a new wrapped byte array of length size.
 
Method Summary
 short from_byte_array(short len, short this_index, byte[] byte_array, short byte_index)
          Deserialization the byte array.
 boolean is_compatible_with(Object o)
          Compatibility check for the OV-chip protocol layer.
 short size()
          Size in bytes necessary to send or receive this object via the OV-chip protocol layer, see APDU_Serializable.size().
 short to_byte_array(short len, short this_index, byte[] byte_array, short byte_index)
          Serialize the byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buf

public final byte[] buf
The byte array. The byte array can be freely changed, but this reference itself must stay constant.

Constructor Detail

APDU_byte_array

public APDU_byte_array(short size)
Create a new wrapped byte array of length size.

Parameters:
size - length of the wrapped byte array

APDU_byte_array

public APDU_byte_array(byte[] buf)
Create a APDU_byte_array by wrapping an existing byte array.

Parameters:
buf - the byte array to wrap
Method Detail

size

public short size()
Size in bytes necessary to send or receive this object via the OV-chip protocol layer, see APDU_Serializable.size().

Specified by:
size in interface APDU_Serializable
Returns:
length of the buf byte array

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.

Objects of this class are only compatible to objects of this class of the same size.

Specified by:
is_compatible_with in interface APDU_Serializable
Parameters:
o - actual argument or result
Returns:
true if this o is an APDU_byte_array of the same size

to_byte_array

public short to_byte_array(short len,
                           short this_index,
                           byte[] byte_array,
                           short byte_index)
Serialize the byte array. See APDU_Serializable.to_byte_array.

Specified by:
to_byte_array in interface APDU_Serializable
Parameters:
len - available space in byte_array
this_index - number of bytes that have already been written in preceeding calls
byte_array - data array to serialize the state into
byte_index - index in byte_array
Returns:
the number of bytes actually written, except for the case where serialization finished by writing precisely len bytes, in this case len + 1 is returned.

from_byte_array

public short from_byte_array(short len,
                             short this_index,
                             byte[] byte_array,
                             short byte_index)
Deserialization the byte array. See APDU_Serializable.from_byte_array.

Specified by:
from_byte_array in interface APDU_Serializable
Parameters:
len - available data in byte_array
this_index - number of bytes that have already been read in preceeding calls
byte_array - data array to deserialize from
byte_index - index in byte_array
Returns:
the number of bytes actually read, except for the case where deserialization finished by reading precisely len bytes, in this case len + 1 is returned.