View Javadoc

1   package serp.bytecode;
2   
3   import java.util.*;
4   
5   import serp.bytecode.lowlevel.*;
6   
7   /***
8    * State implementing the behavior of an object type.
9    *
10   * @author Abe White
11   */
12  class ObjectState extends State {
13      private final ConstantPool _pool = new ConstantPool();
14      private final NameCache _names;
15      private int _index = 0;
16      private int _superclassIndex = 0;
17      private int _magic = Constants.VALID_MAGIC;
18      private int _major = Constants.MAJOR_VERSION;
19      private int _minor = Constants.MINOR_VERSION;
20      private int _access = Constants.ACCESS_PUBLIC | Constants.ACCESS_SUPER;
21      private final List _interfaces = new ArrayList();
22      private final List _fields = new ArrayList();
23      private final List _methods = new ArrayList();
24      private final List _attributes = new ArrayList();
25  
26      public ObjectState(NameCache names) {
27          _names = names;
28      }
29  
30      public int getMagic() {
31          return _magic;
32      }
33  
34      public void setMagic(int magic) {
35          _magic = magic;
36      }
37  
38      public int getMajorVersion() {
39          return _major;
40      }
41  
42      public void setMajorVersion(int major) {
43          _major = major;
44      }
45  
46      public int getMinorVersion() {
47          return _minor;
48      }
49  
50      public void setMinorVersion(int minor) {
51          _minor = minor;
52      }
53  
54      public int getAccessFlags() {
55          return _access;
56      }
57  
58      public void setAccessFlags(int access) {
59          _access = access;
60      }
61  
62      public int getIndex() {
63          return _index;
64      }
65  
66      public void setIndex(int index) {
67          _index = index;
68      }
69  
70      public int getSuperclassIndex() {
71          return _superclassIndex;
72      }
73  
74      public void setSuperclassIndex(int index) {
75          _superclassIndex = index;
76      }
77  
78      public List getInterfacesHolder() {
79          return _interfaces;
80      }
81  
82      public List getFieldsHolder() {
83          return _fields;
84      }
85  
86      public List getMethodsHolder() {
87          return _methods;
88      }
89  
90      public Collection getAttributesHolder() {
91          return _attributes;
92      }
93  
94      public ConstantPool getPool() {
95          return _pool;
96      }
97  
98      public String getName() {
99          if (_index == 0)
100             return null;
101         return _names.getExternalForm(((ClassEntry) _pool.getEntry(_index)).
102             getNameEntry().getValue(), false);
103     }
104 
105     public String getSuperclassName() {
106         if (_superclassIndex == 0)
107             return null;
108         return _names.getExternalForm(((ClassEntry) _pool.getEntry
109             (_superclassIndex)).getNameEntry().getValue(), false);
110     }
111 
112     public String getComponentName() {
113         return null;
114     }
115 
116     public boolean isPrimitive() {
117         return false;
118     }
119 
120     public boolean isArray() {
121         return false;
122     }
123 }