1 21 package oracle.toplink.essentials.exceptions; 23 24 import java.util.List ; 25 import oracle.toplink.essentials.exceptions.i18n.ExceptionMessageGenerator; 26 27 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 message) { 40 super(message); 41 } 42 43 protected DefaultMappingException(String message, Exception internalException) { 44 super(message, internalException); 45 } 46 47 public static DefaultMappingException finderParameterTypeNotFound(String beanName, String finderName, String finderParameterTypeString) { 48 Object [] 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 beanName, String finderName, List finderParameters) { 56 Object [] 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 beanName, String finderName) { 63 Object [] 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 beanName, String ejbSelectName, List ejbSelectParameters) { 70 Object [] 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 getter, String beanName) { 77 Object [] 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 field, String beanName) { 84 Object [] 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 |