package org.apache.bcel.util; import java.io.Closeable; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; import java.util.function.Consumer; import org.apache.bcel.Const; import org.apache.bcel.classfile.Attribute; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.CodeException; import org.apache.bcel.classfile.ConstantPool; import org.apache.bcel.classfile.ConstantValue; import org.apache.bcel.classfile.ExceptionTable; import org.apache.bcel.classfile.InnerClass; import org.apache.bcel.classfile.InnerClasses; import org.apache.bcel.classfile.LineNumber; import org.apache.bcel.classfile.LineNumberTable; import org.apache.bcel.classfile.LocalVariableTable; import org.apache.bcel.classfile.SourceFile; import org.apache.bcel.classfile.Utility; import org.apache.bcel.util.Class2HTML; import org.apache.bcel.util.ConstantHTML; final class AttributeHTML implements Closeable { private final String className; private final PrintWriter printWriter; private int attrCount; private final ConstantHTML constantHtml; private final ConstantPool constantPool; AttributeHTML(String dir, String className, ConstantPool constantPool, ConstantHTML constantHtml, Charset charset) throws FileNotFoundException, UnsupportedEncodingException { this.className = className; this.constantPool = constantPool; this.constantHtml = constantHtml; this.printWriter = new PrintWriter(dir + className + "_attributes.html", charset.name()); this.printWriter.print(""); this.printWriter.println(""); } public void close() { this.printWriter.println("
"); this.printWriter.close(); } private String codeLink(int link, int methodNumber) { return "" + link + ""; } void writeAttribute(Attribute attribute, String anchor) { this.writeAttribute(attribute, anchor, 0); } void writeAttribute(Attribute attribute, String anchor, int methodNumber) { byte tag = attribute.getTag(); if(tag != -1) { ++this.attrCount; if(this.attrCount % 2 == 0) { this.printWriter.print(""); } else { this.printWriter.print(""); } this.printWriter.println("

" + this.attrCount + " " + Const.getAttributeName(tag) + "

"); int index; int cex; int indice; int var20; label71: switch(tag) { case 0: index = ((SourceFile)attribute).getSourceFileIndex(); this.printWriter.print("\n"); break; case 1: index = ((ConstantValue)attribute).getConstantValueIndex(); this.printWriter.print("\n"); break; case 2: Code c = (Code)attribute; this.printWriter.print("\n"); CodeException[] ce = c.getExceptionTable(); int len = ce.length; if(len > 0) { this.printWriter.print("

Exceptions handled

"); } break; case 3: int[] indices = ((ExceptionTable)attribute).getExceptionIndexTable(); this.printWriter.print("\n"); break; case 4: LineNumber[] lineNumbers = ((LineNumberTable)attribute).getLineNumberTable(); this.printWriter.print("

"); var20 = 0; while(true) { if(var20 >= lineNumbers.length) { break label71; } this.printWriter.print("(" + lineNumbers[var20].getStartPC() + ", " + lineNumbers[var20].getLineNumber() + ")"); if(var20 < lineNumbers.length - 1) { this.printWriter.print(", "); } ++var20; } case 5: this.printWriter.print("

\n"); break; case 6: this.printWriter.print("\n"); break; default: this.printWriter.print("

" + attribute); } this.printWriter.println(""); this.printWriter.flush(); } } }