< prev index next >

src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/AttributeHTML.java

Print this page




  28 import com.sun.org.apache.bcel.internal.Const;
  29 import com.sun.org.apache.bcel.internal.classfile.Attribute;
  30 import com.sun.org.apache.bcel.internal.classfile.Code;
  31 import com.sun.org.apache.bcel.internal.classfile.CodeException;
  32 import com.sun.org.apache.bcel.internal.classfile.ConstantPool;
  33 import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8;
  34 import com.sun.org.apache.bcel.internal.classfile.ConstantValue;
  35 import com.sun.org.apache.bcel.internal.classfile.ExceptionTable;
  36 import com.sun.org.apache.bcel.internal.classfile.InnerClass;
  37 import com.sun.org.apache.bcel.internal.classfile.InnerClasses;
  38 import com.sun.org.apache.bcel.internal.classfile.LineNumber;
  39 import com.sun.org.apache.bcel.internal.classfile.LineNumberTable;
  40 import com.sun.org.apache.bcel.internal.classfile.LocalVariable;
  41 import com.sun.org.apache.bcel.internal.classfile.LocalVariableTable;
  42 import com.sun.org.apache.bcel.internal.classfile.SourceFile;
  43 import com.sun.org.apache.bcel.internal.classfile.Utility;
  44 
  45 /**
  46  * Convert found attributes into HTML file.
  47  *
  48  * @version $Id$
  49  *
  50  */
  51 final class AttributeHTML {
  52 
  53     private final String class_name; // name of current class
  54     private final PrintWriter file; // file to write to
  55     private int attr_count = 0;
  56     private final ConstantHTML constant_html;
  57     private final ConstantPool constant_pool;
  58 
  59 
  60     AttributeHTML(final String dir, final String class_name, final ConstantPool constant_pool,
  61             final ConstantHTML constant_html) throws IOException {
  62         this.class_name = class_name;
  63         this.constant_pool = constant_pool;
  64         this.constant_html = constant_html;
  65         file = new PrintWriter(new FileOutputStream(dir + class_name + "_attributes.html"));
  66         file.println("<HTML><BODY BGCOLOR=\"#C0C0C0\"><TABLE BORDER=0>");
  67     }
  68 
  69 
  70     private String codeLink( final int link, final int method_number ) {
  71         return "<A HREF=\"" + class_name + "_code.html#code" + method_number + "@" + link
  72                 + "\" TARGET=Code>" + link + "</A>";
  73     }
  74 
  75 
  76     final void close() {
  77         file.println("</TABLE></BODY></HTML>");
  78         file.close();
  79     }
  80 
  81 
  82     final void writeAttribute( final Attribute attribute, final String anchor ) {
  83         writeAttribute(attribute, anchor, 0);
  84     }
  85 
  86 
  87     final void writeAttribute( final Attribute attribute, final String anchor, final int method_number ) {
  88         final byte tag = attribute.getTag();
  89         int index;
  90         if (tag == Const.ATTR_UNKNOWN) {
  91             return;
  92         }
  93         attr_count++; // Increment number of attributes found so far
  94         if (attr_count % 2 == 0) {
  95             file.print("<TR BGCOLOR=\"#C0C0C0\"><TD>");
  96         } else {
  97             file.print("<TR BGCOLOR=\"#A0A0A0\"><TD>");
  98         }
  99         file.println("<H4><A NAME=\"" + anchor + "\">" + attr_count + " " + Const.getAttributeName(tag)
 100                 + "</A></H4>");
 101         /* Handle different attributes
 102          */
 103         switch (tag) {
 104             case Const.ATTR_CODE:
 105                 final Code c = (Code) attribute;
 106                 // Some directly printable values
 107                 file.print("<UL><LI>Maximum stack size = " + c.getMaxStack()




  28 import com.sun.org.apache.bcel.internal.Const;
  29 import com.sun.org.apache.bcel.internal.classfile.Attribute;
  30 import com.sun.org.apache.bcel.internal.classfile.Code;
  31 import com.sun.org.apache.bcel.internal.classfile.CodeException;
  32 import com.sun.org.apache.bcel.internal.classfile.ConstantPool;
  33 import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8;
  34 import com.sun.org.apache.bcel.internal.classfile.ConstantValue;
  35 import com.sun.org.apache.bcel.internal.classfile.ExceptionTable;
  36 import com.sun.org.apache.bcel.internal.classfile.InnerClass;
  37 import com.sun.org.apache.bcel.internal.classfile.InnerClasses;
  38 import com.sun.org.apache.bcel.internal.classfile.LineNumber;
  39 import com.sun.org.apache.bcel.internal.classfile.LineNumberTable;
  40 import com.sun.org.apache.bcel.internal.classfile.LocalVariable;
  41 import com.sun.org.apache.bcel.internal.classfile.LocalVariableTable;
  42 import com.sun.org.apache.bcel.internal.classfile.SourceFile;
  43 import com.sun.org.apache.bcel.internal.classfile.Utility;
  44 
  45 /**
  46  * Convert found attributes into HTML file.
  47  *

  48  *
  49  */
  50 final class AttributeHTML {
  51 
  52     private final String class_name; // name of current class
  53     private final PrintWriter file; // file to write to
  54     private int attr_count = 0;
  55     private final ConstantHTML constant_html;
  56     private final ConstantPool constant_pool;
  57 
  58 
  59     AttributeHTML(final String dir, final String class_name, final ConstantPool constant_pool,
  60             final ConstantHTML constant_html) throws IOException {
  61         this.class_name = class_name;
  62         this.constant_pool = constant_pool;
  63         this.constant_html = constant_html;
  64         file = new PrintWriter(new FileOutputStream(dir + class_name + "_attributes.html"));
  65         file.println("<HTML><BODY BGCOLOR=\"#C0C0C0\"><TABLE BORDER=0>");
  66     }
  67 
  68 
  69     private String codeLink( final int link, final int method_number ) {
  70         return "<A HREF=\"" + class_name + "_code.html#code" + method_number + "@" + link
  71                 + "\" TARGET=Code>" + link + "</A>";
  72     }
  73 
  74 
  75     void close() {
  76         file.println("</TABLE></BODY></HTML>");
  77         file.close();
  78     }
  79 
  80 
  81     void writeAttribute( final Attribute attribute, final String anchor ) {
  82         writeAttribute(attribute, anchor, 0);
  83     }
  84 
  85 
  86     void writeAttribute( final Attribute attribute, final String anchor, final int method_number ) {
  87         final byte tag = attribute.getTag();
  88         int index;
  89         if (tag == Const.ATTR_UNKNOWN) {
  90             return;
  91         }
  92         attr_count++; // Increment number of attributes found so far
  93         if (attr_count % 2 == 0) {
  94             file.print("<TR BGCOLOR=\"#C0C0C0\"><TD>");
  95         } else {
  96             file.print("<TR BGCOLOR=\"#A0A0A0\"><TD>");
  97         }
  98         file.println("<H4><A NAME=\"" + anchor + "\">" + attr_count + " " + Const.getAttributeName(tag)
  99                 + "</A></H4>");
 100         /* Handle different attributes
 101          */
 102         switch (tag) {
 103             case Const.ATTR_CODE:
 104                 final Code c = (Code) attribute;
 105                 // Some directly printable values
 106                 file.print("<UL><LI>Maximum stack size = " + c.getMaxStack()


< prev index next >