View Javadoc
1   /*
2    * Copyright 2006 Assaf Arkin, Ralf Joachim
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5    * in compliance with the License. You may obtain a copy of the License at
6    *
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software distributed under the License
10   * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11   * or implied. See the License for the specific language governing permissions and limitations under
12   * the License.
13   */
14  package org.exolab.castor.mapping;
15  
16  import org.castor.core.nature.PropertyHolder;
17  
18  /**
19   * Describes the properties of a field. Implementations will extend this inteface to provide
20   * additional properties.
21   *
22   * @author <a href="mailto:arkin AT intalio DOT com">Assaf Arkin</a>
23   * @author <a href="mailto:ralf DOT joachim AT syscon DOT eu">Ralf Joachim</a>
24   * @version $Revision$ $Date: 2005-12-06 14:55:28 -0700 (Tue, 06 Dec 2005) $
25   */
26  public interface FieldDescriptor extends PropertyHolder {
27  
28    /**
29     * Set the class descriptor which contains this field.
30     * 
31     * @param parent The class descriptor which contains this field.
32     */
33    void setContainingClassDescriptor(ClassDescriptor parent);
34  
35    /**
36     * Get the class descriptor which contains this field.
37     * 
38     * @return The class descriptor which contains this field.
39     */
40    ClassDescriptor getContainingClassDescriptor();
41  
42    /**
43     * Returns the name of the field. The field must have a name, even if set through accessor
44     * methods.
45     *
46     * @return Field name.
47     */
48    String getFieldName();
49  
50    /**
51     * Returns the Java type of the field.
52     *
53     * @return Field type.
54     */
55    Class getFieldType();
56  
57    /**
58     * Returns the class descriptor related to the field type. If the field type is a class for which
59     * a descriptor exists, this descriptor is returned. If the field type is a class for which no
60     * mapping is provided, null is returned.
61     *
62     * @return The class descriptor of the field type, or null.
63     */
64    ClassDescriptor getClassDescriptor();
65  
66    /**
67     * Returns the handler of the field. In order to persist or marshal a field descriptor will be
68     * associated with a handler.
69     *
70     * @return The field handler.
71     */
72    FieldHandler getHandler();
73  
74    /**
75     * Returns true if the field is transient. Transient fields are never persisted or marshalled.
76     *
77     * @return True if transient field.
78     */
79    boolean isTransient();
80  
81    /**
82     * Returns true if the field type is immutable.
83     *
84     * @return True if the field type is immutable.
85     */
86    boolean isImmutable();
87  
88    /**
89     * Returns true if the field type is required.
90     *
91     * @return True if the field type is required.
92     */
93    boolean isRequired();
94  
95    /**
96     * Returns true if the field is multivalued (a collection).
97     *
98     * @return True if the field is multivalued.
99     */
100   boolean isMultivalued();
101 
102 }
103