public final class ProtocolAdapter
extends java.lang.Object
The InputStream
instance must provide a proper implementation of
InputStream.available()
method.
Modifier and Type | Class and Description |
---|---|
static interface |
ProtocolAdapter.BarcodeListener
Interface definition for a callbacks to notify for barcode event.
|
static interface |
ProtocolAdapter.CardListener
Interface definition for a callbacks to notify for card event.
|
class |
ProtocolAdapter.Channel
This class represents a protocol channel.
|
static interface |
ProtocolAdapter.PrinterListener
Interface definition for a callbacks to notify for printer event.
|
Modifier and Type | Field and Description |
---|---|
static int |
CHANNEL_EMSR |
static int |
CHANNEL_PRINTER
The channel associated with printer hardware module.
|
static int |
CHANNEL_RFID
The channel associated with RFID reader.
|
static int |
CHANNEL_UNIVERSAL_READER
The channel associated with Universal Reader hardware module.
|
Constructor and Description |
---|
ProtocolAdapter(java.io.InputStream in,
java.io.OutputStream out)
Constructs a new instance of this class from a given
InputStream and OutputStream . |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the streams and release all associated resources.
|
ProtocolAdapter.Channel |
getChannel(int channel)
Gets an instance of
ProtocolAdapter.Channel from specified channel
number. |
java.io.InputStream |
getRawInputStream()
Get input stream that is not wrap by protocol data.
|
java.io.OutputStream |
getRawOutputStream()
Get output stream that is not wrap by protocol data.
|
boolean |
isProtocolEnabled()
Return
true if protocol mode is currently enabled. |
void |
setBarcodeListener(ProtocolAdapter.BarcodeListener listener)
Set a callback listener to notify for barcode event.
|
void |
setCardListener(ProtocolAdapter.CardListener listener)
Set a callback listener to notify for card event.
|
static void |
setDebug(boolean on)
Specify whether the object can output debug information
|
void |
setPrinterListener(ProtocolAdapter.PrinterListener listener)
Set a callback listener to notify for printer event.
|
public static final int CHANNEL_PRINTER
public static final int CHANNEL_EMSR
public static final int CHANNEL_UNIVERSAL_READER
public static final int CHANNEL_RFID
public ProtocolAdapter(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
InputStream
and OutputStream
.
If in
or out
is null
, a
NullPointerException
is thrown.
in
- the input stream.out
- the output stream.java.io.IOException
- if an I/O error occurs.public void close()
public static void setDebug(boolean on)
on
- True to enable debbuging; otherwise false.public void setBarcodeListener(ProtocolAdapter.BarcodeListener listener)
listener
- the listener.public void setCardListener(ProtocolAdapter.CardListener listener)
listener
- the listener.public void setPrinterListener(ProtocolAdapter.PrinterListener listener)
listener
- the listener.public boolean isProtocolEnabled()
true
if protocol mode is currently enabled.public ProtocolAdapter.Channel getChannel(int channel)
ProtocolAdapter.Channel
from specified channel
number.channel
- the channel number. See the CHANNEL_
*
constant field values.ProtocolAdapter.Channel
.public java.io.InputStream getRawInputStream()
public java.io.OutputStream getRawOutputStream()