RFR: 8170769 Provide a simple hexdump facility for binary data
Vincent Ryan
vincent.x.ryan at oracle.com
Fri Dec 7 18:56:12 UTC 2018
I’ll add that replacement method. Thanks.
> On 7 Dec 2018, at 18:49, Kasper Nielsen <kasperni at gmail.com> wrote:
>
> Hi,
>
> I don't know if performance is an issue. But if it is, I think it world make sense to use a precompute array. And replace
>
> private static int hexToBinary(char ch) {
> if ('0' <= ch && ch <= '9') {
> return ch - '0';
> }
> if ('A' <= ch && ch <= 'F') {
> return ch - 'A' + 10;
> }
> if ('a' <= ch && ch <= 'f') {
> return ch - 'a' + 10;
> }
> return -1;
> }
>
> with
>
> private static int hexToBinary(char ch) {
> return ch <= 'f' ? staticPrecomputedArray[ch] : -1;
> }
>
> where int[] staticPrecomputedArray is computed in a static initializer block.
>
> /Kasper
>
> On Fri, 23 Nov 2018 at 14:51, Vincent Ryan <vincent.x.ryan at oracle.com <mailto:vincent.x.ryan at oracle.com>> wrote:
> Hello,
>
> Please review this proposal for a new API to conveniently generate and
> display binary data using hexadecimal string representation.
> It supports both bulk and stream operations and it can also generate the
> well-known hexdump format [1].
>
> This latest revision addresses review comments provided earlier.
> These include adding methods to support for data supplied in a
> ByteBuffer, exposing the default formatter implementation as a public
> static and dropping the superfluous 'Hex' term from several method names.
>
> Thanks
>
>
> Bug: https://bugs.openjdk.java.net/browse/JDK-8170769 <https://bugs.openjdk.java.net/browse/JDK-8170769>
> API:
> http://cr.openjdk.java.net/~vinnie/8170769/javadoc.06/api/java.base/java/util/Hex.html <http://cr.openjdk.java.net/~vinnie/8170769/javadoc.06/api/java.base/java/util/Hex.html>
> Webrev: http://cr.openjdk.java.net/~vinnie/8170769/webrev.06/ <http://cr.openjdk.java.net/~vinnie/8170769/webrev.06/>
>
>
> ____
> [1] https://docs.oracle.com/cd/E88353_01/html/E37839/hexdump-1.html <https://docs.oracle.com/cd/E88353_01/html/E37839/hexdump-1.html>
More information about the core-libs-dev
mailing list