编程语言

img sinbo

qdox生成JavaDoc

发表于2004/9/30 9:22:00  1273人阅读

分类: 杂文

由于项目的需要要根据类来生成javadoc但是还不能用javadoc命令,所以就在qdox的基础上写了这个功能。
package com.highcom.hcgip.javadoc;

import java.io.*;
import com.highcom.hcgip.basic.common.*;
import com.highcom.hcgip.cm.model.*;
import com.thoughtworks.qdox.model.*;
import java.util.*;
import com.highcom.hcgip.cm.util.*;

public class JavaDocCreater {
  private HtmlWriter htmlWriter = null;
  private JavaDoc javaDoc = null;
  /**
   * 生成javadoc函数
   * @param path javadoc存放的路径
   * @param filename javadoc文件名
   * @param docencoding 编码格式
   * @param classFileName .java文件包含路径
   * @throws IOException
   * @throws UnsupportedEncodingException
   */
  public void genJavaDoc(String path, String filename,
                         String docencoding, String classFileName,
                         JavaDocBean javaDocBean) throws
      IOException,
      UnsupportedEncodingException, JavaDocException {
    htmlWriter = new HtmlWriter(path, filename,
                                docencoding);
    if ( (new File(classFileName)).exists()) {
      javaDoc = new JavaDoc(new File(classFileName));
      excute(javaDocBean,filename);
    }
    else
      throw new JavaDocException("the classFile(" + classFileName +
                                 ") is not existed!");
    htmlWriter.close();
  }

  private void excute(JavaDocBean javaDocBean,String filename) {
    htmlWriter.println("<SCRIPT LANGUAGE='JavaScript'><!--");
    htmlWriter.println("function src(){");
    htmlWriter.println("document.javadocsrc.submit();}");
    htmlWriter.println("function example(){");
    htmlWriter.println("document.javadocexample.submit();}//--></SCRIPT>");
    htmlWriter.printPartialHeader(javaDoc.getClassName());
    htmlWriter.print("<BODY BGCOLOR='white'>");
    htmlWriter.println("<table border='0' width='100%' cellpadding='1' cellspacing='0'><tr><td colspan=3 bgcolor='#EEEEFF' class='NavBarCell1'>");
    htmlWriter.println(
        "<form name ='javadocsrc' action ='/download' method='post'>");
    htmlWriter.println("<input type ='hidden' name='filename' ");
    htmlWriter.println("value='" +
                       OppositePath.getSolidusPath(javaDocBean.getSrcpath()) +
                       "'>");
    htmlWriter.println("</form>");
    htmlWriter.println(
        "<form name ='javadocexample' action ='/download' method='post'>");
    htmlWriter.println("<input type ='hidden' name='filename' ");
    htmlWriter.println("value='" +
                       OppositePath.getSolidusPath(javaDocBean.getExamplepath()) +
                       "'>");
    htmlWriter.println("</form>");
    htmlWriter.p();
    htmlWriter.print("原代码下载:");
    htmlWriter.print(htmlWriter.getHyperLink("javascript:src();", "", "下载", true,
                                             ""));
    htmlWriter.printNbsps(4);
    htmlWriter.print("示例下载:");
    if (javaDocBean.getExamplepath() != null &&
        !javaDocBean.getExamplepath().equals(""))
      htmlWriter.print(htmlWriter.getHyperLink("javascript:example();", "",
                                               "下载", true,
                                               ""));
    else
      htmlWriter.print(htmlWriter.getHyperLink("#", "", "下载", true,
                                               ""));
    htmlWriter.printNbsps(4);
    htmlWriter.print(htmlWriter.getHyperLink("/controller?parentid="+javaDocBean.getId()+"&requestType=propositioncommand&subRequestType=getMessage", "",
                                             "意见或建议", true,
                                             ""));

    htmlWriter.pEnd();
    htmlWriter.p();
    htmlWriter.print("依赖关系:");
    htmlWriter.print(javaDocBean.getDepend()); //
    htmlWriter.pEnd();
    htmlWriter.print("</td></tr></table>");
    htmlWriter.hr();
    htmlWriter.println("<H2><FONT SIZE='-1'>");
    htmlWriter.print(javaDoc.getPackage());
    htmlWriter.print("</FONT>");
    htmlWriter.br();
    if (!javaDoc.isInterface()) {
      htmlWriter.print("Class ");
    }
    else {
      htmlWriter.print("Interface ");
    }
    htmlWriter.println(javaDoc.getClassName());
    htmlWriter.print("</H2>");
    htmlWriter.println("<PRE>");
    htmlWriter.println(javaDoc.getSuperClass());
    htmlWriter.println("  |");
    htmlWriter.print("  +--");
    htmlWriter.bold();
    htmlWriter.print(javaDoc.getFullClassName());
    htmlWriter.boldEnd();
    htmlWriter.println("</PRE>");
    htmlWriter.hr();
    htmlWriter.br();
    if (javaDoc.getClassComment() != null) {
      htmlWriter.println(javaDoc.getFullClassName());
      htmlWriter.println(javaDoc.getClassComment());
    }
    DocletTag[] doclet = javaDoc.getClassTags();
    for (int i = 0; i < doclet.length; i++) {
      htmlWriter.p();
      htmlWriter.bold();
      htmlWriter.print(doclet[i].getName() + ":   ");
      htmlWriter.boldEnd();
      htmlWriter.print(doclet[i].getValue());
      htmlWriter.pEnd();
    }
    if (javaDoc.getClassComment() != null)
      htmlWriter.hr();
    htmlWriter.p();
    //////////成员变量
    Vector it = new Vector();
    FieldBean fieldBean = new FieldBean();
    it = javaDoc.getFieldInfo();
    if (it != null && it.size() > 0) {
      htmlWriter.println("<TABLE BORDER='1' CELLPADDING='3' CELLSPACING='0' WIDTH='100%'><TR BGCOLOR='#CCCCFF' CLASS='TableHeadingColor'><TD COLSPAN=2><FONT SIZE='+2'><B>Field Summary</B></FONT></TD></TR>");
      for (int i = 0; i < it.size(); i++) {
        fieldBean = (FieldBean) it.get(i);
        htmlWriter.print("<TR BGCOLOR='white' CLASS='TableRowColor'><TD ALIGN='right' VALIGN='top' WIDTH='32%'><FONT SIZE='-1'><CODE>");
        htmlWriter.print(fieldBean.getType());
        htmlWriter.print("</CODE></FONT></TD>");
        htmlWriter.print("<TD width='68%'><CODE>");
        htmlWriter.print(htmlWriter.getHyperLink(filename, fieldBean.getName(),
                                                 fieldBean.getName(), true, ""));
        htmlWriter.print("</CODE>");
        htmlWriter.br();
        htmlWriter.printNbsps(10);
        htmlWriter.print(fieldBean.getComment() == null ? "" :
                         fieldBean.getComment());
        htmlWriter.print("</TD></TR>");
      }
      htmlWriter.print("</TABLE>");
      htmlWriter.br();
    }
    ///////////////构造函数
    it = javaDoc.getConstructor();
    MethodBean methodBean = new MethodBean();
    if (it != null && it.size() > 0) {
      htmlWriter.println("<TABLE BORDER='1' CELLPADDING='3' CELLSPACING='0' WIDTH='100%'><TR BGCOLOR='#CCCCFF' CLASS='TableHeadingColor'><TD COLSPAN=2><FONT SIZE='+2'><B>Constructor Summary</B></FONT></TD></TR>");
      for (int j = 0; j < it.size(); j++) {
        methodBean = (MethodBean) it.get(j);
        htmlWriter.print(
            "<TR BGCOLOR='white' CLASS='TableRowColor'><TD><CODE><B>");
        String temp = methodBean.getParameter();
        if (temp == null || temp.equals("null"))
          temp = "";
        //temp = ln(temp);
        htmlWriter.print(htmlWriter.getHyperLink(filename,
                                                 methodBean.getName() + "(" +
                                                 temp + ")",
                                                 methodBean.getName() + "(" +
                                                 temp + ")", true, ""));
        htmlWriter.br();
        htmlWriter.printNbsps(10);
        htmlWriter.print(methodBean.getComment() == null ? "" :
                         methodBean.getComment());
      }
      htmlWriter.println("</TD></TR></TABLE>");
      htmlWriter.br();
    }
    ////////////////////////////////
    //成员函数
    it = javaDoc.getMethodInfo();
    MethodBean methodBean1 = new MethodBean();
    if (it != null && it.size() > 0) {
      htmlWriter.println("<TABLE BORDER='1' CELLPADDING='3' CELLSPACING='0' WIDTH='100%'><TR BGCOLOR='#CCCCFF' CLASS='TableHeadingColor'><TD COLSPAN=2><FONT SIZE='+2'><B>Method Summary</B></FONT></TD></TR>");
      for (int k = 0; k < it.size(); k++) {
        methodBean1 = (MethodBean) it.get(k);
        htmlWriter.print(
            "<TR BGCOLOR='white' CLASS='TableRowColor'><TD ALIGN='right' VALIGN='top' WIDTH='32%'><FONT SIZE='-1'><CODE>");
        htmlWriter.printNbsps(1);
        htmlWriter.print(methodBean1.getType());
        htmlWriter.print("</CODE></FONT></TD>");
        htmlWriter.print("<TD><CODE>");
        String temp1 = methodBean1.getParameter();
        if (temp1 == null || temp1.equals("null"))
          temp1 = "";
        //temp1 = ln(temp1);
        htmlWriter.print(htmlWriter.getHyperLink(filename,
                                                 methodBean1.getName() + "(" +
                                                 temp1 + ")",
                                                 methodBean1.getName() + "(" +
                                                 temp1 + ")", true, ""));
        htmlWriter.println("</CODE>");
        htmlWriter.br();
        htmlWriter.printNbsps(10);
        htmlWriter.print(methodBean1.getComment() == null ? "" :
                         methodBean1.getComment());
        htmlWriter.println("</TD></TR>");
      }
      htmlWriter.println("</TABLE>");
      htmlWriter.br();
    }
    //////////////////
    //成员变量的详细信息
    it = new Vector();
    FieldBean fieldBean1 = new FieldBean();
    it = javaDoc.getFieldInfo();
    if (it != null && it.size() > 0) {
      htmlWriter.println("<TABLE BORDER='1' CELLPADDING='3' CELLSPACING='0' WIDTH='100%'><TR BGCOLOR='#CCCCFF' CLASS='TableHeadingColor'><TD COLSPAN=1><FONT SIZE='+2'><B>Field Detail</B></FONT></TD></TR></TABLE>");
      for (int q = 0; q < it.size(); q++) {
        fieldBean1 = (FieldBean) it.get(q);
        htmlWriter.print("<A name=" + fieldBean1.getName() +
                         "><!-- --></A>");
        htmlWriter.print("<H3>");
        htmlWriter.print(fieldBean1.getName());
        htmlWriter.print("</H3>");
        htmlWriter.print("<PRE>");
        htmlWriter.print(fieldBean1.getType());
        htmlWriter.printNbsps(2);
        htmlWriter.bold();
        htmlWriter.print(fieldBean1.getName());
        htmlWriter.boldEnd();
        htmlWriter.print("</PRE>");
        htmlWriter.println("<DL>");
        htmlWriter.print("<DD>");
        htmlWriter.print(fieldBean1.getComment() == null ? "" :
                         fieldBean1.getComment());
        htmlWriter.println("<P><DL></DL></DD></DL>");
        htmlWriter.hr();
      }
    }
///////////////构造函数详细信息
    it = javaDoc.getConstructor();
    MethodBean methodBean2 = new MethodBean();
    if (it != null && it.size() > 0) {
      htmlWriter.println("<TABLE cellSpacing=0 cellPadding=3 width='100%' border=1><TBODY><TR class=TableHeadingColor bgColor=#ccccff><TD><FONT size=+2><B>Constructor Detail</B></FONT></TD></TR></TBODY></TABLE>");
      for (int a = 0; a < it.size(); a++) {
        methodBean2 = (MethodBean) it.get(a);
        String temp = methodBean2.getParameter();
        if (temp == null || temp.equals("null"))
          temp = "";
        String nontemp = temp;
        temp = ln(temp);
        htmlWriter.print("<A name=" + methodBean2.getName() + "(" +
                         nontemp + ")" +
                         "><!-- --></A>");
        htmlWriter.print("<H3>");
        htmlWriter.print(methodBean2.getName());
        htmlWriter.print("</H3>");
        htmlWriter.print("<PRE>");
        htmlWriter.print(methodBean2.getType() == null ? "public" :
                         methodBean2.getType());
        htmlWriter.printNbsps(2);
        htmlWriter.bold();
        htmlWriter.print(methodBean2.getName() + "(" +
                         temp + ")");
        htmlWriter.boldEnd();
        htmlWriter.print("</PRE>");
        htmlWriter.println("<DL>");
        htmlWriter.print("<DD>");
        htmlWriter.print(methodBean2.getComment() == null ? "" :
                         methodBean2.getComment());
        htmlWriter.println("<P>");
        htmlWriter.println("<DT><B>Parameters:</B>");
        DocletTag[] doclettag = methodBean2.getTag();
        for (int i = 0; i < doclettag.length; i++) {
          htmlWriter.print("<DD><CODE>" + doclettag[i].getName() + "</CODE> - " +
                           doclettag[i].getValue());
        }
        htmlWriter.print("</DL>");
        htmlWriter.hr();
      }
    }

///////////////成员函数详细信息
    it = javaDoc.getMethodInfo();
    MethodBean methodBean3 = new MethodBean();
    if (it != null && it.size() > 0) {
      htmlWriter.println("<TABLE cellSpacing=0 cellPadding=3 width='100%' border=1><TBODY><TR class=TableHeadingColor bgColor=#ccccff><TD><FONT size=+2><B>Method Detail</B></FONT></TD></TR></TBODY></TABLE>");
      for (int a = 0; a < it.size(); a++) {
        methodBean3 = (MethodBean) it.get(a);
        String temp = methodBean3.getParameter();
        if (temp == null || temp.equals("null"))
          temp = "";
           String nontemp = temp;
        temp = ln(temp);
        htmlWriter.print("<A name=" + methodBean3.getName() + "(" +
                         nontemp + ")" +
                         "><!-- --></A>");
        htmlWriter.print("<H3>");
        htmlWriter.print(methodBean3.getName());
        htmlWriter.print("</H3>");
        htmlWriter.print("<PRE>");
        htmlWriter.print(methodBean3.getType() == null ? "public" :
                         methodBean3.getType());
        htmlWriter.printNbsps(2);
        htmlWriter.bold();
        htmlWriter.print(methodBean3.getName() + "(" +
                         temp + ")");
        htmlWriter.boldEnd();
        htmlWriter.print("</PRE>");
        htmlWriter.println("<DL>");
        htmlWriter.print("<DD>");
        htmlWriter.print(methodBean3.getComment() == null ? "" :
                         methodBean3.getComment());
        htmlWriter.println("<P>");
        htmlWriter.println("<DT><B>Parameters:</B>");
        DocletTag[] doclettag = methodBean3.getTag();
        for (int i = 0; i < doclettag.length; i++) {
          htmlWriter.print("<DD><CODE>" + doclettag[i].getName() + "</CODE> - " +
                           doclettag[i].getValue());
        }
        htmlWriter.print("</DL>");
        htmlWriter.hr();
      }
    }
    htmlWriter.println("<table border='0' width='100%' cellpadding='1' cellspacing='0'><tr><td colspan=3 bgcolor='#EEEEFF' class='NavBarCell1'>");
    htmlWriter.p();
    htmlWriter.print("原代码下载:");
    htmlWriter.print(htmlWriter.getHyperLink("javascript:src();", "", "下载", true,
                                             ""));
    htmlWriter.printNbsps(4);
    htmlWriter.print("示例下载:");
    if (javaDocBean.getExamplepath() != null &&
        !javaDocBean.getExamplepath().equals(""))
      htmlWriter.print(htmlWriter.getHyperLink("javascript:example();", "",
                                               "下载", true,
                                               ""));
    else
      htmlWriter.print(htmlWriter.getHyperLink("#", "", "下载", true,
                                               ""));
    htmlWriter.printNbsps(4);
    htmlWriter.print(htmlWriter.getHyperLink("/controller?parentid="+javaDocBean.getId()+"&requestType=propositioncommand&subRequestType=getMessage", "",
                                             "意见或建议", true,
                                             ""));


    htmlWriter.pEnd();
    htmlWriter.p();
    htmlWriter.print("依赖关系:");
    htmlWriter.print(javaDocBean.getDepend()); //
    htmlWriter.pEnd();
    htmlWriter.print("</td></tr></table>");

    htmlWriter.hr();
    htmlWriter.bodyEnd();
    htmlWriter.htmlEnd();
  }

  private static String ln(String str) {
    StringTokenizer st = new StringTokenizer(str, ",");
    StringBuffer sb = new StringBuffer();
    while (st.hasMoreTokens()) {
      sb.append(st.nextToken());
      if (st.hasMoreTokens()) {
        sb.append(",");
        sb.append("/n");
      }
    }
    str = sb.toString();

    return str;
  }

  public static void main(String[] atr) {
    JavaDocCreater javaDocCreater = new JavaDocCreater();
    try {
      javaDocCreater.genJavaDoc("d://aa",
                                "RequestHelper.html",
                                "gb2312", "d://aa//RequestHelper.java", null);
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }

  }
}


package com.highcom.hcgip.javadoc;

import java.io.*;
import com.thoughtworks.qdox.*;
import com.thoughtworks.qdox.model.*;
import java.util.*;

public class JavaDoc {
  private File file;
  private JavaDocBuilder builder = null;
  private JavaSource src = null;
  private JavaClass cls[] = null;
  private JavaField[] jf = null;
  private JavaMethod[] jm = null;
  /**
   * 根据参数的不同生成不同的javasource
   * @param file 具体的文件
   */
  public JavaDoc(File file) {
    this.file = file;
    try {
      builder = new JavaDocBuilder();
      this.src = builder.addSource(file);
      cls = src.getClasses();
      jf = cls[0].getFields();
      jm = cls[0].getMethods();

    }
    catch (IOException ex) {
      ex.printStackTrace();
    }
  }

  /**
   * 获取包名
   * @return
   */
  public String getPackage() {
    return src.getPackage();
  }

  /**
   * 返回都包含什么类
   * @return String数组
   */
  public String[] getImports() {
    return src.getImports();
  }

  /**
   * 获得完整类名
   * @return
   */
  public String getFullClassName() {
    return cls[0].getFullyQualifiedName();
  }

  /**
   * 只获得类名,不包含包名
   * @return
   */
  public String getClassName() {
    return cls[0].getName();
  }

  /**
   * 判断是否是接口
   * @return
   */
  public boolean isInterface() {
    return cls[0].isInterface();
  }

  /**
   * 判断是否是public
   * @return
   */
  public boolean isClassPublic() {
    return cls[0].isPublic();
  }

  /**
   * 判断次类是不是Abstract
   * @return
   */
  public boolean isCalssAbstract() {
    return cls[0].isAbstract();
  }

  public boolean isClassFinal() {
    return cls[0].isFinal();
  }

  /**
   * 获得超类
   * @return
   */
  public String getSuperClass() {
    return cls[0].getSuperClass().getValue();
  }

  /**
   * 获得类的注释
   * @return
   */
  public String getClassComment() {
    return cls[0].getComment();
  }

  public String[] getImplements() {
    String it[] = null;
    for (int i = 0; i < cls[0].getImplements().length; i++) {
      it[i] = cls[0].getImplements()[i].getValue();
    }
    return it;
  }

  /**
   * get DocletTags
   * @return
   */
  public DocletTag[] getClassTags() {
    return cls[0].getTags();
  }

  /**
   * 获取定义的成员变量,只获取public 类型的
   * @return 返回数值是数组类型的FieldBean
   */
  public Vector getFieldInfo() {
    Vector it = new Vector();
    String tmp = "";
    for (int i = 0; i < jf.length; i++) {
      if (jf[i].isPublic()) {
        FieldBean fieldBean = new FieldBean();
        tmp = "public ";
        if (jf[i].isStatic())
          tmp += "static ";
        if (jf[i].isFinal())
          tmp += "final ";
        if (jf[i].getType().isArray())
          fieldBean.setType(tmp + jf[i].getType().getValue() + "[]");
        else
          fieldBean.setType(tmp + jf[i].getType().getValue());
        fieldBean.setName(jf[i].getName());
        fieldBean.setComment(jf[i].getComment());
        it.add(fieldBean);
      }

    }
    return it;
  }

  /**
   * 获取构造函数
   * @return
   */
  public Vector getConstructor() {
    Vector it = new Vector();
    String tmp = "";
    int l = 0;
    for (int i = 0; i < jm.length; i++) {
      if (jm[i].isConstructor()) {
        MethodBean methodBean = new MethodBean();
        JavaParameter parmeter[] = jm[i].getParameters();
        for (int j = 0; j < parmeter.length; j++) {
          l++;
          if (parmeter[j].getType().isArray())
            tmp += parmeter[j].getType().getValue() + "[]";
          else
            tmp += parmeter[j].getType().getValue();
          tmp += "&nbsp;" + parmeter[j].getName();
          if (parmeter.length > l)
            tmp += ",";
        }
        methodBean.setName(jm[i].getName());
        methodBean.setParameter(tmp);
        tmp="";
        l=0;
        methodBean.setComment(jm[i].getComment());
        methodBean.setTag(jm[i].getTags());
        it.add(methodBean);
      }
    }
    return it;
  }

  /**
   * 获取成员函数
   * @return
   */
  public Vector getMethodInfo() {
    Vector it = new Vector();
    String tmp = "";
    String str = "";
    int l = 0;
    for (int i = 0; i < jm.length; i++) {
      if (!jm[i].isConstructor()) {
        if (jm[i].isPublic() || jm[i].isProtected()) {
          if (jm[i].isAbstract())
            str = "abstract ";
          if (jm[i].isStatic())
            str += "static ";
          if (jm[i].isSynchronized())
            str += "synchronized ";
          MethodBean methodBean = new MethodBean();
          JavaParameter parmeter[] = jm[i].getParameters();
          for (int j = 0; j < parmeter.length; j++) {
            l++;
            if (parmeter[j].getType().isArray())
              tmp += parmeter[j].getType().getValue() + "[]";
            else
              tmp += parmeter[j].getType().getValue();
            tmp += "&nbsp;" + parmeter[j].getName();
            if (parmeter.length > l)
              tmp += ",";
          }
          if (jm[i].isProtected()) {
            if (jm[i].getReturns().isArray())
              methodBean.setType("protected " + str +
                                 jm[i].getReturns().getValue() + "[]");
            else
              methodBean.setType("protected " + str +
                                 jm[i].getReturns().getValue());
          }
          else {
            if (jm[i].getReturns().isArray())
              methodBean.setType("public " + str + jm[i].getReturns().getValue() +
                                 "[]");
            else
              methodBean.setType("public " + str + jm[i].getReturns().getValue());

          }
          methodBean.setName(jm[i].getName());
          methodBean.setParameter(tmp);
          tmp="";
          str="";
          l=0;
          methodBean.setComment(jm[i].getComment());
          methodBean.setTag(jm[i].getTags());
          it.add(methodBean);
        }
      }
    }

    return it;

  }

  public static void main(String[] args) {
    File f = new File("D://ParamUtils.java");
    JavaDoc j = new JavaDoc(f);
    Vector b = j.getMethodInfo();
    for (int q = 0; q < b.size(); q++) {
      MethodBean mb = (MethodBean) b.get(q);
      p(mb.getType());p(" ");
      p(mb.getName());p(" (");
      p(mb.getParameter());
      pt(")");
    //  pt(mb.getComment());
    }
//      DocletTag[] t = mb.getTag();
//      for (int a = 0; a < t.length; a++) {
//        pt(t[a].getName());
//        pt(t[a].getValue());
//      }
//    }
//    Vector it = j.getFieldInfo();
//    FieldBean a = null;
//    for (int i = 0; i < it.size(); i++) {
//      a = (FieldBean) it.get(i);
//      pt(a.getType());
//      pt(a.getName());
//      pt(a.getComment());
//    }
    /*
        pt("PackageName:" + j.getPackage());
        pt("ClassName:" + j.getClassName());
        pt("ClassFullName:" + j.getFullClassName());
        pt("superCalss:" + j.getSuperClass());
        pt("ClassComment:" + j.getClassComment());
        DocletTag[] d =j.getClassTags();
        for(int i=0;i<d.length;i++)
        {
          pt("name:"+d[i].getName());
          pt("value:"+d[i].getValue());
        }
     */
  }

  static void pt(String str) {
    System.out.println(str);
  }
  static void p(String str) {
      System.out.print(str);
    }

}

