public class Utf8 extends Object implements Comparable<Utf8>, CharSequence, Externalizable
String
, instances are mutable. This is more
efficient than String
when reading or writing a sequence of values,
as a single instance may be reused.Constructor and Description |
---|
Utf8() |
Utf8(byte[] bytes) |
Utf8(String string) |
Utf8(Utf8 other) |
Modifier and Type | Method and Description |
---|---|
char |
charAt(int index) |
int |
compareTo(Utf8 that) |
boolean |
equals(Object o) |
int |
getByteLength()
Return length in bytes.
|
byte[] |
getBytes()
Return UTF-8 encoded bytes.
|
static byte[] |
getBytesFor(String str)
Gets the UTF-8 bytes for a String
|
int |
getLength()
Deprecated.
call
getByteLength() instead. |
int |
hashCode() |
int |
length() |
void |
readExternal(ObjectInput in) |
Utf8 |
set(String string)
Set to the contents of a String.
|
Utf8 |
set(Utf8 other) |
Utf8 |
setByteLength(int newLength)
Set length in bytes.
|
Utf8 |
setLength(int newLength)
Deprecated.
call
setByteLength(int) instead. |
CharSequence |
subSequence(int start,
int end) |
String |
toString() |
void |
writeExternal(ObjectOutput out) |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
chars, codePoints
public Utf8()
public Utf8(String string)
public Utf8(Utf8 other)
public Utf8(byte[] bytes)
public byte[] getBytes()
getByteLength()
.@Deprecated public int getLength()
getByteLength()
instead.public int getByteLength()
@Deprecated public Utf8 setLength(int newLength)
setByteLength(int)
instead.public Utf8 setByteLength(int newLength)
public String toString()
toString
in interface CharSequence
toString
in class Object
public int compareTo(Utf8 that)
compareTo
in interface Comparable<Utf8>
public char charAt(int index)
charAt
in interface CharSequence
public int length()
length
in interface CharSequence
public CharSequence subSequence(int start, int end)
subSequence
in interface CharSequence
public static byte[] getBytesFor(String str)
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
Copyright © 2009–2022 The Apache Software Foundation. All rights reserved.