- /** append Java code to <tt>sb</tt> which evaluates to this instance */
- public void toJava(StringBuffer sb) {
- sb.append("new Tree(null, ");
- sb.append(head==null ? "null" : "\"" + StringUtil.toJavaString(head+"") + "\"");
- sb.append(", new Tree[] { ");
- for(int i=0; i<children.length; i++) {
- if (children[i]==null) sb.append("null");
- else children[i].toJava(sb);
- if (i<children.length-1) sb.append(",\n ");
+
+ // 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();