KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > deployment > annotations > metadata > FieldAnnotationMetadata


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: FieldAnnotationMetadata.java 373 2006-04-21 08:20:44Z benoitf $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.easybeans.deployment.annotations.metadata;
27
28 import org.objectweb.easybeans.deployment.annotations.JField;
29
30 /**
31  * This class represents the annotation metadata of a field.
32  * @author Florent Benoit
33  */

34 public class FieldAnnotationMetadata extends CommonAnnotationMetadata {
35
36     /**
37      * Logger.
38      */

39     //private static JLog logger = JLogFactory.getLog(FieldAnnotationMetadata.class);
40

41     /**
42      * Method on which we got metadata.
43      */

44     private JField jField = null;
45
46     /**
47      * Parent metadata.
48      */

49     private ClassAnnotationMetadata classAnnotationMetadata = null;
50
51     /**
52      * This field is a field from a super class ?<br>
53      */

54     private boolean inherited = false;
55
56
57     /**
58      * Constructor.
59      * @param jField the field on which we will set/add metadata
60      * @param classAnnotationMetadata the parent metadata.
61      */

62     public FieldAnnotationMetadata(final JField jField, final ClassAnnotationMetadata classAnnotationMetadata) {
63         this.jField = jField;
64         this.classAnnotationMetadata = classAnnotationMetadata;
65     }
66
67     /**
68      * @return name of the field
69      */

70     public String JavaDoc getFieldName() {
71         return this.jField.getName();
72     }
73
74     /**
75      * @return JMethod object
76      */

77     public JField getJField() {
78         return this.jField;
79     }
80
81     /**
82      * @return string representation
83      */

84     @Override JavaDoc
85     public String JavaDoc toString() {
86         StringBuilder JavaDoc sb = new StringBuilder JavaDoc();
87         String JavaDoc titleIndent = " ";
88         String JavaDoc indent = " ";
89         // classname
90
sb.append(titleIndent);
91         sb.append(this.getClass().getName().substring(this.getClass().getPackage().getName().length() + 1));
92         sb.append("[\n");
93
94         // Add super class toString()
95
sb.append(super.toString());
96
97         // Field
98
sb.append(indent);
99         sb.append("jField=");
100         sb.append(jField);
101         sb.append("\n");
102
103         // inherited
104
if (inherited) {
105             sb.append(indent);
106             sb.append("inherited=");
107             sb.append(inherited);
108             sb.append("\n");
109         }
110
111
112         sb.append(titleIndent);
113         sb.append("]\n");
114         return sb.toString();
115     }
116
117
118
119     /**
120      * @return true if this method is inherited from a super class
121      */

122     public boolean isInherited() {
123         return inherited;
124     }
125
126     /**
127      * Sets the inheritance of this method.
128      * @param inherited true if method is from a super class
129      */

130     public void setInherited(final boolean inherited) {
131         this.inherited = inherited;
132     }
133
134     /**
135      * @return parent metadata (class)
136      */

137     public ClassAnnotationMetadata getClassAnnotationMetadata() {
138         return classAnnotationMetadata;
139     }
140
141
142
143
144
145 }
146
Popular Tags