Search in sources :

Example 1 with SentenceListener

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);
        }
    }
}
Also used : SentenceEvent(net.sf.marineapi.nmea.event.SentenceEvent) SentenceListener(net.sf.marineapi.nmea.event.SentenceListener) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 SentenceEvent (net.sf.marineapi.nmea.event.SentenceEvent)1 SentenceListener (net.sf.marineapi.nmea.event.SentenceListener)1