1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
package org.apache.commons.classscan.bcel; |
15 | |
|
16 | |
import java.util.Set; |
17 | |
|
18 | |
import org.apache.bcel.classfile.Field; |
19 | |
import org.apache.commons.classscan.model.MetaAnnotation; |
20 | |
import org.apache.commons.classscan.model.MetaType; |
21 | |
import org.apache.commons.classscan.spi.model.SpiMetaClassLoader; |
22 | |
import org.apache.commons.classscan.spi.model.SpiMetaField; |
23 | |
|
24 | |
public class BcelField implements SpiMetaField { |
25 | |
|
26 | |
private final String fieldName; |
27 | |
private final boolean isStatic; |
28 | |
private String fieldSignature; |
29 | |
private MetaType metaType; |
30 | |
private final AnnotationMap annotations; |
31 | |
|
32 | 908391 | public BcelField(Field field) { |
33 | 908391 | fieldName = field.getName(); |
34 | 908391 | isStatic = field.isStatic(); |
35 | 908391 | fieldSignature = field.getSignature(); |
36 | 908391 | annotations = AnnotationMap.createAnnotations(field.getAnnotationEntries()); |
37 | 908391 | } |
38 | |
|
39 | |
@Override |
40 | |
public boolean resolve(SpiMetaClassLoader classLoader) { |
41 | 906642 | metaType = classLoader.resolveTypeForDescriptor(fieldSignature); |
42 | 906642 | if(metaType == null) { |
43 | 88 | return false; |
44 | |
} |
45 | 906554 | fieldSignature = null; |
46 | |
|
47 | 906554 | return annotations.resolve(classLoader); |
48 | |
} |
49 | |
|
50 | |
@Override |
51 | |
public String getName() { |
52 | 33 | return fieldName; |
53 | |
} |
54 | |
|
55 | |
@Override |
56 | |
public Set<? extends MetaAnnotation> getAnnotations() { |
57 | 22 | return annotations; |
58 | |
} |
59 | |
|
60 | |
@Override |
61 | |
public MetaAnnotation getAnnotation(String annotationName) { |
62 | 0 | return annotations.getValue(annotationName); |
63 | |
} |
64 | |
|
65 | |
@Override |
66 | |
public boolean isStatic() { |
67 | 22 | return isStatic; |
68 | |
} |
69 | |
|
70 | |
@Override |
71 | |
public MetaType getType() { |
72 | 22 | return metaType; |
73 | |
} |
74 | |
} |