001: package org.exolab.castor.mapping.loader;
002:
003: import org.exolab.castor.mapping.ClassDescriptor;
004: import org.exolab.castor.mapping.FieldDescriptor;
005: import org.exolab.castor.mapping.FieldHandler;
006:
007: public abstract class AbstractFieldDescriptor implements
008: FieldDescriptor {
009: //--------------------------------------------------------------------------
010:
011: /** A reference to the containing class descriptor (parent). */
012: private ClassDescriptor _parent;
013:
014: /** The name of the field. */
015: private String _fieldName;
016:
017: /** The type of the field. */
018: private Class _fieldType;
019:
020: /** The type class descriptor, if this field is of a type known by a descriptor. */
021: private ClassDescriptor _classDescriptor;
022:
023: /** The field handler for get/set field value. */
024: private FieldHandler _handler;
025:
026: /** True if the field is transient and should not be saved/stored. */
027: private boolean _transient;
028:
029: /** True if the described field type is immutable. */
030: private boolean _immutable;
031:
032: /** True if the field type is required. */
033: private boolean _required;
034:
035: /** True if the object described by this descriptor is multivalued. */
036: private boolean _multivalued;
037:
038: /** True if the field is part of the identity of the class. */
039: private boolean _identity;
040:
041: //--------------------------------------------------------------------------
042:
043: /**
044: * @see org.exolab.castor.mapping.FieldDescriptor#setContainingClassDescriptor(
045: * org.exolab.castor.mapping.ClassDescriptor)
046: * {@inheritDoc}
047: */
048: public final void setContainingClassDescriptor(
049: final ClassDescriptor parent) {
050: _parent = parent;
051: }
052:
053: /**
054: * @see org.exolab.castor.mapping.FieldDescriptor#getContainingClassDescriptor()
055: * {@inheritDoc}
056: */
057: public final ClassDescriptor getContainingClassDescriptor() {
058: return _parent;
059: }
060:
061: /**
062: * Set the name of the field.
063: *
064: * @param fieldName Field name.
065: */
066: public final void setFieldName(final String fieldName) {
067: _fieldName = fieldName;
068: }
069:
070: /**
071: * @see org.exolab.castor.mapping.FieldDescriptor#getFieldName()
072: * {@inheritDoc}
073: */
074: public final String getFieldName() {
075: return _fieldName;
076: }
077:
078: /**
079: * Set the type of the field.
080: *
081: * @param fieldType Field type.
082: */
083: public final void setFieldType(final Class fieldType) {
084: _fieldType = fieldType;
085: }
086:
087: /**
088: * @see org.exolab.castor.mapping.FieldDescriptor#getFieldType()
089: * {@inheritDoc}
090: */
091: public final Class getFieldType() {
092: return _fieldType;
093: }
094:
095: /**
096: * Set the ClassDescriptor for the described field.
097: *
098: * @param classDescriptor The ClassDescriptor for the described field.
099: */
100: public final void setClassDescriptor(
101: final ClassDescriptor classDescriptor) {
102: _classDescriptor = classDescriptor;
103: }
104:
105: /**
106: * @see org.exolab.castor.mapping.FieldDescriptor#getClassDescriptor()
107: * {@inheritDoc}
108: */
109: public final ClassDescriptor getClassDescriptor() {
110: return _classDescriptor;
111: }
112:
113: /**
114: * Set the FieldHandler for the field being described by this FieldDescriptor.
115: *
116: * @param handler The FieldHandler for the field being described.
117: */
118: public final void setHandler(final FieldHandler handler) {
119: _handler = handler;
120: }
121:
122: /**
123: * @see org.exolab.castor.mapping.FieldDescriptor#getHandler()
124: * {@inheritDoc}
125: */
126: public final FieldHandler getHandler() {
127: return _handler;
128: }
129:
130: /**
131: * Sets whether or not the describled field is 'transient'.
132: *
133: * @param isTransient The flag indicating if the described field is 'transient'.
134: */
135: public final void setTransient(final boolean isTransient) {
136: _transient = isTransient;
137: }
138:
139: /**
140: * @see org.exolab.castor.mapping.FieldDescriptor#isTransient()
141: * {@inheritDoc}
142: */
143: public final boolean isTransient() {
144: return _transient;
145: }
146:
147: /**
148: * Set the immutable flag which indicates that changes to this Field result in a
149: * new Object to be created, such as java.lang.String. It serves to identify fields
150: * which should not be constructed until all the data is available.
151: *
152: * @param immutable Flag which if true indicates that the field is immutable.
153: */
154: public final void setImmutable(final boolean immutable) {
155: _immutable = immutable;
156: }
157:
158: /**
159: * @see org.exolab.castor.mapping.FieldDescriptor#isImmutable()
160: * {@inheritDoc}
161: */
162: public final boolean isImmutable() {
163: return _immutable;
164: }
165:
166: /**
167: * Set whether or not the described field is required.
168: *
169: * @param required The flag indicating whether or not the described field is required.
170: */
171: public final void setRequired(final boolean required) {
172: _required = required;
173: }
174:
175: /**
176: * @see org.exolab.castor.mapping.FieldDescriptor#isRequired()
177: * {@inheritDoc}
178: */
179: public final boolean isRequired() {
180: return _required;
181: }
182:
183: /**
184: * Set wheter the object described by this descriptor is multivalued or not.
185: *
186: * @param multivalued True if the object described by this descriptor is multivalued.
187: */
188: public final void setMultivalued(final boolean multivalued) {
189: _multivalued = multivalued;
190: }
191:
192: /**
193: * @see org.exolab.castor.mapping.FieldDescriptor#isMultivalued()
194: * {@inheritDoc}
195: */
196: public final boolean isMultivalued() {
197: return _multivalued;
198: }
199:
200: /**
201: * Set wether the described field is part of the identity of the class it belongs to.
202: *
203: * @param identity <code>true</code> if field is part of the classes identity.
204: */
205: public final void setIdentity(final boolean identity) {
206: _identity = identity;
207: }
208:
209: /**
210: * Is the described field is part of the identity of the class it belongs to?
211: *
212: * @return <code>true</code> if field is part of the classes identity.
213: */
214: public final boolean isIdentity() {
215: return _identity;
216: }
217:
218: //--------------------------------------------------------------------------
219: }
|