KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.ArrayList JavaDoc;
25 import java.util.List JavaDoc;
26
27 import javax.persistence.JoinColumn;
28 import javax.persistence.JoinColumns;
29
30 /**
31  * Object to hold onto join column metadata.
32  *
33  * @author Guy Pelletier
34  * @since TopLink EJB 3.0 Reference Implementation
35  */

36 public class MetadataJoinColumns {
37     protected List JavaDoc<MetadataJoinColumn> m_joinColumns;
38     
39     /**
40      * INTERNAL:
41      */

42     public MetadataJoinColumns() {
43         m_joinColumns = new ArrayList JavaDoc<MetadataJoinColumn>();
44     }
45     
46     /**
47      * INTERNAL:
48      */

49     public MetadataJoinColumns(JoinColumns joinColumns, JoinColumn joinColumn) {
50         this();
51         
52         // Process all the join columns first.
53
if (joinColumns != null) {
54             for (JoinColumn jColumn : joinColumns.value()) {
55                 m_joinColumns.add(new MetadataJoinColumn(jColumn));
56             }
57         }
58         
59         // Process the single key join column second.
60
if (joinColumn != null) {
61             m_joinColumns.add(new MetadataJoinColumn(joinColumn));
62         }
63     }
64     
65     /**
66      * INTERNAL:
67      */

68     public MetadataJoinColumns(JoinColumn[] joinColumns) {
69         this();
70         
71         for (JoinColumn joinColumn : joinColumns) {
72             m_joinColumns.add(new MetadataJoinColumn(joinColumn));
73         }
74     }
75     
76     /**
77      * INTERNAL:
78      */

79     public boolean loadedFromXML() {
80         return false;
81     }
82     
83     /**
84      * INTERNAL:
85      */

86     public int size() {
87         return m_joinColumns.size();
88     }
89     
90     /**
91      * INTERNAL:
92      */

93     public List JavaDoc<MetadataJoinColumn> values() {
94         // If no join columns are specifed, add a default one.
95
if (m_joinColumns.isEmpty()) {
96             m_joinColumns.add(new MetadataJoinColumn());
97         }
98         
99         return m_joinColumns;
100     }
101 }
102
Popular Tags