KickJava   Java API By Example, From Geeks To Geeks.

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


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;
23
24 import java.lang.reflect.*;
25
26 import oracle.toplink.essentials.exceptions.ValidationException;
27 import oracle.toplink.essentials.mappings.DatabaseMapping;
28
29 /**
30  * Validator class for the metadata processors. It defines the common
31  * validation exceptions used by the metadata processors.
32  *
33  * @author Guy Pelletier
34  * @since TopLink EJB 3.0 Reference Implementation
35  */

36 public class MetadataValidator {
37     /**
38      * INTERNAL:
39      */

40     public void throwConflictingSequenceAndTableGeneratorsSpecified(String JavaDoc name, String JavaDoc sequenceGeneratorLocation, String JavaDoc tableGeneratorLocation) {
41         throw ValidationException.conflictingSequenceAndTableGeneratorsSpecified(name, sequenceGeneratorLocation, tableGeneratorLocation);
42     }
43     
44     /**
45      * INTERNAL:
46      */

47     public void throwConflictingSequenceGeneratorsSpecified(String JavaDoc name, String JavaDoc location1, String JavaDoc location2) {
48         throw ValidationException.conflictingSequenceGeneratorsSpecified(name, location1, location2);
49     }
50     
51     /**
52      * INTERNAL:
53      */

54     public void throwConflictingSequenceNameAndTablePkColumnValueSpecified(String JavaDoc name, String JavaDoc sequenceGeneratorLocation, String JavaDoc tableGeneratorLocation) {
55         throw ValidationException.conflictingSequenceNameAndTablePkColumnValueSpecified(name, sequenceGeneratorLocation, tableGeneratorLocation);
56     }
57     
58     /**
59      * INTERNAL:
60      */

61     public void throwConflictingTableGeneratorsSpecified(String JavaDoc name, String JavaDoc location1, String JavaDoc location2) {
62         throw ValidationException.conflictingTableGeneratorsSpecified(name, location1, location2);
63     }
64     
65     /**
66      * INTERNAL:
67      */

68     public void throwCouldNotFindMapKey(String JavaDoc fieldOrPropertyName, Class JavaDoc referenceClass, DatabaseMapping mapping) {
69         throw ValidationException.couldNotFindMapKey(fieldOrPropertyName, referenceClass, mapping);
70     }
71     
72     /**
73      * INTERNAL:
74      */

75     public void throwEmbeddedIdAndIdFound(Class JavaDoc entityClass, String JavaDoc attributeName, String JavaDoc idAttributeName) {
76         throw ValidationException.embeddedIdAndIdAnnotationFound(entityClass, attributeName, idAttributeName);
77     }
78     
79     /**
80      * INTERNAL:
81      */

82     public void throwErrorProcessingNamedQueryAnnotation(Class JavaDoc entityClass, String JavaDoc name, Exception JavaDoc exception) {
83         throw ValidationException.errorProcessingNamedQueryAnnotation(entityClass, name, exception);
84     }
85     
86     /**
87      * INTERNAL:
88      */

89     public void throwExcessiveJoinColumnsSpecified(Class JavaDoc entityClass, Object JavaDoc element) {
90         throw ValidationException.excessiveJoinColumnsSpecified((AnnotatedElement) element, entityClass);
91     }
92     
93     /**
94      * INTERNAL:
95      */

96     public void throwExcessivePrimaryKeyJoinColumnsSpecified(Class JavaDoc entityClass, AnnotatedElement element) {
97         throw ValidationException.excessivePrimaryKeyJoinColumnsSpecified(element);
98     }
99     
100     /**
101      * INTERNAL:
102      */

103     public void throwIncompleteJoinColumnsSpecified(Class JavaDoc entityClass, Object JavaDoc element) {
104         throw ValidationException.incompleteJoinColumnsSpecified((AnnotatedElement) element, entityClass);
105     }
106     
107     /**
108      * INTERNAL:
109      */

110     public void throwIncompletePrimaryKeyJoinColumnsSpecified(Class JavaDoc entityClass, AnnotatedElement annotatedElement) {
111         throw ValidationException.incompletePrimaryKeyJoinColumnsSpecified(annotatedElement);
112     }
113     
114     
115     /**
116      * INTERNAL:
117      */

118     public void throwInvalidCompositePKSpecification(Class JavaDoc entityClass, String JavaDoc idClassName) {
119         throw ValidationException.invalidCompositePKSpecification(entityClass, idClassName);
120     }
121     
122     /**
123      * INTERNAL:
124      */

125     public void throwInvalidEmbeddableAttribute(Class JavaDoc entityClass, String JavaDoc attributeName, Class JavaDoc embeddedClass, String JavaDoc embeddedAttributeName) {
126         throw ValidationException.invalidEmbeddableAttribute(embeddedClass, embeddedAttributeName, entityClass, attributeName);
127     }
128     
129     /**
130      * INTERNAL:
131      */

132     public void throwInvalidOrderByValue(Class JavaDoc entityClass, String JavaDoc propertyOrFieldName, Class JavaDoc referenceClass, String JavaDoc attributeName) {
133         throw ValidationException.invalidOrderByValue(propertyOrFieldName, referenceClass, attributeName, entityClass);
134     }
135         
136     /**
137      * INTERNAL:
138      */

139     public void throwInvalidTypeForEnumeratedAttribute(Class JavaDoc entityClass, String JavaDoc attributeName, Class JavaDoc referenceClass) {
140         throw ValidationException.invalidTypeForEnumeratedAttribute(attributeName, referenceClass, entityClass);
141     }
142     
143     /**
144      * INTERNAL:
145      */

146     public void throwInvalidTypeForLOBAttribute(Class JavaDoc entityClass, String JavaDoc attributeName, Class JavaDoc referenceClass) {
147         throw ValidationException.invalidTypeForLOBAttribute(attributeName, referenceClass, entityClass);
148     }
149     
150     /**
151      * INTERNAL:
152      */

153     public void throwInvalidTypeForSerializedAttribute(Class JavaDoc entityClass, String JavaDoc attributeName, Class JavaDoc referenceClass) {
154         ValidationException.invalidTypeForSerializedAttribute(attributeName, referenceClass, entityClass);
155     }
156     
157     /**
158      * INTERNAL:
159      */

160     public void throwInvalidTypeForTemporalAttribute(Class JavaDoc entityClass, String JavaDoc attributeName, Class JavaDoc referenceClass) {
161         throw ValidationException.invalidTypeForTemporalAttribute(attributeName, referenceClass, entityClass);
162     }
163     
164     /**
165      * INTERNAL:
166      */

167     public void throwInvalidTypeForVersionAttribute(Class JavaDoc entityClass, String JavaDoc attributeName, Class JavaDoc lockingType) {
168         throw ValidationException.invalidTypeForVersionAttribute(attributeName, lockingType, entityClass);
169     }
170     
171     /**
172      * INTERNAL:
173      */

174      public void throwMappingAnnotationsAppliedToTransientAttribute(AnnotatedElement annotatedElement) {
175         throw ValidationException.mappingAnnotationsAppliedToTransientAttribute(annotatedElement);
176      }
177     
178     /**
179      * INTERNAL:
180      */

181     public void throwMultipleEmbeddedIdsFound(Class JavaDoc entityClass, String JavaDoc attributeName, String JavaDoc embeddedIdAttributeName) {
182         throw ValidationException.multipleEmbeddedIdAnnotationsFound(entityClass, attributeName, embeddedIdAttributeName);
183     }
184     
185     /**
186      * INTERNAL:
187      */

188     public void throwNoCorrespondingSetterMethodDefined(Class JavaDoc entityClass, Method method) {
189         throw ValidationException.noCorrespondingSetterMethodDefined(entityClass, method);
190     }
191     
192     /**
193      * INTERNAL:
194      */

195     public void throwNoMappedByAttributeFound(Class JavaDoc owningClass, String JavaDoc owningAttributeName, Class JavaDoc entityClass, String JavaDoc attributeName) {
196         throw ValidationException.noMappedByAttributeFound(owningClass, owningAttributeName, entityClass, attributeName);
197     }
198     
199     /**
200      * INTERNAL:
201      */

202     public void throwNonUniqueEntityName(String JavaDoc clsName1, String JavaDoc clsName2, String JavaDoc name) {
203         throw ValidationException.nonUniqueEntityName(clsName1, clsName2, name);
204     }
205     
206     /**
207      * INTERNAL:
208      */

209     public void throwNoPrimaryKeyAnnotationsFound(Class JavaDoc entityClass) {
210         throw ValidationException.noPrimaryKeyAnnotationsFound(entityClass);
211     }
212
213     /**
214      * INTERNAL:
215      */

216     public void throwNoTemporalTypeSpecified(Class JavaDoc entityClass, String JavaDoc attributeName) {
217         throw ValidationException.noTemporalTypeSpecified(attributeName, entityClass);
218     }
219     
220     /**
221      * INTERNAL:
222      */

223     public void throwOnlyOneGeneratedValueIsAllowed(Class JavaDoc entityClass, String JavaDoc existingField, String JavaDoc otherField) {
224         throw ValidationException.onlyOneGeneratedValueIsAllowed(entityClass, existingField, otherField);
225     }
226
227     /**
228      * INTERNAL:
229      */

230     public void throwRelationshipHasColumnSpecified(Class JavaDoc entityClass, String JavaDoc attributeName) {
231         throw ValidationException.invalidColumnAnnotationOnRelationship(entityClass, attributeName);
232     }
233     
234     /**
235      * INTERNAL:
236      */

237     public void throwSequenceGeneratorUsingAReservedName(String JavaDoc location, String JavaDoc reservedName) {
238         throw ValidationException.sequenceGeneratorUsingAReservedName(reservedName, location);
239     }
240     
241     /**
242      * INTERNAL:
243      */

244     public void throwTableGeneratorUsingAReservedName(String JavaDoc location, String JavaDoc reservedName) {
245         throw ValidationException.tableGeneratorUsingAReservedName(reservedName, location);
246     }
247     
248     /**
249      * INTERNAL:
250      */

251     public void throwUnableToDetermineClassForField(String JavaDoc attributeName, Class JavaDoc entityClass) {
252         throw ValidationException.unableToDetermineClassForField(attributeName, entityClass);
253     }
254     
255     /**
256      * INTERNAL:
257      */

258     public void throwUnableToDetermineClassForProperty(String JavaDoc attributeName, Class JavaDoc entityClass) {
259         throw ValidationException.unableToDetermineClassForProperty(attributeName, entityClass);
260     }
261
262     /**
263      * INTERNAL:
264      */

265     public void throwUniDirectionalOneToManyHasJoinColumnSpecified(Class JavaDoc entityClass, String JavaDoc attributeName) {
266         throw ValidationException.uniDirectionalOneToManyHasJoinColumnAnnotations(entityClass, attributeName);
267     }
268     
269     // How about these??
270
/**
271      * INTERNAL:
272      */

273     //public void throwUnspecifiedCompositePrimaryKeyNotSupported(Class entityClass) {
274
// throw ValidationException.unspecifiedCompositePKNotSupported(entityClass);
275
//}
276

277     /**
278      * INTERNAL:
279      */

280     public void throwIvalidMappingEncountered(Class JavaDoc entityClass, Class JavaDoc targetClass){
281         throw ValidationException.invalidMapping(entityClass, targetClass);
282     }
283     
284     /**
285      * INTERNAL:
286      * This exception should be used to report a case where an embeddable
287      * class is used by entity classes having conflicting access-type and
288      * embeddable's access-type is determined by enclosing entity's access-type.
289      * This is thrown to disallow different representation of the same
290      * embeddable class.
291      */

292     public void throwConflictingAccessTypeInEmbeddable(Class JavaDoc embeddableClass) {
293         throw ValidationException.conflictingAccessTypeForEmbeddable(embeddableClass);
294     }
295
296     /**
297      * INTERNAL:
298      * This exception should be used to report a case where the type of an
299      * embedded field or property is not Embeddable.
300      * .
301      */

302     public void throwInvalidEmbeddedAttribute(
303             Class JavaDoc javaClass, String JavaDoc attributeName, Class JavaDoc embeddableClass) {
304         throw ValidationException.invalidEmbeddedAttribute(
305                 javaClass, attributeName, embeddableClass);
306     }
307
308     /**
309      * INTERNAL:
310      * This exception should be used to report a case where both fields and
311      * properties of a class are annotated.
312      */

313     public void throwBothFieldsAndPropertiesAnnotatedException(Class JavaDoc javaClass) {
314         throw ValidationException.bothFieldsAndPropertiesAnnotated(javaClass);
315     }
316
317     /**
318      * INTERNAL:
319      * This exception should be used to report a case where access-type that
320      * is determined using XML is *different* from access-type determined
321      * using annotations in the class.
322      */

323     public void throwIncorrectOverridingOfAccessType(
324             Class JavaDoc javaClass, String JavaDoc xmlAccessType, String JavaDoc annotAccessType) {
325         throw ValidationException.incorrectOverridingOfAccessType(javaClass, xmlAccessType, annotAccessType);
326     }
327 }
328
Popular Tags