com.datecs.api.smartcard
Class ResponseAPDU

java.lang.Object
  extended by com.datecs.api.smartcard.ResponseAPDU

public final class ResponseAPDU
extends java.lang.Object

This class represents the smart card response APDU as defined in ISO/IEC 7816-4.

Instances of this class are immutable. Where data is passed in or out via byte arrays, defensive cloning is performed.


Constructor Summary
ResponseAPDU(byte[] apdu)
          Constructs a new instance of this class from a given byte array containing the complete APDU contents.
 
Method Summary
 byte[] getBytes()
          Returns a copy of the bytes in this APDU.
 byte[] getData()
          Returns a copy of the data bytes in the response body.
 int getSW()
          Returns the value of the status bytes SW1 and SW2 as a single status word SW.
 int getSW1()
          Returns the value of the status byte SW1 as a value between 0 and 255.
 int getSW2()
          Returns the value of the status byte SW2 as a value between 0 and 255.
 java.lang.String toString()
          Returns the string representation of object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResponseAPDU

public ResponseAPDU(byte[] apdu)
Constructs a new instance of this class from a given byte array containing the complete APDU contents.

If apdu is null, a NullPointerException is thrown.

if apdu.length < 2, a IllegalArgumentException is thrown.

Note that the byte array is cloned to protect against subsequent modification.

Parameters:
apdu - the complete response APDU.
Method Detail

getData

public byte[] getData()
Returns a copy of the data bytes in the response body. If this APDU has no body, this method returns a byte array with a length of zero.

Returns:
a copy of the data bytes in the response body or the empty byte array if this APDU has no body.

getSW1

public int getSW1()
Returns the value of the status byte SW1 as a value between 0 and 255.

Returns:
the value of the status byte SW1 as a value between 0 and 255.

getSW2

public int getSW2()
Returns the value of the status byte SW2 as a value between 0 and 255.

Returns:
the value of the status byte SW2 as a value between 0 and 255.

getSW

public int getSW()
Returns the value of the status bytes SW1 and SW2 as a single status word SW. It is defined as (getSW1() << 8) | getSW2().

Returns:
the value of the status word SW.

getBytes

public byte[] getBytes()
Returns a copy of the bytes in this APDU.

Returns:
a copy of the bytes in this APDU.

toString

public java.lang.String toString()
Returns the string representation of object.

Overrides:
toString in class java.lang.Object