public void toStringBuilder(StringBuilder sb) { if (!isLeaf()) sb.append('('); if (getLabel() != null) { sb.append(getLabel()); } if (!isLeaf()) { for (Tree<L> child : getChildren()) { sb.append(' '); child.toStringBuilder(sb); } sb.append(')'); } }
/* Returns a string representation of this tree using bracket * notation. */ public String toString() { StringBuilder sb = new StringBuilder(); toStringBuilder(sb); return sb.toString(); }