IReaderRepository
com.rvi.application.IReaderRepository · Interface · SocialCard 1.0.3
Define the card transport contract used by the reader service.
When to use it
Section titled “When to use it”Use this interface to provide an alternative transport or to test code that uses ReaderService. Implement read() and write(message). Apply size and access checks and verify stored data if your implementation writes real tags. With an injected repository, the application owns the connection and calls the service directly without connect().
Java example
Section titled “Java example”final NDefMessage initial = new NDefEncoder().encodeURI("https://example.com");final IReaderRepository memory = new IReaderRepository() { private NDefMessage stored = initial;
@Override public NDefMessage read() { return stored; }
@Override public void write(final NDefMessage message) { stored = message; }};
try (final IReaderService reader = new ReaderService(memory)) { reader.writeURI("https://rithush.dev"); System.out.println(reader.readURIs());}Java imports
import com.rvi.application.IReaderRepository;import com.rvi.application.NDefEncoder;import com.rvi.domain.NDefMessage;import com.rvi.service.IReaderService;import com.rvi.service.ReaderService;The fake simulates a successful read and write. It cannot verify tag capacity or physical reader behaviour.
How it works
Section titled “How it works”Both operations can declare CardException. ReaderService wraps checked card failures as ReaderServiceException when it invokes the repository. An injected repository lets you exercise service code without a PC/SC device.