Enum Endianess

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] toBytes​(double aValue)
      Converts the given value to a byte array in the according endian notation.
      byte[] toBytes​(float aValue)
      Converts the given value to a byte array in the according endian notation.
      byte[] toBytes​(int aValue)
      Converts the given value to a byte array in the according endian notation.
      byte[] toBytes​(int aValue, int aLength)
      Converts the given value to a byte array in the according endian notation.
      byte[] toBytes​(long aValue)
      Converts the given value to a byte array in the according endian notation.
      byte[] toBytes​(long aValue, int aLength)
      Converts the given value to a byte array in the according endian notation.
      byte[] toBytes​(short aValue)
      Converts the given value to a byte array in the according endian notation.
      byte[] toBytes​(short aValue, int aLength)
      Converts the given value to a byte array in the according endian notation.
      double toDouble​(byte[] aBytes)
      Converts a byte array in according endianess to an double value.
      float toFloat​(byte[] aBytes)
      Converts a byte array in according endianess to an float value.
      int toInteger​(byte[] aBytes)
      Converts a byte array in according endianess to an integer value.
      long toLong​(byte[] aBytes)
      Converts a byte array in according endianess to a long value.
      short toShort​(byte[] aBytes)
      Converts a byte array in according endianess to an short value.
      byte[] toUnsignedBytes​(int aValue)
      Converts the given value to a byte array in the according endian notation.
      byte[] toUnsignedBytes​(long aValue)
      Converts the given value to a byte array in the according endian notation.
      byte[] toUnsignedBytes​(long aValue, int aLength)
      Converts the given value to a byte array in the according endian notation.
      byte[] toUnsignedBytes​(short aValue)
      Converts the given value to a byte array in the according endian notation.
      int toUnsignedInteger​(byte[] aBytes)
      Converts a byte array in according endianess to an unsigned integer value.
      long toUnsignedLong​(byte[] aBytes)
      Converts a byte array in according endianess to an unsigned long value.
      short toUnsignedShort​(byte[] aBytes)
      Converts a byte array in according endianess to an unsigned short value.
      static Endianess valueOf​(String name)
      Returns the enum constant of this type with the specified name.
      static Endianess[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
    • Enum Constant Detail

      • LITTLE_ENDIAN

        public static final Endianess LITTLE_ENDIAN
      • BIG_ENDIAN

        public static final Endianess BIG_ENDIAN
    • Method Detail

      • values

        public static Endianess[] 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 (Endianess c : Endianess.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Endianess 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
      • toBytes

        public byte[] toBytes​(long aValue,
                              int aLength)
        Converts the given value to a byte array in the according endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        aLength - The number of bytes to use.
        Returns:
        The according array.
      • toBytes

        public byte[] toBytes​(long aValue)
        Converts the given value to a byte array in the according endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toBytes

        public byte[] toBytes​(int aValue,
                              int aLength)
        Converts the given value to a byte array in the according endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        aLength - The number of bytes to use.
        Returns:
        The according array.
      • toBytes

        public byte[] toBytes​(int aValue)
        Converts the given value to a byte array in the according endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toBytes

        public byte[] toBytes​(short aValue,
                              int aLength)
        Converts the given value to a byte array in the according endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        aLength - The number of bytes to use.
        Returns:
        The according array.
      • toBytes

        public byte[] toBytes​(short aValue)
        Converts the given value to a byte array in the according endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toBytes

        public byte[] toBytes​(float aValue)
        Converts the given value to a byte array in the according endian notation. As the float type is 32 bits in java, an array of length 4 will be returned.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toBytes

        public byte[] toBytes​(double aValue)
        Converts the given value to a byte array in the according endian notation. As the float type is 32 bits in java, an array of length 4 will be returned.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toUnsignedBytes

        public byte[] toUnsignedBytes​(long aValue,
                                      int aLength)
        Converts the given value to a byte array in the according endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        aLength - The number of bytes to use.
        Returns:
        The according array.
      • toUnsignedBytes

        public byte[] toUnsignedBytes​(long aValue)
        Converts the given value to a byte array in the according endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toUnsignedBytes

        public byte[] toUnsignedBytes​(int aValue)
        Converts the given value to a byte array in the according endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toUnsignedBytes

        public byte[] toUnsignedBytes​(short aValue)
        Converts the given value to a byte array in the according endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toLong

        public long toLong​(byte[] aBytes)
        Converts a byte array in according endianess to a long value.
        Parameters:
        aBytes - The byte array to be converted.
        Returns:
        The resulting long value.
      • toUnsignedLong

        public long toUnsignedLong​(byte[] aBytes)
        Converts a byte array in according endianess to an unsigned long value.
        Parameters:
        aBytes - The byte array to be converted.
        Returns:
        The resulting long value.
      • toInteger

        public int toInteger​(byte[] aBytes)
        Converts a byte array in according endianess to an integer value.
        Parameters:
        aBytes - The byte array to be converted.
        Returns:
        The resulting integer value.
      • toUnsignedInteger

        public int toUnsignedInteger​(byte[] aBytes)
        Converts a byte array in according endianess to an unsigned integer value.
        Parameters:
        aBytes - The byte array to be converted.
        Returns:
        The resulting integer value.
      • toShort

        public short toShort​(byte[] aBytes)
        Converts a byte array in according endianess to an short value.
        Parameters:
        aBytes - The byte array to be converted.
        Returns:
        The resulting short value.
      • toUnsignedShort

        public short toUnsignedShort​(byte[] aBytes)
        Converts a byte array in according endianess to an unsigned short value.
        Parameters:
        aBytes - The byte array to be converted.
        Returns:
        The resulting short value.
      • toFloat

        public float toFloat​(byte[] aBytes)
        Converts a byte array in according endianess to an float value.
        Parameters:
        aBytes - The byte array to be converted.
        Returns:
        The resulting float value.
      • toDouble

        public double toDouble​(byte[] aBytes)
        Converts a byte array in according endianess to an double value.
        Parameters:
        aBytes - The byte array to be converted.
        Returns:
        The resulting double value.