Package au.gov.amsa.ais
Class Util
- java.lang.Object
-
- au.gov.amsa.ais.Util
-
public final class Util extends java.lang.ObjectAis utility methods.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanareEqual(int i, int j)Returns true if and only if given integers are equal.static voidcheckArgument(boolean b, java.lang.String message)Throws an AisParseException with given message if b is false.static voidcheckLat(double lat)Check lat is within allowable range as per 1371-4.pdf.static voidcheckLatLong(double lat, double lon)Check lat lon are withing allowable range as per 1371-4.pdf.static voidcheckLong(double lon)Check lon is within allowable range as per 1371-4.pdf.static voidcheckMessageId(int messageId, AisMessageType... messageTypes)Check message id corresponds to one of the given list of message types.protected static java.lang.StringdecodeMessage(java.lang.String encodedMessage)Returns decoded message from ascii 8 bit to 6 bit binary then to characters.static AisExtractorFactorygetAisExtractorFactory()Returns singletonAisExtractorFactory.protected static java.lang.StringgetAsciiStringFrom6BitStr(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 characterprotected static intgetValueByBinStr(java.lang.String binaryString, boolean signed)Get a value for specified bits from the binary string.static booleanisClassAPositionReport(int messageId)Returns true if and only if given messageId corresponds to a class A position report (message ids 1,2,3).
-
-
-
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-
-
getAisExtractorFactory
public static AisExtractorFactory getAisExtractorFactory()
Returns singletonAisExtractorFactory.- Returns:
-
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:
-
-