{
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;
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);
}
appendInternal(sb, fieldName, iter.next(), true);
}
while(iter.hasNext()) {
- sb.append(",");
- appendFieldSeparator(sb);
+ sb.append(getArraySeparator());
appendInternal(sb, fieldName, iter.next(), true);
}
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("}");
}
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);
}
}