package com.highcom.hcgip.javadoc;
import java.io.*;
import java.lang.*;
import java.util.*;

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="/";

    /**
     * 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
     */
    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 + fileseparator: "") + 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 &lt;HTML&gt; tag. Add a newline character at the end.
     */
    public void html() {
        println("<HTML>");
    }

    /**
     * Print &lt;/HTML&gt; tag. Add a newline character at the end.
     */
    public void htmlEnd() {
        println("</HTML>");
    }

    /**
     * Print &lt;BODY&gt; tag. Add a newline character at the end.
     */
    public void body() {
        println("<BODY>");
    }

    /**
     * Print &lt;BODY BGCOLOR="bgcolor"&gt; tag. Add a newline character at the end.
     *
     * @param bgcolor BackGroung color.
     */
    public void body(String bgcolor) {
        println("<BODY BGCOLOR=/"" + bgcolor + "/">");
    }

    /**
     * Print &lt;/BODY&gt; tag. Add a newline character at the end.
     */
    public void bodyEnd() {
        println("</BODY>");
    }

    /**
     * Print &lt;TITLE&gt; tag. Add a newline character at the end.
     */
    public void title() {
        println("<TITLE>");
    }

    /**
     * Print &lt;/TITLE&gt; tag. Add a newline character at the end.
     */
    public void titleEnd() {
        println("</TITLE>");
    }

    /**
     * Print &lt;UL&gt; tag. Add a newline character at the end.
     */
    public void ul() {
        println("<UL>");
    }

    /**
     * Print &lt;/UL&gt; tag. Add a newline character at the end.
     */
    public void ulEnd() {
        println("</UL>");
    }

    /**
     * Print &lt;LI&gt; tag.
     */
    public void li() {
        print("<LI>");
    }

    /**
     * Print &lt;LI TYPE="type"&gt; tag.
     *
     * @param type Type string.
     */
    public void li(String type) {
        print("<LI TYPE=/"" + type + "/">");
    }

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

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

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

    /**
     * Print &lt;H2&gt; tag. Add a newline character at the end.
     */
    public void h2() {
        println("<H2>");
    }

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

    /**
     * Print &lt;/H2&gt; tag. Add a newline character at the end.
     */
    public void h2End() {
        println("</H2>");
    }

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

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

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

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

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

    /**
     * Print text with &lt;H4&gt; tag. Also adds &lt;/H4&gt; tag. Add a newline character
     * at the end of the text.
     *
     * @param text Text to be printed with &lt;H4&gt; format.
     */
    public void h4(String text) {
        h4();
        println(text);
        h4End();
    }

    /**
     * Print &lt;H5&gt; tag. Add a newline character at the end.
     */
    public void h5() {
        println("<H5>");
    }

    /**
     * Print &lt;/H5&gt; tag. Add a newline character at the end.
     */
    public void h5End() {
        println("</H5>");
    }

    /**
     * Print HTML &lt;IMG SRC="imggif" WIDTH="width" HEIGHT="height" ALT="imgname&gt;
     * 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("<IMG SRC=/"images/" + imggif + ".gif/""
              + " WIDTH=/"" + width + "/" HEIGHT=/"" + height
              + "/" ALT=/"" + imgname + "/">");
    }

    /**
     * Print &lt;MENU&gt; tag. Add a newline character at the end.
     */
    public void menu() {
        println("<MENU>");
    }

    /**
     * Print &lt;/MENU&gt; tag. Add a newline character at the end.
     */
    public void menuEnd() {
        println("</MENU>");
    }

    /**
     * Print &lt;PRE&gt; tag. Add a newline character at the end.
     */
    public void pre() {
        println("<PRE>");
    }

    /**
     * Print &lt;/PRE&gt; tag. Add a newline character at the end.
     */
    public void preEnd() {
        println("</PRE>");
    }

    /**
     * Print &lt;HR&gt; tag. Add a newline character at the end.
     */
    public void hr() {
        println("<HR>");
    }

    /**
     * Print &lt;HR SIZE="size" WIDTH="widthpercent%"&gt; 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("<HR SIZE=/"" + size + "/" WIDTH=/"" + widthPercent + "%/">");
    }

    /**
     * Print &lt;HR SIZE="size" NOSHADE&gt; 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("<HR SIZE=/"" + size + "/" NOSHADE>");
    }

    /**
     * Get the "&lt;B&gt;" string.
     *
     * @return String Return String "&lt;B&gt;";
     */
    public String getBold() {
        return "<B>";
    }

    /**
     * Get the "&lt;/B&gt;" string.
     *
     * @return String Return String "&lt;/B&gt;";
     */
    public String getBoldEnd() {
        return "</B>";
    }

    /**
     * Print &lt;B&gt; tag.
     */
    public void bold() {
        print("<B>");
    }

    /**
     * Print &lt;/B&gt; tag.
     */
    public void boldEnd() {
        print("</B>");
    }

    /**
     * Print text passed, in bold format using &lt;B&gt; and &lt;/B&gt; tags.
     *
     * @param text String to be printed in between &lt;B&gt; and &lt;/B&gt; tags.
     */
    public void bold(String text) {
        bold();
        print(text);
        boldEnd();
    }

    /**
     * Print text passed, in Italics using &lt;I&gt; and &lt;/I&gt; tags.
     *
     * @param text String to be printed in between &lt;I&gt; and &lt;/I&gt; tags.
     */
    public void italics(String text) {
        print("<I>");
        print(text);
        println("</I>");
    }

    /**
     * Return, text passed, with Italics &lt;I&gt; and &lt;/I&gt; tags, surrounding it.
     * So if the text passed is "Hi", then string returned will be "&lt;I&gt;Hi&lt;/I&gt;".
     *
     * @param text String to be printed in between &lt;I&gt; and &lt;/I&gt; tags.
     */
    public String italicsText(String text) {
        return "<I>" + text + "</I>";
    }

    /**
     * Print "&#38;nbsp;", non-breaking space.
     */
    public void space() {
        print("&nbsp;");
    }

    /**
     * Print &lt;DL&gt; tag. Add a newline character at the end.
     */
    public void dl() {
        println("<DL>");
    }

    /**
     * Print &lt;/DL&gt; tag. Add a newline character at the end.
     */
    public void dlEnd() {
        println("</DL>");
    }

    /**
     * Print &lt;DT&gt; tag.
     */
    public void dt() {
        print("<DT>");
    }

    /**
     * Print &lt;DT&gt; tag.
     */
    public void dd() {
        print("<DD>");
    }

    /**
     * Print &lt;/DD&gt; tag. Add a newline character at the end.
     */
    public void ddEnd() {
        println("</DD>");
    }

    /**
     * Print &lt;SUP&gt; tag. Add a newline character at the end.
     */
    public void sup() {
        println("<SUP>");
    }

    /**
     * Print &lt;/SUP&gt; tag. Add a newline character at the end.
     */
    public void supEnd() {
        println("</SUP>");
    }

    /**
     * Print &lt;FONT SIZE="size"&gt; tag. Add a newline character at the end.
     *
     * @param size String size.
     */
    public void font(String size) {
        println("<FONT SIZE=/"" + size + "/">");
    }

    /**
     * Print &lt;FONT ID="stylename"&gt; tag. Add a newline character at the end.
     *
     * @param stylename String stylename.
     */
    public void fontStyle(String stylename) {
        print("<FONT ID=/"" + stylename + "/">");
    }

    /**
     * Print &lt;FONT SIZE="size" ID="stylename"&gt; tag. Add a newline character
     * at the end.
     *
     * @param size String size.
     * @param stylename String stylename.
     */
    public void fontSizeStyle(String size, String stylename) {
        println("<FONT size=/"" + size + "/" ID=/"" + stylename + "/">");
    }

    /**
     * Print &lt;/FONT&gt; tag.
     */
    public void fontEnd() {
        print("</FONT>");
    }

    /**
     * Get the "&lt;FONT COLOR="color"&gt;" string.
     *
     * @param color String color.
     * @return String Return String "&lt;FONT COLOR="color"&gt;".
     */
    public String getFontColor(String color) {
        return "<FONT COLOR=/"" + color + "/">";
    }

    /**
     * Get the "&lt;/FONT&gt;" string.
     *
     * @return String Return String "&lt;/FONT&gt;";
     */
    public String getFontEnd() {
        return "</FONT>";
    }

    /**
     * Print &lt;CENTER&gt; tag. Add a newline character at the end.
     */
    public void center() {
        println("<CENTER>");
    }

    /**
     * Print &lt;/CENTER&gt; tag. Add a newline character at the end.
     */
    public void centerEnd() {
        println("</CENTER>");
    }

    /**
     * Print anchor &lt;A NAME="name"&gt; tag.
     *
     * @param name Name String.
     */
    public void aName(String name) {
        print("<A NAME=/"" + name + "/">");
    }

    /**
     * Print &lt;/A&gt; tag.
     */
    public void aEnd() {
        print("</A>");
    }

    /**
     * Print &lt;I&gt; tag.
     */
    public void italic() {
        print("<I>");
    }

    /**
     * Print &lt;/I&gt; tag.
     */
    public void italicEnd() {
        print("</I>");
    }

    /**
     * Print contents within anchor &lt;A NAME="name"&gt; tags.
     *
     * @param name String name.
     * @param content String contents.
     */
    public void anchor(String name, String content) {
        aName(name);
        print(content);
        aEnd();
    }

    /**
     * Print anchor &lt;A NAME="name"&gt; and &lt;/A&gt;tags. Print comment string
     * "&lt;!-- --&gt;" within those tags.
     *
     * @param name String name.
     */
    public void anchor(String name) {
        aName(name);
        print("<!-- -->");
        aEnd();
    }

    /**
     * Print newline and then print &lt;P&gt; tag. Add a newline character at the
     * end.
     */
    public void p() {
        println();
        println("<P>");
    }
    public void pEnd(){
      println();
      println("</P>");
    }
    /**
     * Print newline and then print &lt;BR&gt; tag. Add a newline character at the
     * end.
     */
    public void br() {
        println();
        println("<BR>");
    }

    /**
     * Print &lt;ADDRESS&gt; tag. Add a newline character at the end.
     */
    public void address() {
        println("<ADDRESS>");
    }

    /**
     * Print &lt;/ADDRESS&gt; tag. Add a newline character at the end.
     */
    public void addressEnd() {
        println("</ADDRESS>");
    }

    /**
     * Print &lt;HEAD&gt; tag. Add a newline character at the end.
     */
    public void head() {
        println("<HEAD>");
    }

    /**
     * Print &lt;/HEAD&gt; tag. Add a newline character at the end.
     */
    public void headEnd() {
        println("</HEAD>");
    }

    /**
     * Print &lt;CODE&gt; tag.
     */
    public void code() {
        print("<CODE>");
    }

    /**
     * Print &lt;/CODE&gt; tag.
     */
    public void codeEnd() {
        print("</CODE>");
    }

    /**
     * Print &lt;EM&gt; tag. Add a newline character at the end.
     */
    public void em() {
        println("<EM>");
    }

    /**
     * Print &lt;/EM&gt; tag. Add a newline character at the end.
     */
    public void emEnd() {
        println("</EM>");
    }

    /**
     * Print HTML &lt;TABLE BORDER="border" WIDTH="width"
     * CELLPADDING="cellpadding" CELLSPACING="cellspacing"&gt; 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<TABLE BORDER=/"" + border +
                "/" WIDTH=/"" + width +
                "/" CELLPADDING=/"" + cellpadding +
                "/" CELLSPACING=/"" + cellspacing + "/">");
    }

    /**
     * Print HTML &lt;TABLE BORDER="border" CELLPADDING="cellpadding"
     * CELLSPACING="cellspacing"&gt; 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<TABLE BORDER=/"" + border +
                "/" CELLPADDING=/"" + cellpadding +
                "/" CELLSPACING=/"" + cellspacing + "/">");
    }

    /**
     * Print HTML &lt;TABLE BORDER="border" WIDTH="width"&gt;
     *
     * @param border       Border size.
     * @param width        Width of the table.
     */
    public void table(int border, String width) {
        println("/n<TABLE BORDER=/"" + border +
                "/" WIDTH=/"" + width + "/">");
    }

    /**
     * Print the HTML table tag with border size 0 and width 100%.
     */
    public void table() {
        table(0, "100%");
    }

    /**
     * Print &lt;/TABLE&gt; tag. Add a newline character at the end.
     */
    public void tableEnd() {
        println("</TABLE>");
    }

    /**
     * Print &lt;TR&gt; tag. Add a newline character at the end.
     */
    public void tr() {
        println("<TR>");
    }

    /**
     * Print &lt;/TR&gt; tag. Add a newline character at the end.
     */
    public void trEnd() {
        println("</TR>");
    }

    /**
     * Print &lt;TD&gt; tag.
     */
    public void td() {
        print("<TD>");
    }

    /**
     * Print &lt;TD NOWRAP&gt; tag.
     */
    public void tdNowrap() {
        print("<TD NOWRAP>");
    }

    /**
     * Print &lt;TD WIDTH="width"&gt; tag.
     *
     * @param width String width.
     */
    public void tdWidth(String width) {
        print("<TD WIDTH=/"" + width + "/">");
    }

    /**
     * Print &lt;/TD&gt; tag. Add a newline character at the end.
     */
    public void tdEnd() {
        println("</TD>");
    }

    /**
     * Print &lt;LINK str&gt; tag.
     *
     * @param str String.
     */
    public void link(String str) {
        println("<LINK " + str + ">");
    }

    /**
     * Print "&lt;!-- " comment start string.
     */
    public void commentStart() {
         print("<!-- ");
    }

    /**
     * Print "--&gt;" comment end string. Add a newline character at the end.
     */
    public void commentEnd() {
         println("-->");
    }

    /**
     * Print &lt;TR BGCOLOR="color" ID="stylename"&gt; tag. Adds a newline character
     * at the end.
     *
     * @param color String color.
     * @param stylename String stylename.
     */
    public void trBgcolorStyle(String color, String stylename) {
        println("<TR BGCOLOR=/"" + color + "/" ID=/"" + stylename + "/">");
    }

    /**
     * Print &lt;TR BGCOLOR="color"&gt; tag. Adds a newline character at the end.
     *
     * @param color String color.
     */
    public void trBgcolor(String color) {
        println("<TR BGCOLOR=/"" + color + "/">");
    }

    /**
     * Print &lt;TR ALIGN="align" VALIGN="valign"&gt; tag. Adds a newline character
     * at the end.
     *
     * @param align String align.
     * @param valign String valign.
     */
    public void trAlignVAlign(String align, String valign) {
        println("<TR ALIGN=/"" + align + "/" VALIGN=/"" + valign + "/">");
    }

    /**
     * Print &lt;TD COLSPAN=i&gt; tag.
     *
     * @param i integer.
     */
    public void tdColspan(int i) {
        print("<TD COLSPAN=" + i + ">");
    }

    /**
     * Print &lt;TD BGCOLOR="color" ID="stylename"&gt; tag.
     *
     * @param color String color.
     * @param stylename String stylename.
     */
    public void tdBgcolorStyle(String color, String stylename) {
        print("<TD BGCOLOR=/"" + color + "/" ID=/"" + stylename + "/">");
    }

    /**
     * Print &lt;TD COLSPAN=i BGCOLOR="color" ID="stylename"&gt; tag.
     *
     * @param i integer.
     * @param color String color.
     * @param stylename String stylename.
     */
    public void tdColspanBgcolorStyle(int i, String color, String stylename) {
        print("<TD COLSPAN=" + i + " BGCOLOR=/"" + color + "/" ID=/"" +
              stylename + "/">");
    }

    /**
     * Print &lt;TD ALIGN="align"&gt; tag. Adds a newline character
     * at the end.
     *
     * @param align String align.
     */
    public void tdAlign(String align) {
        print("<TD ALIGN=/"" + align + "/">");
    }

    /**
     * Print &lt;TD ALIGN="align" ID="stylename"&gt; tag.
     *
     * @param align        String align.
     * @param stylename    String stylename.
     */
    public void tdVAlignClass(String align, String stylename) {
        print("<TD VALIGN=/"" + align + "/" ID=/"" + stylename + "/">");
    }

    /**
     * Print &lt;TD VALIGN="valign"&gt; tag.
     *
     * @param valign String valign.
     */
    public void tdVAlign(String valign) {
        print("<TD VALIGN=/"" + valign + "/">");
    }

    /**
     * Print &lt;TD ALIGN="align" VALIGN="valign"&gt; tag.
     *
     * @param align   String align.
     * @param valign  String valign.
     */
    public void tdAlignVAlign(String align, String valign) {
        print("<TD ALIGN=/"" + align + "/" VALIGN=/"" + valign + "/">");
    }

    /**
     * Print &lt;TD ALIGN="align" ROWSPAN=rowspan&gt; tag.
     *
     * @param align    String align.
     * @param rowspan  integer rowspan.
     */
    public void tdAlignRowspan(String align, int rowspan) {
        print("<TD ALIGN=/"" + align + "/" ROWSPAN=" + rowspan + ">");
    }

    /**
     * Print &lt;TD ALIGN="align" VALIGN="valign" ROWSPAN=rowspan&gt; tag.
     *
     * @param align    String align.
     * @param valign  String valign.
     * @param rowspan  integer rowspan.
     */
    public void tdAlignVAlignRowspan(String align, String valign,
                                     int rowspan) {
        print("<TD ALIGN=/"" + align + "/" VALIGN=/"" + valign
                + "/" ROWSPAN=" + rowspan + ">");
    }

    /**
     * Print &lt;BLOCKQUOTE&gt; tag. Add a newline character at the end.
     */
    public void blockquote() {
        println("<BLOCKQUOTE>");
    }

    /**
     * Print &lt;/BLOCKQUOTE&gt; tag. Add a newline character at the end.
     */
    public void blockquoteEnd() {
        println("</BLOCKQUOTE>");
    }

    /**
     * Get the "&lt;CODE&gt;" string.
     *
     * @return String Return String "&lt;CODE>";
     */
    public String getCode() {
        return "<CODE>";
    }

    /**
     * Get the "&lt;/CODE&gt;" string.
     *
     * @return String Return String "&lt;/CODE&gt;";
     */
    public String getCodeEnd() {
        return "</CODE>";
    }

    /**
     * Print &lt;NOFRAMES&gt; tag. Add a newline character at the end.
     */
    public void noFrames() {
        println("<NOFRAMES>");
    }

    /**
     * Print &lt;/NOFRAMES&gt; tag. Add a newline character at the end.
     */
    public void noFramesEnd() {
        println("</NOFRAMES>");
    }
    /**
     * print &nbsp;
     * @param num
     */
    public void printNbsps(int num) {
      for(int i=0;i<num;i++){
        print("&nbsp;");
      }
  }

    /**
    * Print some part of the Html file header.
    *
    * @param title    Title of this HTML document.
    */
   public void printPartialHeader(String title) {
       println("<!DOCTYPE HTML PUBLIC /"-//W3C//DTD HTML 4.0 Frameset//EN/"" +
               "/"http://www.w3.org/TR/REC-html40/frameset.dtd/">");
       html();
       head();
       title();
       println(title);
       titleEnd();
       println("<meta http-equiv=/"Content-Type/" content=/"text/html; charset=gb2312/">");
       headEnd();
   }
   /**
        * Get Html Hyper Link string.
        *
        * @param link       String name of the file.
        * @param where      Position of the link in the file. Character '#' is not
        * needed.
        * @param label      Tag for the link.
        * @param bold       Boolean that sets label to bold.
        * @param stylename  String style of text defined in style sheet.
        * @return String    Hyper Link.
        */
       public String getHyperLink(String link, String where,
                                  String label, boolean bold,
                                  String stylename) {
           StringBuffer retlink = new StringBuffer();
           retlink.append("<A HREF=/"");
           retlink.append(link);
           if (where.length() != 0) {
               retlink.append("#");
               retlink.append(where);
           }
           retlink.append("/">");
           if (stylename.length() != 0) {
               retlink.append("<FONT ID=/"");
               retlink.append(stylename);
               retlink.append("/">");
           }
           if (bold) {
               retlink.append("<B>");
           }
           retlink.append(label);
           if (bold) {
               retlink.append("</B>");
           }
           if (stylename.length() != 0) {
               retlink.append("</FONT>");
           }
           retlink.append("</A>");
           return retlink.toString();
       }
       public static void main(String[] args){
        try {
          HtmlWriter h = new HtmlWriter("a//b//c","a.html", "gb2312");
          h.html();

          h.htmlEnd();
          h.close();
        }
        catch (IOException ex) {
        }
       }
}

这些是主要的几个类,希望能对这个感兴趣的人有帮助

阅读全文
0 0

相关文章推荐

img
取 消
img