jaxp/src/share/classes/com/sun/org/apache/bcel/internal/util/ConstantHTML.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 6 7f561c08de6b
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     2
 * reserved comment block
7f561c08de6b Initial load
duke
parents:
diff changeset
     3
 * DO NOT REMOVE OR ALTER!
7f561c08de6b Initial load
duke
parents:
diff changeset
     4
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
     5
7f561c08de6b Initial load
duke
parents:
diff changeset
     6
package com.sun.org.apache.bcel.internal.util;
7f561c08de6b Initial load
duke
parents:
diff changeset
     7
7f561c08de6b Initial load
duke
parents:
diff changeset
     8
/* ====================================================================
7f561c08de6b Initial load
duke
parents:
diff changeset
     9
 * The Apache Software License, Version 1.1
7f561c08de6b Initial load
duke
parents:
diff changeset
    10
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    11
 * Copyright (c) 2001 The Apache Software Foundation.  All rights
7f561c08de6b Initial load
duke
parents:
diff changeset
    12
 * reserved.
7f561c08de6b Initial load
duke
parents:
diff changeset
    13
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    14
 * Redistribution and use in source and binary forms, with or without
7f561c08de6b Initial load
duke
parents:
diff changeset
    15
 * modification, are permitted provided that the following conditions
7f561c08de6b Initial load
duke
parents:
diff changeset
    16
 * are met:
7f561c08de6b Initial load
duke
parents:
diff changeset
    17
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    18
 * 1. Redistributions of source code must retain the above copyright
7f561c08de6b Initial load
duke
parents:
diff changeset
    19
 *    notice, this list of conditions and the following disclaimer.
7f561c08de6b Initial load
duke
parents:
diff changeset
    20
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
 * 2. Redistributions in binary form must reproduce the above copyright
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
 *    notice, this list of conditions and the following disclaimer in
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
 *    the documentation and/or other materials provided with the
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
 *    distribution.
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
 * 3. The end-user documentation included with the redistribution,
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
 *    if any, must include the following acknowledgment:
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
 *       "This product includes software developed by the
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
 *        Apache Software Foundation (http://www.apache.org/)."
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
 *    Alternately, this acknowledgment may appear in the software itself,
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
 *    if and wherever such third-party acknowledgments normally appear.
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
 * 4. The names "Apache" and "Apache Software Foundation" and
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
 *    "Apache BCEL" must not be used to endorse or promote products
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
 *    derived from this software without prior written permission. For
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
 *    written permission, please contact apache@apache.org.
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
 * 5. Products derived from this software may not be called "Apache",
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
 *    "Apache BCEL", nor may "Apache" appear in their name, without
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
 *    prior written permission of the Apache Software Foundation.
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
 * SUCH DAMAGE.
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
 * ====================================================================
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
 * This software consists of voluntary contributions made by many
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
 * individuals on behalf of the Apache Software Foundation.  For more
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
 * information on the Apache Software Foundation, please see
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
 * <http://www.apache.org/>.
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
import com.sun.org.apache.bcel.internal.classfile.*;
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
import java.io.*;
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
 * Convert constant pool into HTML file.
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
 * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
final class ConstantHTML implements com.sun.org.apache.bcel.internal.Constants {
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
  private String        class_name;     // name of current class
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
  private String        class_package;  // name of package
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
  private ConstantPool  constant_pool;  // reference to constant pool
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
  private PrintWriter   file;           // file to write to
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
  private String[]      constant_ref;   // String to return for cp[i]
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
  private Constant[]    constants;      // The constants in the cp
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
  private Method[]      methods;
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
  ConstantHTML(String dir, String class_name, String class_package, Method[] methods,
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
               ConstantPool constant_pool) throws IOException
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
    this.class_name     = class_name;
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
    this.class_package  = class_package;
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
    this.constant_pool  = constant_pool;
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
    this.methods        = methods;
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
    constants           = constant_pool.getConstantPool();
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
    file                = new PrintWriter(new FileOutputStream(dir + class_name + "_cp.html"));
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
    constant_ref        = new String[constants.length];
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
    constant_ref[0]     = "&lt;unknown&gt;";
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
    file.println("<HTML><BODY BGCOLOR=\"#C0C0C0\"><TABLE BORDER=0>");
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
    // Loop through constants, constants[0] is reserved
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
    for(int i=1; i < constants.length; i++) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
      if(i % 2 == 0)
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
        file.print("<TR BGCOLOR=\"#C0C0C0\"><TD>");
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
      else
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
        file.print("<TR BGCOLOR=\"#A0A0A0\"><TD>");
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
      if(constants[i] != null)
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
        writeConstant(i);
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
      file.print("</TD></TR>\n");
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
    file.println("</TABLE></BODY></HTML>");
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
    file.close();
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
  String referenceConstant(int index) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
    return constant_ref[index];
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
7f561c08de6b Initial load
duke
parents:
diff changeset
   115
  private void writeConstant(int index) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   116
    byte   tag = constants[index].getTag();
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
    int    class_index, name_index;
7f561c08de6b Initial load
duke
parents:
diff changeset
   118
    String ref;
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
7f561c08de6b Initial load
duke
parents:
diff changeset
   120
    // The header is always the same
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
    file.println("<H4> <A NAME=cp" + index + ">" + index + "</A> " + CONSTANT_NAMES[tag] + "</H4>");
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
    /* For every constant type get the needed parameters and print them appropiately
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   125
    switch(tag) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   126
    case CONSTANT_InterfaceMethodref:
7f561c08de6b Initial load
duke
parents:
diff changeset
   127
    case CONSTANT_Methodref:
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
      // Get class_index and name_and_type_index, depending on type
7f561c08de6b Initial load
duke
parents:
diff changeset
   129
      if(tag == CONSTANT_Methodref) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
        ConstantMethodref c = (ConstantMethodref)constant_pool.getConstant(index, CONSTANT_Methodref);
7f561c08de6b Initial load
duke
parents:
diff changeset
   131
        class_index = c.getClassIndex();
7f561c08de6b Initial load
duke
parents:
diff changeset
   132
        name_index  = c.getNameAndTypeIndex();
7f561c08de6b Initial load
duke
parents:
diff changeset
   133
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   134
      else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   135
        ConstantInterfaceMethodref c1 = (ConstantInterfaceMethodref)constant_pool.getConstant(index, CONSTANT_InterfaceMethodref);
7f561c08de6b Initial load
duke
parents:
diff changeset
   136
        class_index = c1.getClassIndex();
7f561c08de6b Initial load
duke
parents:
diff changeset
   137
        name_index  = c1.getNameAndTypeIndex();
7f561c08de6b Initial load
duke
parents:
diff changeset
   138
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   139
7f561c08de6b Initial load
duke
parents:
diff changeset
   140
      // Get method name and its class
7f561c08de6b Initial load
duke
parents:
diff changeset
   141
      String method_name        = constant_pool.constantToString(name_index, CONSTANT_NameAndType);
7f561c08de6b Initial load
duke
parents:
diff changeset
   142
      String html_method_name = Class2HTML.toHTML(method_name);
7f561c08de6b Initial load
duke
parents:
diff changeset
   143
7f561c08de6b Initial load
duke
parents:
diff changeset
   144
      // Partially compacted class name, i.e., / -> .
7f561c08de6b Initial load
duke
parents:
diff changeset
   145
      String method_class = constant_pool.constantToString(class_index, CONSTANT_Class);
7f561c08de6b Initial load
duke
parents:
diff changeset
   146
      String short_method_class         = Utility.compactClassName(method_class); // I.e., remove java.lang.
7f561c08de6b Initial load
duke
parents:
diff changeset
   147
      short_method_class = Utility.compactClassName(method_class); // I.e., remove java.lang.
7f561c08de6b Initial load
duke
parents:
diff changeset
   148
      short_method_class = Utility.compactClassName(short_method_class, class_package + ".", true); // Remove class package prefix
7f561c08de6b Initial load
duke
parents:
diff changeset
   149
7f561c08de6b Initial load
duke
parents:
diff changeset
   150
      // Get method signature
7f561c08de6b Initial load
duke
parents:
diff changeset
   151
      ConstantNameAndType c2 = (ConstantNameAndType)constant_pool.getConstant(name_index, CONSTANT_NameAndType);
7f561c08de6b Initial load
duke
parents:
diff changeset
   152
      String signature = constant_pool.constantToString(c2.getSignatureIndex(), CONSTANT_Utf8);
7f561c08de6b Initial load
duke
parents:
diff changeset
   153
      // Get array of strings containing the argument types
7f561c08de6b Initial load
duke
parents:
diff changeset
   154
      String[] args = Utility.methodSignatureArgumentTypes(signature, false);
7f561c08de6b Initial load
duke
parents:
diff changeset
   155
7f561c08de6b Initial load
duke
parents:
diff changeset
   156
      // Get return type string
7f561c08de6b Initial load
duke
parents:
diff changeset
   157
      String type = Utility.methodSignatureReturnType(signature, false);
7f561c08de6b Initial load
duke
parents:
diff changeset
   158
      String ret_type = Class2HTML.referenceType(type);
7f561c08de6b Initial load
duke
parents:
diff changeset
   159
7f561c08de6b Initial load
duke
parents:
diff changeset
   160
      StringBuffer buf = new StringBuffer("(");
7f561c08de6b Initial load
duke
parents:
diff changeset
   161
      for(int i=0; i < args.length; i++) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   162
        buf.append(Class2HTML.referenceType(args[i]));
7f561c08de6b Initial load
duke
parents:
diff changeset
   163
        if(i < args.length - 1)
7f561c08de6b Initial load
duke
parents:
diff changeset
   164
          buf.append(",&nbsp;");
7f561c08de6b Initial load
duke
parents:
diff changeset
   165
      }
7f561c08de6b Initial load
duke
parents:
diff changeset
   166
      buf.append(")");
7f561c08de6b Initial load
duke
parents:
diff changeset
   167
7f561c08de6b Initial load
duke
parents:
diff changeset
   168
      String arg_types = buf.toString();
7f561c08de6b Initial load
duke
parents:
diff changeset
   169
7f561c08de6b Initial load
duke
parents:
diff changeset
   170
      if(method_class.equals(class_name)) // Method is local to class
7f561c08de6b Initial load
duke
parents:
diff changeset
   171
        ref = "<A HREF=\"" + class_name + "_code.html#method" + getMethodNumber(method_name + signature) +
7f561c08de6b Initial load
duke
parents:
diff changeset
   172
          "\" TARGET=Code>" + html_method_name + "</A>";
7f561c08de6b Initial load
duke
parents:
diff changeset
   173
      else
7f561c08de6b Initial load
duke
parents:
diff changeset
   174
        ref = "<A HREF=\"" + method_class + ".html" + "\" TARGET=_top>" + short_method_class +
7f561c08de6b Initial load
duke
parents:
diff changeset
   175
          "</A>." + html_method_name;
7f561c08de6b Initial load
duke
parents:
diff changeset
   176
7f561c08de6b Initial load
duke
parents:
diff changeset
   177
      constant_ref[index] = ret_type + "&nbsp;<A HREF=\"" + class_name + "_cp.html#cp" + class_index +
7f561c08de6b Initial load
duke
parents:
diff changeset
   178
        "\" TARGET=Constants>" +
7f561c08de6b Initial load
duke
parents:
diff changeset
   179
        short_method_class + "</A>.<A HREF=\"" + class_name + "_cp.html#cp" +
7f561c08de6b Initial load
duke
parents:
diff changeset
   180
        index + "\" TARGET=ConstantPool>" + html_method_name + "</A>&nbsp;" + arg_types;
7f561c08de6b Initial load
duke
parents:
diff changeset
   181
7f561c08de6b Initial load
duke
parents:
diff changeset
   182
      file.println("<P><TT>" + ret_type + "&nbsp;" + ref + arg_types + "&nbsp;</TT>\n<UL>" +
7f561c08de6b Initial load
duke
parents:
diff changeset
   183
                   "<LI><A HREF=\"#cp" + class_index + "\">Class index(" + class_index +        ")</A>\n" +
7f561c08de6b Initial load
duke
parents:
diff changeset
   184
                   "<LI><A HREF=\"#cp" + name_index + "\">NameAndType index(" + name_index + ")</A></UL>");
7f561c08de6b Initial load
duke
parents:
diff changeset
   185
      break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   186
7f561c08de6b Initial load
duke
parents:
diff changeset
   187
    case CONSTANT_Fieldref:
7f561c08de6b Initial load
duke
parents:
diff changeset
   188
      // Get class_index and name_and_type_index
7f561c08de6b Initial load
duke
parents:
diff changeset
   189
      ConstantFieldref c3 = (ConstantFieldref)constant_pool.getConstant(index, CONSTANT_Fieldref);
7f561c08de6b Initial load
duke
parents:
diff changeset
   190
      class_index = c3.getClassIndex();
7f561c08de6b Initial load
duke
parents:
diff changeset
   191
      name_index  = c3.getNameAndTypeIndex();
7f561c08de6b Initial load
duke
parents:
diff changeset
   192
7f561c08de6b Initial load
duke
parents:
diff changeset
   193
      // Get method name and its class (compacted)
7f561c08de6b Initial load
duke
parents:
diff changeset
   194
      String field_class = constant_pool.constantToString(class_index, CONSTANT_Class);
7f561c08de6b Initial load
duke
parents:
diff changeset
   195
      String short_field_class = Utility.compactClassName(field_class); // I.e., remove java.lang.
7f561c08de6b Initial load
duke
parents:
diff changeset
   196
      short_field_class = Utility.compactClassName(short_field_class, class_package + ".", true); // Remove class package prefix
7f561c08de6b Initial load
duke
parents:
diff changeset
   197
7f561c08de6b Initial load
duke
parents:
diff changeset
   198
      String field_name  = constant_pool.constantToString(name_index, CONSTANT_NameAndType);
7f561c08de6b Initial load
duke
parents:
diff changeset
   199
7f561c08de6b Initial load
duke
parents:
diff changeset
   200
      if(field_class.equals(class_name)) // Field is local to class
7f561c08de6b Initial load
duke
parents:
diff changeset
   201
        ref = "<A HREF=\"" + field_class + "_methods.html#field" +
7f561c08de6b Initial load
duke
parents:
diff changeset
   202
          field_name + "\" TARGET=Methods>" + field_name + "</A>";
7f561c08de6b Initial load
duke
parents:
diff changeset
   203
      else
7f561c08de6b Initial load
duke
parents:
diff changeset
   204
        ref = "<A HREF=\"" + field_class + ".html\" TARGET=_top>" +
7f561c08de6b Initial load
duke
parents:
diff changeset
   205
          short_field_class + "</A>." + field_name + "\n";
7f561c08de6b Initial load
duke
parents:
diff changeset
   206
7f561c08de6b Initial load
duke
parents:
diff changeset
   207
      constant_ref[index] = "<A HREF=\"" + class_name + "_cp.html#cp" + class_index +   "\" TARGET=Constants>" +
7f561c08de6b Initial load
duke
parents:
diff changeset
   208
        short_field_class + "</A>.<A HREF=\"" + class_name + "_cp.html#cp" +
7f561c08de6b Initial load
duke
parents:
diff changeset
   209
        index + "\" TARGET=ConstantPool>" + field_name + "</A>";
7f561c08de6b Initial load
duke
parents:
diff changeset
   210
7f561c08de6b Initial load
duke
parents:
diff changeset
   211
      file.println("<P><TT>" + ref + "</TT><BR>\n" + "<UL>" +
7f561c08de6b Initial load
duke
parents:
diff changeset
   212
                   "<LI><A HREF=\"#cp" + class_index + "\">Class(" + class_index +      ")</A><BR>\n" +
7f561c08de6b Initial load
duke
parents:
diff changeset
   213
                   "<LI><A HREF=\"#cp" + name_index + "\">NameAndType(" + name_index + ")</A></UL>");
7f561c08de6b Initial load
duke
parents:
diff changeset
   214
      break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   215
7f561c08de6b Initial load
duke
parents:
diff changeset
   216
    case CONSTANT_Class:
7f561c08de6b Initial load
duke
parents:
diff changeset
   217
      ConstantClass c4 = (ConstantClass)constant_pool.getConstant(index, CONSTANT_Class);
7f561c08de6b Initial load
duke
parents:
diff changeset
   218
      name_index  = c4.getNameIndex();
7f561c08de6b Initial load
duke
parents:
diff changeset
   219
      String class_name2  = constant_pool.constantToString(index, tag); // / -> .
7f561c08de6b Initial load
duke
parents:
diff changeset
   220
      String short_class_name = Utility.compactClassName(class_name2); // I.e., remove java.lang.
7f561c08de6b Initial load
duke
parents:
diff changeset
   221
      short_class_name = Utility.compactClassName(short_class_name, class_package + ".", true); // Remove class package prefix
7f561c08de6b Initial load
duke
parents:
diff changeset
   222
7f561c08de6b Initial load
duke
parents:
diff changeset
   223
      ref = "<A HREF=\"" + class_name2 + ".html\" TARGET=_top>" + short_class_name + "</A>";
7f561c08de6b Initial load
duke
parents:
diff changeset
   224
      constant_ref[index] = "<A HREF=\"" + class_name + "_cp.html#cp" + index +
7f561c08de6b Initial load
duke
parents:
diff changeset
   225
        "\" TARGET=ConstantPool>" + short_class_name + "</A>";
7f561c08de6b Initial load
duke
parents:
diff changeset
   226
7f561c08de6b Initial load
duke
parents:
diff changeset
   227
      file.println("<P><TT>" + ref + "</TT><UL>" +
7f561c08de6b Initial load
duke
parents:
diff changeset
   228
                   "<LI><A HREF=\"#cp" + name_index + "\">Name index(" + name_index +   ")</A></UL>\n");
7f561c08de6b Initial load
duke
parents:
diff changeset
   229
      break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   230
7f561c08de6b Initial load
duke
parents:
diff changeset
   231
    case CONSTANT_String:
7f561c08de6b Initial load
duke
parents:
diff changeset
   232
      ConstantString c5 = (ConstantString)constant_pool.getConstant(index, CONSTANT_String);
7f561c08de6b Initial load
duke
parents:
diff changeset
   233
      name_index = c5.getStringIndex();
7f561c08de6b Initial load
duke
parents:
diff changeset
   234
7f561c08de6b Initial load
duke
parents:
diff changeset
   235
      String str = Class2HTML.toHTML(constant_pool.constantToString(index, tag));
7f561c08de6b Initial load
duke
parents:
diff changeset
   236
7f561c08de6b Initial load
duke
parents:
diff changeset
   237
      file.println("<P><TT>" + str + "</TT><UL>" +
7f561c08de6b Initial load
duke
parents:
diff changeset
   238
                   "<LI><A HREF=\"#cp" + name_index + "\">Name index(" + name_index +   ")</A></UL>\n");
7f561c08de6b Initial load
duke
parents:
diff changeset
   239
      break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   240
7f561c08de6b Initial load
duke
parents:
diff changeset
   241
    case CONSTANT_NameAndType:
7f561c08de6b Initial load
duke
parents:
diff changeset
   242
      ConstantNameAndType c6 = (ConstantNameAndType)constant_pool.getConstant(index, CONSTANT_NameAndType);
7f561c08de6b Initial load
duke
parents:
diff changeset
   243
      name_index = c6.getNameIndex();
7f561c08de6b Initial load
duke
parents:
diff changeset
   244
      int signature_index = c6.getSignatureIndex();
7f561c08de6b Initial load
duke
parents:
diff changeset
   245
7f561c08de6b Initial load
duke
parents:
diff changeset
   246
      file.println("<P><TT>" + Class2HTML.toHTML(constant_pool.constantToString(index, tag)) + "</TT><UL>" +
7f561c08de6b Initial load
duke
parents:
diff changeset
   247
                   "<LI><A HREF=\"#cp" + name_index + "\">Name index(" + name_index + ")</A>\n" +
7f561c08de6b Initial load
duke
parents:
diff changeset
   248
                   "<LI><A HREF=\"#cp" + signature_index + "\">Signature index(" +
7f561c08de6b Initial load
duke
parents:
diff changeset
   249
                   signature_index + ")</A></UL>\n");
7f561c08de6b Initial load
duke
parents:
diff changeset
   250
      break;
7f561c08de6b Initial load
duke
parents:
diff changeset
   251
7f561c08de6b Initial load
duke
parents:
diff changeset
   252
    default:
7f561c08de6b Initial load
duke
parents:
diff changeset
   253
      file.println("<P><TT>" + Class2HTML.toHTML(constant_pool.constantToString(index, tag)) + "</TT>\n");
7f561c08de6b Initial load
duke
parents:
diff changeset
   254
    } // switch
7f561c08de6b Initial load
duke
parents:
diff changeset
   255
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   256
7f561c08de6b Initial load
duke
parents:
diff changeset
   257
  private final int getMethodNumber(String str) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   258
    for(int i=0; i < methods.length; i++) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   259
      String cmp = methods[i].getName() + methods[i].getSignature();
7f561c08de6b Initial load
duke
parents:
diff changeset
   260
      if(cmp.equals(str))
7f561c08de6b Initial load
duke
parents:
diff changeset
   261
        return i;
7f561c08de6b Initial load
duke
parents:
diff changeset
   262
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   263
    return -1;
7f561c08de6b Initial load
duke
parents:
diff changeset
   264
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
   265
}