diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2013-09-09 03:31:44 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2013-09-09 03:31:44 +0000 |
commit | c6adc0038b1822dfa77ed5e998bd08dd0519ec89 (patch) | |
tree | a4c6d7189b50c4e63e002c3e7a66f37ad56adbc0 /src/main/java/com/healthmarketscience/jackcess/impl/CustomToStringStyle.java | |
parent | 613141a12aaca99045c6ac886ab1633190b9085d (diff) | |
download | jackcess-c6adc0038b1822dfa77ed5e998bd08dd0519ec89.tar.gz jackcess-c6adc0038b1822dfa77ed5e998bd08dd0519ec89.zip |
a little more revamp tostring output
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@795 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/main/java/com/healthmarketscience/jackcess/impl/CustomToStringStyle.java')
-rw-r--r-- | src/main/java/com/healthmarketscience/jackcess/impl/CustomToStringStyle.java | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/CustomToStringStyle.java b/src/main/java/com/healthmarketscience/jackcess/impl/CustomToStringStyle.java index d909f96..437f176 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/CustomToStringStyle.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/CustomToStringStyle.java @@ -37,7 +37,7 @@ public class CustomToStringStyle extends StandardToStringStyle { private static final long serialVersionUID = 0L; - private static final String FIELD_SEP = SystemUtils.LINE_SEPARATOR + " "; + private static final String ML_FIELD_SEP = SystemUtils.LINE_SEPARATOR + " "; private static final String IMPL_SUFFIX = "Impl"; private static final int MAX_BYTE_DETAIL_LEN = 20; @@ -45,9 +45,10 @@ public class CustomToStringStyle extends StandardToStringStyle private static final long serialVersionUID = 0L; { setContentStart("["); - setFieldSeparator(FIELD_SEP); + setFieldSeparator(ML_FIELD_SEP); setFieldSeparatorAtStart(true); setFieldNameValueSeparator(": "); + setArraySeparator("," + ML_FIELD_SEP); setContentEnd(SystemUtils.LINE_SEPARATOR + "]"); setUseShortClassName(true); } @@ -121,8 +122,7 @@ public class CustomToStringStyle extends StandardToStringStyle appendInternal(sb, fieldName, iter.next(), true); } while(iter.hasNext()) { - sb.append(","); - appendFieldSeparator(sb); + sb.append(getArraySeparator()); appendInternal(sb, fieldName, iter.next(), true); } @@ -154,19 +154,18 @@ public class CustomToStringStyle extends StandardToStringStyle appendInternal(sb, fieldName, e.getValue(), true); } while(iter.hasNext()) { - sb.append(","); - appendFieldSeparator(sb); + sb.append(getArraySeparator()); Map.Entry<?,?> e = iter.next(); sb.append(e.getKey()).append("="); appendInternal(sb, fieldName, e.getValue(), true); } - if(isFieldSeparatorAtStart()) { - appendFieldSeparator(sb); - } // indent entire map contents another level buffer.append(indent(sb)); + if(isFieldSeparatorAtStart()) { + appendFieldSeparator(buffer); + } buffer.append("}"); } @@ -179,16 +178,15 @@ public class CustomToStringStyle extends StandardToStringStyle private static void appendDetail(StringBuffer buffer, ByteBuffer bb) { int len = bb.remaining(); buffer.append("(").append(len).append(") "); + buffer.append(ByteUtil.toHexString(bb, bb.position(), + Math.min(len, MAX_BYTE_DETAIL_LEN))); if(len > MAX_BYTE_DETAIL_LEN) { - buffer.append(ByteUtil.toHexString(bb, len, MAX_BYTE_DETAIL_LEN)) - .append(" ..."); - } else { - buffer.append(ByteUtil.toHexString(bb, len)); + buffer.append(" ..."); } } private static String indent(Object obj) { return ((obj != null) ? obj.toString().replaceAll( - SystemUtils.LINE_SEPARATOR, FIELD_SEP) : null); + SystemUtils.LINE_SEPARATOR, ML_FIELD_SEP) : null); } } |