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() |
public ByteArrayCharSequence(byte[] bytes,
int start,
int end)
public int length()
length in interface CharSequencepublic char charAt(int index)
charAt in interface CharSequencepublic ByteArrayCharSequence subSequence(int start, int end)
subSequence in interface CharSequencepublic String toString()
toString in interface CharSequencetoString in class Objectpublic 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 © 2017. All Rights Reserved.