package gmt.protocol.ais.type;

public enum IECType {
	NONE("NONE"),
	VDM("VDM"),
	VDO("VDO"),
	ABK("ABK"),
	ALR("ALR"),
	TXT("TXT"),
	ACA("ACA"),
	ASN("ASN"),
	RES("RES"),
	SLT("SLT"),
	CAB("CAB"),
	BCF("BCF");	
	
	private final String typeName;
	
	private IECType(String name) {
		this.typeName = name;
	}	
	
	public String getName() {
		return this.typeName;
	}
	
	public static IECType getIECType(String msg) {
		IECType type = IECType.NONE;
		
		String header = msg.substring(3,  6);
		if ( header.equals(VDM.name()) ) {
			type = IECType.VDM;
		} else
		if ( header.equals(VDO.name()) ) {
			type = IECType.VDO;
		} else
		if ( header.equals(ABK.name()) ) {
			type = IECType.ABK;
		} else
		if ( header.equals(ALR.name()) ) {
			type = IECType.ALR;
		} else
		if ( header.equals(TXT.name()) ) {
			type = IECType.TXT;
		} else
		if ( header.equals(ACA.name()) ) {
			type = IECType.ACA;
		} else
		if ( header.equals(ASN.name()) ) {
			type = IECType.ASN;
		} else
		if ( header.equals(RES.name()) ) {
			type = IECType.RES;
		} else
		if ( header.equals(SLT.name()) ) {
			type = IECType.SLT;
		} else
		if ( header.equals(CAB.name()) ) {
			type = IECType.CAB;
		} else
		if ( header.equals(BCF.name()) ) {
			type = IECType.BCF;
		}	
		
		return type;
	}

}
