KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > reflect > ClassDescriptor


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19
20 package org.apache.cayenne.reflect;
21
22 import java.util.Iterator JavaDoc;
23
24 import org.apache.cayenne.map.ObjEntity;
25
26 /**
27  * A runtime descriptor of an persistent class.
28  *
29  * @since 1.2
30  * @author Andrus Adamchik
31  */

32 public interface ClassDescriptor {
33
34     /**
35      * Returns an ObjEntity associated with this descriptor.
36      *
37      * @since 3.0
38      */

39     ObjEntity getEntity();
40
41     /**
42      * Returns a class mapped by this descriptor.
43      */

44     Class JavaDoc getObjectClass();
45
46     /**
47      * Returns a descriptor of the mapped superclass or null if the descriptor's entity
48      * sits at the top of inheritance hierarchy or no inheritance is mapped.
49      */

50     ClassDescriptor getSuperclassDescriptor();
51
52     /**
53      * Returns the most "specialized" descriptor for a given class. This method assumes
54      * that the following is true:
55      *
56      * <pre>
57      * this.getObjectClass().isAssignableFrom(objectClass)
58      * </pre>
59      */

60     ClassDescriptor getSubclassDescriptor(Class JavaDoc objectClass);
61
62     /**
63      * Creates a new instance of a class described by this object.
64      */

65     Object JavaDoc createObject();
66
67     /**
68      * Prepares object properties for access. This may include injection of value holders
69      * into the object and such.
70      */

71     void injectValueHolders(Object JavaDoc object) throws PropertyException;
72
73     /**
74      * Merges object properties from one object to another, avoiding traversal of the
75      * ArcProperties.
76      */

77     void shallowMerge(Object JavaDoc from, Object JavaDoc to) throws PropertyException;
78
79     /**
80      * Returns a property descriptor matching property name, or null if no such property
81      * is found. Lookup includes properties from this descriptor and all its superclass
82      * decsriptors. Returned property can be any one of {@link AttributeProperty},
83      * {@link ToManyProperty}, {@link ToOneProperty}.
84      */

85     Property getProperty(String JavaDoc propertyName);
86
87     /**
88      * Returns a Java Bean property descriptor matching property name or null if no such
89      * property is found. Lookup DOES NOT including properties from the superclass
90      * descriptors. Returned property can be any one of {@link AttributeProperty},
91      * {@link ToManyProperty}, {@link ToOneProperty}.
92      */

93     Property getDeclaredProperty(String JavaDoc propertyName);
94
95     /**
96      * Returns an Iterator over descriptor properties.
97      *
98      * @deprecated since 3.0. Use {@link #visitProperties(PropertyVisitor)} method
99      * instead.
100      */

101     Iterator JavaDoc getProperties();
102
103     /**
104      * Returns an iterator over the properties mapped to id columns.
105      *
106      * @since 3.0
107      */

108     Iterator JavaDoc getIdProperties();
109
110     /**
111      * Passes the visitor to all properties "visit" method, terminating properties
112      * walkthrough in case one of the properties returns false. Returns true if all
113      * visited properties returned true, false - if one property returned false.
114      */

115     boolean visitProperties(PropertyVisitor visitor);
116
117     /**
118      * Passes the visitor to the properties "visit" method for all properties declared in
119      * this descriptor, terminating properties walkthrough in case one of the properties
120      * returns false. Returns true if all visited properties returned true, false - if one
121      * property returned false.
122      *
123      * @since 3.0
124      */

125     boolean visitDeclaredProperties(PropertyVisitor visitor);
126
127     /**
128      * Passes the visitor to the properties "visit" method for all properties declared in
129      * this descriptor, its super and subdescriptors, terminating properties walkthrough
130      * in case one of the properties returns false. Returns true if all visited properties
131      * returned true, false - if one property returned false.
132      *
133      * @since 3.0
134      */

135     boolean visitAllProperties(PropertyVisitor visitor);
136
137     /**
138      * Returns true if an object is not fully resolved.
139      */

140     boolean isFault(Object JavaDoc object);
141 }
142
Popular Tags