Exemplo n.º 1
0
 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(')');
   }
 }
Exemplo n.º 2
0
 /* Returns a string representation of this tree using bracket
  * notation. */
 public String toString() {
   StringBuilder sb = new StringBuilder();
   toStringBuilder(sb);
   return sb.toString();
 }