HtmlWriter.java revision 190
5990N/A * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. 4632N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4632N/A * This code is free software; you can redistribute it and/or modify it 4632N/A * under the terms of the GNU General Public License version 2 only, as 4632N/A * published by the Free Software Foundation. Sun designates this 4632N/A * particular file as subject to the "Classpath" exception as provided 4632N/A * by Sun in the LICENSE file that accompanied this code. 4632N/A * This code is distributed in the hope that it will be useful, but WITHOUT 4632N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4632N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4632N/A * version 2 for more details (a copy is included in the LICENSE file that 4632N/A * You should have received a copy of the GNU General Public License version 4632N/A * 2 along with this work; if not, write to the Free Software Foundation, 4632N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4632N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 4632N/A * CA 95054 USA or visit www.sun.com if you need additional information or 4632N/A * Class for the Html format code generation. 4632N/A * Initilizes PrintWriter with FileWriter, to enable print 4632N/A * related methods to generate the code to the named File through FileWriter. 4632N/A * Name of the file, to which this writer is writing to. 4632N/A * The window title of this file 4632N/A * URL file separator string("/"). 4632N/A * @param path The directory path to be created for this file 4632N/A * or null if none to be created. 4632N/A * @param filename File Name to which the PrintWriter will 4632N/A * @param docencoding Encoding to be used for this file. 4632N/A * @exception IOException Exception raised by the FileWriter is passed on 4632N/A * @exception UnSupportedEncodingException Exception raised by the 4632N/A * OutputStreamWriter is passed on to next level. 4632N/A * Print <HTML> tag. Add a newline character at the end. 4632N/A * Print </HTML> tag. Add a newline character at the end. 4632N/A * Print the script code to be embeded before the </HEAD> tag. 4632N/A println(
" if (location.href.indexOf('is-external=true') == -1) {");
4632N/A * Print the Javascript <SCRIPT> start tag with its type 4632N/A * Print the Javascript </SCRIPT> end tag. 4632N/A * Print the Javascript <NOSCRIPT> start tag. 4632N/A * Print the Javascript </NOSCRIPT> end tag. 4632N/A * Return the Javascript call to be embedded in the <BODY> tag. 4632N/A * Return nothing if winTitle is empty. 4632N/A * @return the Javascript call to be embedded in the <BODY> tag. 4632N/A return " onload=\"windowTitle();\"";
4632N/A * Print <BODY BGCOLOR="bgcolor">, including JavaScript 4632N/A * "onload" call to load windowtitle script. This script shows the name 4632N/A * of the document in the window title bar when frames are on. 4632N/A * @param bgcolor Background color. 4632N/A * @param includeScript boolean set true if printing windowtitle script 4632N/A * Print </BODY> tag. Add a newline character at the end. 4632N/A * Print <TITLE> tag. Add a newline character at the end. 4632N/A * Print <TITLE> tag. Add a newline character at the end. 4632N/A * @param winTitle The title of this document. 4632N/A // Set window title string which is later printed 4632N/A * Print </TITLE> tag. Add a newline character at the end. 4632N/A * Print <UL> tag. Add a newline character at the end. 5555N/A * Print </UL> tag. Add a newline character at the end. 4632N/A * Print <LI TYPE="type"> tag. 5555N/A * Print <H1> tag. Add a newline character at the end. 5555N/A * Print </H1> tag. Add a newline character at the end. 4632N/A * Print text with <H1> tag. Also adds </H1> tag. Add a newline character 4632N/A * @param text Text to be printed with <H1> format. 5555N/A * Print <H2> tag. Add a newline character at the end. 4632N/A * Print text with <H2> tag. Also adds </H2> tag. Add a newline character 4632N/A * @param text Text to be printed with <H2> format. 4632N/A * Print </H2> tag. Add a newline character at the end. 4632N/A * Print <H3> tag. Add a newline character at the end. 4632N/A * Print text with <H3> tag. Also adds </H3> tag. Add a newline character 4632N/A * @param text Text to be printed with <H3> format. 4632N/A * Print </H3> tag. Add a newline character at the end. 4632N/A * Print <H4> tag. Add a newline character at the end. 4632N/A * Print </H4> tag. Add a newline character at the end. 4632N/A * Print text with <H4> tag. Also adds </H4> tag. Add a newline character 4632N/A * @param text Text to be printed with <H4> format. 4632N/A * Print <H5> tag. Add a newline character at the end. 4632N/A * Print </H5> tag. Add a newline character at the end. 4632N/A * Print HTML <IMG SRC="imggif" WIDTH="width" HEIGHT="height" ALT="imgname> 4632N/A * tag. It prepends the "images" directory name to the "imggif". This 4632N/A * method is used for oneone format generation. Add a newline character 4632N/A * @param imggif Image GIF file. 4632N/A * @param imgname Image name. 4632N/A * @param width Width of the image. 4632N/A * @param height Height of the image. 4632N/A * Print <MENU> tag. Add a newline character at the end. 4632N/A * Print </MENU> tag. Add a newline character at the end. 4632N/A * Print <PRE> tag. Add a newline character at the end. 4632N/A * Print <PRE> tag without adding new line character at th eend. 4632N/A * Print </PRE> tag. Add a newline character at the end. 4632N/A * Print <HR> tag. Add a newline character at the end. 4632N/A * Print <HR SIZE="size" WIDTH="widthpercent%"> tag. Add a newline 4632N/A * @param size Size of the ruler. 4632N/A * @param widthPercent Percentage Width of the ruler 5336N/A * Print <HR SIZE="size" NOSHADE> tag. Add a newline character at the end. 4632N/A * @param size Size of the ruler. 4632N/A * @param noshade noshade string. 4632N/A * Get the "<STRONG>" string. 4632N/A * @return String Return String "<STRONG>"; 4632N/A * Get the "</STRONG>" string. 4632N/A * @return String Return String "</STRONG>"; 4632N/A * Print <STRONG> tag. 4632N/A * Print </STRONG> tag. 4632N/A * Print text passed, in strong format using <STRONG> and </STRONG> tags. 4632N/A * @param text String to be printed in between <STRONG> and </STRONG> tags. 4632N/A * Print text passed, in Italics using <I> and </I> tags. 4632N/A * @param text String to be printed in between <I> and </I> tags. 4632N/A * Return, text passed, with Italics <I> and </I> tags, surrounding it. 4632N/A * So if the text passed is "Hi", then string returned will be "<I>Hi</I>". 4632N/A * @param text String to be printed in between <I> and </I> tags. 4632N/A * Print "&nbsp;", non-breaking space. 4632N/A * Print <DL> tag. Add a newline character at the end. 4632N/A * Print </DL> tag. Add a newline character at the end. 4665N/A * Print </DD> tag. Add a newline character at the end. 4665N/A * Print <SUP> tag. Add a newline character at the end. * Print </SUP> tag. Add a newline character at the end. * Print <FONT SIZE="size"> tag. Add a newline character at the end. * @param size String size. * Print <FONT SIZE="size"> tag. * @param size String size. * Print <FONT CLASS="stylename"> tag. Add a newline character at the end. * @param stylename String stylename. * Print <FONT SIZE="size" CLASS="stylename"> tag. Add a newline character * @param size String size. * @param stylename String stylename. * Print </FONT> tag. * Get the "<FONT COLOR="color">" string. * @param color String color. * @return String Return String "<FONT COLOR="color">". return "<FONT COLOR=\"" +
color +
"\">";
* Get the "</FONT>" string. * @return String Return String "</FONT>"; * Print <CENTER> tag. Add a newline character at the end. * Print </CENTER> tag. Add a newline character at the end. * Print anchor <A NAME="name"> tag. * @param name Name String. * Print contents within anchor <A NAME="name"> tags. * @param name String name. * @param content String contents. * Print anchor <A NAME="name"> and </A>tags. Print comment string * "<!-- -->" within those tags. * @param name String name. * Print newline and then print <P> tag. Add a newline character at the * Print newline and then print </P> tag. Add a newline character at the * Print newline and then print <BR> tag. Add a newline character at the * Print <ADDRESS> tag. Add a newline character at the end. * Print </ADDRESS> tag. Add a newline character at the end. * Print <HEAD> tag. Add a newline character at the end. * Print </HEAD> tag. Add a newline character at the end. * Print <CODE> tag. * Print </CODE> tag. * Print <EM> tag. Add a newline character at the end. * Print </EM> tag. Add a newline character at the end. * Print HTML <TABLE BORDER="border" WIDTH="width" * CELLPADDING="cellpadding" CELLSPACING="cellspacing"> tag. * @param border Border size. * @param width Width of the table. * @param cellpadding Cellpadding for the table cells. * @param cellspacing Cellspacing for the table cells. * Print HTML <TABLE BORDER="border" CELLPADDING="cellpadding" * CELLSPACING="cellspacing"> tag. * @param border Border size. * @param cellpadding Cellpadding for the table cells. * @param cellspacing Cellspacing for the table cells. * Print HTML <TABLE BORDER="border" WIDTH="width"> * @param border Border size. * @param width Width of the table. * Print the HTML table tag with border size 0 and width 100%. * Print </TABLE> tag. Add a newline character at the end. * Print <TR> tag. Add a newline character at the end. * Print </TR> tag. Add a newline character at the end. * Print <TD NOWRAP> tag. * Print <TD WIDTH="width"> tag. * @param width String width. * Print </TD> tag. Add a newline character at the end. * Print <LINK str> tag. * Print "<!-- " comment start string. * Print "-->" comment end string. Add a newline character at the end. * Print <TR BGCOLOR="color" CLASS="stylename"> tag. Adds a newline character * @param color String color. * @param stylename String stylename. * Print <TR BGCOLOR="color"> tag. Adds a newline character at the end. * @param color String color. * Print <TR ALIGN="align" VALIGN="valign"> tag. Adds a newline character * @param align String align. * @param valign String valign. * Print <TH ALIGN="align"> tag. * @param align the align attribute. * Print <TH align="align" COLSPAN=i> tag. * @param align the align attribute. print(
"<TH ALIGN=\"" +
align +
"\" COLSPAN=\"" + i +
"\">");
* Print <TH align="align" NOWRAP> tag. * @param align the align attribute. * Print </TH> tag. Add a newline character at the end. * Print <TD COLSPAN=i> tag. print(
"<TD COLSPAN=" + i +
">");
* Print <TD BGCOLOR="color" CLASS="stylename"> tag. * @param color String color. * @param stylename String stylename. * Print <TD COLSPAN=i BGCOLOR="color" CLASS="stylename"> tag. * @param color String color. * @param stylename String stylename. print(
"<TD COLSPAN=" + i +
" BGCOLOR=\"" +
color +
"\" CLASS=\"" +
* Print <TD ALIGN="align"> tag. Adds a newline character * @param align String align. * Print <TD ALIGN="align" CLASS="stylename"> tag. * @param align String align. * @param stylename String stylename. * Print <TD VALIGN="valign"> tag. * @param valign String valign. * Print <TD ALIGN="align" VALIGN="valign"> tag. * @param align String align. * @param valign String valign. * Print <TD ALIGN="align" ROWSPAN=rowspan> tag. * @param align String align. * @param rowspan integer rowspan. * Print <TD ALIGN="align" VALIGN="valign" ROWSPAN=rowspan> tag. * @param align String align. * @param valign String valign. * @param rowspan integer rowspan. * Print <BLOCKQUOTE> tag. Add a newline character at the end. * Print </BLOCKQUOTE> tag. Add a newline character at the end. * Get the "<CODE>" string. * @return String Return String "<CODE>"; * Get the "</CODE>" string. * @return String Return String "</CODE>"; * Print <NOFRAMES> tag. Add a newline character at the end. * Print </NOFRAMES> tag. Add a newline character at the end.