FileDocCategorySizeDatePackage
TLP224Message.javaAPI DocphoneME MR2 API (J2ME)5825Wed May 02 18:00:38 BST 2007com.sun.midp.io.j2me.apdu

TLP224Message

public class TLP224Message extends Exception
The TLP224Message class represents the link level message between a CAD (Card Acceptance Device) and a Terminal. All messages exchanged between the CAD and the Terminal are encoded using the TLP224 protocol. TLP224Messages are used internally to maintain context on the server side and to send commands to and from the client.

Fields Summary
static final byte
EOT
This field contains the EOT code which is always sent as the last octet of any TLP224 message.
static final byte
ACK
This field contains the ACK code which is returned to the sender as the first octet of a TLP224 response when a message has been successfully received.
static final byte
NACK
This field contains the NACK code which is returned to the sender as the first octet of a TLP224 response when a transmission error occurs.
static final byte
POWER_UP
This field contains the TLP224 command to power up the CAD.
static final byte
ISO_INPUT
This field contains the TLP224 command to send data to the card.
static final byte
ISO_OUTPUT
This field contains the TLP224 command to read data from the card.
static final byte
STATUS_SUCCESS
This status code is returned by both the Client and Server CAD's when a command has been successfully executed.
static final byte
STATUS_PROTOCOL_ERROR
This status code is returned by both the Client and Server CAD's when the first byte of a received message is neither an ACK or NACK.
static final byte
STATUS_MESSAGE_TOO_LONG
This status code is returned by both the Client and Server CAD's when a received message exceeds the length of the internal buffers.
static final byte
STATUS_INTERRUPTED_EXCHANGE
This status code is returned by the reader or ServerCad if the card sends a Procedure Byte which aborts a ISO_IN or ISO_OUT command.
static final byte
STATUS_CARD_ERROR
This status code is returned by the reader or ServerCad if SW1 SW2 are not equal to 0x9000.
static final byte
STATUS_CARD_REMOVED
This status code is returned by the reader or ServerCad if the card was removed between exchanges.
static final byte
STATUS_CARD_MISSING
This status code is returned by the reader or ServerCad if there is no card in the reader.
private static final int
MAX_MESSAGE_LEN
This field contains the size of the largest possible TLP224 Message. This message would be <ACK><LEN><255 bytes of command><LRC>
private byte[]
buf
Local buffer for this TLP224 message.
private int
len
Current length of data in local buffer.
Constructors Summary
TLP224Message()
Construct a new TLP224Message using the default (MAX_MESSAGE_LEN) message size.


                    
     
        this.buf = new byte[MAX_MESSAGE_LEN];
        this.len = 0;
    
Methods Summary
bytecomputeLRC(int length)
Compute the TLP224 LRC of this object. The TLP224 LRC is the exclusive-or of all the bytes in the message.

param
length The number of bytes to compute the LRC over.
return
The computed LRC.

        int lrc = 0;
        for (int i = 0; i < length; i++)
            lrc ^= buf[i];
        return (byte) lrc;
    
byte[]getData()
Retrieves the contents of this TLP224Message.

return
The non-null byte array containing the data to be sent or received. Any changes to this byte array also affect the TLP224Message from which it came.

 return buf; 
intgetLength()
Retrieves the length of this TLP224Message.

return
The length in bytes of the internal buffer as previously set by setLength().

 return len; 
voidsetLength(int newLen)
Set the length of the data in this TLP224Message. The length must be less than or equal to the length of the internal buffer.

param
newLen The length to set.
exception
IllegalArgumentException if newLen is greater than the length of the internal buffer.

        this.len = newLen;