Enum Class Endianness

java.lang.Object
java.lang.Enum<Endianness>
mars.mips.hardware.Endianness
All Implemented Interfaces:
Serializable, Comparable<Endianness>, Constable

public enum Endianness extends Enum<Endianness>
An enumeration of the different "endianness" states. "Endianness" refers to the order in which bytes are stored in memory.

For now, this enumeration is essentially a wrapper around an existing enumeration, ByteOrder. The reason for this is primarily that ByteOrder is not actually an enum, but rather a final class with two constant instances as static members since enums were introduced in Java 1.5, after ByteOrder was created. The benefit of an enum is that the compiler understands that no more instances of this class will ever be created, allowing for more convenient logic in many cases (particularly when using switch expressions).

  • Enum Constant Details

    • BIG_ENDIAN

      public static final Endianness BIG_ENDIAN
      The bytes of a multibyte value are ordered from most significant to least significant.
    • LITTLE_ENDIAN

      public static final Endianness LITTLE_ENDIAN
      The bytes of a multibyte value are ordered from least significant to most significant.
  • Method Details

    • values

      public static Endianness[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Endianness valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified name
      NullPointerException - if the argument is null
    • getByteOrder

      public ByteOrder getByteOrder()
      Get the Java standard library representation of this endianness value.
      Returns:
      The ByteOrder variant corresponding to this value.