package org.apache.bcel.util; package .tmp; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; import org.apache.bcel.Const; import org.apache.bcel.classfile.Constant; import org.apache.bcel.classfile.ConstantClass; import org.apache.bcel.classfile.ConstantFieldref; import org.apache.bcel.classfile.ConstantInterfaceMethodref; import org.apache.bcel.classfile.ConstantMethodref; import org.apache.bcel.classfile.ConstantNameAndType; import org.apache.bcel.classfile.ConstantPool; import org.apache.bcel.classfile.ConstantString; import org.apache.bcel.classfile.Method; import org.apache.bcel.classfile.Utility; import org.apache.bcel.util.Class2HTML; final class ConstantHTML { private final String className; private final String classPackage; private final ConstantPool constantPool; private final PrintWriter printWriter; private final String[] constantRef; private final Constant[] constants; private final Method[] methods; ConstantHTML(String dir, String className, String classPackage, Method[] methods, ConstantPool constantPool, Charset charset) throws FileNotFoundException, UnsupportedEncodingException { this.className = className; this.classPackage = classPackage; this.constantPool = constantPool; this.methods = methods; this.constants = constantPool.getConstantPool(); try (PrintWriter newPrintWriter = new PrintWriter(dir + className + "_cp.html", charset.name())) { this.printWriter = newPrintWriter; this.constantRef = new String[this.constants.length]; this.constantRef[0] = "<unknown>"; this.printWriter.print("
"); this.printWriter.println(""); } else { this.printWriter.print(" |
"); } if (this.constants[i] != null) writeConstant(i); this.printWriter.print(" |
" + retType + " " + ref + argTypes + " \n
"); return; case 9: c3 = (ConstantFieldref)this.constantPool.getConstant(index, (byte)9, ConstantFieldref.class); classIndex = c3.getClassIndex(); nameIndex = c3.getNameAndTypeIndex(); fieldClass = this.constantPool.constantToString(classIndex, (byte)7); shortFieldClass = Utility.compactClassName(fieldClass); shortFieldClass = Utility.compactClassName(shortFieldClass, this.classPackage + ".", true); fieldName = this.constantPool.constantToString(nameIndex, (byte)12); if (fieldClass.equals(this.className)) { ref = "" + fieldName + ""; } else { ref = "" + shortFieldClass + "." + fieldName + "\n"; } this.constantRef[index] = "" + shortFieldClass + "." + fieldName + ""; this.printWriter.println("" + ref + "
\n
" + ref + "
\n"); return; case 8: c5 = (ConstantString)this.constantPool.getConstant(index, (byte)8, ConstantString.class); nameIndex = c5.getStringIndex(); str = Class2HTML.toHTML(this.constantPool.constantToString(index, tag)); this.printWriter.println("" + str + "
\n"); return; case 12: c6 = (ConstantNameAndType)this.constantPool.getConstant(index, (byte)12, ConstantNameAndType.class); nameIndex = c6.getNameIndex(); signatureIndex = c6.getSignatureIndex(); this.printWriter.println("" + Class2HTML.toHTML(this.constantPool.constantToString(index, tag)) + "
\n"); return; } this.printWriter.println("" + Class2HTML.toHTML(this.constantPool.constantToString(index, tag)) + "\n"); } }