APIdia Launch Partner
Top Description Fields Constructors Methods
javax.smartcardio

public final Class ResponseAPDU

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.util.Arrays

A response APDU as defined in ISO/IEC 7816-4. It consists of a conditional body and a two byte trailer. This class does not attempt to verify that the APDU encodes a semantically valid response.

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

Authors
Andreas Sterbenz, JSR 268 Expert Group
Since
1.6
See Also
CommandAPDU, CardChannel.transmit

Field Summary

Modifier and TypeField and Description
private byte[]
private static final long

Constructor Summary

AccessConstructor and Description
public
ResponseAPDU(byte[]
the complete response APDU
apdu
)

Constructs a ResponseAPDU from a byte array containing the complete APDU contents (conditional body and trailed).

Method Summary

Modifier and TypeMethod and Description
private static void
check(byte[] apdu)

public boolean

Returns:

true if the specified object is equal to this response APDU
equals
(Object
the object to be compared for equality with this response APDU
obj
)

Overrides java.lang.Object.equals.

Compares the specified object with this response APDU for equality.

public byte[]

Returns:

a copy of the bytes in this APDU.
getBytes
()

Returns a copy of the bytes in this APDU.

public byte[]

Returns:

a copy of the data bytes in the response body or the empty byte array if this APDU has no body.
getData
()

Returns a copy of the data bytes in the response body.

public int

Returns:

the number of data bytes in the response body or 0 if this APDU has no body.
getNr
()

Returns the number of data bytes in the response body (Nr) or 0 if this APDU has no body.

public int

Returns:

the value of the status word SW.
getSW
()

Returns the value of the status bytes SW1 and SW2 as a single status word SW.

public int

Returns:

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

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

public int

Returns:

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

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

public int

Returns:

the hash code value for this response APDU.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns the hash code value for this response APDU.

private void
public String

Returns:

a String representation of this response APDU.
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of this response APDU.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

apduback to summary
private byte[] apdu
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

ResponseAPDUback to summary
public ResponseAPDU(byte[] apdu)

Constructs a ResponseAPDU from a byte array containing the complete APDU contents (conditional body and trailed).

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

Parameters
apdu:byte[]

the complete response APDU

Exceptions
NullPointerException:
if apdu is null
IllegalArgumentException:
if apdu.length is less than 2

Method Detail

checkback to summary
private static void check(byte[] apdu)
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Compares the specified object with this response APDU for equality. Returns true if the given object is also a ResponseAPDU and its bytes are identical to the bytes in this ResponseAPDU.

Parameters
obj:Object

the object to be compared for equality with this response APDU

Returns:boolean

true if the specified object is equal to this response APDU

getBytesback to summary
public byte[] getBytes()

Returns a copy of the bytes in this APDU.

Returns:byte[]

a copy of the bytes in this APDU.

getDataback to summary
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:byte[]

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

getNrback to summary
public int getNr()

Returns the number of data bytes in the response body (Nr) or 0 if this APDU has no body. This call is equivalent to getData().length.

Returns:int

the number of data bytes in the response body or 0 if this APDU has no body.

getSWback to summary
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:int

the value of the status word SW.

getSW1back to summary
public int getSW1()

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

Returns:int

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

getSW2back to summary
public int getSW2()

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

Returns:int

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

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns the hash code value for this response APDU.

Returns:int

the hash code value for this response APDU.

readObjectback to summary
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of this response APDU.

Returns:String

a String representation of this response APDU.