com.ibm.jc.terminal
Class OCFJCTerminal

java.lang.Object
  extended bycom.ibm.jc.JCTerminal
      extended bycom.ibm.jc.terminal.OCFJCTerminal

public class OCFJCTerminal
extends JCTerminal


Field Summary
 
Fields inherited from class com.ibm.jc.JCTerminal
CARD_PRESENT, ERROR, NOT_CONNECTED, PROTOCOL_T0, PROTOCOL_T1, PROTOCOL_TCL, SLOT_EMPTY
 
Constructor Summary
OCFJCTerminal()
          Construct a new terminal object.
 
Method Summary
 void close()
          Close connection to card terminal.
static java.lang.String[] getAvailableTerminals()
          Get a list of the available terminals as defined in the opencard.properties configuration file.
 int getState()
          Return the state of the terminal.
 JCTerminal init(java.lang.String terminalName)
          Initialize the card terminal.
 void open()
          Open the card terminal.
 byte[] send(int nad, byte[] toSend, int offset, int len)
          Send data to the card terminal.
protected  void smartCardInserted(CardTerminalEvent pCardTerminalEvent)
          Event method called by OCF when a card is inserted.
protected  void smartCardRemoved(CardTerminalEvent pCardTerminalEvent)
          Event method called by OCF when a card is removed.
 java.lang.String toString()
          Return the terminal description.
 byte[] waitForCard(int time)
          Wait for insertion of a card and return ATR (answer to reset).
 
Methods inherited from class com.ibm.jc.JCTerminal
filterFor, filterFor, generateParityError, getErrorMessage, getInstance, init, ioctl, pps, send, sendraw
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OCFJCTerminal

public OCFJCTerminal()
Construct a new terminal object. Note that init() must be called before the terminal can be used.

Method Detail

close

public void close()
Close connection to card terminal. Will shut down OCF.

Specified by:
close in class JCTerminal
See Also:
JCTerminal.open()

getAvailableTerminals

public static java.lang.String[] getAvailableTerminals()
                                                throws JCException
Get a list of the available terminals as defined in the opencard.properties configuration file. The strings returned can be used as targets in the init() method. Note: this method will initialise OCF if needed.

Returns:
A list of terminal targets as a String array.
Throws:
A - JCException is thrown if OCF cannot initialize (eg. no terminal connected or no config file).
JCException

getState

public int getState()
Return the state of the terminal.

Specified by:
getState in class JCTerminal
Returns:
int The state of the terminal. See constants defined in com.ibm.jc.JCTerminal

init

public JCTerminal init(java.lang.String terminalName)
                throws JCException
Initialize the card terminal.

Parameters:
terminalName - The name of the terminal to use as defined in the opencard.properties file. Available terminals can be queried using the static getAvailableTerminals() method. If null is passed, the default/first terminal is used.
Throws:
A - JCException is thrown if OCF cannot initialize (eg. no terminal connected or no config file).
JCException

open

public void open()
Open the card terminal. Will initialise OCF if not already done.

Specified by:
open in class JCTerminal

send

public byte[] send(int nad,
                   byte[] toSend,
                   int offset,
                   int len)
            throws JCException
Send data to the card terminal.

Specified by:
send in class JCTerminal
Parameters:
nad - Node address to which data is being sent Currently ignored by implementation!!!
toSend - Byte array containing data to be send
offset - Offset starting at which data sending is to begin
len - Number of bytes to be transmitted
Returns:
The reponse data from the terminal
Throws:
A - JCException is thrown if communication fails or parameters are wrong.
JCException - if communication failed or if some parameters are wrong
See Also:
com.ibm.jc.JCard.send

smartCardInserted

protected void smartCardInserted(CardTerminalEvent pCardTerminalEvent)
Event method called by OCF when a card is inserted.

Parameters:
pCardTerminalEvent - The event object.

smartCardRemoved

protected void smartCardRemoved(CardTerminalEvent pCardTerminalEvent)
Event method called by OCF when a card is removed.

Parameters:
pCardTerminalEvent - The event object.

toString

public java.lang.String toString()
Return the terminal description.

Overrides:
toString in class JCTerminal
Returns:
The description of this card terminal as defined in the opencard.properties configuration file.

waitForCard

public byte[] waitForCard(int time)
                   throws JCException
Wait for insertion of a card and return ATR (answer to reset).

Specified by:
waitForCard in class JCTerminal
Parameters:
time - The time (in milliseconds) for which the call blocks.
Returns:
ATR (answer to reset) or null if no ATR could be retrieved. The reason might be that no card is inserted or because of communication problems.
Throws:
JCException