Class ReaderService

java.lang.Object
com.rvi.service.ReaderService
All Implemented Interfaces:
IReaderService, AutoCloseable

public final class ReaderService extends Object implements IReaderService
  • Constructor Details

    • ReaderService

      public ReaderService()
    • ReaderService

      public ReaderService(IReaderRepository repository)
  • Method Details

    • listReaders

      public static List<String> listReaders()
      Lists exact PC/SC reader names without connecting to a card.
      Returns:
      an immutable list, empty when no reader is connected
      Throws:
      ReaderServiceException - if PC/SC discovery fails
    • create

      public static IReaderService create()
      Creates a disconnected service selecting the first available reader at connect time.
    • create

      public static IReaderService create(String readerName)
      Creates a disconnected service selecting the exact, nonblank PC/SC reader name at connect time.
    • createForTerminal

      public static IReaderService createForTerminal(CardTerminal terminal)
      Creates a disconnected service for the supplied monitor terminal.
    • connect

      public void connect()
      Description copied from interface: IReaderService
      Connects immediately. Place a card on the reader first; does not wait for insertion.
      Specified by:
      connect in interface IReaderService
    • disconnect

      public void disconnect()
      Description copied from interface: IReaderService
      Releases the owned card connection. Safe to call repeatedly.
      Specified by:
      disconnect in interface IReaderService
    • encodeURI

      public NDefMessage encodeURI(String message)
      Description copied from interface: IReaderService
      Encodes one absolute URI, including HTTP, HTTPS, tel and mailto; no hardware needed.
      Specified by:
      encodeURI in interface IReaderService
    • encodeURIs

      public NDefMessage encodeURIs(List<String> urls)
      Description copied from interface: IReaderService
      Encodes a nonempty list of absolute URIs in order; no hardware needed.
      Specified by:
      encodeURIs in interface IReaderService
    • read

      public NDefMessage read()
      Description copied from interface: IReaderService
      Reads validated NDEF bytes. Requires connect(); use readContents() for typed values.
      Specified by:
      read in interface IReaderService
    • write

      public void write(NDefMessage message)
      Description copied from interface: IReaderService
      Replaces card content and verifies it by reading back. Requires connect().
      Specified by:
      write in interface IReaderService
    • close

      public void close()
      Description copied from interface: IReaderService
      Releases the card connection, including when leaving a try-with-resources block.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface IReaderService