Package NMEA

Class NMEABitArray

java.lang.Object
NMEA.NMEABitArray

public class NMEABitArray extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final char[]
    Lookup table to convert from integer to 6 bit ASCII data for AIS vessel names, destinations, etc.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    NMEABitArray(int size)
     
    NMEABitArray(int size, int[] bits)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte
    convert628(char ch)
    converts a character from an AIS data string into a six bit integer value packed into an 8 bit byte.
    static char
    convert826(int n)
    Convert a six bit integer value to AIS / NMEA character data
    static byte[]
    Converts the character lookup data to an integer-to-character LUT, where the indexing is the standard ASCII character, converted to an integer.
    final boolean
    getBit(int bit)
    Returns true if the given bit is set
    int
    getSignedInteger(int b1, int b2)
    Get a signed integer from the bit array.
    getString(int b1, int b2)
    Gets a string based on packed bits from an AIS string using the 6 bit ascii character set.
    int
    getUnsignedInteger(int b1, int b2)
    Get an unsigned integer from the bit array.
    final void
    setBit(int bit)
    Sets a given bit
    final int
    Returns the size of this bit array (in bits).
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • ASCII6

      public static final char[] ASCII6
      Lookup table to convert from integer to 6 bit ASCII data for AIS vessel names, destinations, etc. Table 23 from page 55 of IEC 61993
  • Constructor Details

    • NMEABitArray

      public NMEABitArray()
    • NMEABitArray

      public NMEABitArray(int size, int[] bits)
    • NMEABitArray

      public NMEABitArray(int size)
  • Method Details

    • getBit

      public final boolean getBit(int bit)
      Returns true if the given bit is set
    • setBit

      public final void setBit(int bit)
      Sets a given bit
    • size

      public final int size()
      Returns the size of this bit array (in bits).
    • getUnsignedInteger

      public int getUnsignedInteger(int b1, int b2)
      Get an unsigned integer from the bit array.

      Integers can be any number of bits. The first bit is the most significant.

      Parameters:
      b1 - First bit to unpack
      b2 - Last bit to unpack
      Returns:
      unsigned integer value
    • getSignedInteger

      public int getSignedInteger(int b1, int b2)
      Get a signed integer from the bit array.

      Integers can be any number of bits and are stored in 2's compliment format.

      Parameters:
      b1 - First bit to unpack
      b2 - Last bit to unpack
      Returns:
      signed integer value
    • getString

      public String getString(int b1, int b2)
      Gets a string based on packed bits from an AIS string using the 6 bit ascii character set.
      Parameters:
      b1 - First bit from AIS / NMEA data
      b2 - Last bit from AIS / NMEA data
      Returns:
      character string
    • convert628

      public static byte convert628(char ch)
      converts a character from an AIS data string into a six bit integer value packed into an 8 bit byte.
      Parameters:
      ch - Character from AIS or NMEA string
      Returns:
      6 bit integer (0 to 63)
    • convert826

      public static char convert826(int n)
      Convert a six bit integer value to AIS / NMEA character data
      Parameters:
      n - an six bit ascii code
      Returns:
      a six bit character
    • createLUT6

      public static byte[] createLUT6()
      Converts the character lookup data to an integer-to-character LUT, where the indexing is the standard ASCII character, converted to an integer. The resulting lookup table is sparsely populated and should will return 0 for any index not used in charLUTData.
      Returns:
      a six bit value packed into one byte
    • toString

      public String toString()
      Overrides:
      toString in class Object