package org.apache.bcel.util; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; import org.apache.bcel.classfile.Attribute; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.ExceptionTable; import org.apache.bcel.classfile.Field; import org.apache.bcel.classfile.Method; import org.apache.bcel.classfile.Utility; final class MethodHTML { private final String className; private final PrintWriter printWriter; private final ConstantHTML constantHtml; private final AttributeHTML attributeHtml; MethodHTML(String dir, String className, Method[] methods, Field[] fields, ConstantHTML constantHtml, AttributeHTML attributeHtml, Charset charset) throws FileNotFoundException, UnsupportedEncodingException { this.className = className; this.attributeHtml = attributeHtml; this.constantHtml = constantHtml; PrintWriter newPrintWriter = new PrintWriter(dir + className + "_methods.html", charset.name()); Throwable var9 = null; try { this.printWriter = newPrintWriter; this.printWriter.print(""); this.printWriter.println(""); this.printWriter.println(""); Field[] var10 = fields; int var11 = fields.length; for(int var12 = 0; var12 < var11; ++var12) { Field field = var10[var12]; this.writeField(field); } this.printWriter.println("
Access flagsTypeField name
"); this.printWriter.println(""); for(int i = 0; i < methods.length; ++i) { this.writeMethod(methods[i], i); } this.printWriter.println("
Access flagsReturn typeMethod nameArguments
"); } catch (Throwable var21) { var9 = var21; throw var21; } finally { if (newPrintWriter != null) { if (var9 != null) { try { newPrintWriter.close(); } catch (Throwable var20) { var9.addSuppressed(var20); } } else { newPrintWriter.close(); } } } } private void writeField(Field field) { String type = Utility.signatureToString(field.getSignature()); String name = field.getName(); String access = Utility.accessToString(field.getAccessFlags()); access = Utility.replace(access, " ", " "); this.printWriter.print("" + access + "\n" + Class2HTML.referenceType(type) + "" + name + ""); Attribute[] attributes = field.getAttributes(); int i; for(i = 0; i < attributes.length; ++i) { this.attributeHtml.writeAttribute(attributes[i], name + "@" + i); } for(i = 0; i < attributes.length; ++i) { if (attributes[i].getTag() == 1) { String str = attributes[i].toString(); this.printWriter.print("= " + str + "\n"); break; } } this.printWriter.println(""); } private void writeMethod(Method method, int methodNumber) { String signature = method.getSignature(); String[] args = Utility.methodSignatureArgumentTypes(signature, false); String type = Utility.methodSignatureReturnType(signature, false); String name = method.getName(); String access = Utility.accessToString(method.getAccessFlags()); Attribute[] attributes = method.getAttributes(); access = Utility.replace(access, " ", " "); String htmlName = Class2HTML.toHTML(name); this.printWriter.print("" + access + ""); this.printWriter.print("" + Class2HTML.referenceType(type) + "" + htmlName + "\n("); int i; for(i = 0; i < args.length; ++i) { this.printWriter.print(Class2HTML.referenceType(args[i])); if (i < args.length - 1) { this.printWriter.print(", "); } } this.printWriter.print(")"); for(i = 0; i < attributes.length; ++i) { this.attributeHtml.writeAttribute(attributes[i], "method" + methodNumber + "@" + i, methodNumber); byte tag = attributes[i].getTag(); int j; if (tag != 3) { if (tag == 2) { Attribute[] attributeArray = ((Code)attributes[i]).getAttributes(); for(j = 0; j < attributeArray.length; ++j) { this.attributeHtml.writeAttribute(attributeArray[j], "method" + methodNumber + "@" + i + "@" + j, methodNumber); } } } else { this.printWriter.print("throws"); int[] exceptions = ((ExceptionTable)attributes[i]).getExceptionIndexTable(); for(j = 0; j < exceptions.length; ++j) { this.printWriter.print(this.constantHtml.referenceConstant(exceptions[j])); if (j < exceptions.length - 1) { this.printWriter.print(", "); } } this.printWriter.println(""); } } } }