org.apache.hadoop.fs
Enum XAttrCodec

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

@InterfaceAudience.Public
@InterfaceStability.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 Summary
BASE64
          Value encoded as base64 string is prefixed with 0s.
HEX
          Value encoded as hexadecimal string is prefixed with 0x.
TEXT
          Value encoded as text string is enclosed in double quotes (\").
 
Method Summary
static byte[] decodeValue(String value)
          Decode string representation of a value and check whether it's encoded.
static String encodeValue(byte[] value, XAttrCodec encoding)
          Encode byte[] value to string representation with encoding.
static XAttrCodec valueOf(String name)
          Returns the enum constant of this type with the specified name.
static XAttrCodec[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

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 Detail

values

public static XAttrCodec[] 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 (XAttrCodec c : XAttrCodec.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static XAttrCodec 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

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

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 -
Returns:
String string representation of value
Throws:
IOException


Copyright © 2014 Apache Software Foundation. All Rights Reserved.