use of net.sf.marineapi.nmea.event.SentenceListener in project marine-api by ktuukkan.
the class SentenceReader method fireSentenceEvent.
/**
* Dispatch data to all listeners.
*
* @param sentence sentence string.
*/
void fireSentenceEvent(Sentence sentence) {
String type = sentence.getSentenceId();
Set<SentenceListener> targets = new HashSet<SentenceListener>();
if (listeners.containsKey(type)) {
targets.addAll(listeners.get(type));
}
if (listeners.containsKey(DISPATCH_ALL)) {
targets.addAll(listeners.get(DISPATCH_ALL));
}
for (SentenceListener listener : targets) {
try {
SentenceEvent se = new SentenceEvent(this, sentence);
listener.sentenceRead(se);
} catch (Exception e) {
LOGGER.log(Level.WARNING, LOG_MSG, e);
}
}
}
Aggregations