APIdia Launch Partner
Top Description Inners Fields Constructors Methods
java.lang

pack-priv final Class StringUTF16

extends Object
Class Inheritance
Imports
java.util.Arrays, .Locale, .Objects, .Spliterator, java.util.function.Consumer, .IntConsumer, java.util.stream.Stream, .StreamSupport, jdk.internal.lang.CaseFolding, jdk.internal.misc.Unsafe, jdk.internal.util.ArraysSupport, jdk.internal.vm.annotation.ForceInline, .IntrinsicCandidate

UTF16 String operations.

UTF16 byte arrays have the identical layout as char arrays. They share the same base offset and scale, and for each two-byte unit interpreted as a char, it has the same endianness as a char, which is the platform endianness. This is ensured in the static initializer of StringUTF16.

Unless stated otherwise, all methods assume that

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class
private static class

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv static char
charAt(byte[] value, int index)

pack-priv static void
checkBoundsBeginEnd(int begin, int end, byte[] val)

private static void
checkBytesLength(int
a UTF-16 string byte array length
length
)

Checks if the provided length is a valid UTF-16 string byte array length.

private static void
checkIndex(int off, byte[] val)

private static void
checkOffset(int off, byte[] val)

pack-priv static int
codePointAt(byte[] value, int index, int end, boolean checked)

pack-priv static int
codePointAt(byte[] value, int index, int end)

pack-priv static int
codePointAtSB(byte[] val, int index, int end)

private static int
codePointBefore(byte[] value, int index, boolean checked)

pack-priv static int
codePointBefore(byte[] value, int index)

pack-priv static int
codePointBeforeSB(byte[] val, int index)

private static int
codePointCount(byte[] value, int beginIndex, int endIndex, boolean checked)

pack-priv static int
codePointCount(byte[] value, int beginIndex, int endIndex)

pack-priv static int
codePointCountSB(byte[] val, int beginIndex, int endIndex)

private static int
codePointIncluding(byte[] ba, int cp, int index, int start, int end)

pack-priv static byte
coderFromArrayLen(byte[] value, int len)

private static int
compareCodePointCI(int cp1, int cp2)

pack-priv static int

Returns:

0 if value is equal to other, a value less than 0 if value is lexicographically less than other; a value greater than 0 otherwise.
compareTo
(byte[]
a UTF-16 string byte array
value
,
byte[]
a UTF-16 string byte array
other
)

Lexicographically compares two UTF-16 strings as specified in String::compareTo.

pack-priv static int
compareTo(byte[]
a UTF-16 string byte array
value
,
byte[]
a UTF-16 string byte array
other
,
int
the number of characters in value to compare
len1
,
int
the number of characters in other to compare
len2
)

Lexicographically compares two UTF-16 string prefixes as specified in String::compareTo.

private static int
compareTo0(byte[] value, byte[] other)

pack-priv static int
compareToCI(byte[] value, byte[] other)

Case-insensitive compareTo.

pack-priv static int
compareToCI_Latin1(byte[] value, byte[] other)

Case-insensitive compareToLatin1.

private static int
compareToCIImpl(byte[] value, int toffset, int tlen, byte[] other, int ooffset, int olen)

pack-priv static int
compareToFC(byte[] value, byte[] other)

private static int
compareToFC0(byte[] value, int off, int last, byte[] other, int ooff, int olast)

pack-priv static int
compareToFC_Latin1(byte[] value, byte[] other)

pack-priv static int

Returns:

0 if value is equal to other, a value less than 0 if value is lexicographically less than other; a value greater than 0 otherwise.
compareToLatin1
(byte[]
a UTF-16 string byte array
value
,
byte[]
a Latin-1 string byte array
other
)

Lexicographically compares a UTF-16 string to a Latin-1 one as specified in String::compareTo.

pack-priv static int

Returns:

0 if the value prefix is equal to the other prefix, a value less than 0 if the value prefix is lexicographically less than the other prefix; a value greater than 0 otherwise.
compareToLatin1
(byte[]
a UTF-16 string byte array
value
,
byte[]
a Latin-1 string byte array
other
,
int
the number of characters from value to compare
len1
,
int
the number of characters from other to compare
len2
)

Lexicographically compares a UTF-16 string prefix to a Latin-1 one as specified in String::compareTo.

private static int
compareToLatin1_0(byte[] value, byte[] other)

private static int
compareValues(byte[] value, byte[] other, int len1, int len2)

pack-priv static byte[]

Returns:

Compress the char array (containing UTF16) into a compact strings byte array
compress
(final char[]
a char array
val
,
final int
starting offset
off
,
final int
count of chars to be compressed, count > 0
count
)

Returns Compress the char array (containing UTF16) into a compact strings byte array.

pack-priv static byte[]

Returns:

Compress the internal byte array (containing UTF16) into a compact strings byte array
compress
(final byte[]
a byte array with UTF16 coding
val
,
final int
starting offset
off
,
final int
count of chars to be compressed, count > 0
count
)

Returns Compress the internal byte array (containing UTF16) into a compact strings byte array.

pack-priv static byte[]

Returns:

compress the code points into a compact strings byte array
compress
(final int[]
an int array of code points
val
,
int
starting offset
off
,
final int
length of code points to be compressed, length > 0
count
)

Returns compress the code points into a compact strings byte array.

pack-priv static int

Returns:

the number of characters copied
compress
(char[]
the source char array
src
,
int
the index (inclusive) of the first character in src
srcOff
,
byte[]
the target Latin-1 string byte array
dst
,
int
the index (inclusive) of the first character in dst
dstOff
,
int
the maximum number of characters to copy
len
)

Copies the prefix of Latin-1 characters from a char array sub-range to a Latin-1 string byte array sub-range.

pack-priv static int

Returns:

the number of characters copied
compress
(byte[]
the source UTF-16 string byte array
src
,
int
the index (inclusive) of the first character in src
srcOff
,
byte[]
the target Latin-1 string byte array
dst
,
int
the index (inclusive) of the first character in dst
dstOff
,
int
the maximum number of characters to copy
len
)

Copies the prefix of Latin-1 characters from a UTF-16 string byte array sub-range to a Latin-1 one.

private static int
compress0(char[] src, int srcOff, byte[] dst, int dstOff, int len)

private static int
compress0(byte[] src, int srcOff, byte[] dst, int dstOff, int len)

private static int
computeCodePointSize(int[] val, int off, int end)

pack-priv static boolean
contentEquals(byte[] v1, byte[] v2, int len)

pack-priv static boolean
contentEquals(byte[] value, CharSequence cs, int len)

private static byte[]
extractCodepoints(int[] val, int off, int end, byte[] dst, int dstOff)

pack-priv static void
getBytes(byte[] value, int srcBegin, int srcEnd, byte[] dst, int dstBegin)

pack-priv static char

Returns:

the code point at the the specified position of the provided UTF-16 string byte array
getChar
(byte[]
a UTF-16 string byte array
val
,
int
the index of the character to get the code point from
index
)

Returns the code point at the the specified position of the provided UTF-16 string byte array.

pack-priv static void
getChars(byte[]
the source UTF-16 string byte array to copy from
value
,
int
the index (inclusive) of the first character in the source sub-range
srcBegin
,
int
the index (exclusive) of the last character in the source sub-range
srcEnd
,
char[]
the target character array to copy to
dst
,
int
the index (inclusive) of the first character in the target sub-range
dstBegin
)

Copies the specified sub-range of characters from a UTF-16 string byte array to the specified character array sub-range.

private static void
getChars0(byte[] value, int srcBegin, int srcEnd, char[] dst, int dstBegin)

pack-priv static int
hashCode(byte[] value)

pack-priv static int

Returns:

the index of the first character matching the provided one in the given UTF-16 string byte array sub-range; -1 otherwise
indexOf
(byte[]
a UTF-16 string byte array to search in
value
,
int
a character to search for
ch
,
int
the index (inclusive) of the first character in the sub-range
fromIndex
,
int
the index (exclusive) of the last character in the sub-range
toIndex
)

Returns the index of the first character matching the provided one in the given UTF-16 string byte array sub-range; -1 otherwise.

pack-priv static int

Returns:

the index of the first character of the matching value sub-range if a match is found; -1 otherwise
indexOf
(byte[]
a UTF-16 string byte array to search in
value
,
byte[]
a UTF-16 string byte array to search for
str
)

Searches for the first occurrence of str in value, and, if found, returns the index of the first character of the matching value sub-range; -1 otherwise.

pack-priv static int

Returns:

the index of the first character of the matching value sub-range if a match is found; -1 otherwise
indexOf
(byte[]
a UTF-16 string byte array to search in
value
,
int
the index (exclusive) of the last character in value
valueToIndex
,
byte[]
a UTF-16 string byte array to search for
str
,
int
the index (exclusive) of the last character in str
strToIndex
,
int
the index (inclusive) of the first character in value
valueFromIndex
)

Searches for the first occurrence of the given str sub-range in the given value sub-range, and, if found, returns the index of the first character of the matching value sub-range; -1 otherwise.

private static int
indexOf0(byte[] value, byte[] str)

private static int
indexOf0(byte[] value, int valueToIndex, byte[] str, int strToIndex, int valueFromIndex)

private static int
indexOfChar0(byte[] value, int ch, int fromIndex, int max)

pack-priv static int

Returns:

the index of the first character of the matching value sub-range if a match is found; -1 otherwise
indexOfLatin1
(byte[]
a UTF-16 string byte array to search in
value
,
byte[]
a Latin-1 string byte array to search for
str
)

