类 SentenceReader

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

public class SentenceReader extends Object
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 the reader are created using SentenceFactory, where you can also add your own parsers at runtime.

作者:
Kimmo Tuukkanen
另请参阅:
  • 字段详细资料

    • DEFAULT_TIMEOUT

      public static final int DEFAULT_TIMEOUT
      Default timeout value in milliseconds.
      另请参阅:
  • 构造器详细资料

    • SentenceReader

      public SentenceReader(DatagramSocket source)
      Creates a SentenceReader for UDP/DatagramSocket.
      参数:
      source - Socket from which to read NMEA data
    • SentenceReader

      public SentenceReader(InputStream source)
      Creates a new instance of SentenceReader.
      参数:
      source - Stream from which to read NMEA data
    • SentenceReader

      public SentenceReader(AbstractDataReader reader)
      Creates a new instance of SentenceReader with custom data reader.
      参数:
      reader - Custom data reader to use.
      另请参阅:
  • 方法详细资料

    • addSentenceListener

      public void addSentenceListener(SentenceListener listener)
      Adds a SentenceListener to receive all incoming sentences.
      参数:
      listener - SentenceListener to be registered.
      另请参阅:
    • addSentenceListener

      public void addSentenceListener(SentenceListener sl, SentenceId type)
      Adds a SentenceListener to receive sentences of specified type.
      参数:
      sl - SentenceListener to add
      type - Sentence type for which the listener is registered.
      另请参阅:
    • addSentenceListener

      public void addSentenceListener(SentenceListener sl, String type)
      Adds a SentenceListener to receive sentences of specified type.
      参数:
      sl - SentenceListener to add
      type - Sentence type for which the listener is registered.
      另请参阅:
    • getExceptionListener

      public ExceptionListener getExceptionListener()
      Returns the exception call-back listener.
      返回:
      Currently set ExceptionListener, or null if none.
    • getPauseTimeout

      public int getPauseTimeout()
      Returns the current reading paused timeout.
      返回:
      Timeout limit in milliseconds.
      另请参阅:
    • removeSentenceListener

      public void removeSentenceListener(SentenceListener listener)
      Removes the specified sentence listener regardless of sentence type(s) it was added for.
      参数:
      listener - SentenceListener to be removed.
    • removeSentenceListener

      public void removeSentenceListener(SentenceListener listener, SentenceId sid)
      Removes the sentence listener for specified sentence type.
      参数:
      listener - SentenceListener to be removed.
      sid - Sentence Id
    • removeSentenceListener

      public void removeSentenceListener(SentenceListener listener, String type)
      Removes the sentence listener for specified sentence type.
      参数:
      listener - SentenceListener to be removed.
      type - Sentence type
      另请参阅:
    • setDatagramSocket

      public void setDatagramSocket(DatagramSocket socket)
      Sets the DatagramSocket to be used as data source. If reader is running, it is first stopped and you must call start() to resume reading.
      参数:
      socket - DatagramSocket to set
    • setDataListener

      public void setDataListener(DataListener listener)
      Set listener for any data that is not recognized as NMEA 0183. devices and environments that produce mixed content with both NMEA and non-NMEA data.
      参数:
      listener - Listener to set, null to remove.
    • setExceptionListener

      public void setExceptionListener(ExceptionListener exceptionListener)
      Set exception call-back listener.
      参数:
      exceptionListener - Listener to set, or null to reset.
    • setInputStream

      public void setInputStream(InputStream stream)
      Sets the InputStream to be used as data source. If reader is running, it is first stopped and you must call start() to resume reading.
      参数:
      stream - InputStream to set.
    • setPauseTimeout

      public void setPauseTimeout(int millis)
      Set timeout time for reading paused events. Default is 5000 ms.
      参数:
      millis - Timeout in milliseconds.
    • start

      public void start()
      Starts reading the input stream and dispatching events.
      抛出:
      IllegalStateException - If reader is already running.
    • stop

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