1 21 package oracle.toplink.essentials.exceptions; 23 24 import java.util.*; 25 import oracle.toplink.essentials.exceptions.i18n.*; 26 27 30 public class EJBQLException extends TopLinkException { 31 public static final int recognitionException = 8001; 32 public static final int generalParsingException = 8002; 33 public static final int classNotFoundException = 8003; 34 public static final int aliasResolutionException = 8004; 35 public static final int resolutionClassNotFoundException = 8005; 36 public static final int missingDescriptorException = 8006; 37 public static final int missingMappingException = 8007; 38 public static final int invalidContextKeyException = 8008; 39 public static final int expressionNotSupported = 8009; 40 public static final int generalParsingException2 = 8010; 41 public static final int invalidCollectionMemberDecl = 8011; 42 public static final int notYetImplemented = 8012; 43 public static final int constructorClassNotFound = 8013; 44 public static final int invalidSizeArgument = 8014; 45 public static final int invalidEnumLiteral = 8015; 46 public static final int invalidSelectForGroupByQuery = 8016; 47 public static final int invalidHavingExpression = 8017; 48 public static final int invalidMultipleUseOfSameParameter = 8018; 49 public static final int multipleVariableDeclaration = 8019; 50 public static final int invalidFunctionArgument = 8020; 51 public static final int expectedOrderableOrderByItem = 8021; 52 public static final int invalidExpressionArgument = 8022; 53 public static final int syntaxError = 8023; 54 public static final int syntaxErrorAt = 8024; 55 public static final int unexpectedToken = 8025; 56 public static final int unexpectedChar = 8026; 57 public static final int expectedCharFound = 8027; 58 public static final int unexpectedEOF = 8028; 59 public static final int invalidNavigation = 8029; 60 public static final int unknownAttribute = 8030; 61 public static final int unsupportJoinArgument = 8031; 62 public Collection internalExceptions = null; 63 64 68 protected EJBQLException() { 69 super(); 70 } 71 72 76 protected EJBQLException(String theMessage) { 77 super(theMessage); 78 } 79 80 84 protected EJBQLException(String message, Exception internalException) { 85 super(message, internalException); 86 } 87 88 92 protected EJBQLException(String message, Exception internalException, int theErrorCode) { 93 this(message, internalException); 94 this.setErrorCode(theErrorCode); 95 } 96 97 101 public static EJBQLException recognitionException(String theEjbql, String theMessage) { 102 Object [] args = { theEjbql, theMessage }; 103 104 String message = ExceptionMessageGenerator.buildMessage(EJBQLException.class, recognitionException, args); 105 EJBQLException exception = new EJBQLException(message); 106 exception.setErrorCode(recognitionException); 107 return exception; 108 } 109 110 114 public static EJBQLException generalParsingException(String theEjbql, Exception theException) { 115 Object [] args = { theEjbql, theException.getMessage() }; 116 117 String message = ExceptionMessageGenerator.buildMessage(EJBQLException.class, generalParsingException, args); 118 EJBQLException exception = new EJBQLException(message, theException, generalParsingException); 119 exception.setErrorCode(generalParsingException); 120 return exception; 121 } 122 123 127 public static EJBQLException generalParsingException(String theEjbql) { 128 Object [] args = { theEjbql }; 129 130 String message = ExceptionMessageGenerator.buildMessage(EJBQLException.class, generalParsingException2, args); 131 EJBQLException exception = new EJBQLException(message); 132 exception.setErrorCode(generalParsingException); 133 return exception; 134 } 135 136 public static EJBQLException classNotFoundException(String theClassName, String theMessage, Exception theException) { 137 Object [] args = { theClassName, theMessage }; 138 139 String message = ExceptionMessageGenerator.buildMessage(EJBQLException.class, classNotFoundException, args); 140 EJBQLException exception = new EJBQLException(message, theException, classNotFoundException); 141 exception.setErrorCode(classNotFoundException); 142 return exception; 143 } 144 145 public static EJBQLException resolutionClassNotFoundException(String theClassName) { 146 Object [] args = { theClassName }; 147 148 String message = ExceptionMessageGenerator.buildMessage(EJBQLException.class, resolutionClassNotFoundException, args); 149 EJBQLException exception = new EJBQLException(message); 150 exception.setErrorCode(resolutionClassNotFoundException); 151 return exception; 152 } 153 154 public static EJBQLException missingDescriptorException(String theClassName) { 155 Object [] args = { theClassName }; 156 157 String message = ExceptionMessageGenerator.buildMessage(EJBQLException.class, missingDescriptorException, args); 158 EJBQLException exception = new EJBQLException(message); 159 exception.setErrorCode(missingDescriptorException); 160 161 return exception; 162 } 163 164 public static EJBQLException missingMappingException(String theAttributeName) { 165 Object [] args = { theAttributeName }; 166 167 String message = ExceptionMessageGenerator.buildMessage(EJBQLException.class, missingMappingException, args); 168 EJBQLException exception = new EJBQLException(message); 169 exception.setErrorCode(missingMappingException); 170 171 return exception; 172 } 173 174 public static EJBQLException aliasResolutionException(String theAlias) { 175 Object [] args = { theAlias }; 176 177 String message = ExceptionMessageGenerator.buildMessage(EJBQLException.class, aliasResolutionException, args); 178 EJBQLException exception = new EJBQLException(message); 179 exception.setErrorCode(aliasResolutionException); 180 return exception; 181 } 182 183 public static EJBQLException invalidContextKeyException(String theKey) { 184 Object [] args = { theKey }; 185 186 String message = ExceptionMessageGenerator.buildMessage(EJBQLException.class, invalidContextKeyException, args); 187 EJBQLException exception = new EJBQLException(message); 188 exception.setErrorCode(invalidContextKeyException); 189 return exception; 190 } 191 192 public static EJBQLException expressionNotSupported(String unsupportedExpression) { 193 Object [] args = { unsupportedExpression }; 194 195 String message = ExceptionMessageGenerator.buildMessage(EJBQLException.class, expressionNotSupported, args); 196 EJBQLException exception = new EJBQLException(message); 197 exception.setErrorCode(expressionNotSupported); 198 return exception; 199 } 200 201 public static EJBQLException invalidCollectionMemberDecl(String attributeName) { 202 Object [] args = { attributeName }; 203 204 String message = ExceptionMessageGenerator.buildMessage( 205 EJBQLException.class, invalidCollectionMemberDecl, args); 206 EJBQLException exception = new EJBQLException(message); 207 exception.setErrorCode(invalidCollectionMemberDecl); 208 return exception; 209 } 210 211 public static EJBQLException notYetImplemented(String detail) { 212 Object [] args = { detail }; 213 214 String message = ExceptionMessageGenerator.buildMessage( 215 EJBQLException.class, notYetImplemented, args); 216 EJBQLException exception = new EJBQLException(message); 217 exception.setErrorCode(notYetImplemented); 218 return exception; 219 } 220 221 public static EJBQLException constructorClassNotFound(String className) { 222 Object [] args = { className }; 223 224 String message = ExceptionMessageGenerator.buildMessage( 225 EJBQLException.class, constructorClassNotFound, args); 226 EJBQLException exception = new EJBQLException(message); 227 exception.setErrorCode(constructorClassNotFound); 228 return exception; 229 } 230 231 public static EJBQLException invalidSizeArgument(String attributeName) { 232 Object [] args = { attributeName }; 233 234 String message = ExceptionMessageGenerator.buildMessage( 235 EJBQLException.class, invalidSizeArgument, args); 236 EJBQLException exception = new EJBQLException(message); 237 exception.setErrorCode(invalidSizeArgument); 238 return exception; 239 } 240 241 public static EJBQLException invalidEnumLiteral(String enumType, String constant) { 242 Object [] args = { enumType, constant }; 243 244 String message = ExceptionMessageGenerator.buildMessage( 245 EJBQLException.class, invalidEnumLiteral, args); 246 EJBQLException exception = new EJBQLException(message); 247 exception.setErrorCode(invalidEnumLiteral); 248 return exception; 249 } 250 251 public static EJBQLException invalidSelectForGroupByQuery(String select, String groupBy) { 252 Object [] args = { select, groupBy }; 253 254 String message = ExceptionMessageGenerator.buildMessage( 255 EJBQLException.class, invalidSelectForGroupByQuery, args); 256 EJBQLException exception = new EJBQLException(message); 257 exception.setErrorCode(invalidSelectForGroupByQuery); 258 return exception; 259 } 260 261 public static EJBQLException invalidHavingExpression(String having, String groupBy) { 262 Object [] args = { having, groupBy }; 263 264 String message = ExceptionMessageGenerator.buildMessage( 265 EJBQLException.class, invalidHavingExpression, args); 266 EJBQLException exception = new EJBQLException(message); 267 exception.setErrorCode(invalidHavingExpression); 268 return exception; 269 } 270 271 public static EJBQLException invalidMultipleUseOfSameParameter( 272 String parameter, String oldType, String newType) { 273 Object [] args = { parameter, oldType, newType }; 274 275 String message = ExceptionMessageGenerator.buildMessage( 276 EJBQLException.class, invalidMultipleUseOfSameParameter, args); 277 EJBQLException exception = new EJBQLException(message); 278 exception.setErrorCode(invalidMultipleUseOfSameParameter); 279 return exception; 280 } 281 282 public static EJBQLException multipleVariableDeclaration( 283 String variable, String oldDecl) { 284 Object [] args = { variable, oldDecl }; 285 286 String message = ExceptionMessageGenerator.buildMessage( 287 EJBQLException.class, multipleVariableDeclaration, args); 288 EJBQLException exception = new EJBQLException(message); 289 exception.setErrorCode(multipleVariableDeclaration); 290 return exception; 291 } 292 293 public static EJBQLException invalidFunctionArgument(String functionName, String attributeName, String type) { 294 Object [] args = { functionName, attributeName, type }; 295 296 String message = ExceptionMessageGenerator.buildMessage( 297 EJBQLException.class, invalidFunctionArgument, args); 298 EJBQLException exception = new EJBQLException(message); 299 exception.setErrorCode(invalidFunctionArgument); 300 return exception; 301 } 302 303 public static EJBQLException invalidExpressionArgument(String functionName, String attributeName, String type) { 304 Object [] args = { functionName, attributeName, type }; 305 306 String message = ExceptionMessageGenerator.buildMessage( 307 EJBQLException.class, invalidExpressionArgument, args); 308 EJBQLException exception = new EJBQLException(message); 309 exception.setErrorCode(invalidExpressionArgument); 310 return exception; 311 } 312 313 public static EJBQLException unsupportJoinArgument(String functionName, String type) { 314 Object [] args = { functionName, type }; 315 316 String message = ExceptionMessageGenerator.buildMessage( 317 EJBQLException.class, unsupportJoinArgument, args); 318 EJBQLException exception = new EJBQLException(message); 319 exception.setErrorCode(unsupportJoinArgument); 320 return exception; 321 } 322 323 public static EJBQLException expectedOrderableOrderByItem(String item, String type) { 324 Object [] args = { item, type }; 325 326 String message = ExceptionMessageGenerator.buildMessage( 327 EJBQLException.class, expectedOrderableOrderByItem, args); 328 EJBQLException exception = new EJBQLException(message); 329 exception.setErrorCode(expectedOrderableOrderByItem); 330 return exception; 331 } 332 333 public static EJBQLException syntaxError(String query) { 334 Object [] args = { query }; 335 336 String message = ExceptionMessageGenerator.buildMessage( 337 EJBQLException.class, syntaxError, args); 338 EJBQLException exception = new EJBQLException(message); 339 exception.setErrorCode(syntaxError); 340 return exception; 341 } 342 343 public static EJBQLException syntaxErrorAt(String query, String token) { 344 Object [] args = { query, token }; 345 346 String message = ExceptionMessageGenerator.buildMessage( 347 EJBQLException.class, syntaxErrorAt, args); 348 EJBQLException exception = new EJBQLException(message); 349 exception.setErrorCode(syntaxErrorAt); 350 return exception; 351 } 352 353 public static EJBQLException unexpectedToken(String query, String token) { 354 Object [] args = { query, token }; 355 356 String message = ExceptionMessageGenerator.buildMessage( 357 EJBQLException.class, unexpectedToken, args); 358 EJBQLException exception = new EJBQLException(message); 359 exception.setErrorCode(unexpectedToken); 360 return exception; 361 } 362 363 public static EJBQLException unexpectedChar(String query, String unexpected) { 364 Object [] args = { query, unexpected }; 365 366 String message = ExceptionMessageGenerator.buildMessage( 367 EJBQLException.class, unexpectedChar, args); 368 EJBQLException exception = new EJBQLException(message); 369 exception.setErrorCode(unexpectedChar); 370 return exception; 371 } 372 373 public static EJBQLException expectedCharFound(String query, String expected, String found) { 374 Object [] args = { query, expected, found }; 375 376 String message = ExceptionMessageGenerator.buildMessage( 377 EJBQLException.class, expectedCharFound, args); 378 EJBQLException exception = new EJBQLException(message); 379 exception.setErrorCode(expectedCharFound); 380 return exception; 381 } 382 383 public static EJBQLException unexpectedEOF(String query) { 384 Object [] args = { query }; 385 386 String message = ExceptionMessageGenerator.buildMessage( 387 EJBQLException.class, unexpectedEOF, args); 388 EJBQLException exception = new EJBQLException(message); 389 exception.setErrorCode(unexpectedEOF); 390 return exception; 391 } 392 393 public static EJBQLException invalidNavigation( 394 String expr, String lhs, String type) { 395 Object [] args = { expr, lhs, type }; 396 397 String message = ExceptionMessageGenerator.buildMessage( 398 EJBQLException.class, invalidNavigation, args); 399 EJBQLException exception = new EJBQLException(message); 400 exception.setErrorCode(invalidNavigation); 401 return exception; 402 } 403 404 public static EJBQLException unknownAttribute(String type, String name) { 405 Object [] args = { type, name }; 406 407 String message = ExceptionMessageGenerator.buildMessage( 408 EJBQLException.class, unknownAttribute, args); 409 EJBQLException exception = new EJBQLException(message); 410 exception.setErrorCode(unknownAttribute); 411 return exception; 412 } 413 414 419 public Object addInternalException(Object theException) { 420 getInternalExceptions().add(theException); 421 return theException; 422 } 423 424 428 public boolean hasInternalExceptions() { 429 return !getInternalExceptions().isEmpty(); 430 } 431 432 437 public Collection getInternalExceptions() { 438 if (internalExceptions == null) { 439 setInternalExceptions(new Vector()); 440 } 441 return internalExceptions; 442 } 443 444 448 public void setInternalExceptions(Collection theExceptions) { 449 internalExceptions = theExceptions; 450 } 451 452 458 public void printFullStackTrace() { 459 if (hasInternalExceptions()) { 460 Iterator exceptions = getInternalExceptions().iterator(); 461 while (exceptions.hasNext()) { 462 Throwable error = (Throwable )exceptions.next(); 463 error.printStackTrace(); 464 } 465 } 466 } 467 } 468 | Popular Tags |