Skip to content

Commit

Permalink
chore: improved context tostring
Browse files Browse the repository at this point in the history
  • Loading branch information
lvca committed Apr 29, 2024
1 parent 232173d commit 0a5f381
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,16 @@ public String toString(final int depth) {
if (inputParameters != null) {
dumpDepth(buffer, depth).append("PARAMETERS:");
for (Map.Entry<String, Object> entry : inputParameters.entrySet()) {
dumpDepth(buffer, depth + 1).append(entry.getKey()).append(" = ").append(entry.getValue());
dumpDepth(buffer, depth + 1).append(entry.getKey()).append(" = ");
printValue(buffer, entry.getValue());
}
}

if (variables != null) {
dumpDepth(buffer, depth).append("VARIABLES:");
for (Map.Entry<String, Object> entry : variables.entrySet()) {
dumpDepth(buffer, depth + 1).append(entry.getKey()).append(" = ").append(entry.getValue());
dumpDepth(buffer, depth + 1).append(entry.getKey()).append(" = ");
printValue(buffer, entry.getValue());
}
}

Expand All @@ -307,7 +309,7 @@ public String toString(final int depth) {

if (child != null) {
dumpDepth(buffer, depth).append("CHILD:");
((BasicCommandContext) child).toString(depth + 1);
buffer.append(((BasicCommandContext) child).toString(depth + 1));
}

return buffer.toString();
Expand Down Expand Up @@ -410,4 +412,15 @@ private StringBuilder dumpDepth(final StringBuilder buffer, final int depth) {
buffer.append(" ");
return buffer;
}

private StringBuilder printValue(final StringBuilder buffer, final Object value) {
if (value == null)
buffer.append("null");
else if (value instanceof InternalResultSet)
buffer.append("resultset ").append(((InternalResultSet) value).countEntries()).append(" entries");
else
buffer.append(value);

return buffer;
}
}

0 comments on commit 0a5f381

Please sign in to comment.