KickJava   Java API By Example, From Geeks To Geeks.

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


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 oracle.toplink.essentials.internal.helper.DatabaseField;
25 import oracle.toplink.essentials.descriptors.ClassDescriptor;
26
27 /**
28  * <p>
29  * <b>Purpose</b>: Define an alias to a database field.
30  * <p>
31  * <b>Responsibilities</b>:
32  * <ul>
33  * <li> Define the field that is being aliased.
34  * </ul>
35  */

36 public class DirectQueryKey extends QueryKey {
37     DatabaseField field;
38
39     /**
40      * INTERNAL:
41      * Return the field for the query key.
42      */

43     public DatabaseField getField() {
44         return field;
45     }
46
47     /**
48      * PUBLIC:
49      * Return the field name for the query key.
50      */

51     public String JavaDoc getFieldName() {
52         return getField().getName();
53     }
54
55     /**
56      * PUBLIC:
57      * Return the qualified field name for the query key.
58      */

59     public String JavaDoc getQualifiedFieldName() {
60         return getField().getQualifiedName();
61     }
62
63     /**
64      * INTERNAL:
65      * Initialize any information in the receiver that requires its descriptor.
66      * Set the receiver's descriptor back reference.
67      * @param descriptor is the owner descriptor of the receiver.
68      */

69     public void initialize(ClassDescriptor descriptor) {
70         super.initialize(descriptor);
71         if (!getField().hasTableName()) {
72             getField().setTable(descriptor.getDefaultTable());
73         }
74     }
75
76     /**
77      * INTERNAL:
78      * override the isDirectQueryKey() method in the superclass to return true.
79      * @return boolean
80      */

81     public boolean isDirectQueryKey() {
82         return true;
83     }
84
85     /**
86      * INTERNAL:
87      * Set the field for the query key.
88      */

89     public void setField(DatabaseField field) {
90         this.field = field;
91     }
92
93     /**
94      * PUBLIC:
95      * Set the field name for the query key.
96      */

97     public void setFieldName(String JavaDoc fieldName) {
98         setField(new DatabaseField(fieldName));
99     }
100 }
101
Popular Tags