1 package edu.berkeley.sbp.util;
5 public interface ToHTML {
6 public void toHTML(HTML h);
8 public static class HTML {
9 private final StringBuffer sb;
10 public HTML(StringBuffer sb) { this.sb = sb; }
12 public void append(String s) {
17 public void appendText(String s) {
18 /* FIXME: escapify this!!! */
22 public void entity(int entity) { sb.append("&#"+entity+";"); }
23 public void entity(String entity) { sb.append("&"+entity+";"); }
25 public void append(Object o) {
26 if (o==null) append("<tt><font color=red>null</font></tt>");
27 else if (o instanceof ToHTML) ((ToHTML)o).toHTML(this);
28 else if (o instanceof Object[]) append((Object[])o);
29 else append(o.toString());
31 public void append(int i) { sb.append(i); }
32 public void append(char c) { sb.append(c); }
34 public void append(Object[] o) {
35 for(int i=0; i<o.length; i++) {
41 public void tag(String s) {
46 public void tag(String s, Object o) { tag(s, null, o); }
47 public void tag(String s, Object[] attrs, Object o) {
52 for(int i=0; i<attrs.length; i+=2) {