From: James Ahlborn Date: Wed, 26 May 2010 12:31:47 +0000 (+0000) Subject: tweak byte formatting logic X-Git-Tag: jackcess-1.2.1~10 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1b59ad9bfc0da2d68dd5ba295456810a55b27b9f;p=jackcess.git tweak byte formatting logic git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@469 f203690c-595d-4dc9-a70b-905162fa7fd2 --- diff --git a/src/java/com/healthmarketscience/jackcess/ByteUtil.java b/src/java/com/healthmarketscience/jackcess/ByteUtil.java index fbb1521..223b5b0 100644 --- a/src/java/com/healthmarketscience/jackcess/ByteUtil.java +++ b/src/java/com/healthmarketscience/jackcess/ByteUtil.java @@ -43,6 +43,9 @@ public final class ByteUtil { private static final String[] HEX_CHARS = new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}; + + private static final int NUM_BYTES_PER_BLOCK = 4; + private static final int NUM_BYTES_PER_LINE = 24; private ByteUtil() {} @@ -380,15 +383,20 @@ public final class ByteUtil { h = (byte) (b & 0x0F); rtn.append(HEX_CHARS[h]); - if (formatted == true) + int next = (i + 1); + if(formatted && (next < size)) { - rtn.append(" "); + if((next % NUM_BYTES_PER_LINE) == 0) { - if ((i + 1) % 4 == 0) { - rtn.append(" "); - } - if ((i + 1) % 24 == 0) { rtn.append("\n"); + + } else { + + rtn.append(" "); + + if ((next % NUM_BYTES_PER_BLOCK) == 0) { + rtn.append(" "); + } } } }