public interface ObservableReader extends Reader
Modifier and Type | Interface and Description |
---|---|
static class |
ObservableReader.NotificationMode
Indicates the expected behavior when processing a default selection.
|
static class |
ObservableReader.PollingMode
Indicates the action to be taken after processing a card.
|
static interface |
ObservableReader.ReaderObserver
This interface has to be implemented by reader observers.
|
Modifier and Type | Method and Description |
---|---|
void |
addObserver(ObservableReader.ReaderObserver observer)
Register a new reader observer to be notified when a reader event occurs.
|
void |
clearObservers()
Unregister all observers at once
|
int |
countObservers()
Provides the current number of registered observers
|
void |
finalizeCardProcessing()
Terminates the processing of the card, in particular after an interruption by exception
Do nothing if the channel is already closed. Channel closing is nominally managed by using the ChannelControl.CLOSE_AFTER flag
during the last transmission with the card. |
void |
removeObserver(ObservableReader.ReaderObserver observer)
Unregister a reader observer.
|
void |
setDefaultSelectionRequest(AbstractDefaultSelectionsRequest defaultSelectionsRequest,
ObservableReader.NotificationMode notificationMode)
Defines the default selection request to be processed when a card is inserted.
|
void |
setDefaultSelectionRequest(AbstractDefaultSelectionsRequest defaultSelectionsRequest,
ObservableReader.NotificationMode notificationMode,
ObservableReader.PollingMode pollingMode)
Defines the default selection request and starts the card detection using the provided polling
mode.
|
void |
startCardDetection(ObservableReader.PollingMode pollingMode)
Starts the card detection.
|
void |
stopCardDetection()
Stops the card detection.
|
activateProtocol, deactivateProtocol, getName, isCardPresent, isContactless
void addObserver(ObservableReader.ReaderObserver observer)
The provided observer will receive all the events produced by this reader (card insertion, removal, etc.)
It is possible to add as many observers as necessary. They will be notified of events sequentially in the order in which they are added.
observer
- An observer object implementing the required interface (should be not null).void removeObserver(ObservableReader.ReaderObserver observer)
The observer will no longer receive any of the events produced by this reader.
observer
- The observer object to be removed (should be not null).void clearObservers()
int countObservers()
void startCardDetection(ObservableReader.PollingMode pollingMode)
The ObservableReader.PollingMode
indicates the action to be followed after processing the card: if
ObservableReader.PollingMode.REPEATING
, the card detection is restarted, if ObservableReader.PollingMode.SINGLESHOT
, the card detection is stopped until a new call to startCardDetection
is made
pollingMode
- The polling mode to use (should be not null).void stopCardDetection()
void setDefaultSelectionRequest(AbstractDefaultSelectionsRequest defaultSelectionsRequest, ObservableReader.NotificationMode notificationMode)
Depending on the card and the notificationMode parameter, a EventType#CARD_INSERTED
, EventType#CARD_MATCHED
or no event at all will be notified
to the application observers.
defaultSelectionsRequest
- The default selection request to be operated (should be not
null).notificationMode
- The notification mode to use (should be not null).void setDefaultSelectionRequest(AbstractDefaultSelectionsRequest defaultSelectionsRequest, ObservableReader.NotificationMode notificationMode, ObservableReader.PollingMode pollingMode)
The notification mode indicates whether a ReaderEvent.EventType.CARD_INSERTED
event
should be notified even if the selection has failed (ObservableReader.NotificationMode.ALWAYS
) or
whether the card insertion should be ignored in this case (ObservableReader.NotificationMode.MATCHED_ONLY
).
The polling mode indicates the action to be followed after processing the card: if ObservableReader.PollingMode.REPEATING
, the card detection is restarted, if ObservableReader.PollingMode.SINGLESHOT
, the
card detection is stopped until a new call to * startCardDetection is made.
defaultSelectionsRequest
- The default selection request to be operated.notificationMode
- The notification mode to use (should be not null).pollingMode
- The polling mode to use (should be not null).void finalizeCardProcessing()
ChannelControl.CLOSE_AFTER
flag
during the last transmission with the card. However, there are cases where exchanges with the
card are interrupted by an exception, in which case it is necessary to explicitly close the
channel using this method.