blob: 8d082fb90d9bd2e35c1fb36d3279444cc457db65 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
package ch.epfl.lamp.fjbg;
import java.util.List;
import java.util.LinkedList;
import java.util.Iterator;
/**
* Abstract superclass for a Java class, field or method.
*
* @author Nikolay Mihaylov
* @version 1.0
*/
abstract public class JMember {
protected boolean frozen = false;
protected final FJBGContext context;
protected String name;
protected int accessFlags;
protected final List/*<JAttribute>*/ attributes = new LinkedList();
protected JMember(FJBGContext context) { this.context = context; }
protected JMember(FJBGContext context, int accessFlags, String name) {
this(context);
this.name = name;
this.accessFlags = accessFlags;
}
/**
* Gets the access flags of the class.
* @return The int representing the access flags of the class.
*/
public int getAccessFlags() { return accessFlags; }
/**
* Gets the name of the member.
* @return The string representing the name of the member.
*/
public String getName() { return name; }
/**
* Gets the type of the objects that are instances of the class.
* @return The type of the instances of the class.
*/
public abstract JType getType();
/**
* Gets the class corresponding to/owning this member
* @return The class owning this member or the class itself.
*/
public abstract JClass getJClass();
/**
* Gets the constant pool of the class.
* @return The constant pool of the class.
*/
public JConstantPool getConstantPool() { return getJClass().getConstantPool(); }
public FJBGContext getContext() { return context; }
/**
* Adds an attribute to the class.
* @param attr The attribute to be added.
*/
public void addAttribute(JAttribute attr) {
assert !frozen;
attributes.add(attr);
}
/**
* Gets the list of all attributes of the class.
* @return The list of the attributes of the class representation.
*/
public List/*<JAttribute>*/ getAttributes() {
return attributes;
}
/**
* Get the attribute with the given name, or null if it doesn't
* exist.
*/
public JAttribute getAttribute(String name) {
Iterator attrIt = getAttributes().iterator();
while (attrIt.hasNext()) {
JAttribute attr = (JAttribute)attrIt.next();
if (attr.getName().equals(name))
return attr;
}
return null;
}
}
|