001: /**********************************************************************
002: Copyright (c) 2004 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:
016: Contributors:
017: 2003 Kikucho Kousuke - org.jpox.enhancer.conf.InvalidMetaDataException
018: 2005 Andy Jefferson - changed to extend JDOFatalUserException
019: ...
020: **********************************************************************/package org.jpox.metadata;
021:
022: import java.io.PrintStream;
023: import java.io.PrintWriter;
024:
025: import org.jpox.exceptions.JPOXUserException;
026: import org.jpox.util.Localiser;
027:
028: /**
029: * Representation of an exception thrown when an error occurs in Meta-Data definition.
030: * Provides a series of convenience constructors to accomodate the typical numbers
031: * of parameters embodies in messages.
032: *
033: * @version $Revision: 1.5 $
034: */
035: public class InvalidMetaDataException extends JPOXUserException {
036: /** Message resources key */
037: protected String messageKey;
038:
039: /** Cause of the exception */
040: protected Throwable cause;
041:
042: /**
043: * Default Constructor
044: */
045: public InvalidMetaDataException() {
046: super ();
047: setFatal();
048: }
049:
050: /**
051: * Constructor with message resource and cause exception
052: * @param localiser message resources
053: * @param key message resources key
054: * @param cause cause exception
055: */
056: public InvalidMetaDataException(Localiser localiser, String key,
057: Throwable cause) {
058: this (localiser, key, "", "", "");
059: this .cause = cause;
060: setFatal();
061: }
062:
063: /**
064: * Constructor with message resource, message param and cause exception
065: * @param localiser message resources
066: * @param key message resources key
067: * @param param1 message resources param0
068: * @param cause cause exception
069: */
070: public InvalidMetaDataException(Localiser localiser, String key,
071: Object param1, Throwable cause) {
072: this (localiser, key, param1, "", "");
073: this .cause = cause;
074: setFatal();
075: }
076:
077: /**
078: * Constructor with message resource, message params and cause exception
079: * @param localiser message resources
080: * @param key message resources key
081: * @param param1 message resources param0
082: * @param param2 message resources param1
083: * @param cause cause exception
084: */
085: public InvalidMetaDataException(Localiser localiser, String key,
086: Object param1, Object param2, Throwable cause) {
087: this (localiser, key, param1, param2, "");
088: this .cause = cause;
089: setFatal();
090: }
091:
092: /**
093: * Constructor with message resource, message params and cause exception
094: * @param localiser message resources
095: * @param key message resources key
096: * @param param1 message resources param0
097: * @param param2 message resources param1
098: * @param param3 message resources param2
099: * @param cause cause exception
100: */
101: public InvalidMetaDataException(Localiser localiser, String key,
102: Object param1, Object param2, Object param3, Throwable cause) {
103: super (localiser.msg(key, param1, param2, param3));
104: this .messageKey = key;
105: this .cause = cause;
106: setFatal();
107: }
108:
109: /**
110: * Constructor with message resource
111: * @param localiser message resources
112: * @param key message resources key
113: */
114: public InvalidMetaDataException(Localiser localiser, String key) {
115: this (localiser, key, "", "", "");
116: setFatal();
117: }
118:
119: /**
120: * Constructor with message resource, message param
121: * @param localiser message resources
122: * @param key message resources key
123: * @param param1 message resources param0
124: */
125: public InvalidMetaDataException(Localiser localiser, String key,
126: Object param1) {
127: this (localiser, key, param1, "", "");
128: setFatal();
129: }
130:
131: /**
132: * Constructor with message resource, message params
133: * @param localiser message resources
134: * @param key message resources key
135: * @param param1 message resources param0
136: * @param param2 message resources param1
137: */
138: public InvalidMetaDataException(Localiser localiser, String key,
139: Object param1, Object param2) {
140: this (localiser, key, param1, param2, "");
141: setFatal();
142: }
143:
144: /**
145: * Constructor with message resource, message params
146: * @param localiser message resources
147: * @param key message resources key
148: * @param param1 message resources param0
149: * @param param2 message resources param1
150: * @param param3 message resources param2
151: */
152: public InvalidMetaDataException(Localiser localiser, String key,
153: Object param1, Object param2, Object param3) {
154: super (localiser.msg(key, param1, param2, param3));
155: this .messageKey = key;
156: setFatal();
157: }
158:
159: /**
160: * Constructor with message resource, message params
161: * @param localiser message resources
162: * @param key message resources key
163: * @param param1 message resources param1
164: * @param param2 message resources param2
165: * @param param3 message resources param3
166: * @param param4 message resources param4
167: */
168: public InvalidMetaDataException(Localiser localiser, String key,
169: Object param1, Object param2, Object param3, Object param4) {
170: super (localiser.msg(key, param1, param2, param3, param4));
171: this .messageKey = key;
172: setFatal();
173: }
174:
175: /**
176: * Constructor with message resource, message params
177: * @param localiser message resources
178: * @param key message resources key
179: * @param param1 message resources param1
180: * @param param2 message resources param2
181: * @param param3 message resources param3
182: * @param param4 message resources param4
183: * @param param5 message resources param5
184: */
185: public InvalidMetaDataException(Localiser localiser, String key,
186: Object param1, Object param2, Object param3, Object param4,
187: Object param5) {
188: super (localiser
189: .msg(key, param1, param2, param3, param4, param5));
190: this .messageKey = key;
191: setFatal();
192: }
193:
194: /**
195: * Return message resource key
196: * @return Message resource key
197: */
198: public String getMessageKey() {
199: return messageKey;
200: }
201:
202: /* (non-Javadoc)
203: * @see java.lang.Throwable#printStackTrace()
204: */
205: public void printStackTrace() {
206: super .printStackTrace();
207: if (cause != null) {
208: cause.printStackTrace();
209: }
210: }
211:
212: /* (non-Javadoc)
213: * @see java.lang.Throwable#printStackTrace(java.io.PrintStream)
214: */
215: public void printStackTrace(PrintStream s) {
216: super .printStackTrace(s);
217: if (cause != null) {
218: cause.printStackTrace(s);
219: }
220: }
221:
222: /* (non-Javadoc)
223: * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
224: */
225: public void printStackTrace(PrintWriter s) {
226: super.printStackTrace(s);
227: if (cause != null) {
228: cause.printStackTrace(s);
229: }
230: }
231: }
|