PCSC4Java  0.2
Library PCSC for Java language.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
fr.redbilled.pcscforjava.CardTerminals Class Reference
Inheritance diagram for fr.redbilled.pcscforjava.CardTerminals:

List of all members.

Classes

enum  State

Public Member Functions

List< CardTerminallist () throws CardException
abstract List< CardTerminallist (State state) throws CardException
CardTerminal getTerminal (String name)
void waitForChange () throws CardException
abstract boolean waitForChange (long timeout) throws CardException
abstract boolean isValidContext ()
abstract void closeContext () throws CardException
abstract void updateCardTerminalsListByEvent () throws CardException
abstract boolean isPlugAndPlaySupported () throws CardException

Protected Member Functions

 CardTerminals ()
void finalize () throws Throwable

Detailed Description

The set of terminals supported by a TerminalFactory. This class allows applications to enumerate the available CardTerminals, obtain a specific CardTerminal, or wait for the insertion or removal of cards.

This class is multi-threading safe and can be used by multiple threads concurrently. However, this object keeps track of the card presence state of each of its terminals. Multiple objects should be used if independent calls to waitForChange} are required.

Applications can obtain instances of this class by calling TerminalFactory::terminals}.

See also:
TerminalFactory
CardTerminal
Since:
1.6
Author:
Andreas Sterbenz
JSR 268 Expert Group

Definition at line 51 of file CardTerminals.java.


Constructor & Destructor Documentation

Constructs a new CardTerminals object.

This constructor is called by subclasses only. Application should call TerminalFactory::terminals} to obtain a CardTerminals object.

Definition at line 60 of file CardTerminals.java.


Member Function Documentation

abstract void fr.redbilled.pcscforjava.CardTerminals.closeContext ( ) throws CardException [pure virtual]

Closes an established resource manager context. It is a good way to finish the use of the smart card API.

Exceptions:
CardExceptionif the card operation failed

Here is the caller graph for this function:

void fr.redbilled.pcscforjava.CardTerminals.finalize ( ) throws Throwable [protected]

Destructs the CardTerminals object.

Definition at line 256 of file CardTerminals.java.

Here is the call graph for this function:

Returns the terminal with the specified name or null if no such terminal exists.

Returns:
the terminal with the specified name or null if no such terminal exists.
Exceptions:
NullPointerExceptionif name is null

Definition at line 113 of file CardTerminals.java.

Here is the call graph for this function:

Here is the caller graph for this function:

abstract boolean fr.redbilled.pcscforjava.CardTerminals.isValidContext ( ) [pure virtual]

Check if the current resource manager context is in valid state or not. It is a good way to be sure that the current resources are always available and up to date.

Returns:
false if the current resource manager context is no more valid, true otherwise.
Exceptions:
CardExceptionif the card operation failed

Returns an unmodifiable list of all available terminals.

Returns:
an unmodifiable list of all available terminals.
Exceptions:
CardExceptionif the card operation failed

Definition at line 71 of file CardTerminals.java.

Here is the caller graph for this function:

abstract List<CardTerminal> fr.redbilled.pcscforjava.CardTerminals.list ( State  state) throws CardException [pure virtual]

Returns an unmodifiable list of all terminals matching the specified state.

If state is State.ALL, this method returns all CardTerminals encapsulated by this object. If state is State.CARD_PRESENT or State.CARD_ABSENT, it returns all CardTerminals where a card is currently present or absent, respectively.

If state is State.CARD_INSERTION or State.CARD_REMOVAL, it returns all CardTerminals for which an insertion (or removal, respectively) was detected during the last call to waitForChange}. If waitForChange() has not been called on this object, CARD_INSERTION is equivalent to CARD_PRESENT and CARD_REMOVAL is equivalent to CARD_ABSENT. For an example of the use of CARD_INSERTION, see waitForChange.

Parameters:
statethe State
Returns:
an unmodifiable list of all terminals matching the specified attribute.
Exceptions:
NullPointerExceptionif attr is null
CardExceptionif the card operation failed

Updates the card terminals list when an event of type card terminal insertion / removal occurs.

This method is called as a callback by subclasses only. Application should call TerminalFactory::terminals} which launch the detection thread and call this method.

Waits for card insertion or removal in any of the terminals of this object.

This call is equivalent to calling waitForChange(long) waitForChange(0)}.

Exceptions:
IllegalStateExceptionif this CardTerminals object does not contain any terminals
CardExceptionif the card operation failed

Definition at line 140 of file CardTerminals.java.

abstract boolean fr.redbilled.pcscforjava.CardTerminals.waitForChange ( long  timeout) throws CardException [pure virtual]

Waits for card insertion or removal in any of the terminals of this object or until the timeout expires.

This method examines each CardTerminal of this object. If a card was inserted into or removed from a CardTerminal since the previous call to waitForChange(), it returns immediately. Otherwise, or if this is the first call to waitForChange() on this object, it blocks until a card is inserted into or removed from a CardTerminal.

If timeout is greater than 0, the method returns after timeout milliseconds even if there is no change in state. In that case, this method returns false; otherwise it returns true.

This method is often used in a loop in combination with list(State.CARD_INSERTION), for example:

  TerminalFactory factory = ...;
  CardTerminals terminals = factory.terminals();
  while (true) {
      for (CardTerminal terminal : terminals.list(CARD_INSERTION)) {
          // examine Card in terminal, return if it matches
      }
      terminals.waitForChange();
  }
Parameters:
timeoutif positive, block for up to timeout milliseconds; if zero, block indefinitely; must not be negative
Returns:
false if the method returns due to an expired timeout, true otherwise.
Exceptions:
IllegalStateExceptionif this CardTerminals object does not contain any terminals
IllegalArgumentExceptionif timeout is negative
CardExceptionif the card operation failed

The documentation for this class was generated from the following file: