use of au.gov.amsa.ais.message.AisMessageOther in project risky by amsa-code.
the class StreamsTest method stringRepresentationOfTimestampedAndLineContainsMessageInCaseOfSuccess.
@Test
public void stringRepresentationOfTimestampedAndLineContainsMessageInCaseOfSuccess() {
final Timestamped<AisMessage> aisMessage = new Timestamped<>(new AisMessageOther(4242, "source", 0), 0);
final TimestampedAndLine<AisMessage> message = new TimestampedAndLine<>(Optional.of(aisMessage), "test", null);
final String representation = message.toString();
assertNotNull(representation);
assertTrue("String representation should contain message ID, but got: " + representation, representation.contains("4242"));
}
use of au.gov.amsa.ais.message.AisMessageOther in project risky by amsa-code.
the class AisMessageParser method parse.
/**
* Returns an {@link AisMessage} from the string representation of the
* message as per 1371-4 IMO specification (as per the appropriate column in
* the NMEA message).
*
* @param message
* @param source
* @return
*/
public AisMessage parse(String message, String source, int padBits) {
AisExtractor extractor = factory.create(message, 0, padBits);
int id = extractor.getMessageId();
if (Util.isClassAPositionReport(id)) {
return new AisPositionA(message, source, padBits);
} else if (id == 4)
return new AisBaseStation(message, source, padBits);
else if (id == 5)
return new AisShipStaticA(message, source, padBits);
else if (id == 18)
return new AisPositionB(message, source, padBits);
else if (id == 19)
return new AisPositionBExtended(message, source, padBits);
else if (id == 21)
return new AisAidToNavigation(message, source, padBits);
else if (id == AisMessageType.STATIC_DATA_REPORT.getId()) {
int partNumber = AbstractAisBStaticDataReport.extractPartNumber(factory, message, padBits);
return parseStaticDataReport(partNumber, id, message, source, padBits);
} else if (id == 27)
return new AisPositionGPS(message, source, padBits);
else
return new AisMessageOther(id, source, padBits);
}
Aggregations