01: /*
02: * Copyright 2006 Assaf Arkin, Ralf Joachim
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.exolab.castor.mapping.loader;
17:
18: import org.exolab.castor.mapping.FieldHandler;
19:
20: /**
21: * A basic field descriptor implementation. Engines will extend this
22: * class to provide additional functionality.
23: *
24: * @author <a href="mailto:arkin AT intalio DOT com">Assaf Arkin</a>
25: * @author <a href="mailto:ralf DOT joachim AT syscon DOT eu">Ralf Joachim</a>
26: * @version $Revision: 6907 $ $Date: 2005-12-06 14:55:28 -0700 (Tue, 06 Dec 2005) $
27: */
28: public class FieldDescriptorImpl extends AbstractFieldDescriptor {
29: //--------------------------------------------------------------------------
30:
31: protected FieldDescriptorImpl() {
32: }
33:
34: /**
35: * Constructs a new field descriptor.
36: *
37: * @param fieldName The field name
38: * @param typeInfo The field type information
39: * @param handler The field handler (may be null)
40: * @param trans True if the field is transient
41: */
42: public FieldDescriptorImpl(final String fieldName,
43: final TypeInfo typeInfo, final FieldHandler handler,
44: final boolean trans) {
45: super ();
46:
47: if (fieldName == null) {
48: throw new IllegalArgumentException(
49: "Argument 'fieldName' is null");
50: }
51:
52: if (handler == null) {
53: throw new IllegalArgumentException(
54: "Argument 'fieldDesc' has no handler");
55: }
56:
57: setFieldName(fieldName);
58: setFieldType(typeInfo.getFieldType());
59: setHandler(handler);
60: setTransient(trans);
61: setImmutable(typeInfo.isImmutable());
62: setRequired(typeInfo.isRequired());
63: setMultivalued(typeInfo.getCollectionHandler() != null);
64: }
65:
66: //--------------------------------------------------------------------------
67:
68: public String toString() {
69: return getFieldName() + "(" + getFieldType().getName() + ")";
70: }
71:
72: //--------------------------------------------------------------------------
73: }
|