private void writeMethod()

in src/main/java/org/apache/bcel/util/MethodHTML.java [98:147]


    private void writeMethod(final Method method, final int methodNumber) {
        // Get raw signature
        final String signature = method.getSignature();
        // Get array of strings containing the argument types
        final String[] args = Utility.methodSignatureArgumentTypes(signature, false);
        // Get return type string
        final String type = Utility.methodSignatureReturnType(signature, false);
        // Get method name
        final String name = method.getName();
        // Get method's access flags
        String access = Utility.accessToString(method.getAccessFlags());
        // Get the method's attributes, the Code Attribute in particular
        final Attribute[] attributes = method.getAttributes();
        /*
         * HTML doesn't like names like <clinit> and spaces are places to break lines. Both we don't want...
         */
        access = Utility.replace(access, " ", "&nbsp;");
        final String htmlName = Class2HTML.toHTML(name);
        printWriter.print("<TR VALIGN=TOP><TD><FONT COLOR=\"#FF0000\"><A NAME=method" + methodNumber + ">" + access + "</A></FONT></TD>");
        printWriter.print("<TD>" + Class2HTML.referenceType(type) + "</TD><TD>" + "<A HREF=" + className + "_code.html#method" + methodNumber + " TARGET=Code>"
            + htmlName + "</A></TD>\n<TD>(");
        for (int i = 0; i < args.length; i++) {
            printWriter.print(Class2HTML.referenceType(args[i]));
            if (i < args.length - 1) {
                printWriter.print(", ");
            }
        }
        printWriter.print(")</TD></TR>");
        // Check for thrown exceptions
        for (int i = 0; i < attributes.length; i++) {
            attributeHtml.writeAttribute(attributes[i], "method" + methodNumber + "@" + i, methodNumber);
            final byte tag = attributes[i].getTag();
            if (tag == Const.ATTR_EXCEPTIONS) {
                printWriter.print("<TR VALIGN=TOP><TD COLSPAN=2></TD><TH ALIGN=LEFT>throws</TH><TD>");
                final int[] exceptions = ((ExceptionTable) attributes[i]).getExceptionIndexTable();
                for (int j = 0; j < exceptions.length; j++) {
                    printWriter.print(constantHtml.referenceConstant(exceptions[j]));
                    if (j < exceptions.length - 1) {
                        printWriter.print(", ");
                    }
                }
                printWriter.println("</TD></TR>");
            } else if (tag == Const.ATTR_CODE) {
                final Attribute[] attributeArray = ((Code) attributes[i]).getAttributes();
                for (int j = 0; j < attributeArray.length; j++) {
                    attributeHtml.writeAttribute(attributeArray[j], "method" + methodNumber + "@" + i + "@" + j, methodNumber);
                }
            }
        }
    }