|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.marineapi.nmea.io.SentenceReader
public class SentenceReader
Sentence reader detects supported NMEA 0183 sentences from the specified data source and dispatches them to registered listeners as sentence events. Each event contains a parser for the read sentence.
Parsers dispatched by reader are created using SentenceFactory
class,
where you can also register your own custom parsers.
AbstractSentenceListener
,
SentenceListener
,
SentenceEvent
,
SentenceFactory
Field Summary | |
---|---|
static int |
DEFAULT_TIMEOUT
Default timeout value in milliseconds. |
Constructor Summary | |
---|---|
SentenceReader(DatagramSocket source)
Creates a SentenceReader for UDP/DatagramSocket. |
|
SentenceReader(InputStream source)
Creates a new instance of SentenceReader. |
Method Summary | |
---|---|
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. |
net.sf.marineapi.nmea.io.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 |
setExceptionListener(net.sf.marineapi.nmea.io.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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_TIMEOUT
Constructor Detail |
---|
public SentenceReader(DatagramSocket source)
source
- Socket from which to read NMEA datapublic SentenceReader(InputStream source)
source
- Stream from which to read NMEA dataMethod Detail |
---|
public 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 net.sf.marineapi.nmea.io.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 setExceptionListener(net.sf.marineapi.nmea.io.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()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |