RFR: 8251989: Hex formatting and parsing utility [v18]
Roger Riggs
rriggs at openjdk.java.net
Sat Dec 5 16:35:02 UTC 2020
> java.util.HexFormat utility:
>
> - Format and parse hexadecimal strings, with parameters for delimiter, prefix, suffix and upper/lowercase
> - Static factories and builder methods to create HexFormat copies with modified parameters.
> - Consistent naming of methods for conversion of byte arrays to formatted strings and back: formatHex and parseHex
> - Consistent naming of methods for conversion of primitive types: toHexDigits... and fromHexDigits...
> - Prefix and suffixes now apply to each formatted value, not the string as a whole
> - Using java.util.Appendable as a target for buffered conversions so output to Writers and PrintStreams
> like System.out are supported in addition to StringBuilder. (IOExceptions are converted to unchecked exceptions)
> - Immutable and thread safe, a "value-based" class
>
> See the [HexFormat javadoc](http://cr.openjdk.java.net/~rriggs/8251989-hex-formatter/java.base/java/util/HexFormat.html) for details.
>
> Review comments and suggestions welcome.
Roger Riggs has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 29 additional commits since the last revision:
- Added @apiNote to fromHexDigits methods to link and compare to similar methods in Integer and Long.
- Merge branch 'master' into 8251989-hex-formatter
- Add class level clarification of use of uppercase for primitive conversions
Switched order of declaration of a couple of method to make the javadoc sequence easier to read
- Clarify that the fromHexDigit method does not use the prefix, suffix, delimiter, or uppercase parameter.
- Clarify that the fromHexDigits does not use the uppercase parameter.
- Increased memory to 4G for the test and add diagnostic info for OOME
- Review comment updates:
- misc javadoc markup fixes.
- added checking of byte array sizes to generate useful exceptions if the arrays would be too large.
- Small implementation cleanups
- Clarified hexadecimal characters used in converting from characters to values to be strictly 0-9, a-f, and A-F.
Added a test to verify isHexDigit and fromHexDigit for the entire range of chars
- Merge branch 'master' into 8251989-hex-formatter
- Addressed review comments on use of formatted hexadecimal strings, updated copyrights, etc.
- ... and 19 more: https://git.openjdk.java.net/jdk/compare/4e2842b3...af7b1fa9
-------------
Changes:
- all: https://git.openjdk.java.net/jdk/pull/482/files
- new: https://git.openjdk.java.net/jdk/pull/482/files/0a8088b1..af7b1fa9
Webrevs:
- full: https://webrevs.openjdk.java.net/?repo=jdk&pr=482&range=17
- incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=482&range=16-17
Stats: 24226 lines in 635 files changed: 18266 ins; 3456 del; 2504 mod
Patch: https://git.openjdk.java.net/jdk/pull/482.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/482/head:pull/482
PR: https://git.openjdk.java.net/jdk/pull/482
More information about the core-libs-dev
mailing list