Class UTF8

java.lang.Object
org.apache.hadoop.io.UTF8
All Implemented Interfaces:
Comparable<UTF8>, Writable, WritableComparable<UTF8>

@Deprecated @LimitedPrivate({"HDFS","MapReduce"}) @Stable public class UTF8 extends Object implements WritableComparable<UTF8>
Deprecated.
replaced by Text
A WritableComparable for strings that uses the UTF8 encoding.

Also includes utilities for efficiently reading and writing UTF-8. Note that this decodes UTF-8 but actually encodes CESU-8, a variant of UTF-8: see http://en.wikipedia.org/wiki/CESU-8

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Deprecated.
    A WritableComparator optimized for UTF8 keys.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated.
     
    UTF8(String string)
    Deprecated.
    Construct from a given string.
    UTF8(UTF8 utf8)
    Deprecated.
    Construct from a given string.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Deprecated.
    Compare two UTF8s.
    boolean
    Deprecated.
    Returns true iff o is a UTF8 with the same contents.
    static String
    fromBytes(byte[] bytes)
    Deprecated.
     
    byte[]
    Deprecated.
     
    static byte[]
    getBytes(String string)
    Deprecated.
     
    int
    Deprecated.
     
    int
    Deprecated.
     
    void
    Deprecated.
    Deserialize the fields of this object from in.
    static String
    Deprecated.
     
    void
    set(String string)
    Deprecated.
    Set to contain the contents of a string.
    void
    set(UTF8 other)
    Deprecated.
    Set to contain the contents of a string.
    static void
    Deprecated.
    Skips over one UTF8 in the input.
    Deprecated.
    Convert to a String.
    Deprecated.
    Convert to a string, checking for valid UTF8.
    void
    Deprecated.
    Serialize the fields of this object to out.
    static int
    Deprecated.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • UTF8

      public UTF8()
      Deprecated.
    • UTF8

      public UTF8(String string)
      Deprecated.
      Construct from a given string.
      Parameters:
      string - input string.
    • UTF8

      public UTF8(UTF8 utf8)
      Deprecated.
      Construct from a given string.
      Parameters:
      utf8 - input utf8.
  • Method Details

    • getBytes

      public byte[] getBytes()
      Deprecated.
      Returns:
      The raw bytes.
    • getLength

      public int getLength()
      Deprecated.
      Returns:
      The number of bytes in the encoded string.
    • set

      public void set(String string)
      Deprecated.
      Set to contain the contents of a string.
      Parameters:
      string - input string.
    • set

      public void set(UTF8 other)
      Deprecated.
      Set to contain the contents of a string.
      Parameters:
      other - input other.
    • readFields

      public void readFields(DataInput in) throws IOException
      Deprecated.
      Description copied from interface: Writable
      Deserialize the fields of this object from in.

      For efficiency, implementations should attempt to re-use storage in the existing object where possible.

      Specified by:
      readFields in interface Writable
      Parameters:
      in - DataInput to deseriablize this object from.
      Throws:
      IOException - any other problem for readFields.
    • skip

      public static void skip(DataInput in) throws IOException
      Deprecated.
      Skips over one UTF8 in the input.
      Parameters:
      in - datainput.
      Throws:
      IOException - raised on errors performing I/O.
    • write

      public void write(DataOutput out) throws IOException
      Deprecated.
      Description copied from interface: Writable
      Serialize the fields of this object to out.
      Specified by:
      write in interface Writable
      Parameters:
      out - DataOuput to serialize this object into.
      Throws:
      IOException - any other problem for write.
    • compareTo

      public int compareTo(UTF8 o)
      Deprecated.
      Compare two UTF8s.
      Specified by:
      compareTo in interface Comparable<UTF8>
    • toString

      public String toString()
      Deprecated.
      Convert to a String.
      Overrides:
      toString in class Object
    • toStringChecked

      public String toStringChecked() throws IOException
      Deprecated.
      Convert to a string, checking for valid UTF8.
      Returns:
      the converted string
      Throws:
      UTFDataFormatException - if the underlying bytes contain invalid UTF8 data.
      IOException
    • equals

      public boolean equals(Object o)
      Deprecated.
      Returns true iff o is a UTF8 with the same contents.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Deprecated.
      Overrides:
      hashCode in class Object
    • getBytes

      public static byte[] getBytes(String string)
      Deprecated.
      Parameters:
      string - input string.
      Returns:
      Convert a string to a UTF-8 encoded byte array.
      See Also:
    • fromBytes

      public static String fromBytes(byte[] bytes) throws IOException
      Deprecated.
      Parameters:
      bytes - input bytes.
      Returns:
      Convert a UTF-8 encoded byte array back into a string.
      Throws:
      IOException - if the byte array is invalid UTF8
    • readString

      public static String readString(DataInput in) throws IOException
      Deprecated.
      Parameters:
      in - DataInput.
      Returns:
      Read a UTF-8 encoded string.
      Throws:
      IOException - raised on errors performing I/O.
      See Also:
    • writeString

      public static int writeString(DataOutput out, String s) throws IOException
      Deprecated.
      Parameters:
      out - input out.
      s - input s.
      Returns:
      Write a UTF-8 encoded string.
      Throws:
      IOException - raised on errors performing I/O.
      See Also: