示例#1
0
  /**
   * Write contents of the given JavaClass into HTML files.
   *
   * @param java_class The class to write
   * @param dir The directory to put the files in
   */
  public Class2HTML(JavaClass java_class, String dir) throws IOException {
    Method[] methods = java_class.getMethods();

    this.java_class = java_class;
    this.dir = dir;
    class_name = java_class.getClassName(); // Remember full name
    constant_pool = java_class.getConstantPool();

    // Get package name by tacking off everything after the last `.'
    int index = class_name.lastIndexOf('.');
    if (index > -1) class_package = class_name.substring(0, index);
    else class_package = ""; // default package

    ConstantHTML constant_html =
        new ConstantHTML(dir, class_name, class_package, methods, constant_pool);

    /* Attributes can't be written in one step, so we just open a file
     * which will be written consequently.
     */
    AttributeHTML attribute_html = new AttributeHTML(dir, class_name, constant_pool, constant_html);

    // MethodHTML method_html = new MethodHTML(dir, class_name, methods, java_class.getFields(),
    //				    constant_html, attribute_html);
    // Write main file (with frames, yuk)
    writeMainHTML(attribute_html);
    new CodeHTML(dir, class_name, methods, constant_pool, constant_html);
    attribute_html.close();
  }
示例#2
0
  private void writeMainHTML(AttributeHTML attribute_html) throws IOException {
    PrintWriter file = new PrintWriter(new FileOutputStream(dir + class_name + ".html"));
    Attribute[] attributes = java_class.getAttributes();

    file.println(
        "<HTML>\n"
            + "<HEAD><TITLE>Documentation for "
            + class_name
            + "</TITLE>"
            + "</HEAD>\n"
            + "<FRAMESET BORDER=1 cols=\"30%,*\">\n"
            + "<FRAMESET BORDER=1 rows=\"80%,*\">\n"
            + "<FRAME NAME=\"ConstantPool\" SRC=\""
            + class_name
            + "_cp.html"
            + "\"\n MARGINWIDTH=\"0\" "
            + "MARGINHEIGHT=\"0\" FRAMEBORDER=\"1\" SCROLLING=\"AUTO\">\n"
            + "<FRAME NAME=\"Attributes\" SRC=\""
            + class_name
            + "_attributes.html"
            + "\"\n MARGINWIDTH=\"0\" "
            + "MARGINHEIGHT=\"0\" FRAMEBORDER=\"1\" SCROLLING=\"AUTO\">\n"
            + "</FRAMESET>\n"
            + "<FRAMESET BORDER=1 rows=\"80%,*\">\n"
            + "<FRAME NAME=\"Code\" SRC=\""
            + class_name
            + "_code.html\"\n MARGINWIDTH=0 "
            + "MARGINHEIGHT=0 FRAMEBORDER=1 SCROLLING=\"AUTO\">\n"
            + "<FRAME NAME=\"Methods\" SRC=\""
            + class_name
            + "_methods.html\"\n MARGINWIDTH=0 "
            + "MARGINHEIGHT=0 FRAMEBORDER=1 SCROLLING=\"AUTO\">\n"
            + "</FRAMESET></FRAMESET></HTML>");

    file.close();

    for (int i = 0; i < attributes.length; i++)
      attribute_html.writeAttribute(attributes[i], "class" + i);
  }