1 /* file name : Object.java
2 * authors : Christopher Ellsworth (Chris@chrisellsworth.com)
3 * : Clarence Alston
4 * created : 11/06/2002 08:03:20
5 * copyright :
6 *
7 * modifications:
8 *
9 */
10 package jrre;
11
12 import jrre.types.*;
13
14 import java.util.HashMap;
15 /***
16 * Object implementation for the JRRE system.
17 *
18 * @author Christopher Ellsworth (Chris@chrisellsworth.com)
19 * @author Clarence Alston
20 */
21 public class ObjectInstance {
22
23 /***
24 * Contains the values for all of the fields in
25 * the object.
26 */
27 private HashMap instanceData;
28
29 private jrre.api.java.lang.Class classData;
30
31 /***
32 * Constructs the object with the number
33 * of fields that it will have to store
34 * the value's of.
35 *
36 * @param dataSize The size to initialize with.
37 */
38 public ObjectInstance(int dataSize){
39
40 instanceData = new HashMap(dataSize);
41 }
42
43 /***
44 * Gets the ClassData.
45 */
46 public jrre.api.java.lang.Class getClassData(){
47 return this.classData;
48 }
49
50 /***
51 * Sets the ClassData.
52 * @param ClassData The location in the method data to set it to.
53 */
54 public void setClassData(jrre.api.java.lang.Class classData){
55 this.classData = classData;
56 }
57
58 public String toString(){
59
60 String className = this.classData.getFullyQualifiedName();
61 className = className.replace('/', '.');
62 className = "L"+className+";@"+this.hashCode();
63 return className;
64 }
65
66 /***
67 * Gets the data at the linked to the specified
68 * descriptor.
69 *
70 * @param index
71 * @return The instance data specified by the
72 * supplied descriptor.
73 */
74 public Type getInstanceValue(int index){
75 return (Type)instanceData.get(new Integer(index));
76 }
77
78 /***
79 * Sets a value to the instance data at the
80 * index specified.
81 *
82 * @param index
83 * @param value
84 */
85 public void setInstanceValue(int index, Type value){
86 instanceData.put(new Integer(index), value);
87 }
88 }
This page was automatically generated by Maven