/* * @(#)HtmlWriter.java 1.28 99/06/28 * * Copyright 1997-1999 by Sun Microsystems, Inc., * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. * All rights reserved. * * This software is the confidential and proprietary information * of Sun Microsystems, Inc. ("Confidential Information"). You * shall not disclose such Confidential Information and shall use * it only in accordance with the terms of the license agreement * you entered into with Sun. */ package com.sun.tools.doclets; import com.sun.javadoc.*; import java.io.*; import java.lang.*; import java.util.*; /** * Class for the Html format code generation. * Initilizes PrintWriter with FileWriter, to enable print * related methods to generate the code to the named File through FileWriter. * * @since JDK1.2 * @author Atul M Dambalkar */ public class HtmlWriter extends PrintWriter { /** * Name of the file, to which this writer is writing to. */ protected final String htmlFilename; /** * URL file separator string("/"). */ public static final String fileseparator = DirectoryManager.urlfileseparator; /** * Initializes PrintWriter with the FileWriter. * * @param filename File Name to which the PrintWriter will do the Output. * @param docencoding Encoding to be used for this file. * @exception IOException Exception raised by the FileWriter is passed on * to next level. * @exception UnSupportedEncodingException Exception raised by the * OutputStreamWriter is passed on to next level. */ public HtmlWriter(String filename, String docencoding) throws IOException, UnsupportedEncodingException { super(genWriter(null, filename, docencoding)); htmlFilename = filename; } /** * Initializes PrintWriter with the FileWriter. * * @param path The directory path to be created for this file. * @param filename File Name to which the PrintWriter will do the Output. * @param docencoding Encoding to be used for this file. * @exception IOException Exception raised by the FileWriter is passed on * to next level. * @exception UnSupportedEncodingException Exception raised by the * OutputStreamWriter is passed on to next level. */ public HtmlWriter(String path, String filename, String docencoding) throws IOException, UnsupportedEncodingException { super(genWriter(path, filename, docencoding)); htmlFilename = filename; } /** * Create the directory path for the file to be generated, construct * FileOutputStream and OutputStreamWriter depending upon docencoding. * * @param path The directory path to be created for this file. * @param filename File Name to which the PrintWriter will do the Output. * @param docencoding Encoding to be used for this file. * @exception IOException Exception raised by the FileWriter is passed on * to next level. * @exception UnSupportedEncodingException Exception raised by the * OutputStreamWriter is passed on to next level. * @return Writer Writer for the file getting generated. * @see java.io.FileOutputStream * @see java.io.OutputStreamWriter */ public static Writer genWriter(String path, String filename, String docencoding) throws IOException, UnsupportedEncodingException { FileOutputStream fos; if (path != null) { DirectoryManager.createDirectory(path); fos = new FileOutputStream(((path.length() > 0)? path + File.separator: "") + filename); } else { fos = new FileOutputStream(filename); } if (docencoding == null) { OutputStreamWriter oswriter = new OutputStreamWriter(fos); docencoding = oswriter.getEncoding(); return oswriter; } else { return new OutputStreamWriter(fos, docencoding); } } /** * Print <HTML> tag. Add a newline character at the end. */ public void html() { println(""); } /** * Print </HTML> tag. Add a newline character at the end. */ public void htmlEnd() { println(""); } /** * Print <BODY> tag. Add a newline character at the end. */ public void body() { println(""); } /** * Print <BODY BGCOLOR="bgcolor"> tag. Add a newline character at the end. * * @param bgcolor BackGroung color. */ public void body(String bgcolor) { println(""); } /** * Print </BODY> tag. Add a newline character at the end. */ public void bodyEnd() { println(""); } /** * Print <TITLE> tag. Add a newline character at the end. */ public void title() { println(""); } /** * Print </TITLE> tag. Add a newline character at the end. */ public void titleEnd() { println(""); } /** * Print <UL> tag. Add a newline character at the end. */ public void ul() { println(""); } /** * Print <LI> tag. */ public void li() { print("
  • "); } /** * Print <LI TYPE="type"> tag. * * @param type Type string. */ public void li(String type) { print("
  • "); } /** * Print <H1> tag. Add a newline character at the end. */ public void h1() { println("

    "); } /** * Print </H1> tag. Add a newline character at the end. */ public void h1End() { println("

    "); } /** * Print text with <H1> tag. Also adds </H1> tag. Add a newline character * at the end of the text. * * @param text Text to be printed with <H1> format. */ public void h1(String text) { h1(); println(text); h1End(); } /** * Print <H2> tag. Add a newline character at the end. */ public void h2() { println("

    "); } /** * Print text with <H2> tag. Also adds </H2> tag. Add a newline character * at the end of the text. * * @param text Text to be printed with <H2> format. */ public void h2(String text) { h2(); println(text); h2End(); } /** * Print </H2> tag. Add a newline character at the end. */ public void h2End() { println("

    "); } /** * Print <H3> tag. Add a newline character at the end. */ public void h3() { println("

    "); } /** * Print text with <H3> tag. Also adds </H3> tag. Add a newline character * at the end of the text. * * @param text Text to be printed with <H3> format. */ public void h3(String text) { h3(); println(text); h3End(); } /** * Print </H3> tag. Add a newline character at the end. */ public void h3End() { println("

    "); } /** * Print <H4> tag. Add a newline character at the end. */ public void h4() { println("

    "); } /** * Print </H4> tag. Add a newline character at the end. */ public void h4End() { println("

    "); } /** * Print text with <H4> tag. Also adds </H4> tag. Add a newline character * at the end of the text. * * @param text Text to be printed with <H4> format. */ public void h4(String text) { h4(); println(text); h4End(); } /** * Print <H5> tag. Add a newline character at the end. */ public void h5() { println("
    "); } /** * Print </H5> tag. Add a newline character at the end. */ public void h5End() { println("
    "); } /** * Print HTML <IMG SRC="imggif" WIDTH="width" HEIGHT="height" ALT="imgname> * tag. It prepends the "images" directory name to the "imggif". This * method is used for oneone format generation. Add a newline character * at the end. * * @param imggif Image GIF file. * @param imgname Image name. * @param width Width of the image. * @param height Height of the image. */ public void img(String imggif, String imgname, int width, int height) { println("\"""); } /** * Print <MENU> tag. Add a newline character at the end. */ public void menu() { println(""); } /** * Print </MENU> tag. Add a newline character at the end. */ public void menuEnd() { println(""); } /** * Print <PRE> tag. Add a newline character at the end. */ public void pre() { println("
    ");
        }
    
        /**
         * Print </PRE> tag. Add a newline character at the end.
         */
        public void preEnd() {
            println("
    "); } /** * Print <HR> tag. Add a newline character at the end. */ public void hr() { println("
    "); } /** * Print <HR SIZE="size" WIDTH="widthpercent%"> tag. Add a newline * character at the end. * * @param size Size of the ruler. * @param widthPercent Percentage Width of the ruler */ public void hr(int size, int widthPercent) { println("
    "); } /** * Print <HR SIZE="size" NOSHADE> tag. Add a newline character at the end. * * @param size Size of the ruler. * @param noshade noshade string. */ public void hr(int size, String noshade) { println("
    "); } /** * Get the "<B>" string. * * @return String Return String "<B>"; */ public String getBold() { return ""; } /** * Get the "</B>" string. * * @return String Return String "</B>"; */ public String getBoldEnd() { return ""; } /** * Print <B> tag. */ public void bold() { print(""); } /** * Print </B> tag. */ public void boldEnd() { print(""); } /** * Print text passed, in bold format using <B> and </B> tags. * * @param text String to be printed in between <B> and </B> tags. */ public void bold(String text) { bold(); print(text); boldEnd(); } /** * Print text passed, in Italics using <I> and </I> tags. * * @param text String to be printed in between <I> and </I> tags. */ public void italics(String text) { print(""); print(text); println(""); } /** * Return, text passed, with Italics <I> and </I> tags, surrounding it. * So if the text passed is "Hi", then string returned will be "<I>Hi</I>". * * @param text String to be printed in between <I> and </I> tags. */ public String italicsText(String text) { return "" + text + ""; } /** * Print "&nbsp;", non-breaking space. */ public void space() { print(" "); } /** * Print <DL> tag. Add a newline character at the end. */ public void dl() { println("
    "); } /** * Print </DL> tag. Add a newline character at the end. */ public void dlEnd() { println("
    "); } /** * Print <DT> tag. */ public void dt() { print("
    "); } /** * Print <DT> tag. */ public void dd() { print("
    "); } /** * Print </DD> tag. Add a newline character at the end. */ public void ddEnd() { println("
    "); } /** * Print <SUP> tag. Add a newline character at the end. */ public void sup() { println(""); } /** * Print </SUP> tag. Add a newline character at the end. */ public void supEnd() { println(""); } /** * Print <FONT SIZE="size"> tag. Add a newline character at the end. * * @param size String size. */ public void font(String size) { println(""); } /** * Print <FONT CLASS="stylename"> tag. Add a newline character at the end. * * @param stylename String stylename. */ public void fontStyle(String stylename) { print(""); } /** * Print <FONT SIZE="size" CLASS="stylename"> tag. Add a newline character * at the end. * * @param size String size. * @param stylename String stylename. */ public void fontSizeStyle(String size, String stylename) { println(""); } /** * Print </FONT> tag. */ public void fontEnd() { print(""); } /** * Get the "<FONT COLOR="color">" string. * * @param color String color. * @return String Return String "<FONT COLOR="color">". */ public String getFontColor(String color) { return ""; } /** * Get the "</FONT>" string. * * @return String Return String "</FONT>"; */ public String getFontEnd() { return ""; } /** * Print <CENTER> tag. Add a newline character at the end. */ public void center() { println("
    "); } /** * Print </CENTER> tag. Add a newline character at the end. */ public void centerEnd() { println("
    "); } /** * Print anchor <A NAME="name"> tag. * * @param name Name String. */ public void aName(String name) { print(""); } /** * Print </A> tag. */ public void aEnd() { print(""); } /** * Print <I> tag. */ public void italic() { print(""); } /** * Print </I> tag. */ public void italicEnd() { print(""); } /** * Print contents within anchor <A NAME="name"> tags. * * @param name String name. * @param content String contents. */ public void anchor(String name, String content) { aName(name); print(content); aEnd(); } /** * Print anchor <A NAME="name"> and </A>tags. Print comment string * "<!-- -->" within those tags. * * @param name String name. */ public void anchor(String name) { aName(name); print(""); aEnd(); } /** * Print newline and then print <P> tag. Add a newline character at the * end. */ public void p() { println(); println("

    "); } /** * Print newline and then print <BR> tag. Add a newline character at the * end. */ public void br() { println(); println("
    "); } /** * Print <ADDRESS> tag. Add a newline character at the end. */ public void address() { println("

    "); } /** * Print </ADDRESS> tag. Add a newline character at the end. */ public void addressEnd() { println("
    "); } /** * Print <HEAD> tag. Add a newline character at the end. */ public void head() { println(""); } /** * Print </HEAD> tag. Add a newline character at the end. */ public void headEnd() { println(""); } /** * Print <CODE> tag. */ public void code() { print(""); } /** * Print </CODE> tag. */ public void codeEnd() { print(""); } /** * Print <EM> tag. Add a newline character at the end. */ public void em() { println(""); } /** * Print </EM> tag. Add a newline character at the end. */ public void emEnd() { println(""); } /** * 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. */ public void table(int border, String width, int cellpadding, int cellspacing) { println("\n"); } /** * 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. */ public void table(int border, int cellpadding, int cellspacing) { println("\n
    "); } /** * Print HTML <TABLE BORDER="border" WIDTH="width"> * * @param border Border size. * @param width Width of the table. */ public void table(int border, String width) { println("\n
    "); } /** * Print the HTML table tag with border size 0 and width 100%. */ public void table() { table(0, "100%"); } /** * Print </TABLE> tag. Add a newline character at the end. */ public void tableEnd() { println("
    "); } /** * Print <TR> tag. Add a newline character at the end. */ public void tr() { println(""); } /** * Print </TR> tag. Add a newline character at the end. */ public void trEnd() { println(""); } /** * Print <TD> tag. */ public void td() { print(""); } /** * Print <TD NOWRAP> tag. */ public void tdNowrap() { print(""); } /** * Print <TD WIDTH="width"> tag. * * @param width String width. */ public void tdWidth(String width) { print(""); } /** * Print </TD> tag. Add a newline character at the end. */ public void tdEnd() { println(""); } /** * Print <LINK str> tag. * * @param str String. */ public void link(String str) { println(""); } /** * Print "<!-- " comment start string. */ public void commentStart() { print(""); } /** * Print <TR BGCOLOR="color" CLASS="stylename"> tag. Adds a newline character * at the end. * * @param color String color. * @param stylename String stylename. */ public void trBgcolorStyle(String color, String stylename) { println(""); } /** * Print <TR BGCOLOR="color"> tag. Adds a newline character at the end. * * @param color String color. */ public void trBgcolor(String color) { println(""); } /** * Print <TR ALIGN="align" VALIGN="valign"> tag. Adds a newline character * at the end. * * @param align String align. * @param valign String valign. */ public void trAlignVAlign(String align, String valign) { println(""); } /** * Print <TD COLSPAN=i> tag. * * @param i integer. */ public void tdColspan(int i) { print(""); } /** * Print <TD BGCOLOR="color" CLASS="stylename"> tag. * * @param color String color. * @param stylename String stylename. */ public void tdBgcolorStyle(String color, String stylename) { print(""); } /** * Print <TD COLSPAN=i BGCOLOR="color" CLASS="stylename"> tag. * * @param i integer. * @param color String color. * @param stylename String stylename. */ public void tdColspanBgcolorStyle(int i, String color, String stylename) { print(""); } /** * Print <TD ALIGN="align"> tag. Adds a newline character * at the end. * * @param align String align. */ public void tdAlign(String align) { print(""); } /** * Print <TD ALIGN="align" CLASS="stylename"> tag. * * @param align String align. * @param stylename String stylename. */ public void tdVAlignClass(String align, String stylename) { print(""); } /** * Print <TD VALIGN="valign"> tag. * * @param valign String valign. */ public void tdVAlign(String valign) { print(""); } /** * Print <TD ALIGN="align" VALIGN="valign"> tag. * * @param align String align. * @param valign String valign. */ public void tdAlignVAlign(String align, String valign) { print(""); } /** * Print <TD ALIGN="align" ROWSPAN=rowspan> tag. * * @param align String align. * @param rowspan integer rowspan. */ public void tdAlignRowspan(String align, int rowspan) { print(""); } /** * Print <TD ALIGN="align" VALIGN="valign" ROWSPAN=rowspan> tag. * * @param align String align. * @param valign String valign. * @param rowspan integer rowspan. */ public void tdAlignVAlignRowspan(String align, String valign, int rowspan) { print(""); } /** * Print <BLOCKQUOTE> tag. Add a newline character at the end. */ public void blockquote() { println("
    "); } /** * Print </BLOCKQUOTE> tag. Add a newline character at the end. */ public void blockquoteEnd() { println("
    "); } /** * Get the "<CODE>" string. * * @return String Return String "<CODE>"; */ public String getCode() { return ""; } /** * Get the "</CODE>" string. * * @return String Return String "</CODE>"; */ public String getCodeEnd() { return ""; } /** * Print <NOFRAMES> tag. Add a newline character at the end. */ public void noFrames() { println(""); } /** * Print &lt;/NOFRAMES&gt; tag. Add a newline character at the end. */ public void noFramesEnd() { println(""); } }