001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@ow2.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: FieldAnnotationMetadata.java 2059 2007-11-22 17:22:33Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.deployment.annotations.metadata;
025:
026: import org.ow2.easybeans.deployment.annotations.JField;
027:
028: /**
029: * This class represents the annotation metadata of a field.
030: * @author Florent Benoit
031: */
032: public class FieldAnnotationMetadata extends CommonAnnotationMetadata {
033:
034: /**
035: * Logger.
036: */
037: //private static Log logger = LogFactory.getLog(FieldAnnotationMetadata.class);
038: /**
039: * Method on which we got metadata.
040: */
041: private JField jField = null;
042:
043: /**
044: * Parent metadata.
045: */
046: private ClassAnnotationMetadata classAnnotationMetadata = null;
047:
048: /**
049: * This field is a field from a super class ?<br>
050: */
051: private boolean inherited = false;
052:
053: /**
054: * Constructor.
055: * @param jField the field on which we will set/add metadata
056: * @param classAnnotationMetadata the parent metadata.
057: */
058: public FieldAnnotationMetadata(final JField jField,
059: final ClassAnnotationMetadata classAnnotationMetadata) {
060: this .jField = jField;
061: this .classAnnotationMetadata = classAnnotationMetadata;
062: }
063:
064: /**
065: * @return name of the field
066: */
067: public String getFieldName() {
068: return this .jField.getName();
069: }
070:
071: /**
072: * @return JMethod object
073: */
074: public JField getJField() {
075: return this .jField;
076: }
077:
078: /**
079: * @return string representation
080: */
081: @Override
082: public String toString() {
083: StringBuilder sb = new StringBuilder();
084: String titleIndent = " ";
085: String indent = " ";
086: // classname
087: sb.append(titleIndent);
088: sb.append(this .getClass().getName().substring(
089: this .getClass().getPackage().getName().length() + 1));
090: sb.append("[\n");
091:
092: // Add super class toString()
093: sb.append(super .toString());
094:
095: // Field
096: sb.append(indent);
097: sb.append("jField=");
098: sb.append(jField);
099: sb.append("\n");
100:
101: // inherited
102: if (inherited) {
103: sb.append(indent);
104: sb.append("inherited=");
105: sb.append(inherited);
106: sb.append("\n");
107: }
108:
109: sb.append(titleIndent);
110: sb.append("]\n");
111: return sb.toString();
112: }
113:
114: /**
115: * @return true if this method is inherited from a super class
116: */
117: public boolean isInherited() {
118: return inherited;
119: }
120:
121: /**
122: * Sets the inheritance of this method.
123: * @param inherited true if method is from a super class
124: */
125: public void setInherited(final boolean inherited) {
126: this .inherited = inherited;
127: }
128:
129: /**
130: * @return parent metadata (class)
131: */
132: public ClassAnnotationMetadata getClassAnnotationMetadata() {
133: return classAnnotationMetadata;
134: }
135:
136: }
|