| Constructor and Description |
|---|
Text() |
Text(byte[] utf8)
Construct from a byte array.
|
Text(java.lang.String string)
Construct from a string.
|
Text(Text utf8)
Construct from another text.
|
| Modifier and Type | Method and Description |
|---|---|
void |
append(byte[] utf8,
int start,
int len)
Appends a range of bytes to the end of the given text.
|
void |
clear()
Clears the string to empty.
|
static java.lang.String |
decode(byte[] utf8,
int start,
int length) |
static java.lang.String |
decode(byte[] utf8,
int start,
int length,
boolean replace)
Converts the provided byte array to a String using the UTF-8 encoding.
|
static int |
decodeVIntSize(byte value) |
static java.nio.ByteBuffer |
encode(java.lang.String string)
Converts the provided String to bytes using the UTF-8 encoding.
|
static java.nio.ByteBuffer |
encode(java.lang.String string,
boolean replace)
Converts the provided String to bytes using the UTF-8 encoding.
|
boolean |
equals(java.lang.Object o)
Returns true iff
o is a Text with the same contents. |
byte[] |
getBytes()
Returns the raw bytes; however, only data up to
getLength() is
valid. |
int |
getLength()
Returns the number of bytes in the byte array
|
int |
hashCode() |
static boolean |
isNegativeVInt(byte value) |
void |
readFields(java.io.DataInput inputStream)
deserialize
|
static long |
readVLong(java.io.DataInput stream) |
void |
set(byte[] utf8)
Sets to a UTF-8 byte array.
|
void |
set(byte[] utf8,
int start,
int len)
Sets the Text to range of bytes.
|
void |
set(java.lang.String string)
Sets to contain the contents of a string.
|
void |
set(Text other)
Copies a text.
|
java.lang.String |
toString()
Convert text back to string
|
void |
write(java.io.DataOutput out)
Serialize the fields of this object to
out. |
public Text()
public Text(java.lang.String string)
string - input stringpublic Text(Text utf8)
utf8 - text to copypublic Text(byte[] utf8)
utf8 - input byte arraypublic static boolean isNegativeVInt(byte value)
public static long readVLong(java.io.DataInput stream)
throws java.io.IOException
java.io.IOExceptionpublic static int decodeVIntSize(byte value)
public static java.lang.String decode(byte[] utf8,
int start,
int length)
throws java.nio.charset.CharacterCodingException
java.nio.charset.CharacterCodingExceptionpublic static java.lang.String decode(byte[] utf8,
int start,
int length,
boolean replace)
throws java.nio.charset.CharacterCodingException
replace is true, then malformed input is replaced with the
substitution character, which is U+FFFD. Otherwise the method throws a
MalformedInputException.utf8 - UTF-8 encoded byte arraystart - start pointlength - length of arrayreplace - whether to replace malformed input with substitution
characterjava.nio.charset.MalformedInputException - if a malformed input is usedjava.nio.charset.CharacterCodingException - if the conversion failedpublic static java.nio.ByteBuffer encode(java.lang.String string)
throws java.nio.charset.CharacterCodingException
string - string to encodejava.nio.charset.CharacterCodingException - if conversion failedpublic static java.nio.ByteBuffer encode(java.lang.String string,
boolean replace)
throws java.nio.charset.CharacterCodingException
replace is true, then malformed input is replaced with the
substitution character, which is U+FFFD. Otherwise the method throws a
MalformedInputException.string - string to encodereplace - whether to replace malformed input with substitution
characterjava.nio.charset.MalformedInputException - if a malformed input is usedjava.nio.charset.CharacterCodingException - if the conversion failedpublic byte[] getBytes()
getLength() is
valid.public int getLength()
public void set(java.lang.String string)
string - input stringpublic void set(byte[] utf8)
utf8 - input UTF-8 byte arraypublic void set(Text other)
other - text object to copy.public void set(byte[] utf8,
int start,
int len)
utf8 - the data to copy fromstart - the first position of the new stringlen - the number of bytes of the new stringpublic void append(byte[] utf8,
int start,
int len)
utf8 - the data to copy fromstart - the first position to append from utf8len - the number of bytes to appendpublic void clear()
public java.lang.String toString()
toString in class java.lang.ObjectObject.toString()public void write(java.io.DataOutput out)
throws java.io.IOException
Writableout.public void readFields(java.io.DataInput inputStream)
throws java.io.IOException
readFields in interface WritableinputStream - DataInput to deserialize this object from.java.io.IOException - if I/O error occurspublic boolean equals(java.lang.Object o)
o is a Text with the same contents.equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object