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   <pre>
22       CONSTANT_Class_info {
23          u1 tag;
24          u2 name_index;
25       }
26   
27       or
28   
29       CONSTANT_String_info {
30          u1 tag
31          u2 string_index
32       }
33   
34    */
35   public class constClass_or_String extends constBase {
36     int index = 0;
37     constUtf8 Utf8 = null;
38   
39     void read( DataInputStream dStream ) {
40       index = readU2( dStream );
41     }
42   
43     // For both class and strings, the index referrs to a
44     // constUtf8 object.
45     public void set_ref(constBase objAry[] ) {
46       constBase tmp = objAry[ index ];
47   
48       if (tmp instanceof constUtf8) {
49         Utf8 = (constUtf8)tmp;
50       }
51       else {
52         System.out.println("Object at index " + index + " is not a constUtf8");
53       }
54     } // set_ref
55   
56     public void pr() {
57       super.pr();
58       System.out.print(": ");
59       if (Utf8 != null) {
60         Utf8.pr();
61       }
62       else {
63         System.out.println("null ref");
64       }
65     } // pr
66   
67     public void prString() {
68       if (Utf8 != null) {
69         String name;
70   
71         name = objNameFormat.toDotSeparator( Utf8.getString() );
72         if (name != null) {
73   	System.out.print( name );
74         }
75         else {
76   	System.out.println("\nconstClass_or_String: prName - name is null");
77         }
78       }    
79     }
80   
81     public String getPrintableString() {
82       return Utf8.getPrintableString();
83     }
84   
85     public String getString() {
86       return Utf8.getString();
87     } // getName
88   
89   } // constClass_or_String
90   
91