Class ByteArrayCharSequence
java.lang.Object
com.googlecode.concurrenttrees.radix.node.concrete.bytearray.ByteArrayCharSequence
- All Implemented Interfaces:
CharSequence
A
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchar
charAt
(int index) int
length()
subSequence
(int start, int end) static byte[]
toSingleByteUtf8Encoding
(CharSequence charSequence) Encodes a givenCharSequence
into abyte[]
in UTF-8 encoding, with the requirement that it must be possible to represent all characters as a single byte in UTF-8.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Field Details
-
bytes
final byte[] bytes -
start
final int start -
end
final int end
-
-
Constructor Details
-
ByteArrayCharSequence
public ByteArrayCharSequence(byte[] bytes, int start, int end)
-
-
Method Details
-
length
public int length()- Specified by:
length
in interfaceCharSequence
-
charAt
public char charAt(int index) - Specified by:
charAt
in interfaceCharSequence
-
subSequence
- Specified by:
subSequence
in interfaceCharSequence
-
toString
- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classObject
-
toSingleByteUtf8Encoding
Encodes a givenCharSequence
into abyte[]
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.- Parameters:
charSequence
- TheCharSequence
to encode- Returns:
- A new
byte[]
encoding characters from the givenCharSequence
in UTF-8 - Throws:
IllegalStateException
- If the characters cannot be encoded as described
-