Browse Source

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
tags/jackcess-2.0.1
James Ahlborn 10 years ago
parent
commit
c6adc0038b

+ 12
- 14
src/main/java/com/healthmarketscience/jackcess/impl/CustomToStringStyle.java View File

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

+ 3
- 1
src/main/java/com/healthmarketscience/jackcess/impl/RowImpl.java View File

@@ -60,6 +60,8 @@ public class RowImpl extends LinkedHashMap<String,Object> implements Row

@Override
public String toString() {
return "Row[" + _id + "] " + super.toString();
return CustomToStringStyle.valueBuilder("Row[" + _id + "]")
.append(null, this)
.toString();
}
}

Loading…
Cancel
Save