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