java.lang.Object
dk.tbsalling.aismessages.ais.messages.AISMessage
All Implemented Interfaces:
CachedDecodedValues, Serializable
Direct Known Subclasses:
AddressedBinaryMessage, AddressedSafetyRelatedMessage, AidToNavigationReport, AssignedModeCommand, BaseStationReport, BinaryAcknowledge, BinaryBroadcastMessage, BinaryMessageMultipleSlot, BinaryMessageSingleSlot, ChannelManagement, ClassBCSStaticDataReport, DataLinkManagement, Error, ExtendedClassBEquipmentPositionReport, GNSSBinaryBroadcastMessage, GroupAssignmentCommand, Interrogation, LongRangeBroadcastMessage, PositionReport, SafetyRelatedAcknowledge, SafetyRelatedBroadcastMessage, ShipAndVoyageData, StandardClassBCSPositionReport, StandardSARAircraftPositionReport, UTCAndDateInquiry, UTCAndDateResponse

public abstract class AISMessage
extends Object
implements Serializable, CachedDecodedValues
The AISMessage class models a complete and self-contained AIS message.

If the AISMessage was created from received NMEA strings, then the original NMEA strings are cached, together with the decoded values of the message.

Lazy extraction of values.

Author:
tbsalling
See Also:
Serialized Form
  • Field Details

  • Constructor Details

    • AISMessage

      protected AISMessage()
    • AISMessage

      protected AISMessage​(dk.tbsalling.aismessages.nmea.messages.NMEAMessage[] nmeaMessages)
    • AISMessage

      protected AISMessage​(dk.tbsalling.aismessages.nmea.messages.NMEAMessage[] nmeaMessages, String bitString)
  • Method Details

    • digest

      public byte[] digest() throws NoSuchAlgorithmException
      Compute a SHA-1 message digest of this AISmessage. Suitable for e.g. doublet discovery and filtering.
      Returns:
      Message digest
      Throws:
      NoSuchAlgorithmException - if SHA-1 algorithm is not accessible
    • dataFields

      public Map<String,​Object> dataFields()
      Returns:
      a map of data field name and values.
    • checkAISMessage

      protected void checkAISMessage()
      This method performs a rudimentary sanity check of the AIS data payload contained in the NMEA sentence(s). These tests are mainly based on bitwise message length, even though other types of tests may occur.
      Throws:
      dk.tbsalling.aismessages.nmea.exceptions.InvalidMessage - if the AIS payload of the NMEAmessage(s) is invalid.
    • getNmeaMessages

      public dk.tbsalling.aismessages.nmea.messages.NMEAMessage[] getNmeaMessages()
    • getMessageType

      public abstract AISMessageType getMessageType()
    • getMetadata

      public final Metadata getMetadata()
    • setMetadata

      public final void setMetadata​(Metadata metadata)
    • setTagBlock

      public final void setTagBlock​(dk.tbsalling.aismessages.nmea.tagblock.NMEATagBlock nmeaTagBlock)
    • getNmeaTagBlock

      public final dk.tbsalling.aismessages.nmea.tagblock.NMEATagBlock getNmeaTagBlock()
    • getRepeatIndicator

      public final Integer getRepeatIndicator()
    • getSourceMmsi

      public final MMSI getSourceMmsi()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • tagBlockToString

      public String tagBlockToString()
    • getBitString

      protected String getBitString()
    • getZeroBitStuffedString

      protected String getZeroBitStuffedString​(int endIndex)
    • getBits

      public String getBits​(int beginIndex, int endIndex)
    • getNumberOfBits

      protected int getNumberOfBits()
    • decodePayloadToBitString

      protected static String decodePayloadToBitString​(dk.tbsalling.aismessages.nmea.messages.NMEAMessage... nmeaMessages)
    • create

      public static AISMessage create​(Metadata metadata, dk.tbsalling.aismessages.nmea.messages.NMEAMessage... nmeaMessages)
      Create proper type of AISMessage from 1..n NMEA messages, and attach metadata.
      Parameters:
      metadata - Meta data
      nmeaMessages - NMEA messages
      Returns:
      AISMessage the AIS message
      Throws:
      dk.tbsalling.aismessages.nmea.exceptions.InvalidMessage - if the AIS payload of the NMEAmessage(s) is invalid
    • create

      public static AISMessage create​(Metadata metadata, dk.tbsalling.aismessages.nmea.tagblock.NMEATagBlock nmeaTagBlock, dk.tbsalling.aismessages.nmea.messages.NMEAMessage... nmeaMessages)
      Create proper type of AISMessage from 1..n NMEA messages, and attach metadata.
      Parameters:
      metadata - Meta data
      nmeaTagBlock - NMEA Tag Block
      nmeaMessages - NMEA messages
      Returns:
      AISMessage the AIS message
      Throws:
      dk.tbsalling.aismessages.nmea.exceptions.InvalidMessage - if the AIS payload of the NMEAmessage(s) is invalid
    • create

      public static AISMessage create​(dk.tbsalling.aismessages.nmea.messages.NMEAMessage... nmeaMessages)
      Create proper type of AISMessage from 1..n NMEA messages.
      Parameters:
      nmeaMessages - NMEA messages
      Returns:
      AISMessage the AIS message
      Throws:
      dk.tbsalling.aismessages.nmea.exceptions.InvalidMessage - if the AIS payload of the NMEAmessage(s) is invalid
    • isValid

      public boolean isValid()
    • equals

      public boolean equals​(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object