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: AttributeMapping.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.xmlconfig.mapping;
025:
026: /**
027: * Defines a mapping for attributes of a class.
028: * @author Florent Benoit
029: */
030: public class AttributeMapping extends AbsMapping {
031:
032: /**
033: * Value of this element has to be used (this is not an xml attribute).<br>
034: * Default is false.
035: */
036: private boolean isElement = false;
037:
038: /**
039: * Element should be used as a List.
040: */
041: private boolean isListElement = false;
042:
043: /**
044: * Getter to use.
045: */
046: private String getter = null;
047:
048: /**
049: * Setter to use.
050: */
051: private String setter = null;
052:
053: /**
054: * This attribute is mapped to an XML element ?
055: */
056: public void setElement() {
057: this .isElement = true;
058: }
059:
060: /**
061: * Is that this attribute is mapped to an XML element ?
062: * @return true if it the case
063: */
064: public boolean isElement() {
065: return this .isElement;
066: }
067:
068: /**
069: * This attribute is considered as a List.
070: */
071: public void setListElement() {
072: this .isListElement = true;
073: }
074:
075: /**
076: * Is that this attribute should be considered as a list ?
077: * @return true if it the case
078: */
079: public boolean isListElement() {
080: return this .isListElement;
081: }
082:
083: /**
084: * @return the getter for this attribute.
085: */
086: public String getGetter() {
087: return getter;
088: }
089:
090: /**
091: * Sets the getter for this attribute.
092: * @param getter the given getter name
093: */
094: public void setGetter(final String getter) {
095: this .getter = getter;
096: }
097:
098: /**
099: * @return the setter for this attribute.
100: */
101: public String getSetter() {
102: return setter;
103: }
104:
105: /**
106: * Sets the setter for this attribute.
107: * @param setter the given setter name
108: */
109: public void setSetter(final String setter) {
110: this .setter = setter;
111: }
112:
113: /**
114: * Returns a string representation of the object.
115: * @return string representation
116: */
117: @Override
118: public String toString() {
119: StringBuilder sb = new StringBuilder();
120: // classname
121: sb.append(this .getClass().getName().substring(
122: this .getClass().getPackage().getName().length() + 1));
123: sb.append("[");
124: sb.append(super .toString());
125: if (isElement) {
126: sb.append(", isElement=");
127: sb.append(isElement);
128: }
129: if (isListElement) {
130: sb.append(", isListElement=");
131: sb.append(isListElement);
132: }
133: sb.append("]");
134:
135: return sb.toString();
136: }
137:
138: }
|