NodeState state = model.getState();
String tarFile = "";
if (state instanceof SegmentNodeState) {
SegmentNodeState s = (SegmentNodeState) state;
RecordId recordId = s.getRecordId();
sb.append("Record " + recordId);
tarFile = getFile(recordId);
if (tarFile.length() > 0) {
sb.append(" in " + tarFile);
}
sb.append(newline);
RecordId templateId = SegmentNodeStateHelper.getTemplateId(s);
String f = getFile(templateId);
sb.append("TemplateId ");
sb.append(templateId);
if (!f.equals(tarFile)) {
sb.append(" in " + f);
}
sb.append(newline);
}
sb.append("Size: ");
sb.append(" direct: ");
sb.append(FileUtils.byteCountToDisplaySize(model.getSize()[0]));
sb.append("; linked: ");
sb.append(FileUtils.byteCountToDisplaySize(model.getSize()[1]));
sb.append(newline);
sb.append("Properties (count: " + state.getPropertyCount() + ")");
sb.append(newline);
Map<String, String> propLines = new TreeMap<String, String>();
for (PropertyState ps : state.getProperties()) {
StringBuilder l = new StringBuilder();
l.append(" - " + ps.getName() + " = {" + ps.getType() + "} ");
if (ps.getType().isArray()) {
int count = ps.count();
l.append("(count " + count + ") [");
String separator = ", ";
int max = 50;
if (ps.getType() == Type.BINARIES) {
separator = newline + " ";
max = Integer.MAX_VALUE;
l.append(separator);
}
for (int i = 0; i < Math.min(count, max); i++) {
if (i > 0) {
l.append(separator);
}
l.append(toString(ps, i, tarFile));
}
if (count > max) {
l.append(", ... (" + count + " values)");
}
if (ps.getType() == Type.BINARIES) {
l.append(separator);
}
l.append("]");
} else {
l.append(toString(ps, 0, tarFile));
}
if (ps instanceof SegmentPropertyState) {
RecordId rid = ((SegmentPropertyState) ps).getRecordId();
l.append(" (" + rid);
String f = getFile(rid);
if (!f.equals(tarFile)) {
l.append(" in " + f);
}
l.append(")");
} else {
l.append(" (" + ps.getClass().getSimpleName() + ")");
}
propLines.put(ps.getName(), l.toString());
}
for (String l : propLines.values()) {
sb.append(l);
sb.append(newline);
}
sb.append("Child nodes (count: " + state.getChildNodeCount(Long.MAX_VALUE)
+ ")");
sb.append(newline);
Map<String, String> childLines = new TreeMap<String, String>();
for (ChildNodeEntry ce : state.getChildNodeEntries()) {
StringBuilder l = new StringBuilder();
l.append(" + " + ce.getName());
NodeState c = ce.getNodeState();
if (c instanceof SegmentNodeState) {
RecordId rid = ((SegmentNodeState) c).getRecordId();
l.append(" (" + rid);
String f = getFile(rid);
if (!f.equals(tarFile)) {
l.append(" in " + f);
}