APIdia Launch Partner
Top Description Constructors Methods
java.lang

pack-priv Class StringCoding

extends Object
Class Inheritance
Imports
jdk.internal.util.Preconditions, jdk.internal.vm.annotation.IntrinsicCandidate, java.util.function.BiFunction

Utility class for string encoding and decoding.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static int
countNonZeroAscii(String s)

Count the number of leading non-zero ascii chars in the range.

private static int
countNonZeroAsciiLatin1(byte[] ba, int off, int len)

Count the number of non-zero ascii chars in the range.

private static int
countNonZeroAsciiUTF16(byte[] ba, int off, int strlen)

Count the number of leading non-zero ascii chars in the range.

pack-priv static int
countPositives(byte[]
a byte array
ba
,
int
the index of the first byte to start reading from
off
,
int
the total number of bytes to read
len
)

Count the number of leading positive bytes in the range.

private static int
countPositives0(byte[] ba, int off, int len)

pack-priv static int

Returns:

the total number of characters successfully encoded
encodeAsciiArray
(char[]
the source character array
sa
,
int
the index of the source array to start reading from
sp
,
byte[]
the target byte array
da
,
int
the index of the target array to start writing to
dp
,
int
the maximum number of characters to be encoded
len
)

Encodes as many ASCII codepoints as possible from the source character array into the destination byte array, assuming that the encoding is ASCII compatible.

pack-priv static int
encodeAsciiArray0(char[] sa, int sp, byte[] da, int dp, int len)

pack-priv static int

Returns:

the total number of characters (not bytes!) successfully encoded
encodeISOArray
(byte[]
the source byte array containing characters encoded in UTF-16
sa
,
int
the index of the character (not byte!) from the source array to start reading from
sp
,
byte[]
the target byte array
da
,
int
the index of the target array to start writing to
dp
,
int
the maximum number of characters (not bytes!) to be encoded
len
)

Encodes as many ISO-8859-1 codepoints as possible from the source byte array containing characters encoded in UTF-16, into the destination byte array, assuming that the encoding is ISO-8859-1 compatible.

private static int
encodeISOArray0(byte[] sa, int sp, byte[] da, int dp, int len)

pack-priv static boolean
hasNegatives(byte[] ba, int off, int len)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

StringCodingback to summary
private StringCoding()

Method Detail

countNonZeroAsciiback to summary
pack-priv static int countNonZeroAscii(String s)

Count the number of leading non-zero ascii chars in the range.

countNonZeroAsciiLatin1back to summary
private static int countNonZeroAsciiLatin1(byte[] ba, int off, int len)

Count the number of non-zero ascii chars in the range.

countNonZeroAsciiUTF16back to summary
private static int countNonZeroAsciiUTF16(byte[] ba, int off, int strlen)

Count the number of leading non-zero ascii chars in the range.

countPositivesback to summary
pack-priv static int countPositives(byte[] ba, int off, int len)

Count the number of leading positive bytes in the range.

Implementation Specification

the implementation must return len if there are no negative bytes in the range. If there are negative bytes, the implementation must return a value that is less than or equal to the index of the first negative byte in the range.

Parameters
ba:byte[]

a byte array

off:int

the index of the first byte to start reading from

len:int

the total number of bytes to read

Exceptions
NullPointerException:
if ba is null
ArrayIndexOutOfBoundsException:
if the provided sub-range is out of bounds
countPositives0back to summary
private static int countPositives0(byte[] ba, int off, int len)
Annotations
@IntrinsicCandidate
encodeAsciiArrayback to summary
pack-priv static int encodeAsciiArray(char[] sa, int sp, byte[] da, int dp, int len)

Encodes as many ASCII codepoints as possible from the source character array into the destination byte array, assuming that the encoding is ASCII compatible.

Parameters
sa:char[]

the source character array

sp:int

the index of the source array to start reading from

da:byte[]

the target byte array

dp:int

the index of the target array to start writing to

len:int

the maximum number of characters to be encoded

Returns:int

the total number of characters successfully encoded

Exceptions
NullPointerException:
if any of the provided arrays is null
encodeAsciiArray0back to summary
pack-priv static int encodeAsciiArray0(char[] sa, int sp, byte[] da, int dp, int len)
Annotations
@IntrinsicCandidate
encodeISOArrayback to summary
pack-priv static int encodeISOArray(byte[] sa, int sp, byte[] da, int dp, int len)

Encodes as many ISO-8859-1 codepoints as possible from the source byte array containing characters encoded in UTF-16, into the destination byte array, assuming that the encoding is ISO-8859-1 compatible.

Parameters
sa:byte[]

the source byte array containing characters encoded in UTF-16

sp:int

the index of the character (not byte!) from the source array to start reading from

da:byte[]

the target byte array

dp:int

the index of the target array to start writing to

len:int

the maximum number of characters (not bytes!) to be encoded

Returns:int

the total number of characters (not bytes!) successfully encoded

Exceptions
NullPointerException:
if any of the provided arrays is null
encodeISOArray0back to summary
private static int encodeISOArray0(byte[] sa, int sp, byte[] da, int dp, int len)
Annotations
@IntrinsicCandidate
hasNegativesback to summary
pack-priv static boolean hasNegatives(byte[] ba, int off, int len)