All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.esi.metis.aisparser.impl.HandleVDMLineImpl Maven / Gradle / Ivy

Go to download

This package supports the parsing of AIS messages in Java. AIS, the Automatic Identification System, is a system aiming at improving maritime safety by exchanging messages between ships, other vehicles in particular aircraft involved in search-and-rescue (SAR), and (fixed) base stations. To be precise, this package support the ITU-R M.1371-4 AIS standard. See our extensive javadoc and in particular the class AISParser for more information on how to use this package. The parser was used in the Poseidon project, and is improved in the Metis project to better handle uncertain information. Both projects were led by the Embedded Systems Institute. In both projects Thales Nederlands was the carrying industrial partner, and multiple Dutch universities participated.

The newest version!
package nl.esi.metis.aisparser.impl;

import nl.esi.metis.aisparser.HandleInvalidVDMLine;
import nl.esi.metis.aisparser.HandleVDMLine;
import nl.esi.metis.aisparser.HandleVDMMessage;
import nl.esi.metis.aisparser.VDMLine;
import nl.esi.metis.aisparser.VDMMessage;

public class HandleVDMLineImpl implements HandleVDMLine {

	private HandleVDMMessage handler;
	private HandleInvalidVDMLine errorHandler;
	
	public HandleVDMLineImpl(HandleVDMMessage handler, HandleInvalidVDMLine errorHandler)
	{
		this.handler = handler;
		this.errorHandler = errorHandler;
	}

	private VDMMessage current = null;
	public void handleVDMLine(VDMLine line) {
		if (line.isSemanticallyValid())
		{
			if(current == null)
			{
				current = new VDMMessage(line);
			}
			else
			{
				if (current.isPartOfMessage(line))
				{
					current.add(line);
				}
				else
				{
					handler.handleVDMMessage(current);	//correctness must be checked by VDMMessageHandler	 
					current = new VDMMessage(line);
				}
			}
			
			//When message is complete, we don't wait for the next message before we process it.
			if (current.atEnd())
			{
				handler.handleVDMMessage(current);
				current = null;
			}
		}
		else
		{
			errorHandler.handleInvalidVDMLine(line);
		}
	}
	
	public void finished() {
		if(current != null)
		{
			handler.handleVDMMessage(current);
			//TODO: must finished message be passed on even further?
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy