KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > deployment > annotations > analyzer > ScanFieldVisitor


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * 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 375 2006-04-21 08:21:41Z benoitf $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.easybeans.deployment.annotations.analyzer;
27
28 import org.objectweb.asm.FieldVisitor;
29 import org.objectweb.easybeans.deployment.annotations.JField;
30 import org.objectweb.easybeans.deployment.annotations.metadata.ClassAnnotationMetadata;
31 import org.objectweb.easybeans.deployment.annotations.metadata.FieldAnnotationMetadata;
32
33 /**
34  * This classes analyses a given field and build/fill meta data information.
35  * @author Florent Benoit
36  */

37 public class ScanFieldVisitor extends ScanCommonVisitor<FieldAnnotationMetadata> implements FieldVisitor {
38
39
40     /**
41      * Class generated by the visitor which correspond to meta data contained in the parsed field.
42      */

43     private FieldAnnotationMetadata fieldAnnotationMetadata = null;
44
45
46     /**
47      * Parent of field annotation meta data that are built by this visitor.
48      */

49     private ClassAnnotationMetadata classAnnotationMetadata = null;
50
51     /**
52      * Constructor.
53      * @param jField field object on which we set meta data.
54      * @param classAnnotationMetadata the parent object on which add generated meta-data.
55      */

56     public ScanFieldVisitor(final JField jField, final ClassAnnotationMetadata classAnnotationMetadata) {
57
58         // object build and to fill
59
this.fieldAnnotationMetadata = new FieldAnnotationMetadata(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 JavaDoc
82     public void visitEnd() {
83         classAnnotationMetadata.addFieldAnnotationMetadata(fieldAnnotationMetadata);
84     }
85
86 }
87
Popular Tags