KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > querykeys > QueryKey


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2005, Oracle. All rights reserved.
22
package oracle.toplink.essentials.querykeys;
23
24 import java.io.*;
25 import oracle.toplink.essentials.descriptors.ClassDescriptor;
26
27 /**
28  * <p>
29  * <b>Purpose</b>: Define a Java appropriate alias to a database field or function.
30  * <p>
31  * <b>Responsibilities</b>:
32  * <ul>
33  * <li> Define the name of the alias.
34  * <li> Define the descriptor of the alias.
35  * </ul>
36  */

37 public class QueryKey implements Cloneable JavaDoc, Serializable {
38     protected String JavaDoc name;
39     protected ClassDescriptor descriptor;
40
41     /**
42      * INTERNAL:
43      * Clones itself.
44      */

45     public Object JavaDoc clone() {
46         Object JavaDoc object = null;
47
48         try {
49             object = super.clone();
50         } catch (Exception JavaDoc exception) {
51             throw new InternalError JavaDoc(exception.toString());
52         }
53
54         return object;
55     }
56
57     /**
58      * INTERNAL:
59      * Convert all the class-name-based settings in this QueryKey to actual class-based
60      * settings
61      * Will be overridded by subclasses
62      * @param classLoader
63      */

64     public void convertClassNamesToClasses(ClassLoader JavaDoc classLoader){}
65
66     /**
67      * INTERNAL:
68      * Return the descriptor.
69      */

70     public ClassDescriptor getDescriptor() {
71         return descriptor;
72     }
73
74     /**
75      * PUBLIC:
76      * Return the name for the query key.
77      * This is the name that will be used in the expression.
78      */

79     public String JavaDoc getName() {
80         return name;
81     }
82
83     /**
84      * INTERNAL:
85      * Initialize any information in the receiver that requires its descriptor.
86      * Set the receiver's descriptor back reference.
87      * @param aDescriptor is the owner descriptor of the receiver.
88      */

89     public void initialize(ClassDescriptor aDescriptor) {
90         setDescriptor(aDescriptor);
91     }
92
93     /**
94      * INTERNAL:
95      * return whether this query key is abstract
96      * @return boolean
97      */

98     public boolean isAbstractQueryKey() {
99         return (this.getClass().equals(oracle.toplink.essentials.internal.helper.ClassConstants.QueryKey_Class));
100     }
101
102     /**
103      * PUBLIC::
104      * Related query key should implement this method to return true.
105      */

106     public boolean isCollectionQueryKey() {
107         return false;
108     }
109
110     /**
111      * PUBLIC::
112      * Related query key should implement this method to return true.
113      */

114     public boolean isDirectCollectionQueryKey() {
115         return false;
116     }
117
118     /**
119      * PUBLIC::
120      * Related query key should implement this method to return true.
121      */

122     public boolean isDirectQueryKey() {
123         return false;
124     }
125
126     /**
127      * PUBLIC::
128      * Related query key should implement this method to return true.
129      */

130     public boolean isForeignReferenceQueryKey() {
131         return false;
132     }
133
134     /**
135      * PUBLIC::
136      * Related query key should implement this method to return true.
137      */

138     public boolean isManyToManyQueryKey() {
139         return false;
140     }
141
142     /**
143      * PUBLIC::
144      * Related query key should implement this method to return true.
145      */

146     public boolean isOneToManyQueryKey() {
147         return false;
148     }
149
150     /**
151      * PUBLIC::
152      * Related query key should implement this method to return true.
153      */

154     public boolean isOneToOneQueryKey() {
155         return false;
156     }
157
158     /**
159      * INTERNAL:
160      * This is a QueryKey. return true.
161      * @return boolean
162      */

163     public boolean isQueryKey() {
164         return true;
165     }
166
167     /**
168      * INTERNAL:
169      * Set the descriptor.
170      */

171     public void setDescriptor(ClassDescriptor descriptor) {
172         this.descriptor = descriptor;
173     }
174
175     /**
176      * PUBLIC:
177      * Set the name for the query key.
178      * This is the name that will be used in the expression.
179      */

180     public void setName(String JavaDoc name) {
181         this.name = name;
182     }
183
184     /**
185      * INTERNAL:
186      * return a string representation of this instance of QueryKey
187      */

188     public String JavaDoc toString() {
189         return oracle.toplink.essentials.internal.helper.Helper.getShortClassName(this) + "(" + getName() + ")";
190     }
191 }
192
Popular Tags