- All Implemented Interfaces:
AutoCloseable
CardTerminals.- Author:
- gematik
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.smartcardio.CardTerminals
CardTerminals.State -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this resource, relinquishing any underlying resources.booleanisClosed()Getter.list(CardTerminals.State state) Returns an unmodifiable list of all terminals matching the specified state.booleanwaitForChange(long timeout) Waits for card insertion or removal in any terminal of this object or until the timeout expires.Methods inherited from class javax.smartcardio.CardTerminals
getTerminal, list, waitForChange
-
Constructor Details
-
IfdCollection
public IfdCollection()Default constructor.
-
-
Method Details
-
list
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 isState.CARD_PRESENTorState.CARD_ABSENT, it returns all CardTerminals where a card is currently present or absent, respectively.If state is
State.CARD_INSERTIONorState.CARD_REMOVAL, it returns all CardTerminals for which an insertion (or removal, respectively) was detected during the last call towaitForChange(long). IfwaitForChange()has not been called on this object,CARD_INSERTIONis equivalent toCARD_PRESENTandCARD_REMOVALis equivalent toCARD_ABSENT. For an example of the use ofCARD_INSERTION, seewaitForChange(long).- Specified by:
listin classCardTerminals- Parameters:
state- theStateof each element in the returned list- Returns:
- an unmodifiable list of all terminals matching the specified
state. - Throws:
NullPointerException- if state is nullCardException- if the card operation failed- See Also:
-
waitForChange
Waits for card insertion or removal in any terminal 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 towaitForChange()on this object, it blocks until a card is inserted into or removed from a CardTerminal.If
timeoutis greater than 0, the method returns aftertimeoutmilliseconds even if there is no change in state. In that case, this method returnsfalse; otherwise it returnstrue.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(); }- Specified by:
waitForChangein classCardTerminals- Parameters:
timeout- if positive, block for up totimeoutmilliseconds; if zero, block indefinitely; must not be negative- Returns:
- false if the method returns due to an expired timeout, true otherwise.
- Throws:
IllegalStateException- if thisCardTerminalsobject does not contain any terminalsIllegalArgumentException- if timeout is negativeCardException- if the card operation failed- See Also:
-
close
Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by thetry-with-resources statement.- Specified by:
closein interfaceAutoCloseable- Throws:
PcscException- if this resource cannot be closed- See Also:
-
isClosed
public boolean isClosed()Getter.- Returns:
TRUEifclose()has previously been called,FALSEotherwise
-