Enum Class XAttrCodec

java.lang.Object
java.lang.Enum<XAttrCodec>
org.apache.hadoop.fs.XAttrCodec
All Implemented Interfaces:
Serializable, Comparable<XAttrCodec>, Constable

@Public @Stable public enum XAttrCodec extends Enum<XAttrCodec>
The value of XAttr is byte[], this class is to covert byte[] to some kind of string representation or convert back. String representation is convenient for display and input. For example display in screen as shell response and json response, input as http or shell parameter.
  • Enum Constant Details

    • TEXT

      public static final XAttrCodec TEXT
      Value encoded as text string is enclosed in double quotes (\").
    • HEX

      public static final XAttrCodec HEX
      Value encoded as hexadecimal string is prefixed with 0x.
    • BASE64

      public static final XAttrCodec BASE64
      Value encoded as base64 string is prefixed with 0s.
  • Method Details

    • values

      public static XAttrCodec[] 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 XAttrCodec 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
    • decodeValue

      public static byte[] decodeValue(String value) throws IOException
      Decode string representation of a value and check whether it's encoded. If the given string begins with 0x or 0X, it expresses a hexadecimal number. If the given string begins with 0s or 0S, base64 encoding is expected. If the given string is enclosed in double quotes, the inner string is treated as text. Otherwise the given string is treated as text.
      Parameters:
      value - string representation of the value.
      Returns:
      byte[] the value
      Throws:
      IOException - raised on errors performing I/O.
    • encodeValue

      public static String encodeValue(byte[] value, XAttrCodec encoding) throws IOException
      Encode byte[] value to string representation with encoding. Values encoded as text strings are enclosed in double quotes (\"), while strings encoded as hexadecimal and base64 are prefixed with 0x and 0s, respectively.
      Parameters:
      value - byte[] value
      encoding - encoding.
      Returns:
      String string representation of value
      Throws:
      IOException - raised on errors performing I/O.