diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2015-05-28 23:32:26 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2015-05-28 23:32:26 +0000 |
commit | 16ac6b107e8f5deae70c391be3fbc5d02d751fd0 (patch) | |
tree | 7730b7f3aac2b28855f6aa231c65dad00329e592 /src/java | |
parent | 86c7025e066ec8986b296f2f5d8f9bb6cd5f6612 (diff) | |
download | poi-16ac6b107e8f5deae70c391be3fbc5d02d751fd0.tar.gz poi-16ac6b107e8f5deae70c391be3fbc5d02d751fd0.zip |
Fixed several test drivers or the implementation
renamed font functions in HSLFTextRun
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/common_sl@1682356 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r-- | src/java/org/apache/poi/util/HexDump.java | 50 |
1 files changed, 21 insertions, 29 deletions
diff --git a/src/java/org/apache/poi/util/HexDump.java b/src/java/org/apache/poi/util/HexDump.java index 979ca1c9c5..3c086ba606 100644 --- a/src/java/org/apache/poi/util/HexDump.java +++ b/src/java/org/apache/poi/util/HexDump.java @@ -170,49 +170,41 @@ public class HexDump { * @return output string */ - public static String dump(final byte [] data, final long offset, - final int index) { - StringBuffer buffer; - if ((index < 0) || (index >= data.length)) + public static String dump(final byte [] data, final long offset, final int index) { + if ((index < 0) || (index > data.length)) { throw new ArrayIndexOutOfBoundsException( "illegal index: " + index + " into array of length " + data.length); } - long display_offset = offset + index; - buffer = new StringBuffer(74); + long display_offset = offset + index; + StringBuilder buffer = new StringBuilder(74); - for (int j = index; j < data.length; j += 16) - { + for (int j = index; j <= data.length; j += 16) { int chars_read = data.length - j; - if (chars_read > 16) - { + if (chars_read > 16) { chars_read = 16; } + buffer.append(dump(display_offset)).append(' '); - for (int k = 0; k < 16; k++) - { - if (k < chars_read) - { - buffer.append(dump(data[ k + j ])); - } - else - { - buffer.append(" "); - } + for (int k = 0; k < 16; k++) { + String hexDmp = (k < chars_read) ? dump(data[ k + j ]) : " "; + buffer.append(hexDmp); buffer.append(' '); } - for (int k = 0; k < chars_read; k++) - { - if ((data[ k + j ] >= ' ') && (data[ k + j ] < 127)) - { - buffer.append(( char ) data[ k + j ]); - } - else - { - buffer.append('.'); + for (int k = 0; k < chars_read; k++) { + byte dataB = data[ k + j ]; + char charB = (char)(dataB & 0xFF); + switch (charB) { + case 127: case 128: case 129: case 141: case 142: case 143: case 144: case 157: case 158: + charB = '.'; + break; + default: + if (charB < ' ') charB = '.'; + break; } + buffer.append(charB); } buffer.append(EOL); display_offset += chars_read; |