com.ibm.jc
Class ATR

java.lang.Object
  extended bycom.ibm.jc.ATR

public class ATR
extends java.lang.Object

ATR parsing & representation.


Field Summary
static int BAD_TCK
          ATR status: ATR has a bad TCK checksum value (3).
static int NA
          A value of NA marks some T[ABCD]i as not present.
static int OK
          ATR status: ATR is formatted ok (0).
static int T_0
          T=0 protocol selector (value 0).
static int T_1
          T=1 protocol selector (value 1).
static int TA
          Selects A byte of a (TAi,TBi,TCi,TDi) quadruple (value 0).
static int TB
          Selects B byte of a (TAi,TBi,TCi,TDi) quadruple (value 1).
static int TC
          Selects C byte of a (TAi,TBi,TCi,TDi) quadruple (value 2).
static int TD
          Selects D byte of a (TAi,TBi,TCi,TDi) quadruple (value 3).
static int TOO_LONG
          ATR status: ATR is too long - excess bytes (2).
static int TOO_SHORT
          ATR status: ATR is too short - badly formatted ok (1).
 
Constructor Summary
ATR(byte[] receivedATR)
          Parse given ATR and possibly set TCK.
ATR(byte[] receivedATR, boolean fixTCK)
          Parse given ATR and possibly set TCK.
 
Method Summary
 byte[] getBytes()
           
 byte[] getHistoricalChars()
           
 int getMaxTXi()
           
 int getStatus()
          Get ATR status.
 int getT0()
          Second character of ATR.
 int getTCK()
          Retrieve checksum byte.
 int getTS()
          First character of ATR.
 int getTxi(int abcd, int i)
          T[ABCD]i with i>0 and abcd on of {TA,TB,TC,TD}.
 boolean isATS()
          Determines whether this is indeed a T=CL Answer to Select (ATS)
 boolean onlyT_0()
          Return true if only T=0 is indicated (possibly by default).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OK

public static final int OK
ATR status: ATR is formatted ok (0).

See Also:
Constant Field Values

TOO_SHORT

public static final int TOO_SHORT
ATR status: ATR is too short - badly formatted ok (1).

See Also:
Constant Field Values

TOO_LONG

public static final int TOO_LONG
ATR status: ATR is too long - excess bytes (2).

See Also:
Constant Field Values

BAD_TCK

public static final int BAD_TCK
ATR status: ATR has a bad TCK checksum value (3).

See Also:
Constant Field Values

T_0

public static final int T_0
T=0 protocol selector (value 0).

See Also:
Constant Field Values

T_1

public static final int T_1
T=1 protocol selector (value 1).

See Also:
Constant Field Values

TA

public static final int TA
Selects A byte of a (TAi,TBi,TCi,TDi) quadruple (value 0).

See Also:
Constant Field Values

TB

public static final int TB
Selects B byte of a (TAi,TBi,TCi,TDi) quadruple (value 1).

See Also:
Constant Field Values

TC

public static final int TC
Selects C byte of a (TAi,TBi,TCi,TDi) quadruple (value 2).

See Also:
Constant Field Values

TD

public static final int TD
Selects D byte of a (TAi,TBi,TCi,TDi) quadruple (value 3).

See Also:
Constant Field Values

NA

public static final int NA
A value of NA marks some T[ABCD]i as not present. Regular T[ABCD]i bytes have values 0..255 and NA has value -1.

See Also:
Constant Field Values
Constructor Detail

ATR

public ATR(byte[] receivedATR)
Parse given ATR and possibly set TCK.

Parameters:
receivedATR - the ATR to be parsed

ATR

public ATR(byte[] receivedATR,
           boolean fixTCK)
Parse given ATR and possibly set TCK.

Parameters:
receivedATR - the ATR to be parsed. If the first byte is the length of the array-1 then it is assumed that the ATR is a ATS under protocol T=CL.
fixTCK - fix last byte if ATR with the correct checksum if ATR addresses any other protocol than T=0
Method Detail

getStatus

public int getStatus()
Get ATR status.

Returns:
One of the ATR status constants

isATS

public boolean isATS()
Determines whether this is indeed a T=CL Answer to Select (ATS)


onlyT_0

public boolean onlyT_0()
Return true if only T=0 is indicated (possibly by default). In this case, no TCK is contained in the ATR.


getTS

public int getTS()
First character of ATR. Returns for a valid ATR 3B,3F which signals indirect or indirect convention. In case of an ATS (T=CL) the length of the ATS is returned including the length byte itself.


getT0

public int getT0()
Second character of ATR.


getTCK

public int getTCK()
Retrieve checksum byte.


getHistoricalChars

public byte[] getHistoricalChars()
Returns:
historical characters for ATRs and application data for ATSs.

getMaxTXi

public int getMaxTXi()
Returns:
the maximum valid quadruple index.

getTxi

public int getTxi(int abcd,
                  int i)
T[ABCD]i with i>0 and abcd on of {TA,TB,TC,TD}.

Returns:
a value 0..255 for the component or NA (-1) if requested component was not part of ATR.

getBytes

public byte[] getBytes()
Returns:
full ATR as byte array.