KickJava   Java API By Example, From Geeks To Geeks.

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


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.sequencing;
23
24 import javax.persistence.SequenceGenerator;
25
26 /**
27  * A wrapper class to the MetadataSequenceGenerator that holds onto a
28  * @SequenceGenerator for its metadata values.
29  *
30  * @author Guy Pelletier
31  * @since TopLink EJB 3.0 Reference Implementation
32  */

33 public class MetadataSequenceGenerator extends MetadataGenerator {
34     private SequenceGenerator m_sequenceGenerator;
35     
36     /**
37      * INTERNAL:
38      */

39     protected MetadataSequenceGenerator(String JavaDoc entityClassName) {
40         super(entityClassName);
41     }
42     
43     /**
44      * INTERNAL:
45      */

46     public MetadataSequenceGenerator(SequenceGenerator sequenceGenerator, String JavaDoc entityClassName) {
47         super(entityClassName);
48         m_sequenceGenerator = sequenceGenerator;
49     }
50     
51     /**
52      * INTERNAL:
53      */

54     public boolean equals(Object JavaDoc objectToCompare) {
55         if (objectToCompare instanceof MetadataSequenceGenerator) {
56             MetadataSequenceGenerator generator = (MetadataSequenceGenerator) objectToCompare;
57             
58             if (!generator.getName().equals(getName())) {
59                 return false;
60             }
61             
62             if (generator.getInitialValue() != getInitialValue()) {
63                 return false;
64             }
65             
66             if (generator.getAllocationSize() != getAllocationSize()) {
67                 return false;
68             }
69             
70             return generator.getSequenceName().equals(getSequenceName());
71         }
72         
73         return false;
74     }
75     
76     /**
77      * INTERNAL:
78      */

79     public int getAllocationSize() {
80         return m_sequenceGenerator.allocationSize();
81     }
82     
83     /**
84      * INTERNAL:
85      */

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

93     public String JavaDoc getName() {
94         return m_sequenceGenerator.name();
95     }
96     
97     /**
98      * INTERNAL:
99      */

100     public String JavaDoc getSequenceName() {
101         return m_sequenceGenerator.sequenceName();
102     }
103 }
104
Popular Tags