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 entity(int entity) { sb.append("&#"+entity+";"); }
+ public void entity(String entity) { sb.append("&"+entity+";"); }
+
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);
}
}
- public void tag(String s, Object o) {
+ public void tag(String s) {
+ sb.append("<");
+ append(s);
+ sb.append("/>");
+ }
+ public void tag(String s, Object o) { tag(s, null, o); }
+ public void tag(String s, Object[] attrs, Object o) {
if (s != null) {
- append("<");
+ sb.append("<");
append(s);
- append(">");
+ if (attrs != null)
+ for(int i=0; i<attrs.length; i+=2) {
+ sb.append(' ');
+ append(attrs[i]);
+ sb.append("=\'");
+ append(attrs[i+1]);
+ sb.append("\'");
+ }
+ sb.append(">");
}
append(o);
if (s != null) {
- append("</");
+ sb.append("</");
append(s);
- append(">");
+ sb.append(">");
}
}