FileDocCategorySizeDatePackage
HtmlWriter.javaAPI DocExample24938Wed Apr 19 11:17:16 BST 2000com.sun.tools.doclets

HtmlWriter

public class HtmlWriter extends PrintWriter
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

Fields Summary
protected final String
htmlFilename
Name of the file, to which this writer is writing to.
public static final String
fileseparator
URL file separator string("/").
Constructors Summary
public HtmlWriter(String filename, String docencoding)
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.


                                                              
         
                         
        super(genWriter(null, filename, docencoding));
        htmlFilename = filename;
    
public HtmlWriter(String path, String filename, String docencoding)
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.

        super(genWriter(path, filename, docencoding));
        htmlFilename = filename;
    
Methods Summary
public voidaEnd()
Print </A> tag.

        print("</A>");
    
public voidaName(java.lang.String name)
Print anchor <A NAME="name"> tag.

param
name Name String.

        print("<A NAME=\"" + name + "\">");
    
public voidaddress()
Print <ADDRESS> tag. Add a newline character at the end.

        println("<ADDRESS>");
    
public voidaddressEnd()
Print </ADDRESS> tag. Add a newline character at the end.

        println("</ADDRESS>");
    
public voidanchor(java.lang.String name, java.lang.String content)
Print contents within anchor <A NAME="name"> tags.

param
name String name.
param
content String contents.

        aName(name);
        print(content);
        aEnd();
    
public voidanchor(java.lang.String name)
Print anchor <A NAME="name"> and </A>tags. Print comment string "<!-- -->" within those tags.

param
name String name.

        aName(name);
        print("<!-- -->");
        aEnd();
    
public voidblockquote()
Print <BLOCKQUOTE> tag. Add a newline character at the end.

        println("<BLOCKQUOTE>");
    
public voidblockquoteEnd()
Print </BLOCKQUOTE> tag. Add a newline character at the end.

        println("</BLOCKQUOTE>");
    
public voidbody()
Print <BODY> tag. Add a newline character at the end.

        println("<BODY>");
    
public voidbody(java.lang.String bgcolor)
Print <BODY BGCOLOR="bgcolor"> tag. Add a newline character at the end.

param
bgcolor BackGroung color.

        println("<BODY BGCOLOR=\"" + bgcolor + "\">");
    
public voidbodyEnd()
Print </BODY> tag. Add a newline character at the end.

        println("</BODY>");
    
public voidbold()
Print <B> tag.

        print("<B>");
    
public voidbold(java.lang.String text)
Print text passed, in bold format using <B> and </B> tags.

param
text String to be printed in between <B> and </B> tags.

        bold();
        print(text);
        boldEnd();
    
public voidboldEnd()
Print </B> tag.

        print("</B>");
    
public voidbr()
Print newline and then print <BR> tag. Add a newline character at the end.

        println();
        println("<BR>");
    
public voidcenter()
Print <CENTER> tag. Add a newline character at the end.

        println("<CENTER>");
    
public voidcenterEnd()
Print </CENTER> tag. Add a newline character at the end.

        println("</CENTER>");
    
public voidcode()
Print <CODE> tag.

        print("<CODE>");
    
public voidcodeEnd()
Print </CODE> tag.

        print("</CODE>");
    
public java.lang.StringcodeText(java.lang.String text)

        return "<CODE>" + text + "</CODE>";
    
public voidcommentEnd()
Print "-->" comment end string. Add a newline character at the end.

         println("-->");
    
public voidcommentStart()
Print "<!-- " comment start string.

         print("<!-- ");
    
public voiddd()
Print <DT> tag.

        print("<DD>");
    
public voidddEnd()
Print </DD> tag. Add a newline character at the end.

        println("</DD>"); 
    
public voiddl()
Print <DL> tag. Add a newline character at the end.

        println("<DL>");
    
public voiddlEnd()
Print </DL> tag. Add a newline character at the end.

        println("</DL>");
    
public voiddt()
Print <DT> tag.

        print("<DT>");
    
public voidem()
Print <EM> tag. Add a newline character at the end.

        println("<EM>");
    
public voidemEnd()
Print </EM> tag. Add a newline character at the end.

        println("</EM>");
    
public voidfont(java.lang.String size)
Print <FONT SIZE="size"> tag. Add a newline character at the end.

param
size String size.

        println("<FONT SIZE=\"" + size + "\">");
    
public voidfontEnd()
Print </FONT> tag.

        print("</FONT>");
    
public voidfontSizeStyle(java.lang.String size, java.lang.String stylename)
Print <FONT SIZE="size" CLASS="stylename"> tag. Add a newline character at the end.

param
size String size.
param
stylename String stylename.

        println("<FONT size=\"" + size + "\" CLASS=\"" + stylename + "\">");
    
public voidfontStyle(java.lang.String stylename)
Print <FONT CLASS="stylename"> tag. Add a newline character at the end.

param
stylename String stylename.

        print("<FONT CLASS=\"" + stylename + "\">");
    
public static java.io.WritergenWriter(java.lang.String path, java.lang.String filename, java.lang.String docencoding)
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

        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);
        }
    
public java.lang.StringgetBold()
Get the "<B>" string.

return
String Return String "<B>";

        return "<B>";
    
public java.lang.StringgetBoldEnd()
Get the "</B>" string.

return
String Return String "</B>";

        return "</B>";
    
public java.lang.StringgetCode()
Get the "<CODE>" string.

return
String Return String "<CODE>";

        return "<CODE>";
    
public java.lang.StringgetCodeEnd()
Get the "</CODE>" string.

return
String Return String "</CODE>";

        return "</CODE>";
    
public java.lang.StringgetFontColor(java.lang.String color)
Get the "<FONT COLOR="color">" string.

param
color String color.
return
String Return String "<FONT COLOR="color">".

        return "<FONT COLOR=\"" + color + "\">";
    
public java.lang.StringgetFontEnd()
Get the "</FONT>" string.

return
String Return String "</FONT>";

        return "</FONT>";
    
public voidh1()
Print <H1> tag. Add a newline character at the end.

        println("<H1>");
    
public voidh1(java.lang.String text)
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.

        h1();
        println(text);
        h1End();
    
public voidh1End()
Print </H1> tag. Add a newline character at the end.

        println("</H1>");
    
public voidh2()
Print <H2> tag. Add a newline character at the end.

        println("<H2>");
    
public voidh2(java.lang.String text)
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.

        h2();
        println(text);
        h2End();
    
public voidh2End()
Print </H2> tag. Add a newline character at the end.

        println("</H2>");
    
public voidh3()
Print <H3> tag. Add a newline character at the end.

        println("<H3>");
    
public voidh3(java.lang.String text)
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.

        h3();
        println(text);
        h3End();
    
public voidh3End()
Print </H3> tag. Add a newline character at the end.

        println("</H3>");
    
public voidh4()
Print <H4> tag. Add a newline character at the end.

        println("<H4>");
    
public voidh4(java.lang.String text)
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.

        h4();
        println(text);
        h4End();
    
public voidh4End()
Print </H4> tag. Add a newline character at the end.

        println("</H4>");
    
public voidh5()
Print <H5> tag. Add a newline character at the end.

        println("<H5>");
    
public voidh5End()
Print </H5> tag. Add a newline character at the end.

        println("</H5>");
    
public voidhead()
Print <HEAD> tag. Add a newline character at the end.

        println("<HEAD>");
    
public voidheadEnd()
Print </HEAD> tag. Add a newline character at the end.

        println("</HEAD>");
    
public voidhr()
Print <HR> tag. Add a newline character at the end.

        println("<HR>");
    
public voidhr(int size, int widthPercent)
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

        println("<HR SIZE=\"" + size + "\" WIDTH=\"" + widthPercent + "%\">");
    
public voidhr(int size, java.lang.String noshade)
Print <HR SIZE="size" NOSHADE> tag. Add a newline character at the end.

param
size Size of the ruler.
param
noshade noshade string.

        println("<HR SIZE=\"" + size + "\" NOSHADE>");
    
public voidhtml()
Print <HTML> tag. Add a newline character at the end.

        println("<HTML>");
    
public voidhtmlEnd()
Print </HTML> tag. Add a newline character at the end.

        println("</HTML>");
    
public voidimg(java.lang.String imggif, java.lang.String imgname, int width, int height)
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.

        println("<IMG SRC=\"images/" + imggif + ".gif\"" 
              + " WIDTH=\"" + width + "\" HEIGHT=\"" + height 
              + "\" ALT=\"" + imgname + "\">");
    
public voiditalic()
Print <I> tag.

        print("<I>");
    
public voiditalicEnd()
Print </I> tag.

        print("</I>");
    
public voiditalics(java.lang.String text)
Print text passed, in Italics using <I> and </I> tags.

param
text String to be printed in between <I> and </I> tags.

        print("<I>");
        print(text);
        println("</I>");
    
public java.lang.StringitalicsText(java.lang.String text)
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.

        return "<I>" + text + "</I>";
    
public voidli()
Print <LI> tag.

        print("<LI>");
    
public voidli(java.lang.String type)
Print <LI TYPE="type"> tag.

param
type Type string.

        print("<LI TYPE=\"" + type + "\">");
    
public voidlink(java.lang.String str)
Print <LINK str> tag.

param
str String.

        println("<LINK " + str + ">");
    
public voidmenu()
Print <MENU> tag. Add a newline character at the end.

        println("<MENU>");
    
public voidmenuEnd()
Print </MENU> tag. Add a newline character at the end.

        println("</MENU>");
    
public voidnoFrames()
Print <NOFRAMES> tag. Add a newline character at the end.

        println("<NOFRAMES>");
    
public voidnoFramesEnd()
Print </NOFRAMES> tag. Add a newline character at the end.

        println("</NOFRAMES>");
    
public voidp()
Print newline and then print <P> tag. Add a newline character at the end.

        println();
        println("<P>");
    
public voidpre()
Print <PRE> tag. Add a newline character at the end.

        println("<PRE>");
    
public voidpreEnd()
Print </PRE> tag. Add a newline character at the end.

        println("</PRE>");
    
public voidspace()
Print "&nbsp;", non-breaking space.

        print(" ");
    
public voidsup()
Print <SUP> tag. Add a newline character at the end.

        println("<SUP>");
    
public voidsupEnd()
Print </SUP> tag. Add a newline character at the end.

        println("</SUP>");
    
public voidtable(int border, java.lang.String width, int cellpadding, int cellspacing)
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.

        println("\n<TABLE BORDER=\"" + border +
                "\" WIDTH=\"" + width +
                "\" CELLPADDING=\"" + cellpadding +
                "\" CELLSPACING=\"" + cellspacing + "\">");
    
public voidtable(int border, int cellpadding, int cellspacing)
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.

        println("\n<TABLE BORDER=\"" + border +
                "\" CELLPADDING=\"" + cellpadding +
                "\" CELLSPACING=\"" + cellspacing + "\">");
    
public voidtable(int border, java.lang.String width)
Print HTML <TABLE BORDER="border" WIDTH="width">

param
border Border size.
param
width Width of the table.

        println("\n<TABLE BORDER=\"" + border +
                "\" WIDTH=\"" + width + "\">");
    
public voidtable()
Print the HTML table tag with border size 0 and width 100%.

        table(0, "100%"); 
    
public voidtableEnd()
Print </TABLE> tag. Add a newline character at the end.

        println("</TABLE>");
    
public voidtd()
Print <TD> tag.

        print("<TD>");
    
public voidtdAlign(java.lang.String align)
Print <TD ALIGN="align"> tag. Adds a newline character at the end.

param
align String align.

        print("<TD ALIGN=\"" + align + "\">");
    
public voidtdAlignRowspan(java.lang.String align, int rowspan)
Print <TD ALIGN="align" ROWSPAN=rowspan> tag.

param
align String align.
param
rowspan integer rowspan.

        print("<TD ALIGN=\"" + align + "\" ROWSPAN=" + rowspan + ">");
    
public voidtdAlignVAlign(java.lang.String align, java.lang.String valign)
Print <TD ALIGN="align" VALIGN="valign"> tag.

param
align String align.
param
valign String valign.

        print("<TD ALIGN=\"" + align + "\" VALIGN=\"" + valign + "\">");
    
public voidtdAlignVAlignRowspan(java.lang.String align, java.lang.String valign, int rowspan)
Print <TD ALIGN="align" VALIGN="valign" ROWSPAN=rowspan> tag.

param
align String align.
param
valign String valign.
param
rowspan integer rowspan.

        print("<TD ALIGN=\"" + align + "\" VALIGN=\"" + valign 
                + "\" ROWSPAN=" + rowspan + ">");
    
public voidtdBgcolorStyle(java.lang.String color, java.lang.String stylename)
Print <TD BGCOLOR="color" CLASS="stylename"> tag.

param
color String color.
param
stylename String stylename.

        print("<TD BGCOLOR=\"" + color + "\" CLASS=\"" + stylename + "\">");
    
public voidtdColspan(int i)
Print <TD COLSPAN=i> tag.

param
i integer.

        print("<TD COLSPAN=" + i + ">");
    
public voidtdColspanBgcolorStyle(int i, java.lang.String color, java.lang.String stylename)
Print <TD COLSPAN=i BGCOLOR="color" CLASS="stylename"> tag.

param
i integer.
param
color String color.
param
stylename String stylename.

        print("<TD COLSPAN=" + i + " BGCOLOR=\"" + color + "\" CLASS=\"" +
              stylename + "\">");
    
public voidtdEnd()
Print </TD> tag. Add a newline character at the end.

        println("</TD>");
    
public voidtdNowrap()
Print <TD NOWRAP> tag.

        print("<TD NOWRAP>");
    
public voidtdVAlign(java.lang.String valign)
Print <TD VALIGN="valign"> tag.

param
valign String valign.

        print("<TD VALIGN=\"" + valign + "\">");
    
public voidtdVAlignClass(java.lang.String align, java.lang.String stylename)
Print <TD ALIGN="align" CLASS="stylename"> tag.

param
align String align.
param
stylename String stylename.

        print("<TD VALIGN=\"" + align + "\" CLASS=\"" + stylename + "\">");
    
public voidtdWidth(java.lang.String width)
Print <TD WIDTH="width"> tag.

param
width String width.

        print("<TD WIDTH=\"" + width + "\">");
    
public voidtitle()
Print <TITLE> tag. Add a newline character at the end.

        println("<TITLE>");
    
public voidtitleEnd()
Print </TITLE> tag. Add a newline character at the end.

        println("</TITLE>");
    
public voidtr()
Print <TR> tag. Add a newline character at the end.

        println("<TR>");
    
public voidtrAlignVAlign(java.lang.String align, java.lang.String valign)
Print <TR ALIGN="align" VALIGN="valign"> tag. Adds a newline character at the end.

param
align String align.
param
valign String valign.

        println("<TR ALIGN=\"" + align + "\" VALIGN=\"" + valign + "\">");
    
public voidtrBgcolor(java.lang.String color)
Print <TR BGCOLOR="color"> tag. Adds a newline character at the end.

param
color String color.

        println("<TR BGCOLOR=\"" + color + "\">");
    
public voidtrBgcolorStyle(java.lang.String color, java.lang.String stylename)
Print <TR BGCOLOR="color" CLASS="stylename"> tag. Adds a newline character at the end.

param
color String color.
param
stylename String stylename.

        println("<TR BGCOLOR=\"" + color + "\" CLASS=\"" + stylename + "\">");
    
public voidtrEnd()
Print </TR> tag. Add a newline character at the end.

        println("</TR>");
    
public voidul()
Print <UL> tag. Add a newline character at the end.

        println("<UL>");
    
public voidulEnd()
Print </UL> tag. Add a newline character at the end.

        println("</UL>");