public final class ByteString extends Object implements Comparable<ByteString>, Serializable, CharSequence
Option
values and in an OptionMap
. Some operations can treat this byte string
as an ASCII- or ISO-8858-1-encoded character string.Modifier and Type | Method and Description |
---|---|
void |
appendTo(ByteBuffer dest)
Append the bytes of this string into the given buffer.
|
byte |
byteAt(int idx)
Get the byte at an index.
|
char |
charAt(int index) |
int |
compareTo(ByteString other)
Compare this string to another in a case-sensitive manner.
|
int |
compareToIgnoreCase(ByteString other)
Compare this string to another in a case-insensitive manner.
|
ByteString |
concat(byte[] suffixBytes) |
ByteString |
concat(byte[] suffixBytes,
int offs,
int len) |
ByteString |
concat(ByteString suffix) |
ByteString |
concat(ByteString suffix,
int offs,
int len) |
ByteString |
concat(String suffix) |
static ByteString |
concat(String prefix,
ByteString suffix) |
ByteString |
concat(String suffix,
int offs,
int len) |
static ByteString |
concat(String prefix,
String suffix) |
boolean |
contains(ByteString other)
Determine whether this string contains another string (case-sensitive).
|
boolean |
contains(String other)
Determine whether this string contains another string (case-sensitive).
|
boolean |
containsIgnoreCase(ByteString other)
Determine whether this string contains another string (case-insensitive).
|
boolean |
containsIgnoreCase(String other)
Determine whether this string contains another string (case-sensitive).
|
static ByteString |
copyOf(byte[] b,
int offs,
int len)
Create a byte string from the given array segment.
|
void |
copyTo(byte[] dst)
Copy all the bytes from this string to the given array at the given offset.
|
void |
copyTo(byte[] dst,
int offs)
Copy all the bytes from this string to the given array at the given offset.
|
void |
copyTo(byte[] dst,
int offs,
int len)
Copy
len bytes from this string to the given array at the given offset. |
void |
copyTo(int srcOffs,
byte[] dst,
int offs,
int len)
Copy
len bytes from this string at offset srcOffs to the given array at the given offset. |
boolean |
endsWith(ByteString suffix) |
boolean |
endsWith(char suffix) |
boolean |
endsWith(String suffix) |
boolean |
endsWithIgnoreCase(ByteString suffix) |
boolean |
endsWithIgnoreCase(char suffix) |
boolean |
endsWithIgnoreCase(String suffix) |
boolean |
equals(ByteString other)
Determine if this ByteString equals another ByteString.
|
boolean |
equals(Object obj)
Determine if this ByteString equals another ByteString.
|
boolean |
equalsIgnoreCase(ByteString other)
Determine if this ByteString equals another ByteString, ignoring case (ASCII).
|
boolean |
equalToString(String str)
Determine whether this
ByteString is equal (case-sensitively) to the given String . |
boolean |
equalToStringIgnoreCase(String str)
Determine whether this
ByteString is equal (case-insensitively) to the given String . |
static ByteString |
fromInt(int val)
Get a string version of the given value.
|
static ByteString |
fromLong(long val)
Get a string version of the given value.
|
byte[] |
getBytes()
Get a copy of the bytes of this ByteString.
|
void |
getBytes(byte[] dest)
Deprecated.
Replaced by
copyTo(byte[]) . |
void |
getBytes(byte[] dest,
int offs)
Deprecated.
Replaced by
copyTo(byte[],int) . |
void |
getBytes(byte[] dest,
int offs,
int len)
Deprecated.
Replaced by
copyTo(byte[],int,int) . |
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)
Get a byte string from the bytes of the character string.
|
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 |
hashCodeIgnoreCase() |
int |
indexOf(ByteString other) |
int |
indexOf(ByteString other,
int start) |
int |
indexOf(char c)
Get the index of the given character in this string.
|
int |
indexOf(char c,
int start)
Get the index of the given character in this string.
|
int |
indexOf(String other) |
int |
indexOf(String other,
int start) |
int |
indexOfIgnoreCase(ByteString other) |
int |
indexOfIgnoreCase(ByteString other,
int start) |
int |
indexOfIgnoreCase(String other) |
int |
indexOfIgnoreCase(String other,
int start) |
int |
lastIndexOf(ByteString other) |
int |
lastIndexOf(ByteString other,
int start) |
int |
lastIndexOf(char c)
Get the last index of the given character in this string.
|
int |
lastIndexOf(char c,
int start)
Get the last index of the given character in this string.
|
int |
lastIndexOf(String other) |
int |
lastIndexOf(String other,
int start) |
int |
lastIndexOfIgnoreCase(ByteString other) |
int |
lastIndexOfIgnoreCase(ByteString other,
int start) |
int |
lastIndexOfIgnoreCase(String other) |
int |
lastIndexOfIgnoreCase(String other,
int start) |
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.
|
boolean |
regionMatches(boolean ignoreCase,
int offset,
byte[] other,
int otherOffset,
int len) |
boolean |
regionMatches(boolean ignoreCase,
int offset,
ByteString other,
int otherOffset,
int len) |
boolean |
regionMatches(boolean ignoreCase,
int offset,
String other,
int otherOffset,
int len) |
boolean |
startsWith(ByteString prefix) |
boolean |
startsWith(char prefix) |
boolean |
startsWith(String prefix) |
boolean |
startsWithIgnoreCase(ByteString prefix) |
boolean |
startsWithIgnoreCase(char prefix) |
boolean |
startsWithIgnoreCase(String prefix) |
ByteString |
subSequence(int start,
int end) |
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.
|
int |
toInt()
Get the unsigned
int value of this string. |
int |
toInt(int start)
Get the unsigned
int value of this string. |
long |
toLong()
Get the unsigned
long value of this string. |
long |
toLong(int start)
Get the unsigned
long value of this string. |
String |
toString()
Decode this byte string as a Latin-1 string.
|
String |
toString(String charset)
Convert this byte string to a standard string.
|
String |
toUtf8String()
Decode this byte string as a UTF-8 string.
|
int |
tryAppendTo(int offs,
ByteBuffer buffer)
Append as many bytes as possible to a byte buffer.
|
void |
writeTo(OutputStream output)
Append to an output stream.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
chars, codePoints
public static ByteString of(byte... bytes)
bytes
- the bytespublic static ByteString copyOf(byte[] b, int offs, int len)
b
- the byte arrayoffs
- the offset into the arraylen
- the number of bytes to copypublic static ByteString getBytes(String str, String charset) throws UnsupportedEncodingException
str
- the character stringcharset
- the character set to useUnsupportedEncodingException
- if the encoding is not supportedpublic static ByteString getBytes(String str, Charset charset)
str
- the character stringcharset
- the character set to usepublic static ByteString getBytes(String str)
str
- the character stringpublic static ByteString getBytes(ByteBuffer buffer)
buffer
- the bufferpublic static ByteString getBytes(ByteBuffer buffer, int length)
buffer
- the bufferlength
- the number of bytes to getpublic byte[] getBytes()
public void getBytes(byte[] dest)
copyTo(byte[])
.dest
- the destination arraypublic void getBytes(byte[] dest, int offs)
copyTo(byte[],int)
.dest
- the destination arrayoffs
- the offset into the destination arraypublic void getBytes(byte[] dest, int offs, int len)
copyTo(byte[],int,int)
.dest
- the destination arrayoffs
- the offset into the destination arraylen
- the maximum number of bytes to copypublic void copyTo(int srcOffs, byte[] dst, int offs, int len)
len
bytes from this string at offset srcOffs
to the given array at the given offset.srcOffs
- the source offsetdst
- the destinationoffs
- the destination offsetlen
- the number of bytes to copypublic void copyTo(byte[] dst, int offs, int len)
len
bytes from this string to the given array at the given offset.dst
- the destinationoffs
- the destination offsetlen
- the number of bytespublic void copyTo(byte[] dst, int offs)
dst
- the destinationoffs
- the destination offsetpublic void copyTo(byte[] dst)
dst
- the destinationpublic void appendTo(ByteBuffer dest)
dest
- the target bufferpublic int tryAppendTo(int offs, ByteBuffer buffer)
offs
- the start offsetbuffer
- the buffer to append topublic void writeTo(OutputStream output) throws IOException
output
- the stream to write toIOException
- if an error occurspublic int compareTo(ByteString other)
compareTo
in interface Comparable<ByteString>
other
- the other stringpublic int compareToIgnoreCase(ByteString other)
other
- the other stringpublic String toString(String charset) throws UnsupportedEncodingException
charset
- the character set to useUnsupportedEncodingException
- if the charset is unknownpublic int length()
length
in interface CharSequence
public String toString()
toString
in interface CharSequence
toString
in class Object
public String toUtf8String()
public byte byteAt(int idx)
public ByteString substring(int offs)
offs
- the offsetpublic ByteString substring(int offs, int len)
offs
- the offsetlen
- the substring lengthpublic int hashCode()
public int hashCodeIgnoreCase()
public boolean equals(Object obj)
public boolean equals(ByteString other)
other
- the other objecttrue
if they are equalpublic boolean equalsIgnoreCase(ByteString other)
other
- the other objecttrue
if they are equalpublic int toInt(int start)
int
value of this string. If the value is greater than would fit in 32 bits, only
the low 32 bits are returned. Parsing stops on the first non-digit character.start
- the index to start at (must be less than or equal to length)public int toInt()
int
value of this string. If the value is greater than would fit in 32 bits, only
the low 32 bits are returned. Parsing stops on the first non-digit character.public long toLong(int start)
long
value of this string. If the value is greater than would fit in 64 bits, only
the low 64 bits are returned. Parsing stops on the first non-digit character.start
- the index to start at (must be less than or equal to length)public long toLong()
long
value of this string. If the value is greater than would fit in 64 bits, only
the low 64 bits are returned. Parsing stops on the first non-digit character.public static ByteString fromLong(long val)
val
- the valuepublic static ByteString fromInt(int val)
val
- the valuepublic boolean equalToString(String str)
ByteString
is equal (case-sensitively) to the given String
.str
- the string to checktrue
if the given string is equal (case-sensitively) to this instance, false
otherwisepublic boolean equalToStringIgnoreCase(String str)
ByteString
is equal (case-insensitively) to the given String
.str
- the string to checktrue
if the given string is equal (case-insensitively) to this instance, false
otherwisepublic int indexOf(char c)
c
- the characterpublic int indexOf(char c, int start)
c
- the characterpublic int lastIndexOf(char c)
c
- the characterpublic int lastIndexOf(char c, int start)
c
- the characterpublic boolean contains(ByteString other)
other
- the string to testtrue
if this string contains other
, false
otherwisepublic boolean contains(String other)
other
- the string to testtrue
if this string contains other
, false
otherwisepublic boolean containsIgnoreCase(ByteString other)
other
- the string to testtrue
if this string contains other
, false
otherwisepublic boolean containsIgnoreCase(String other)
other
- the string to testtrue
if this string contains other
, false
otherwisepublic int indexOf(ByteString other)
public int indexOf(ByteString other, int start)
public int indexOf(String other)
public int indexOf(String other, int start)
public int indexOfIgnoreCase(ByteString other)
public int indexOfIgnoreCase(ByteString other, int start)
public int indexOfIgnoreCase(String other)
public int indexOfIgnoreCase(String other, int start)
public int lastIndexOf(ByteString other)
public int lastIndexOf(ByteString other, int start)
public int lastIndexOf(String other)
public int lastIndexOf(String other, int start)
public int lastIndexOfIgnoreCase(ByteString other)
public int lastIndexOfIgnoreCase(ByteString other, int start)
public int lastIndexOfIgnoreCase(String other)
public int lastIndexOfIgnoreCase(String other, int start)
public boolean regionMatches(boolean ignoreCase, int offset, byte[] other, int otherOffset, int len)
public boolean regionMatches(boolean ignoreCase, int offset, ByteString other, int otherOffset, int len)
public boolean regionMatches(boolean ignoreCase, int offset, String other, int otherOffset, int len)
public boolean startsWith(ByteString prefix)
public boolean startsWith(String prefix)
public boolean startsWith(char prefix)
public boolean startsWithIgnoreCase(ByteString prefix)
public boolean startsWithIgnoreCase(String prefix)
public boolean startsWithIgnoreCase(char prefix)
public boolean endsWith(ByteString suffix)
public boolean endsWith(String suffix)
public boolean endsWith(char suffix)
public boolean endsWithIgnoreCase(ByteString suffix)
public boolean endsWithIgnoreCase(String suffix)
public boolean endsWithIgnoreCase(char suffix)
public ByteString concat(byte[] suffixBytes)
public ByteString concat(byte[] suffixBytes, int offs, int len)
public ByteString concat(ByteString suffix)
public ByteString concat(ByteString suffix, int offs, int len)
public ByteString concat(String suffix)
public ByteString concat(String suffix, int offs, int len)
public static ByteString concat(String prefix, ByteString suffix)
public static ByteString concat(String prefix, String suffix)
public char charAt(int index)
charAt
in interface CharSequence
public ByteString subSequence(int start, int end)
subSequence
in interface CharSequence
Copyright © 2017 JBoss by Red Hat. All rights reserved.