KickJava   Java API By Example, From Geeks To Geeks.

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


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 package oracle.toplink.essentials.internal.ejb.cmp3.metadata;
22
23 import oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLConstants;
24
25 /**
26  * Metadata object to hold persistence unit information.
27  *
28  * @author Guy Pelletier
29  * @since TopLink EJB 3.0 Reference Implementation
30  */

31 public class MetadataPersistenceUnit {
32     protected String JavaDoc m_access;
33     protected String JavaDoc m_schema;
34     protected String JavaDoc m_catalog;
35     protected String JavaDoc m_conflict;
36     protected boolean m_isCascadePersist;
37     protected boolean m_isMetadataComplete;
38     
39     /**
40      * INTERNAL:
41      */

42     public MetadataPersistenceUnit() {
43         m_access = "";
44         m_schema = "";
45         m_catalog = "";
46         m_isCascadePersist = false;
47         m_isMetadataComplete = false;
48     }
49     
50     /**
51      * INTERNAL:
52      * If equals returns false, call getConflict() for a finer grain reason why.
53      */

54     public boolean equals(Object JavaDoc objectToCompare) {
55         MetadataPersistenceUnit persistenceUnit = (MetadataPersistenceUnit) objectToCompare;
56             
57         if (! persistenceUnit.getAccess().equals(getAccess())) {
58             m_conflict = XMLConstants.ACCESS;
59             return false;
60         }
61             
62         if (! persistenceUnit.getCatalog().equals(getCatalog())) {
63             m_conflict = XMLConstants.CATALOG;
64             return false;
65         }
66             
67         if (! persistenceUnit.getSchema().equals(getSchema())) {
68             m_conflict = XMLConstants.SCHEMA;
69             return false;
70         }
71             
72         if (persistenceUnit.isCascadePersist() != isCascadePersist()) {
73             m_conflict = XMLConstants.CASCADE_PERSIST;
74             return false;
75         }
76                 
77         if (persistenceUnit.isMetadataComplete() != isMetadataComplete()) {
78             m_conflict = XMLConstants.METADATA_COMPLETE;
79             return false;
80         }
81         
82         return true;
83     }
84     
85     /**
86      * INTERNAL:
87      */

88     public String JavaDoc getAccess() {
89        return m_access;
90     }
91     
92     /**
93      * INTERNAL:
94      */

95     public String JavaDoc getCatalog() {
96        return m_catalog;
97     }
98     
99     /**
100      * INTERNAL:
101      * Calling this method after an equals call that returns false will give
102      * you the conflicting metadata.
103      */

104     public String JavaDoc getConflict() {
105        return m_conflict;
106     }
107     
108     /**
109      * INTERNAL:
110      */

111     public String JavaDoc getSchema() {
112        return m_schema;
113     }
114     
115     /**
116      * INTERNAL:
117      */

118     public boolean isCascadePersist() {
119         return m_isCascadePersist;
120     }
121     
122     /**
123      * INTERNAL:
124      */

125     public boolean isMetadataComplete() {
126         return m_isMetadataComplete;
127     }
128     
129     /**
130      * INTERNAL:
131      */

132     public void setAccess(String JavaDoc access) {
133        m_access = access;
134     }
135     
136     /**
137      * INTERNAL:
138      */

139     public void setCatalog(String JavaDoc catalog) {
140        m_catalog = catalog;
141     }
142     
143     /**
144      * INTERNAL:
145      */

146     public void setIsCascadePersist(boolean isCascadePersist) {
147         m_isCascadePersist = isCascadePersist;
148     }
149     
150     /**
151      * INTERNAL:
152      */

153     public void setIsMetadataComplete(boolean isMetadataComplete) {
154         m_isMetadataComplete = isMetadataComplete;
155     }
156     
157     /**
158      * INTERNAL:
159      */

160     public void setSchema(String JavaDoc schema) {
161        m_schema = schema;
162     }
163 }
164
Popular Tags