package org.apache.bcel.util; package .var.folders.cl.9twcgjfx4vsg5zl73c6wxmvm0000gn.T; 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; import org.apache.bcel.util.AttributeHTML; import org.apache.bcel.util.Class2HTML; import org.apache.bcel.util.ConstantHTML; 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; try (PrintWriter newPrintWriter = new PrintWriter(dir + className + "_methods.html", charset.name())) { this.printWriter = newPrintWriter; this.printWriter.print(""); this.printWriter.println(""); this.printWriter.println(""); for (Field field : fields) writeField(field); this.printWriter.println("
Access flagsTypeField name
"); this.printWriter.println(""); for (int i = 0; i < methods.length; i++) writeMethod(methods[i], i); this.printWriter.println("
Access flagsReturn typeMethod nameArguments
"); } } 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(); if (tag == 3) { this.printWriter.print("throws"); int[] exceptions = ((ExceptionTable)attributes[i]).getExceptionIndexTable(); for (int 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(""); } else if (tag == 2) { Attribute[] attributeArray = ((Code)attributes[i]).getAttributes(); for (int j = 0; j < attributeArray.length; j++) this.attributeHtml.writeAttribute(attributeArray[j], "method" + methodNumber + "@" + i + "@" + j, methodNumber); } } } }