Example #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();
  }