import java.util.*;
public interface ToHTML {
- public void ToHTML(PrintWriter p);
+ public void toHTML(HTML h);
+
+ public static class HTML {
+ private final StringBuffer sb;
+ public HTML(StringBuffer sb) { this.sb = sb; }
+ public void append(String s) {
+ /* FIXME */
+ sb.append(s);
+ }
+ public void append(Object o) {
+ if (o==null) append("<tt><font color=red>null</font></tt>");
+ else if (o instanceof ToHTML) ((ToHTML)o).toHTML(this);
+ else if (o instanceof Object[]) append((Object[])o);
+ else append(o.toString());
+ }
+ public void append(int i) { sb.append(i); }
+ public void append(char c) { sb.append(c); }
+
+ public void append(Object[] o) {
+ for(int i=0; i<o.length; i++) {
+ if (i>0) append(' ');
+ append(o[i]);
+ }
+ }
+
+ public void tag(String s, Object o) {
+ if (s != null) {
+ append("<");
+ append(s);
+ append(">");
+ }
+ append(o);
+ if (s != null) {
+ append("</");
+ append(s);
+ append(">");
+ }
+ }
+
+ }
}