public class SentenceReader extends Object
Parsers dispatched by reader are created using SentenceFactory
class,
where you can also register your own custom parsers.
AbstractSentenceListener
,
SentenceListener
,
SentenceEvent
,
SentenceFactory
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_TIMEOUT
Default timeout value in milliseconds.
|
Constructor and Description |
---|
SentenceReader(DatagramSocket source)
Creates a SentenceReader for UDP/DatagramSocket.
|
SentenceReader(InputStream source)
Creates a new instance of SentenceReader.
|
Modifier and Type | Method and Description |
---|---|
void |
addSentenceListener(SentenceListener listener)
Adds a
SentenceListener that wants to receive all sentences read
by the reader. |
void |
addSentenceListener(SentenceListener sl,
SentenceId type)
Adds a
SentenceListener that is interested in receiving only
sentences of certain type. |
void |
addSentenceListener(SentenceListener sl,
String type)
Adds a
SentenceListener that is interested in receiving only
sentences of certain type. |
ExceptionListener |
getExceptionListener()
Returns the exception call-back listener.
|
int |
getPauseTimeout()
Returns the current reading paused timeout.
|
void |
removeSentenceListener(SentenceListener listener)
Remove a listener from reader.
|
void |
setDatagramSocket(DatagramSocket socket)
Sets the DatagramSocket to be used as data source.
|
void |
setDataListener(DataListener listener)
Set listener for any data that is not recognized as NMEA 0183.
|
void |
setExceptionListener(ExceptionListener exceptionListener)
Set exception call-back listener.
|
void |
setInputStream(InputStream stream)
Sets the InputStream to be used as data source.
|
void |
setPauseTimeout(int millis)
Set timeout time for reading paused events.
|
void |
start()
Starts reading the input stream and dispatching events.
|
void |
stop()
Stops the reader and event dispatching.
|
public static final int DEFAULT_TIMEOUT
public SentenceReader(DatagramSocket source)
source
- Socket from which to read NMEA datapublic SentenceReader(InputStream source)
source
- Stream from which to read NMEA datapublic void addSentenceListener(SentenceListener listener)
SentenceListener
that wants to receive all sentences read
by the reader.listener
- SentenceListener
to be registered.SentenceListener
public void addSentenceListener(SentenceListener sl, SentenceId type)
SentenceListener
that is interested in receiving only
sentences of certain type.sl
- SentenceListener to addtype
- Sentence type for which the listener is registered.SentenceListener
public void addSentenceListener(SentenceListener sl, String type)
SentenceListener
that is interested in receiving only
sentences of certain type.sl
- SentenceListener to addtype
- Sentence type for which the listener is registered.SentenceListener
public ExceptionListener getExceptionListener()
null
if none.public int getPauseTimeout()
setPauseTimeout(int)
public void removeSentenceListener(SentenceListener listener)
listener
- SentenceListener
to be removed.public void setDatagramSocket(DatagramSocket socket)
start()
to resume reading.socket
- DatagramSocket to setpublic void setDataListener(DataListener listener)
listener
- Listener to set, null
to remove.public void setExceptionListener(ExceptionListener exceptionListener)
exceptionListener
- Listener to set, or null
to reset.public void setInputStream(InputStream stream)
start()
to resume reading.stream
- InputStream to set.public void setPauseTimeout(int millis)
millis
- Timeout in milliseconds.public void start()
IllegalStateException
- If reader is already running.public void stop()
Copyright (C) 2010-2017 Java Marine API authors. All Rights Reserved.