01: package org.hibernate.bytecode.javassist;
02:
03: /**
04: * An exception thrown while generating a bulk accessor.
05: *
06: * @author Muga Nishizawa
07: * @author modified by Shigeru Chiba
08: */
09: public class BulkAccessorException extends RuntimeException {
10: private Throwable myCause;
11:
12: /**
13: * Gets the cause of this throwable.
14: * It is for JDK 1.3 compatibility.
15: */
16: public Throwable getCause() {
17: return (myCause == this ? null : myCause);
18: }
19:
20: /**
21: * Initializes the cause of this throwable.
22: * It is for JDK 1.3 compatibility.
23: */
24: public synchronized Throwable initCause(Throwable cause) {
25: myCause = cause;
26: return this ;
27: }
28:
29: private int index;
30:
31: /**
32: * Constructs an exception.
33: */
34: public BulkAccessorException(String message) {
35: super (message);
36: index = -1;
37: initCause(null);
38: }
39:
40: /**
41: * Constructs an exception.
42: *
43: * @param index the index of the property that causes an exception.
44: */
45: public BulkAccessorException(String message, int index) {
46: this (message + ": " + index);
47: this .index = index;
48: }
49:
50: /**
51: * Constructs an exception.
52: */
53: public BulkAccessorException(String message, Throwable cause) {
54: super (message);
55: index = -1;
56: initCause(cause);
57: }
58:
59: /**
60: * Constructs an exception.
61: *
62: * @param index the index of the property that causes an exception.
63: */
64: public BulkAccessorException(Throwable cause, int index) {
65: this ("Property " + index);
66: this .index = index;
67: initCause(cause);
68: }
69:
70: /**
71: * Returns the index of the property that causes this exception.
72: *
73: * @return -1 if the index is not specified.
74: */
75: public int getIndex() {
76: return this.index;
77: }
78: }
|