Enum BinaryVectors.Endianness

    • Enum Constant Detail

      • BIG_ENDIAN

        public static final BinaryVectors.Endianness BIG_ENDIAN
        Decreasing numeric significance with increasing addresses/indices.

        Most significant part first.

      • LITTLE_ENDIAN

        public static final BinaryVectors.Endianness LITTLE_ENDIAN
        Increasing numeric significance with increasing addresses/indices.

        Least significant part first.

    • Method Detail

      • values

        public static BinaryVectors.Endianness[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (BinaryVectors.Endianness c : BinaryVectors.Endianness.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static BinaryVectors.Endianness valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • packIntsToLong

        public abstract long packIntsToLong​(int i0,
                                            int i1)
        Pack two 32 bit integers into a 64 bit long.
        Parameters:
        i0 - First integer, associated with lower index/address
        i1 - Second integer, associated with higher index/address
        Returns:
        Packed long
      • unpackInt0FromLong

        public abstract int unpackInt0FromLong​(long l)
        Unpack first 32 bit integer from a 64 bit long according to the represented endianness.
        Parameters:
        l - Packed long
        Returns:
        Integer associated with the lower index/address
      • unpackInt1FromLong

        public abstract int unpackInt1FromLong​(long l)
        Unpack second 32 bit integer from a 64 bit long according to the represented endianness.
        Parameters:
        l - Packed long
        Returns:
        Integer associated with the higher index/address
      • packBytesToLong

        public long packBytesToLong​(byte b0,
                                    byte b1,
                                    byte b2,
                                    byte b3,
                                    byte b4,
                                    byte b5,
                                    byte b6,
                                    byte b7)
        Pack eight 8 bit bytes into a 64 bit long.
        Parameters:
        b0 - First byte, associated with lowest index/address
        b1 - Second byte
        b2 - Third byte
        b3 - Fourth byte
        b4 - Fifth byte
        b5 - Sixth byte
        b6 - Seventh byte
        b7 - Eighth byte, associated with the highest index/address
        Returns:
        Packed long
      • packBytesToInt

        public int packBytesToInt​(byte b0,
                                  byte b1,
                                  byte b2,
                                  byte b3)
        Pack four 8 bit bytes into a 32 bit int.
        Parameters:
        b0 - First byte, associated with lowest index/address
        b1 - Second byte
        b2 - Third byte
        b3 - Fourth byte, associated with the highest index/address
        Returns:
        Packed int
      • packBytesToLong

        public abstract long packBytesToLong​(byte[] buffer,
                                             int firstIndex)
        Pack eight 8 bit bytes into a 64 bit long.
        Parameters:
        buffer - Buffer containing bytes to pack
        firstIndex - Index of the first byte to pack in the buffer
        Returns:
        Packed long; bytes from the given array; from given index to (including) given index + 7 are packed
      • packBytesToInt

        public abstract int packBytesToInt​(byte[] buffer,
                                           int firstIndex)
        Pack four 8 bit bytes into a 32 bit int.
        Parameters:
        buffer - Buffer containing bytes to pack
        firstIndex - Index of the first byte to pack in the buffer
        Returns:
        Packed int; bytes from the given array; from given index to (including) given index + 3 are packed
      • unpackBytesFromLong

        public byte[] unpackBytesFromLong​(long l)
        Unpack eight 8 bit bytes from a 64 bit long.
        Parameters:
        l - Packed long
        Returns:
        Array of 8 bytes. Index 0 is associated with the lowest index/address.
      • unpackBytesFromInt

        public byte[] unpackBytesFromInt​(int i)
        Unpack four 8 bit bytes from a 32 bit int.
        Parameters:
        i - Packed int
        Returns:
        Array of 4 bytes. Index 0 is associated with the lowest index/address.
      • unpackBytesFromLong

        public abstract void unpackBytesFromLong​(long l,
                                                 byte[] buffer,
                                                 int firstIndex)
        Unpack eight 8 bit bytes from a 64 bit long.
        Parameters:
        l - Packed long
        buffer - target buffer
        firstIndex - Index of the first byte to write in the buffer (associated with the lowest index/address)
      • unpackBytesFromInt

        public abstract void unpackBytesFromInt​(int i,
                                                byte[] buffer,
                                                int firstIndex)
        Unpack four 8 bit bytes from a 32 bit int.
        Parameters:
        i - Packed int
        buffer - target buffer
        firstIndex - Index of the first byte to write in the buffer (associated with the lowest index/address)
      • parseBinaryStringAsLong

        public abstract long parseBinaryStringAsLong​(String s)
        Parse a binary String as a 64 bit long.
        Parameters:
        s - Binary String to parse
        Returns:
        parsef long
        Throws:
        IllegalArgumentException - when parameter String length differs from 64 or contains other than '0' and '1' characters
      • appendLongAsBinaryString

        public abstract void appendLongAsBinaryString​(StringBuilder b,
                                                      long l)
        Convert 64 bit long to binary string.
        Parameters:
        b - Target buffer to write to
        l - Long to convert
      • unpackIntFromBitSet

        public abstract int unpackIntFromBitSet​(BitSet b,
                                                int start)
        Unpack an int value from a BitSet.
        Parameters:
        b - Source BitSet.
        start - Position of first bit to read in the BitSet
        Returns:
        Unpacked int.
      • unpackLongFromBitSet

        public abstract long unpackLongFromBitSet​(BitSet b,
                                                  int start)
        Unpack a long value from a BitSet.
        Parameters:
        b - Source BitSet.
        start - Position of first bit to read in the BitSet
        Returns:
        Unpacked long.
      • packIntIntoBitSet

        public abstract int packIntIntoBitSet​(int i,
                                              BitSet b,
                                              int start)
        Pack an int value into a BitSet.
        Parameters:
        i - Value to pack
        b - Target BitSet
        start - Position of the first bit to write
        Returns:
        Position of first bit to write by a subsequent pack
      • packLongIntoBitSet

        public abstract int packLongIntoBitSet​(long l,
                                               BitSet b,
                                               int start)
        Pack a long value into a BitSet.
        Parameters:
        l - Value to pack
        b - Target BitSet
        start - Position of the first bit to write
        Returns:
        Position of first bit to write by a subsequent pack