1 /* file name : Class.java
2 * authors : Christopher Ellsworth (Chris@chrisellsworth.com)
3 * Clarence Alston (massclax@hotmail.com)
4 * created : 10/31/2002 11:19:28
5 *
6 * modifications:
7 *
8 * Bad design. Need to seperate jrre.api.java.lang from jrre.classloader.
9 *
10 * Can we use String descriptors instead of CPInfo's?
11 */
12 package jrre.api.java.lang;
13
14 import jrre.types.*;
15 import jrre.api.java.lang.reflect.*;
16
17 //import jrre.classloader.*;
18 //import jrre.classloader.classfile.attributes.*;
19 import jrre.classloader.classfile.pool_entries.*;
20
21 /***
22 * Representation of a class loaded by the ClassLoader. Use
23 * <code>instanceOf()</code> to create a new instance to put
24 * on the heap.
25 * @see jrre.classloader.ClassLoader
26 */
27 public class Class {
28
29 private Fields fields;
30 private Methods methods;
31 //private Attributes attributes;
32 private SymbolTable symbolTable = new SymbolTable();
33 private ClassProperties classProperties;
34 private Interfaces interfaces;
35
36 private StringBuffer loadingMessages;
37
38 /***
39 * Contains the values for all of the static fields in
40 * the class.
41 */
42 private java.util.HashMap classData = new java.util.HashMap();
43
44 public Type getStaticMemberValue(String key){
45 return ((Type)classData.get(key));
46 }
47
48 public void setStaticMemberValue(String key, Type value){
49 classData.put(key, value);
50 }
51
52 /***
53 * Gets the LoadingMessages.
54 */
55 public StringBuffer getLoadingMessages(){
56 return this.loadingMessages;
57 }
58
59 /***
60 * Sets the LoadingMessages.
61 * @param LoadingMessages The value to set it to.
62 */
63 public void setLoadingMessages(StringBuffer loadingMessages){
64 this.loadingMessages = loadingMessages;
65 }
66
67 /***
68 *
69 **/
70 public void addSymbol(int key,CPInfo c){
71 symbolTable.addSymbol(key,c);
72 }
73
74 /***
75 *
76 **/
77 public CPInfo getSymbol(int key){
78 return symbolTable.getSymbol(key);
79 }
80
81 public int getSymbolTableSize(){ return symbolTable.getSize(); }
82
83 /***
84 *
85 **/
86 public void initTableSize(int size){
87 symbolTable = new SymbolTable(size);
88 }
89
90 public void setFields(Fields fields){
91 this.fields = fields;
92 }
93
94 public void setMethods(Methods methods){
95 this.methods = methods;
96 }
97
98 public void setProperties(ClassProperties classProperties){
99 this.classProperties = classProperties;
100 }
101
102 public ClassProperties getProperties(){ return classProperties; }
103
104 public void setInterfaces(Interfaces interfaces){
105 this.interfaces = interfaces;
106 }
107
108 public String getFullyQualifiedName(){
109 int classIndex = classProperties.getThisClass();
110 CPClass cpClass = (CPClass)symbolTable.getSymbol(classIndex);
111 int nameIndex = cpClass.getNameIndex();
112 CPUTF8 descriptor = (CPUTF8)symbolTable.getSymbol(nameIndex);
113 return descriptor.getValue();
114 }
115
116 public String toString(){
117
118 return getFullyQualifiedName();
119 }
120
121 public String getString(){
122 StringBuffer toReturn = new StringBuffer();
123
124 toReturn.append(getFullyQualifiedName()+"\n");
125
126 toReturn.append(symbolTable.toString());
127
128 toReturn.append(methods.toString());
129
130
131 return toReturn.toString();
132 }
133
134 public jrre.ObjectInstance instanceOf(){
135
136 int fieldsSize = fields.getSize();
137
138 jrre.ObjectInstance toReturn = new jrre.ObjectInstance(fieldsSize);
139 toReturn.setClassData(this);
140
141 return toReturn;
142 }
143
144 public MethodEntry getMethod(String fullyQualifiedName){
145 return methods.getMethod(fullyQualifiedName);
146 }
147
148 public MethodEntry getMethod(int cpIndex){
149
150 return methods.getMethod(cpIndex);
151 }
152
153 public FieldEntry getField(String fullyQualifiedName){
154 return fields.getField(fullyQualifiedName);
155 }
156 }
This page was automatically generated by Maven