net.sf.marineapi.nmea.io
Class SentenceReader

java.lang.Object
  extended by net.sf.marineapi.nmea.io.SentenceReader

public class SentenceReader
extends Object

Sentence provider reads NMEA sentences from the specified InputStream and dispatches them to listeners as SentenceEvents.

The sentence parsers dispatched by reader are created using the SentenceFactory where you can also register your own custom parsers.

Version:
$Revision: 100 $
Author:
Kimmo Tuukkanen
See Also:
SentenceListener, SentenceEvent

Constructor Summary
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.
protected  void finalize()
           
 int getPauseTimeout()
          Returns the current reading paused timeout.
 void removeSentenceListener(SentenceListener sl)
          Remove a listener from reader.
 void setInputStream(InputStream stream)
          Sets the input stream from which to read NMEA data.
 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, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SentenceReader

public SentenceReader(InputStream source)
Creates a new instance of SentenceReader.

Parameters:
source - Stream from which to read NMEA data
Method Detail

addSentenceListener

public void addSentenceListener(SentenceListener listener)
Adds a SentenceListener that wants to receive all sentences read by the reader.

Parameters:
listener - SentenceListener to be registered.
See Also:
SentenceListener

addSentenceListener

public void addSentenceListener(SentenceListener sl,
                                SentenceId type)
Adds a SentenceListener that is interested in receiving only sentences of certain type.

Parameters:
sl - SentenceListener to add
type - Sentence type for which the listener is registered.
See Also:
SentenceListener

addSentenceListener

public void addSentenceListener(SentenceListener sl,
                                String type)
Adds a SentenceListener that is interested in receiving only sentences of certain type.

Parameters:
sl - SentenceListener to add
type - Sentence type for which the listener is registered.
See Also:
SentenceListener

getPauseTimeout

public int getPauseTimeout()
Returns the current reading paused timeout.

Returns:
Timeout limit in milliseconds.
See Also:
setPauseTimeout(int)

removeSentenceListener

public void removeSentenceListener(SentenceListener sl)
Remove a listener from reader. When removed, listener will not receive any events from the reader.

Parameters:
sl - SentenceListener to be removed.

setInputStream

public void setInputStream(InputStream stream)
Sets the input stream from which to read NMEA data. If reader is running, it is first stopped and you must call start() to resume reading.

Parameters:
stream - New input stream to set.

setPauseTimeout

public void setPauseTimeout(int millis)
Set timeout time for reading paused events. Default is 5000 ms.

Parameters:
millis - Timeout in milliseconds.

start

public void start()
Starts reading the input stream and dispatching events.


stop

public void stop()
Stops the reader and event dispatching.


finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable


Copyright (C) 2010-2011 Java Marine API author(s). All Rights Reserved.