package com.sun.org.apache.bcel.internal.util; import com.sun.org.apache.bcel.internal.classfile.ConstantString; import com.sun.org.apache.bcel.internal.classfile.ConstantClass; import com.sun.org.apache.bcel.internal.classfile.ConstantFieldref; import com.sun.org.apache.bcel.internal.classfile.ConstantNameAndType; import com.sun.org.apache.bcel.internal.classfile.Utility; import com.sun.org.apache.bcel.internal.classfile.ConstantMethodref; import com.sun.org.apache.bcel.internal.classfile.ConstantInterfaceMethodref; import com.sun.org.apache.bcel.internal.Const; import java.io.IOException; import java.io.FileOutputStream; import com.sun.org.apache.bcel.internal.classfile.Method; import com.sun.org.apache.bcel.internal.classfile.Constant; import java.io.PrintWriter; import com.sun.org.apache.bcel.internal.classfile.ConstantPool; final class ConstantHTML { private final String class_name; private final String class_package; private final ConstantPool constant_pool; private final PrintWriter file; private final String[] constant_ref; private final Constant[] constants; private final Method[] methods; ConstantHTML(String dir, String class_name, String class_package, Method[] methods, ConstantPool constant_pool) throws IOException { this.class_name = class_name; this.class_package = class_package; this.constant_pool = constant_pool; this.methods = methods; this.constants = constant_pool.getConstantPool(); this.file = new PrintWriter(new FileOutputStream(dir + class_name + "_cp.html")); (this.constant_ref = new String[this.constants.length])[0] = "<unknown>"; this.file.println("
"); } else { this.file.print(" |
"); } if (this.constants[i] != null) { this.writeConstant(i); } this.file.print(" |
" + ret_type + " " + ref + arg_types + " \n
"); break; } case 9: { ConstantFieldref c4 = (ConstantFieldref)this.constant_pool.getConstant(index, (byte)9); int class_index = c4.getClassIndex(); int name_index = c4.getNameAndTypeIndex(); String field_class = this.constant_pool.constantToString(class_index, (byte)7); String short_field_class = Utility.compactClassName(field_class); short_field_class = Utility.compactClassName(short_field_class, this.class_package + ".", true); String field_name = this.constant_pool.constantToString(name_index, (byte)12); String ref; if (field_class.equals(this.class_name)) { ref = "" + field_name + ""; } else { ref = "" + short_field_class + "." + field_name + "\n"; } this.constant_ref[index] = "" + short_field_class + "." + field_name + ""; this.file.println("" + ref + "
\n
" + ref + "
\n"); break; } case 8: { ConstantString c6 = (ConstantString)this.constant_pool.getConstant(index, (byte)8); int name_index = c6.getStringIndex(); String str = Class2HTML.toHTML(this.constant_pool.constantToString(index, tag)); this.file.println("" + str + "
\n"); break; } case 12: { ConstantNameAndType c7 = (ConstantNameAndType)this.constant_pool.getConstant(index, (byte)12); int name_index = c7.getNameIndex(); int signature_index = c7.getSignatureIndex(); this.file.println("" + Class2HTML.toHTML(this.constant_pool.constantToString(index, tag)) + "
\n"); break; } default: { this.file.println("" + Class2HTML.toHTML(this.constant_pool.constantToString(index, tag)) + "\n"); break; } } } private int getMethodNumber(String str) { int i = 0; while (i < this.methods.length) { String cmp = this.methods[i].getName() + this.methods[i].getSignature(); if (cmp.equals(str)) { return i; } ++i; } return -1; } }