// package com.wrox.util; // From "Professional Java Server Programming", Patzer et al., // page 50. public class JO_HTML { public static final int NORMAL = 0; public static final int HEADING = 1; public static final int LINE = 2; public StringBuffer buffer; public JO_HTML (String title) { buffer = new StringBuffer (4096); this.buffer.append ("\n\n"); this.buffer.append (title); this.buffer.append ("\n\n\n"); } public void add (int style, String text, boolean linebreak) { switch (style) { case NORMAL: this.buffer.append (text); break; case HEADING: this.buffer.append ("\n

"); this.buffer.append (text); this.buffer.append ("

\n"); break; case LINE: this.buffer.append ("
\n"); break; default: break; } if (linebreak) { buffer.append ("
\n"); } } public String getPage () { this.buffer.append ("\n\n"); return this.buffer.toString (); } }