001: /**********************************************************************
002: Copyright (c) 2007 Andy Jefferson and others. All rights reserved.
003: Licensed under the Apache License, Version 2.0 (the "License");
004: you may not use this file except in compliance with the License.
005: You may obtain a copy of the License at
006:
007: http://www.apache.org/licenses/LICENSE-2.0
008:
009: Unless required by applicable law or agreed to in writing, software
010: distributed under the License is distributed on an "AS IS" BASIS,
011: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012: See the License for the specific language governing permissions and
013: limitations under the License.
014:
015: Contributors:
016: ...
017: **********************************************************************/package org.jpox.metadata;
018:
019: import java.io.PrintStream;
020: import java.io.PrintWriter;
021:
022: import org.jpox.exceptions.JPOXUserException;
023: import org.jpox.util.Localiser;
024:
025: /**
026: * Exception thrown when an annotation has been specified that is invalid in the circumstances.
027: *
028: * @version $Revision: 1.1 $
029: */
030: public class InvalidAnnotationException extends JPOXUserException {
031: /** Message resources key */
032: protected String messageKey;
033:
034: /** Cause of the exception */
035: protected Throwable cause;
036:
037: /**
038: * Default Constructor
039: */
040: public InvalidAnnotationException() {
041: super ();
042: setFatal();
043: }
044:
045: /**
046: * Constructor with message resource and cause exception
047: * @param localiser message resources
048: * @param key message resources key
049: * @param cause cause exception
050: */
051: public InvalidAnnotationException(Localiser localiser, String key,
052: Throwable cause) {
053: this (localiser, key, "", "", "");
054: this .cause = cause;
055: setFatal();
056: }
057:
058: /**
059: * Constructor with message resource, message param and cause exception
060: * @param localiser message resources
061: * @param key message resources key
062: * @param param1 message resources param0
063: * @param cause cause exception
064: */
065: public InvalidAnnotationException(Localiser localiser, String key,
066: Object param1, Throwable cause) {
067: this (localiser, key, param1, "", "");
068: this .cause = cause;
069: setFatal();
070: }
071:
072: /**
073: * Constructor with message resource, message params and cause exception
074: * @param localiser message resources
075: * @param key message resources key
076: * @param param1 message resources param0
077: * @param param2 message resources param1
078: * @param cause cause exception
079: */
080: public InvalidAnnotationException(Localiser localiser, String key,
081: Object param1, Object param2, Throwable cause) {
082: this (localiser, key, param1, param2, "");
083: this .cause = cause;
084: setFatal();
085: }
086:
087: /**
088: * Constructor with message resource, message params and cause exception
089: * @param localiser message resources
090: * @param key message resources key
091: * @param param1 message resources param0
092: * @param param2 message resources param1
093: * @param param3 message resources param2
094: * @param cause cause exception
095: */
096: public InvalidAnnotationException(Localiser localiser, String key,
097: Object param1, Object param2, Object param3, Throwable cause) {
098: super (localiser.msg(key, param1, param2, param3));
099: this .messageKey = key;
100: this .cause = cause;
101: setFatal();
102: }
103:
104: /**
105: * Constructor with message resource
106: * @param localiser message resources
107: * @param key message resources key
108: */
109: public InvalidAnnotationException(Localiser localiser, String key) {
110: this (localiser, key, "", "", "");
111: setFatal();
112: }
113:
114: /**
115: * Constructor with message resource, message param
116: * @param localiser message resources
117: * @param key message resources key
118: * @param param1 message resources param0
119: */
120: public InvalidAnnotationException(Localiser localiser, String key,
121: Object param1) {
122: this (localiser, key, param1, "", "");
123: setFatal();
124: }
125:
126: /**
127: * Constructor with message resource, message params
128: * @param localiser message resources
129: * @param key message resources key
130: * @param param1 message resources param0
131: * @param param2 message resources param1
132: */
133: public InvalidAnnotationException(Localiser localiser, String key,
134: Object param1, Object param2) {
135: this (localiser, key, param1, param2, "");
136: setFatal();
137: }
138:
139: /**
140: * Constructor with message resource, message params
141: * @param localiser message resources
142: * @param key message resources key
143: * @param param1 message resources param0
144: * @param param2 message resources param1
145: * @param param3 message resources param2
146: */
147: public InvalidAnnotationException(Localiser localiser, String key,
148: Object param1, Object param2, Object param3) {
149: super (localiser.msg(key, param1, param2, param3));
150: this .messageKey = key;
151: setFatal();
152: }
153:
154: /**
155: * Constructor with message resource, message params
156: * @param localiser message resources
157: * @param key message resources key
158: * @param param1 message resources param1
159: * @param param2 message resources param2
160: * @param param3 message resources param3
161: * @param param4 message resources param4
162: */
163: public InvalidAnnotationException(Localiser localiser, String key,
164: Object param1, Object param2, Object param3, Object param4) {
165: super (localiser.msg(key, param1, param2, param3, param4));
166: this .messageKey = key;
167: setFatal();
168: }
169:
170: /**
171: * Constructor with message resource, message params
172: * @param localiser message resources
173: * @param key message resources key
174: * @param param1 message resources param1
175: * @param param2 message resources param2
176: * @param param3 message resources param3
177: * @param param4 message resources param4
178: * @param param5 message resources param5
179: */
180: public InvalidAnnotationException(Localiser localiser, String key,
181: Object param1, Object param2, Object param3, Object param4,
182: Object param5) {
183: super (localiser
184: .msg(key, param1, param2, param3, param4, param5));
185: this .messageKey = key;
186: setFatal();
187: }
188:
189: /**
190: * Return message resource key
191: * @return Message resource key
192: */
193: public String getMessageKey() {
194: return messageKey;
195: }
196:
197: /* (non-Javadoc)
198: * @see java.lang.Throwable#printStackTrace()
199: */
200: public void printStackTrace() {
201: super .printStackTrace();
202: if (cause != null) {
203: cause.printStackTrace();
204: }
205: }
206:
207: /* (non-Javadoc)
208: * @see java.lang.Throwable#printStackTrace(java.io.PrintStream)
209: */
210: public void printStackTrace(PrintStream s) {
211: super .printStackTrace(s);
212: if (cause != null) {
213: cause.printStackTrace(s);
214: }
215: }
216:
217: /* (non-Javadoc)
218: * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
219: */
220: public void printStackTrace(PrintWriter s) {
221: super.printStackTrace(s);
222: if (cause != null) {
223: cause.printStackTrace(s);
224: }
225: }
226: }
|