Class ReaderService
java.lang.Object
com.rvi.service.ReaderService
- All Implemented Interfaces:
IReaderService, AutoCloseable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Releases the card connection, including when leaving a try-with-resources block.voidconnect()Connects immediately.static IReaderServicecreate()Creates a disconnected service selecting the first available reader at connect time.static IReaderServiceCreates a disconnected service selecting the exact, nonblank PC/SC reader name at connect time.static IReaderServicecreateForTerminal(CardTerminal terminal) Creates a disconnected service for the supplied monitor terminal.voidReleases the owned card connection.Encodes one absolute URI, including HTTP, HTTPS, tel and mailto; no hardware needed.encodeURIs(List<String> urls) Encodes a nonempty list of absolute URIs in order; no hardware needed.Lists exact PC/SC reader names without connecting to a card.read()Reads validated NDEF bytes.voidwrite(NDefMessage message) Replaces card content and verifies it by reading back.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface IReaderService
readContents, readURIs, writeURI
-
Constructor Details
-
ReaderService
public ReaderService() -
ReaderService
-
-
Method Details
-
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
Creates a disconnected service selecting the first available reader at connect time. -
create
Creates a disconnected service selecting the exact, nonblank PC/SC reader name at connect time. -
createForTerminal
Creates a disconnected service for the supplied monitor terminal. -
connect
public void connect()Description copied from interface:IReaderServiceConnects immediately. Place a card on the reader first; does not wait for insertion.- Specified by:
connectin interfaceIReaderService
-
disconnect
public void disconnect()Description copied from interface:IReaderServiceReleases the owned card connection. Safe to call repeatedly.- Specified by:
disconnectin interfaceIReaderService
-
encodeURI
Description copied from interface:IReaderServiceEncodes one absolute URI, including HTTP, HTTPS, tel and mailto; no hardware needed.- Specified by:
encodeURIin interfaceIReaderService
-
encodeURIs
Description copied from interface:IReaderServiceEncodes a nonempty list of absolute URIs in order; no hardware needed.- Specified by:
encodeURIsin interfaceIReaderService
-
read
Description copied from interface:IReaderServiceReads validated NDEF bytes. Requires connect(); use readContents() for typed values.- Specified by:
readin interfaceIReaderService
-
write
Description copied from interface:IReaderServiceReplaces card content and verifies it by reading back. Requires connect().- Specified by:
writein interfaceIReaderService
-
close
public void close()Description copied from interface:IReaderServiceReleases the card connection, including when leaving a try-with-resources block.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceIReaderService
-