01: /**
02: * EasyBeans
03: * Copyright (C) 2006 Bull S.A.S.
04: * Contact: easybeans@ow2.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * --------------------------------------------------------------------------
22: * $Id: ScanFieldVisitor.java 2059 2007-11-22 17:22:33Z benoitf $
23: * --------------------------------------------------------------------------
24: */package org.ow2.easybeans.deployment.annotations.analyzer;
25:
26: import org.ow2.easybeans.asm.FieldVisitor;
27: import org.ow2.easybeans.deployment.annotations.JField;
28: import org.ow2.easybeans.deployment.annotations.metadata.ClassAnnotationMetadata;
29: import org.ow2.easybeans.deployment.annotations.metadata.FieldAnnotationMetadata;
30:
31: /**
32: * This classes analyses a given field and build/fill meta data information.
33: * @author Florent Benoit
34: */
35: public class ScanFieldVisitor extends
36: ScanCommonVisitor<FieldAnnotationMetadata> implements
37: FieldVisitor {
38:
39: /**
40: * Class generated by the visitor which correspond to meta data contained in the parsed field.
41: */
42: private FieldAnnotationMetadata fieldAnnotationMetadata = null;
43:
44: /**
45: * Parent of field annotation meta data that are built by this visitor.
46: */
47: private ClassAnnotationMetadata classAnnotationMetadata = null;
48:
49: /**
50: * Constructor.
51: * @param jField field object on which we set meta data.
52: * @param classAnnotationMetadata the parent object on which add generated meta-data.
53: */
54: public ScanFieldVisitor(final JField jField,
55: final ClassAnnotationMetadata classAnnotationMetadata) {
56:
57: // object build and to fill
58: this .fieldAnnotationMetadata = new FieldAnnotationMetadata(
59: jField, classAnnotationMetadata);
60:
61: // parent
62: this .classAnnotationMetadata = classAnnotationMetadata;
63:
64: // list of visitors to use
65: initVisitors();
66: }
67:
68: /**
69: * Build visitors used by this one.
70: */
71: private void initVisitors() {
72: super .initVisitors(fieldAnnotationMetadata);
73:
74: }
75:
76: /**
77: * Visits the end of the method. This method, which is the last one to be
78: * called, is used to inform the visitor that all the annotations and
79: * attributes of the method have been visited.
80: */
81: @Override
82: public void visitEnd() {
83: classAnnotationMetadata
84: .addFieldAnnotationMetadata(fieldAnnotationMetadata);
85: }
86:
87: }
|