+
+ // PrintableTree /////////////////////////////////////////////////////////////////////////////
+
+ protected String headToString() { return head()==null?null:head().toString(); }
+ protected String headToJava() {
+ // FIXME
+ if (head()==null) return null;
+ if (head() instanceof ToJava) {
+ StringBuffer sb = new StringBuffer();
+ ((ToJava)head()).toJava(sb);
+ return sb.toString();
+ }
+ return (head()==null?"null":("\""+StringUtil.toJavaString(head().toString())+"\""));
+ }
+ protected String left() { return "{"; }
+ protected String right() { return "}"; }
+ protected boolean ignoreSingleton() { return false; }
+
+
+ // ToGraphViz /////////////////////////////////////////////////////////////////////////////
+
+ public GraphViz.Node toGraphViz(GraphViz gv) {
+ if (gv.hasNode(this)) return gv.createNode(this);
+ GraphViz.Node n = gv.createNode(this);
+ n.label = head()==null ? "" : head().toString();
+ //n.color = "red";
+ for(Tree t : this) n.edge(t, null);
+ return n;
+ }
+ public boolean isTransparent() { return false; }
+ public boolean isHidden() { return false; }
+
+ public static interface TreeFunctor<T,R> extends Functor<Iterable<Tree<T>>, R> { }
+