1    
2    /*
3    
4      The author of this software is Ian Kaplan
5      Bear Products International
6      www.bearcave.com
7      iank@bearcave.com
8    
9      Copyright (c) Ian Kaplan, 1999, 2000
10   
11     See copyright file for usage and licensing
12   
13   */
14   
15   package jconst;
16   
17   import java.io.*;
18   import util.*;
19   
20   /*
21    * constName_and_Type_info
22    *
23   
24       CONSTANT_NameAndType {
25          u1 tag;
26          u2 index;
27          u2 descriptor_index
28       }
29   
30       Both index and descriptor index refer to a CONSTANT_Utf8 entry in
31       the constant table
32   
33    */
34   public class constName_and_Type_info extends constClass_or_String {
35     int descriptor_index;
36     constUtf8 descriptor_Utf8;
37   
38     public void read( DataInputStream dStream ) {
39       super.read(dStream);
40       descriptor_index = readU2(dStream);
41     }
42   
43     public void set_ref(constBase objAry[] ) {
44       super.set_ref( objAry );
45       constBase tmp = objAry[ descriptor_index ];
46   
47       if (tmp instanceof constUtf8) {
48         descriptor_Utf8 = (constUtf8)tmp;
49       }
50       else {
51         System.out.println("Descriptor object at index is not a constUtf8");
52       }
53     } // set_ref
54   
55   
56     public String getString() {
57       StringBuffer str = new StringBuffer();
58       
59       str.append( super.getString() );
60       str.append(", ");
61       if (descriptor_Utf8 != null) {
62         str.append( descriptor_Utf8.getString() );
63       }
64       else {
65         str.append("null ref");
66       }
67       return str.toString();
68     } // getString
69   
70   
71     public void pr() {
72       System.out.print( getString() );
73     } // pr
74   
75   } // constName_and_type_info
76   
77