Class Util


  • public final class Util
    extends java.lang.Object
    Ais utility methods.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean areEqual​(int i, int j)
      Returns true if and only if given integers are equal.
      static void checkArgument​(boolean b, java.lang.String message)
      Throws an AisParseException with given message if b is false.
      static void checkLat​(double lat)
      Check lat is within allowable range as per 1371-4.pdf.
      static void checkLatLong​(double lat, double lon)
      Check lat lon are withing allowable range as per 1371-4.pdf.
      static void checkLong​(double lon)
      Check lon is within allowable range as per 1371-4.pdf.
      static void checkMessageId​(int messageId, AisMessageType... messageTypes)
      Check message id corresponds to one of the given list of message types.
      protected static java.lang.String decodeMessage​(java.lang.String encodedMessage)
      Returns decoded message from ascii 8 bit to 6 bit binary then to characters.
      static AisExtractorFactory getAisExtractorFactory()
      Returns singleton AisExtractorFactory.
      protected static java.lang.String getAsciiStringFrom6BitStr​(java.lang.String str)
      Decode 6 bit String to standard ASCII String Input is a binary string of 0 and 1 each 6 bit is a character that will be converted to the standard ASCII character
      protected static int getValueByBinStr​(java.lang.String binaryString, boolean signed)
      Get a value for specified bits from the binary string.
      static boolean isClassAPositionReport​(int messageId)
      Returns true if and only if given messageId corresponds to a class A position report (message ids 1,2,3).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getValueByBinStr

        protected static int getValueByBinStr​(java.lang.String binaryString,
                                              boolean signed)
        Get a value for specified bits from the binary string.
        Parameters:
        fromBit -
        toBit -
        Returns:
        Throws:
        AisParseException
      • decodeMessage

        protected static java.lang.String decodeMessage​(java.lang.String encodedMessage)
        Returns decoded message from ascii 8 bit to 6 bit binary then to characters.
        Parameters:
        encodedMessage -
        Returns:
      • getAsciiStringFrom6BitStr

        protected static java.lang.String getAsciiStringFrom6BitStr​(java.lang.String str)
        Decode 6 bit String to standard ASCII String Input is a binary string of 0 and 1 each 6 bit is a character that will be converted to the standard ASCII character
        Parameters:
        str -
        Returns:
      • checkLatLong

        public static void checkLatLong​(double lat,
                                        double lon)
        Check lat lon are withing allowable range as per 1371-4.pdf. Note that values of long=181, lat=91 have special meaning.
        Parameters:
        lat -
        lon -
      • checkLat

        public static void checkLat​(double lat)
        Check lat is within allowable range as per 1371-4.pdf. Note that value of lat=91 has special meaning.
        Parameters:
        lat -
      • checkLong

        public static void checkLong​(double lon)
        Check lon is within allowable range as per 1371-4.pdf. Note that value of long=181, has special meaning.
        Parameters:
        lon -
      • checkArgument

        public static void checkArgument​(boolean b,
                                         java.lang.String message)
        Throws an AisParseException with given message if b is false.
        Parameters:
        b -
        message -
      • checkMessageId

        public static void checkMessageId​(int messageId,
                                          AisMessageType... messageTypes)
        Check message id corresponds to one of the given list of message types.
        Parameters:
        messageId -
        messageTypes -
      • areEqual

        public static boolean areEqual​(int i,
                                       int j)
        Returns true if and only if given integers are equal. This was extracted to assist in source code branch coverage.
        Parameters:
        i -
        j -
        Returns:
      • isClassAPositionReport

        public static boolean isClassAPositionReport​(int messageId)
        Returns true if and only if given messageId corresponds to a class A position report (message ids 1,2,3).
        Parameters:
        messageId -
        Returns: