|
XNIO API 3.0.4.GA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.xnio.ByteString
public final class ByteString
An immutable string of bytes. Since instances of this class are guaranteed to be immutable, they are
safe to use as Option
values and in an OptionMap
.
Method Summary | |
---|---|
int |
compareTo(ByteString o)
Compare this ByteString to another. |
static ByteString |
copyOf(byte[] b,
int offs,
int len)
Create a byte string from the given array segment. |
boolean |
equals(ByteString other)
Determine if this ByteString equals another ByteString. |
boolean |
equals(Object obj)
Determine if this ByteString equals another ByteString. |
byte[] |
getBytes()
Get a copy of the bytes of this ByteString. |
void |
getBytes(byte[] dest)
Copy the bytes of this ByteString into the destination array. |
void |
getBytes(byte[] dest,
int offs)
Copy the bytes of this ByteString into the destination array. |
void |
getBytes(byte[] dest,
int offs,
int len)
Copy the bytes of this ByteString into the destination array. |
static ByteString |
getBytes(ByteBuffer buffer)
Get a byte string from all remaining bytes of a ByteBuffer. |
static ByteString |
getBytes(ByteBuffer buffer,
int length)
Get a byte string from a ByteBuffer. |
static ByteString |
getBytes(String str,
Charset charset)
Get a byte string from the bytes of a character string. |
static ByteString |
getBytes(String str,
String charset)
Get a byte string from the bytes of a character string. |
int |
hashCode()
Get the hash code for this ByteString. |
int |
length()
Get the number of bytes in this byte string. |
static ByteString |
of(byte... bytes)
Create a byte string of the given literal bytes. |
ByteString |
substring(int offs)
Get the substring of this string starting at the given offset. |
ByteString |
substring(int offs,
int len)
Get the substring of this string starting at the given offset. |
String |
toString(String charset)
Convert this byte string to a standard string. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static ByteString of(byte... bytes)
bytes
- the bytes
public static ByteString copyOf(byte[] b, int offs, int len)
b
- the byte arrayoffs
- the offset into the arraylen
- the number of bytes to copy
public static ByteString getBytes(String str, String charset) throws UnsupportedEncodingException
str
- the character stringcharset
- the character set to use
UnsupportedEncodingException
- if the encoding is not supportedpublic static ByteString getBytes(String str, Charset charset)
str
- the character stringcharset
- the character set to use
public static ByteString getBytes(ByteBuffer buffer)
buffer
- the buffer
public static ByteString getBytes(ByteBuffer buffer, int length)
buffer
- the bufferlength
- the number of bytes to get
public byte[] getBytes()
public void getBytes(byte[] dest)
dest
- the destination arraypublic void getBytes(byte[] dest, int offs)
dest
- the destination arrayoffs
- the offset into the destination arraypublic void getBytes(byte[] dest, int offs, int len)
dest
- the destination arrayoffs
- the offset into the destination arraylen
- the maximum number of bytes to copypublic String toString(String charset) throws UnsupportedEncodingException
charset
- the character set to use
UnsupportedEncodingException
- if the charset is unknownpublic int length()
public ByteString substring(int offs)
offs
- the offset
public ByteString substring(int offs, int len)
offs
- the offsetlen
- the substring length
public int compareTo(ByteString o)
compareTo
in interface Comparable<ByteString>
o
- the other ByteString
public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
obj
- the other object
true
if they are equalpublic boolean equals(ByteString other)
other
- the other object
true
if they are equal
|
XNIO API 3.0.4.GA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |