KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > internal > ejb > cmp3 > metadata > columns > MetadataPrimaryKeyJoinColumn


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, 2006, Oracle. All rights reserved.
22
package oracle.toplink.essentials.internal.ejb.cmp3.metadata.columns;
23
24 import javax.persistence.PrimaryKeyJoinColumn;
25
26 import oracle.toplink.essentials.internal.helper.DatabaseField;
27
28 /**
29  * Object to hold onto join column metadata in a TopLink database fields.
30  *
31  * @author Guy Pelletier
32  * @since TopLink EJB 3.0 Reference Implementation
33  */

34 public class MetadataPrimaryKeyJoinColumn {
35     protected DatabaseField m_pkField;
36     protected DatabaseField m_fkField;
37     
38     public static final String JavaDoc DEFAULT_NAME = "";
39     public static final String JavaDoc DEFAULT_COLUMN_DEFINITION = "";
40     public static final String JavaDoc DEFAULT_REFERENCED_COLUMN_NAME = "";
41     
42     /**
43      * INTERNAL:
44      */

45     public MetadataPrimaryKeyJoinColumn(String JavaDoc sourceTableName, String JavaDoc targetTableName) {
46         m_pkField = new DatabaseField();
47         m_pkField.setName(DEFAULT_REFERENCED_COLUMN_NAME);
48         m_pkField.setTableName(sourceTableName);
49         
50         m_fkField = new DatabaseField();
51         m_fkField.setName(DEFAULT_NAME);
52         m_fkField.setTableName(targetTableName);
53         m_fkField.setColumnDefinition(DEFAULT_COLUMN_DEFINITION);
54     }
55     
56     /**
57      * INTERNAL:
58      * Called for association override.
59      */

60     public MetadataPrimaryKeyJoinColumn(PrimaryKeyJoinColumn primaryKeyJoinColumn, String JavaDoc sourceTableName, String JavaDoc targetTableName) {
61         this(sourceTableName, targetTableName);
62         
63         if (primaryKeyJoinColumn != null) {
64             // Process the primary key field metadata.
65
m_pkField.setName(primaryKeyJoinColumn.referencedColumnName());
66         
67             // Process the foreign key field metadata.
68
m_fkField.setName(primaryKeyJoinColumn.name());
69             m_fkField.setColumnDefinition(primaryKeyJoinColumn.columnDefinition());
70         }
71     }
72     
73     /**
74      * INTERNAL:
75      */

76     public DatabaseField getForeignKeyField() {
77         return m_fkField;
78     }
79     
80     /**
81      * INTERNAL:
82      */

83     public DatabaseField getPrimaryKeyField() {
84         return m_pkField;
85     }
86     
87     /**
88      * INTERNAL:
89      */

90     public boolean isForeignKeyFieldNotSpecified() {
91         return m_fkField.getName().equals("");
92     }
93     
94     /**
95      * INTERNAL:
96      */

97     public boolean isPrimaryKeyFieldNotSpecified() {
98         return m_pkField.getName().equals("");
99     }
100     
101     /**
102      * INTERNAL:
103      */

104     public boolean loadedFromXML() {
105         return false;
106     }
107 }
108
Popular Tags