01: package net.sf.clirr.core.internal.bcel;
02:
03: import org.apache.bcel.classfile.Attribute;
04: import org.apache.bcel.classfile.Field;
05: import org.apache.bcel.classfile.JavaClass;
06:
07: import net.sf.clirr.core.spi.JavaType;
08: import net.sf.clirr.core.spi.Scope;
09:
10: final class BcelField implements net.sf.clirr.core.spi.Field {
11: private final Field field;
12: private final JavaClass owningClass;
13:
14: BcelField(JavaClass owningClass, Field field) {
15: this .owningClass = owningClass;
16: this .field = field;
17: }
18:
19: public String getName() {
20: return field.getName();
21: }
22:
23: public JavaType getType() {
24: return new BcelJavaType(field.getType(), owningClass
25: .getRepository());
26: }
27:
28: public boolean isFinal() {
29: return field.isFinal();
30: }
31:
32: public boolean isStatic() {
33: return field.isStatic();
34: }
35:
36: public boolean isDeprecated() {
37: Attribute[] attrs = field.getAttributes();
38: for (int i = 0; i < attrs.length; ++i) {
39: if (attrs[i] instanceof org.apache.bcel.classfile.Deprecated) {
40: return true;
41: }
42: }
43:
44: return false;
45: }
46:
47: public Object getConstantValue() {
48: return field.getConstantValue();
49: }
50:
51: public Scope getDeclaredScope() {
52: return BcelScopeHelper.getScope(field.getAccessFlags());
53: }
54:
55: public Scope getEffectiveScope() {
56: return getDeclaredScope(); // FIXME
57: }
58:
59: public String toString() {
60: return field.toString();
61: }
62: }
|