KickJava   Java API By Example, From Geeks To Geeks.

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


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.JoinColumn;
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 MetadataJoinColumn {
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_TABLE = "";
40     public static final String JavaDoc DEFAULT_COLUMN_DEFINITION = "";
41     public static final String JavaDoc DEFAULT_REFERENCED_COLUMN_NAME = "";
42     
43     public static final boolean DEFAULT_UNIQUE = false;
44     public static final boolean DEFAULT_NULLABLE = true;
45     public static final boolean DEFAULT_UPDATABLE = true;
46     public static final boolean DEFAULT_INSERTABLE = true;
47     
48     /**
49      * INTERNAL:
50      */

51     public MetadataJoinColumn() {
52         m_pkField = new DatabaseField();
53         m_pkField.setName(DEFAULT_REFERENCED_COLUMN_NAME);
54         
55         m_fkField = new DatabaseField();
56         m_fkField.setName(DEFAULT_NAME);
57         m_fkField.setTableName(DEFAULT_TABLE);
58         m_fkField.setUnique(DEFAULT_UNIQUE);
59         m_fkField.setNullable(DEFAULT_NULLABLE);
60         m_fkField.setUpdatable(DEFAULT_UPDATABLE);
61         m_fkField.setInsertable(DEFAULT_INSERTABLE);
62         m_fkField.setColumnDefinition(DEFAULT_COLUMN_DEFINITION);
63     }
64     
65     /**
66      * INTERNAL:
67      * Called for association override.
68      */

69     public MetadataJoinColumn(JoinColumn joinColumn) {
70         this();
71         
72         if (joinColumn != null) {
73             // Process the primary key field metadata.
74
m_pkField.setName(joinColumn.referencedColumnName());
75         
76             // Process the foreign key field metadata.
77
m_fkField.setName(joinColumn.name());
78             m_fkField.setTableName(joinColumn.table());
79             m_fkField.setUnique(joinColumn.unique());
80             m_fkField.setNullable(joinColumn.nullable());
81             m_fkField.setUpdatable(joinColumn.updatable());
82             m_fkField.setInsertable(joinColumn.insertable());
83             m_fkField.setColumnDefinition(joinColumn.columnDefinition());
84         }
85     }
86     
87     /**
88      * INTERNAL:
89      */

90     public DatabaseField getForeignKeyField() {
91         return m_fkField;
92     }
93     
94     /**
95      * INTERNAL:
96      */

97     public DatabaseField getPrimaryKeyField() {
98         return m_pkField;
99     }
100     
101     /**
102      * INTERNAL:
103      */

104     public boolean isForeignKeyFieldNotSpecified() {
105         return m_fkField.getName().equals("");
106     }
107     
108     /**
109      * INTERNAL:
110      */

111     public boolean isPrimaryKeyFieldNotSpecified() {
112         return m_pkField.getName().equals("");
113     }
114     
115     /**
116      * INTERNAL:
117      */

118     public boolean loadedFromXML() {
119         return false;
120     }
121 }
122
Popular Tags