diff --git a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/ByteChunk.java b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/ByteChunk.java index ec20e4e57..25a525ab6 100644 --- a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/ByteChunk.java +++ b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/ByteChunk.java @@ -62,6 +62,42 @@ public class ByteChunk extends Chunk { this.value = value; } + /** + * Returns the data in a debug-friendly string format + */ + public String toString() { + return toDebugFriendlyString(value); + } + + /** + * Formats the byte array in a debug-friendly way, + * showing all of a short array, and the start of a + * longer one. + */ + protected static String toDebugFriendlyString(byte[] value) { + if (value == null) + return "(Null Byte Array)"; + + StringBuffer text = new StringBuffer(); + text.append("Bytes len=").append(value.length); + text.append(" ["); + + int limit = Math.min(value.length, 16); + if (value.length > 16) { + limit = 12; + } + for (int i=0; i 0) + text.append(','); + text.append(value[i]); + } + if (value.length > 16) { + text.append(",...."); + } + text.append("]"); + return text.toString(); + } + /** * Returns the data, formatted as a string assuming it * was a non-unicode string. diff --git a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/PropertyValue.java b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/PropertyValue.java index 1b67ba024..1ea8a2628 100644 --- a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/PropertyValue.java +++ b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/PropertyValue.java @@ -60,7 +60,16 @@ public class PropertyValue { } public String toString() { - return property + " = " + getValue(); + Object v = getValue(); + if (v == null) + return "(No value available)"; + + if (v instanceof byte[]) { + return ByteChunk.toDebugFriendlyString((byte[])v); + } else { + // Just use the normal toString on the value + return v.toString(); + } } // TODO classes for the other important value types