|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.protobuf.ByteString
public final class ByteString
Immutable array of bytes.
Nested Class Summary | |
---|---|
static class |
ByteString.Output
Outputs to a ByteString instance. |
Field Summary | |
---|---|
static ByteString |
EMPTY
Empty ByteString. |
Method Summary | |
---|---|
java.nio.ByteBuffer |
asReadOnlyByteBuffer()
Constructs a new read-only java.nio.ByteBuffer with the
same backing byte array. |
byte |
byteAt(int index)
Gets the byte at the given index. |
static ByteString |
copyFrom(byte[] bytes)
Copies the given bytes into a ByteString . |
static ByteString |
copyFrom(byte[] bytes,
int offset,
int size)
Copies the given bytes into a ByteString . |
static ByteString |
copyFrom(java.lang.String text,
java.lang.String charsetName)
Encodes text into a sequence of bytes using the named charset
and returns the result as a ByteString . |
static ByteString |
copyFromUtf8(java.lang.String text)
Encodes text into a sequence of UTF-8 bytes and returns the
result as a ByteString . |
void |
copyTo(byte[] target,
int offset)
Copies bytes into a buffer at the given offset. |
void |
copyTo(byte[] target,
int sourceOffset,
int targetOffset,
int size)
Copies bytes into a buffer. |
boolean |
equals(java.lang.Object o)
|
int |
hashCode()
|
boolean |
isEmpty()
Returns true if the size is 0 , false otherwise. |
CodedInputStream |
newCodedInput()
Creates a CodedInputStream which can be used to read the bytes. |
java.io.InputStream |
newInput()
Creates an InputStream which can be used to read the bytes. |
static ByteString.Output |
newOutput()
Creates a new ByteString.Output . |
static ByteString.Output |
newOutput(int initialCapacity)
Creates a new ByteString.Output with the given initial capacity. |
int |
size()
Gets the number of bytes. |
byte[] |
toByteArray()
Copies bytes to a byte[] . |
java.lang.String |
toString(java.lang.String charsetName)
Constructs a new String by decoding the bytes using the
specified charset. |
java.lang.String |
toStringUtf8()
Constructs a new String by decoding the bytes as UTF-8. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final ByteString EMPTY
Method Detail |
---|
public byte byteAt(int index)
java.lang.ArrayIndexOutOfBoundsException
- index
is < 0 or >= sizepublic int size()
public boolean isEmpty()
true
if the size is 0
, false
otherwise.
public static ByteString copyFrom(byte[] bytes, int offset, int size)
ByteString
.
public static ByteString copyFrom(byte[] bytes)
ByteString
.
public static ByteString copyFrom(java.lang.String text, java.lang.String charsetName) throws java.io.UnsupportedEncodingException
text
into a sequence of bytes using the named charset
and returns the result as a ByteString
.
java.io.UnsupportedEncodingException
public static ByteString copyFromUtf8(java.lang.String text)
text
into a sequence of UTF-8 bytes and returns the
result as a ByteString
.
public void copyTo(byte[] target, int offset)
target
- buffer to copy intooffset
- in the target bufferpublic void copyTo(byte[] target, int sourceOffset, int targetOffset, int size)
target
- buffer to copy intosourceOffset
- offset within these bytestargetOffset
- offset within the target buffersize
- number of bytes to copypublic byte[] toByteArray()
byte[]
.
public java.nio.ByteBuffer asReadOnlyByteBuffer()
java.nio.ByteBuffer
with the
same backing byte array.
public java.lang.String toString(java.lang.String charsetName) throws java.io.UnsupportedEncodingException
String
by decoding the bytes using the
specified charset.
java.io.UnsupportedEncodingException
public java.lang.String toStringUtf8()
String
by decoding the bytes as UTF-8.
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.io.InputStream newInput()
InputStream
which can be used to read the bytes.
public CodedInputStream newCodedInput()
CodedInputStream
which can be used to read the bytes.
Using this is more efficient than creating a CodedInputStream
wrapping the result of newInput()
.
public static ByteString.Output newOutput(int initialCapacity)
ByteString.Output
with the given initial capacity.
public static ByteString.Output newOutput()
ByteString.Output
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |