KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > exceptions > DefaultMappingException


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, 2005, Oracle. All rights reserved.
22
package oracle.toplink.essentials.exceptions;
23
24 import java.util.List JavaDoc;
25 import oracle.toplink.essentials.exceptions.i18n.ExceptionMessageGenerator;
26
27 /**
28  * <P><B>Purpose</B>:
29  * Wrapper for any exception that occurred through OC4J cmp deafult mapping.
30  */

31 public class DefaultMappingException extends TopLinkException {
32     public final static int FINDER_PARAMETER_TYPE_NOT_FOUND = 20001;
33     public final static int FINDER_NOT_DEFINED_IN_HOME = 20002;
34     public final static int EJB_SELECT_NOT_DEFINED_IN_BEAN = 20003;
35     public final static int FINDER_NOT_START_WITH_FIND_OR_EJBSELECT = 20004;
36     public final static int GETTER_NOT_FOUND = 20005;
37     public final static int FIELD_NOT_FOUND = 20006;
38
39     public DefaultMappingException(String JavaDoc message) {
40         super(message);
41     }
42
43     protected DefaultMappingException(String JavaDoc message, Exception JavaDoc internalException) {
44         super(message, internalException);
45     }
46
47     public static DefaultMappingException finderParameterTypeNotFound(String JavaDoc beanName, String JavaDoc finderName, String JavaDoc finderParameterTypeString) {
48         Object JavaDoc[] args = { beanName, finderName, finderParameterTypeString };
49
50         DefaultMappingException exception = new DefaultMappingException(ExceptionMessageGenerator.buildMessage(DefaultMappingException.class, FINDER_PARAMETER_TYPE_NOT_FOUND, args));
51         exception.setErrorCode(FINDER_PARAMETER_TYPE_NOT_FOUND);
52         return exception;
53     }
54
55     public static DefaultMappingException finderNotDefinedInHome(String JavaDoc beanName, String JavaDoc finderName, List JavaDoc finderParameters) {
56         Object JavaDoc[] args = { beanName, finderName, finderParameters.toArray() };
57         DefaultMappingException exception = new DefaultMappingException(ExceptionMessageGenerator.buildMessage(DefaultMappingException.class, FINDER_NOT_DEFINED_IN_HOME, args));
58         exception.setErrorCode(FINDER_NOT_DEFINED_IN_HOME);
59         return exception;
60     }
61
62     public static DefaultMappingException finderNotStartWithFindOrEjbSelect(String JavaDoc beanName, String JavaDoc finderName) {
63         Object JavaDoc[] args = { beanName, finderName };
64         DefaultMappingException exception = new DefaultMappingException(ExceptionMessageGenerator.buildMessage(DefaultMappingException.class, FINDER_NOT_START_WITH_FIND_OR_EJBSELECT, args));
65         exception.setErrorCode(FINDER_NOT_START_WITH_FIND_OR_EJBSELECT);
66         return exception;
67     }
68
69     public static DefaultMappingException ejbSelectNotDefinedInBean(String JavaDoc beanName, String JavaDoc ejbSelectName, List JavaDoc ejbSelectParameters) {
70         Object JavaDoc[] args = { beanName, ejbSelectName, ejbSelectParameters.toArray() };
71         DefaultMappingException exception = new DefaultMappingException(ExceptionMessageGenerator.buildMessage(DefaultMappingException.class, EJB_SELECT_NOT_DEFINED_IN_BEAN, args));
72         exception.setErrorCode(EJB_SELECT_NOT_DEFINED_IN_BEAN);
73         return exception;
74     }
75
76     public static DefaultMappingException getterNotFound(String JavaDoc getter, String JavaDoc beanName) {
77         Object JavaDoc[] args = { getter, beanName };
78         DefaultMappingException exception = new DefaultMappingException(ExceptionMessageGenerator.buildMessage(DefaultMappingException.class, GETTER_NOT_FOUND, args));
79         exception.setErrorCode(GETTER_NOT_FOUND);
80         return exception;
81     }
82
83     public static DefaultMappingException fieldNotFound(String JavaDoc field, String JavaDoc beanName) {
84         Object JavaDoc[] args = { field, beanName };
85         DefaultMappingException exception = new DefaultMappingException(ExceptionMessageGenerator.buildMessage(DefaultMappingException.class, FIELD_NOT_FOUND, args));
86         exception.setErrorCode(FIELD_NOT_FOUND);
87         return exception;
88     }
89 }
90
Popular Tags