01: package com.bm.ejb3metadata.annotations.analyzer;
02:
03: import org.ejb3unit.asm.FieldVisitor;
04:
05: import com.bm.ejb3metadata.annotations.JField;
06: import com.bm.ejb3metadata.annotations.metadata.ClassAnnotationMetadata;
07: import com.bm.ejb3metadata.annotations.metadata.FieldAnnotationMetadata;
08:
09: /**
10: * This classes analyses a given field and build/fill meta data information.
11: *
12: * @author Daniel Wiese
13: */
14: public class ScanFieldVisitor extends
15: ScanCommonVisitor<FieldAnnotationMetadata> implements
16: FieldVisitor {
17:
18: /**
19: * Class generated by the visitor which correspond to meta data contained in
20: * the parsed field.
21: */
22: private FieldAnnotationMetadata fieldAnnotationMetadata = null;
23:
24: /**
25: * Parent of field annotation meta data that are built by this visitor.
26: */
27: private ClassAnnotationMetadata classAnnotationMetadata = null;
28:
29: /**
30: * Constructor.
31: *
32: * @param jField
33: * field object on which we set meta data.
34: * @param classAnnotationMetadata
35: * the parent object on which add generated meta-data.
36: */
37: public ScanFieldVisitor(final JField jField,
38: final ClassAnnotationMetadata classAnnotationMetadata) {
39:
40: // object build and to fill
41: this .fieldAnnotationMetadata = new FieldAnnotationMetadata(
42: jField, classAnnotationMetadata);
43:
44: // parent
45: this .classAnnotationMetadata = classAnnotationMetadata;
46:
47: // list of visitors to use
48: initVisitors();
49: }
50:
51: /**
52: * Build visitors used by this one.
53: */
54: private void initVisitors() {
55: super .initVisitors(fieldAnnotationMetadata);
56:
57: }
58:
59: /**
60: * Visits the end of the method. This method, which is the last one to be
61: * called, is used to inform the visitor that all the annotations and
62: * attributes of the method have been visited.
63: */
64: @Override
65: public void visitEnd() {
66: classAnnotationMetadata
67: .addFieldAnnotationMetadata(fieldAnnotationMetadata);
68: }
69:
70: }
|