Searches for the first occurrence of the given Latin-1 string byte array str in the given UTF-16 string byte array value, and, if found, returns the index of the first character of the matching value sub-range; -1 otherwise.

pack-priv static int

Returns:

the index of the first character of the matching src sub-range if a match is found; -1 otherwise
indexOfLatin1
(byte[]
a UTF-16 string byte array to search in
src
,
int
the index (exclusive) of the last character in src
srcToIndex
,
byte[]
a Latin-1 string byte array to search for
tgt
,
int
the index (exclusive) of the last character in tgt
tgtToIndex
,
int
the index (inclusive) of the first character in src
tgtFromIndex
)

Searches for the first occurrence of the given Latin-1 string byte array tgt sub-range in the given UTF-16 string byte array src sub-range, and, if found, returns the index of the first character in src; -1 otherwise.

private static int
indexOfLatin1_0(byte[] value, byte[] str)

private static int
indexOfLatin1_0(byte[] src, int srcToIndex, byte[] tgt, int tgtToIndex, int srcFromIndex)

private static int
indexOfLatin1Unsafe(byte[] src, int srcCount, byte[] tgt, int tgtCount, int fromIndex)

pack-priv static int
indexOfNonWhitespace(byte[] value)

private static int
indexOfSupplementary(byte[] value, int ch, int fromIndex, int max)

Handles (rare) calls of indexOf with a supplementary character.

private static int
indexOfUnsafe(byte[] value, int valueToIndex, byte[] str, int strToIndex, int valueFromIndex)

pack-priv static int
lastIndexOf(byte[] src, int srcCount, byte[] tgt, int tgtCount, int fromIndex)

pack-priv static int
lastIndexOf(byte[] value, int ch, int fromIndex)

pack-priv static int
lastIndexOfLatin1(byte[] src, int srcCount, byte[] tgt, int tgtCount, int fromIndex)

pack-priv static int
private static int
lastIndexOfSupplementary(final byte[] value, int ch, int fromIndex)

Handles (rare) calls of lastIndexOf with a supplementary character.

pack-priv static int
length(byte[] value)

pack-priv static Stream<String>
lines(byte[] value)

pack-priv static byte[]
newBytesFor(int len)

private static int
newBytesLength(int len)

pack-priv static String
newString(byte[] val, int index, int len)

pack-priv static void
putChar(byte[]
a UTF-16 string byte array
val
,
int
the index of the character to write the code point to
index
,
int
a code point
c
)

Writes the given code point to the specified position of the provided UTF-16 string byte array.

pack-priv static void
putCharsAt(byte[] value, int i, char c1, char c2, char c3, char c4)

pack-priv static void
putCharsAt(byte[] value, int i, char c1, char c2, char c3, char c4, char c5)

pack-priv static void
putCharSB(byte[] val, int index, int c)

pack-priv static void
putCharsSB(byte[] val, int index, char[] ca, int off, int end)

pack-priv static void
putCharsSB(byte[] val, int index, CharSequence s, int off, int end)

pack-priv static boolean
regionMatchesCI(byte[] value, int toffset, byte[] other, int ooffset, int len)

pack-priv static boolean
regionMatchesCI_Latin1(byte[] value, int toffset, byte[] other, int ooffset, int len)

pack-priv static String
replace(byte[] value, char oldChar, char newChar)

pack-priv static String
replace(byte[] value, int valLen, boolean valLat1, byte[] targ, int targLen, boolean targLat1, byte[] repl, int replLen, boolean replLat1)

pack-priv static void
reverse(byte[] val, int count)

private static void
reverseAllValidSurrogatePairs(byte[] val, int count)

Outlined helper method for reverse()

pack-priv static String
strip(byte[] value)

pack-priv static String
stripLeading(byte[] value)

pack-priv static String
stripTrailing(byte[] value)

pack-priv static byte[]

Returns:

a UTF-16 string byte array produced by encoding the characters in the provided character array sub-range
toBytes
(char[]
a character array to encode
value
,
int
the index of the character to start encoding from
off
,
int
the number of characters to encode
len
)

Returns a UTF-16 string byte array produced by encoding the characters in the provided character array sub-range.

pack-priv static byte[]
toBytes(int[] val, int index, int len)

pack-priv static byte[]
toBytes(char c)

private static byte[]
toBytes0(char[] value, int off, int len)

pack-priv static byte[]
pack-priv static char[]
toChars(byte[] value)

pack-priv static String
toLowerCase(String str, byte[] value, Locale locale)

private static String
toLowerCaseEx(String str, byte[] value, byte[] result, int first, Locale locale, boolean localeDependent)

pack-priv static String
toUpperCase(String str, byte[] value, Locale locale)

private static String
toUpperCaseEx(String str, byte[] value, byte[] result, int first, Locale locale, boolean localeDependent)

pack-priv static String
trim(byte[] value)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait