APIdia Launch Partner
Top Description Fields Constructors Methods
jdk.internal.util

public final Class HexDigits

extends Object
Class Inheritance
Imports
jdk.internal.access.SharedSecrets, jdk.internal.vm.annotation.Stable

Digits provides a fast methodology for converting integers and longs to hexadecimal digits ASCII strings.
Since
21

Field Summary

Modifier and TypeField and Description
private static final short[]
DIGITS

Each element of the array represents the ascii encoded hex relative to its index, for example:

      0 -> '00' -> '0' | ('0' << 8) -> 0x3030
      1 -> '01' -> '0' | ('1' << 8) -> 0x3130
      2 -> '02' -> '0' | ('2' << 8) -> 0x3230

    ...

Constructor Summary

AccessConstructor and Description
private
HexDigits()

Constructor.

Method Summary

Modifier and TypeMethod and Description
public static short

Returns:

a short encoding a pair of hex ASCII-encoded digit characters
digitPair
(int
value to convert
i
,
boolean
true uppper case, false lower case
ucase
)

For values from 0 to 255 return a short encoding a pair of hex ASCII-encoded digit characters in little-endian

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DIGITSback to summary
private static final short[] DIGITS

Each element of the array represents the ascii encoded hex relative to its index, for example:

      0 -> '00' -> '0' | ('0' << 8) -> 0x3030
      1 -> '01' -> '0' | ('1' << 8) -> 0x3130
      2 -> '02' -> '0' | ('2' << 8) -> 0x3230

    ...

     10 -> '0a' -> '0' | ('a' << 8) -> 0x6130
     11 -> '0b' -> '0' | ('b' << 8) -> 0x6230
     12 -> '0c' -> '0' | ('b' << 8) -> 0x6330

    ...

     26 -> '1a' -> '1' | ('a' << 8) -> 0x6131
     27 -> '1b' -> '1' | ('b' << 8) -> 0x6231
     28 -> '1c' -> '1' | ('c' << 8) -> 0x6331

    ...

    253 -> 'fd' -> 'f' | ('d' << 8) -> 0x6466
    254 -> 'fe' -> 'f' | ('e' << 8) -> 0x6566
    255 -> 'ff' -> 'f' | ('f' << 8) -> 0x6666
Annotations
@Stable

Constructor Detail

HexDigitsback to summary
private HexDigits()

Constructor.

Method Detail

digitPairback to summary
public static short digitPair(int i, boolean ucase)

For values from 0 to 255 return a short encoding a pair of hex ASCII-encoded digit characters in little-endian

Parameters
i:int

value to convert

ucase:boolean

true uppper case, false lower case

Returns:short

a short encoding a pair of hex ASCII-encoded digit characters