RFR 8251989: Hex formatting and parsing

Roger Riggs Roger.Riggs at oracle.com
Wed Sep 2 20:26:07 UTC 2020


Please review the updated API in the Javadoc.
http://cr.openjdk.java.net/~rriggs/hex-formatter/java.base/java/util/Hex.html

A few offline contacts encouaged me to explore expanding the support
for formatting and parsing of primitive types.
Adding formatting toHex methods and [arsing fromHex methods makes the
API easier to use.

For example, there are a number of protocols that need to escape char 
values
as hex. For symmetry across the primitive types, byte, char, short, int, 
and long
methods are added.

The handling of invalid digits was changed to consistently throw
IllegalArgumentException; it is unlikely that encoding and decoding
run into invalid characters and the previous technique requiring the caller
to check the value for negative numbers is error prone.

There is some danger of proliferating methods yet, so not all combinations
are included.  Feedback welcome.

With the API still shifting, the implemention is not ready to review.

Thanks, Roger



More information about the core-libs-dev mailing list