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();
}
Returns:
false if the method returns due to an expired timeout,
true otherwise.
Parameters:
-
timeout - if positive, block for up to
timeout
milliseconds; if zero, block indefinitely; must not be negative
Throws:
-
IllegalStateException - if this
CardTerminals
object does not contain any terminals
-
IllegalArgumentException - if timeout is negative
-
CardException - if the card operation failed