public class ByteArrayCharSequence extends Object implements CharSequence
CharSequence
view onto a byte array of UTF-8-encoded characters, with the proviso that all of the
characters were encoded as a single byte in UTF-8. This uses Java's built-in casting from UTF-8 to char primitives.Modifier and Type | Class and Description |
---|---|
static class |
ByteArrayCharSequence.IncompatibleCharacterException |
Constructor and Description |
---|
ByteArrayCharSequence(byte[] bytes,
int start,
int end) |
Modifier and Type | Method and Description |
---|---|
char |
charAt(int index) |
int |
length() |
ByteArrayCharSequence |
subSequence(int start,
int end) |
static byte[] |
toSingleByteUtf8Encoding(CharSequence charSequence)
Encodes a given
CharSequence into a byte[] in UTF-8 encoding, with the requirement that
it must be possible to represent all characters as a single byte in UTF-8. |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
chars, codePoints
public ByteArrayCharSequence(byte[] bytes, int start, int end)
public int length()
length
in interface CharSequence
public char charAt(int index)
charAt
in interface CharSequence
public ByteArrayCharSequence subSequence(int start, int end)
subSequence
in interface CharSequence
public String toString()
toString
in interface CharSequence
toString
in class Object
public static byte[] toSingleByteUtf8Encoding(CharSequence charSequence)
CharSequence
into a byte[]
in UTF-8 encoding, with the requirement that
it must be possible to represent all characters as a single byte in UTF-8. Otherwise an exception will be
thrown.charSequence
- The CharSequence
to encodebyte[]
encoding characters from the given CharSequence
in UTF-8IllegalStateException
- If the characters cannot be encoded as describedCopyright © 2016. All rights reserved.