1 /
14
15 package jconst;
16
17 import java.io.*;
18 import util.*;
19
20
44 public class constRef extends constBase {
45 int index;
46 int name_and_type_index;
47 constClass_or_String class_ref;
48 constName_and_Type_info name_ref;
49
50 public void read( DataInputStream dStream ) {
51 index = readU2( dStream );
52 name_and_type_index = readU2( dStream );
53 }
54
55 public void set_ref(constBase objAry[] ) {
56 constBase tmp = objAry[ index ];
57
58 if (tmp instanceof constClass_or_String) {
59 class_ref = (constClass_or_String)tmp;
60 }
61 else {
62 System.out.println("object at const. pool index " + index +
63 " is not a constClass_or_String");
64 }
65
66 tmp = objAry[ name_and_type_index ];
67 if (tmp instanceof constName_and_Type_info) {
68 name_ref = (constName_and_Type_info)tmp;
69 }
70 else {
71 System.out.println("object at const. pool index " + index +
72 " is not a constName_and_Type_info");
73 }
74 }
76
77 public String getString() {
78 StringBuffer str = new StringBuffer();
79
80 str.append( super.getString() );
81 str.append(": ");
82 if (class_ref != null) {
83 str.append( class_ref.getString() );
84 }
85 else
86 str.append("null ref");
87
88 str.append(", ");
89
90 if (name_ref != null) {
91 str.append( name_ref.getString() );
92 }
93 else
94 str.append("null ref");
95 return str.toString();
96 }
98
99 public void pr() {
100 System.out.print( getString() );
101 }
103 }