All Downloads are FREE. Search and download functionalities are using the official Maven repository.

no.entur.android.nfc.websocket.server.PooledCardTerminal Maven / Gradle / Ivy

The newest version!
package no.entur.android.nfc.websocket.server;

import java.util.List;

import javax.smartcardio.CardException;
import javax.smartcardio.CardTerminal;

public class PooledCardTerminal {

    private final ExtendedCardTerminal cardTerminal;

    private volatile boolean borrowed = false;

    private final CardPollingServer cardPollingServer;

    private boolean closed;

    public PooledCardTerminal(ExtendedCardTerminal cardTerminal) {
        this.cardTerminal = cardTerminal;
        this.cardPollingServer = new CardPollingServer(cardTerminal);
    }

    public ExtendedCardTerminal getCardTerminal() {
        return cardTerminal;
    }

    public void setListener(CardListener listener) {
        this.cardPollingServer.setListener(listener);
    }

    public void startPolling() throws CardException {
        cardTerminal.startPolling();
        cardPollingServer.start();
    }

    public void stopPolling() throws CardException {
        cardPollingServer.stop();
        cardTerminal.stopPolling();
    }

    public boolean isBorrowed() {
        return borrowed;
    }

    public void borrow() {
        this.borrowed = true;
    }

    public void unborrow() {
        this.borrowed = false;

        cardPollingServer.setListener(null);
    }

    public void close() {
        closed = true;
    }

    public boolean isClosed() {
        return closed;
    }

    public boolean matches(List tags) {
        return cardTerminal.getTags().containsAll(tags);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy