类 AbstractSentenceListener<T extends Sentence>
- 类型参数:
T- Sentence interface to be listened.
- 所有已实现的接口:
EventListener,SentenceListener
- 直接已知子类:
AbstractAISMessageListener,AbstractUBXMessageListener,SentenceListenerExamples.GSAListener,TypedSentenceListenerExample
Abstract listener for NMEA-0183 sentences. Extend this class to create a
listener for a specific sentence type and register it in a SentenceReader. For listeners that need to handle
all incoming sentences, it is recommended to implement the SentenceListener interface.
Recommended usage:
class MyListener extends AbstractSentenceListener<GGASentence>
Notice that more advanced use of generics and inheritance may require using
the AbstractSentenceListener(Class) constructor. For example, the
following example won't work because of the generic types not being available
at runtime:
class MyListener<A, B extends Sentence> extends AbstractSentenceListener<B> ... MyListener<String, GGASentence> ml = new MyListener<>();
Methods of the SentenceListener interface implemented by this class
are empty, except for sentenceRead(net.sf.marineapi.nmea.event.SentenceEvent) which is final
and detects the incoming sentences and casts them in correct interface
before calling the sentenceRead(net.sf.marineapi.nmea.sentence.Sentence) method. The other methods
may be overridden as needed.
- 作者:
- Kimmo Tuukkanen
- 另请参阅:
-
构造器概要
构造器限定符构造器说明Default constructor with automatic generic type resolving.protectedConstructor with explicit generic type parameter. -
方法概要
修饰符和类型方法说明voidEmpty implementation.voidEmpty implementation.voidEmpty implementation.final voidsentenceRead(SentenceEvent event) Invoked for all received sentences.abstract voidsentenceRead(T sentence) Invoked when sentence of typeTis received.
-
构造器详细资料
-
AbstractSentenceListener
public AbstractSentenceListener()Default constructor with automatic generic type resolving. Notice that theGenericTypeResolvermay not always succeed.- 抛出:
IllegalStateException- If the generic type cannot be resolved at runtime.- 另请参阅:
-
AbstractSentenceListener
Constructor with explicit generic type parameter. This constructor may be used when the default constructor fails to resolve the generic typeTat runtime.- 参数:
c- Sentence typeTto be listened.- 另请参阅:
-
-
方法详细资料
-
sentenceRead
Invoked for all received sentences. Checks the type of each sentence and invokes the
sentenceRead(net.sf.marineapi.nmea.sentence.Sentence)if it matches the listener's generic typeT.This method has been declared
finalto ensure the correct filtering of sentences.- 指定者:
sentenceRead在接口中SentenceListener- 参数:
event- SentenceEvent containing the data.
-
sentenceRead
Invoked when sentence of typeTis received.- 参数:
sentence- Sentence of typeT
-
readingPaused
public void readingPaused()Empty implementation.- 指定者:
readingPaused在接口中SentenceListener
-
readingStarted
public void readingStarted()Empty implementation.- 指定者:
readingStarted在接口中SentenceListener
-
readingStopped
public void readingStopped()Empty implementation.- 指定者:
readingStopped在接口中SentenceListener
-