Package org.apache.hadoop.fs
Enum Class XAttrCodec
- All Implemented Interfaces:
Serializable,Comparable<XAttrCodec>,Constable
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.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]decodeValue(String value) Decode string representation of a value and check whether it's encoded.static StringencodeValue(byte[] value, XAttrCodec encoding) Encode byte[] value to string representation with encoding.static XAttrCodecReturns the enum constant of this class with the specified name.static XAttrCodec[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
TEXT
Value encoded as text string is enclosed in double quotes (\"). -
HEX
Value encoded as hexadecimal string is prefixed with 0x. -
BASE64
Value encoded as base64 string is prefixed with 0s.
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
decodeValue
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
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[] valueencoding- encoding.- Returns:
- String string representation of value
- Throws:
IOException- raised on errors performing I/O.
-