Browse Source

tweak byte formatting logic

git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@469 f203690c-595d-4dc9-a70b-905162fa7fd2
tags/jackcess-1.2.1
James Ahlborn 14 years ago
parent
commit
1b59ad9bfc
1 changed files with 14 additions and 6 deletions
  1. 14
    6
      src/java/com/healthmarketscience/jackcess/ByteUtil.java

+ 14
- 6
src/java/com/healthmarketscience/jackcess/ByteUtil.java View File

@@ -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(" ");
}
}
}
}

Loading…
Cancel
Save