Enum Class Encodings

java.lang.Object
java.lang.Enum<Encodings>
org.openpreservation.format.xml.Encodings
All Implemented Interfaces:
Serializable, Comparable<Encodings>, java.lang.constant.Constable

public enum Encodings extends Enum<Encodings>
An enum defining the Byte Order Marks for UTF-8, UTF-16 and UTF-32. See Byte Order Mark
  • Enum Constant Details

    • NONE

      public static final Encodings NONE
      Empty Byte String to match no encoding
    • UTF_8

      public static final Encodings UTF_8
      UTF-8 Byte Order Mark
    • UTF_16_BE

      public static final Encodings UTF_16_BE
      UTF-16 Big Endian Byte Order Mark
    • UTF_16_LE

      public static final Encodings UTF_16_LE
      UTF-16 Little Endian Byte Order Mark
    • UTF_32_BE

      public static final Encodings UTF_32_BE
      UTF-32 Big Endian Byte Order Mark
    • UTF_32_LE

      public static final Encodings UTF_32_LE
      UTF-32 Little Endian Byte Order Mark
  • Field Details

    • encoding

      public final String encoding
      The String encoding name for the Byte Order Mark
  • Method Details

    • values

      public static Encodings[] 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 Encodings 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
    • fromEncoding

      public static Encodings fromEncoding(String encoding)
      Get an Encodings instance from the String name or NONE if no match
      Parameters:
      encoding - the name of the encoding to retrieve
      Returns:
      the Endcoding with the given name, or Encoding.NONE if no match
      Throws:
      NullPointerException - if encoding is null
    • fromRepresentation

      public static Encodings fromRepresentation(byte[] bytes)
      Get an Encodings instance from the byte array representation, or NONE if no match.
      Parameters:
      bytes - the byte[] representation of the encoding to retrieve
      Returns:
      the Endcodings instance with the given representation, or Encoding.NONE if no match
      Throws:
      NullPointerException - if bytes is null.
    • getLength

      public int getLength()
      Returns the length of the Byte Order Mark in bytes
      Returns:
      the int length of the Byte Order Mark in bytes