01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.jetspeed.exception;
18:
19: import java.util.Locale;
20: import java.util.ResourceBundle;
21:
22: import org.apache.jetspeed.i18n.KeyedMessage;
23:
24: /**
25: * Occurs when anything unexpected happens within Jetspeed.Any defined exceptions
26: * within Jetspeed should always extend from this.
27: *
28: * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
29: * @version $Id: JetspeedException.java 516448 2007-03-09 16:25:47Z ate $
30: **/
31:
32: public class JetspeedException extends Exception {
33: public static final String KEYED_MESSAGE_BUNDLE = "org.apache.jetspeed.exception.JetspeedExceptionMessages";
34:
35: private KeyedMessage keyedMessage;
36:
37: public JetspeedException() {
38: super ();
39: }
40:
41: public JetspeedException(String message) {
42: super (message);
43: }
44:
45: public JetspeedException(KeyedMessage typedMessage) {
46: super (typedMessage.getMessage());
47: this .keyedMessage = typedMessage;
48: }
49:
50: public JetspeedException(Throwable nested) {
51: super (nested);
52: }
53:
54: public JetspeedException(String msg, Throwable nested) {
55: super (msg, nested);
56: }
57:
58: public JetspeedException(KeyedMessage keyedMessage, Throwable nested) {
59: super (keyedMessage.getMessage(), nested);
60: this .keyedMessage = keyedMessage;
61: }
62:
63: public KeyedMessage getKeyedMessage() {
64: return keyedMessage;
65: }
66:
67: public String getMessage() {
68: if (keyedMessage != null) {
69: return keyedMessage.getMessage();
70: }
71: return super .getMessage();
72: }
73:
74: public String getMessage(ResourceBundle bundle) {
75: if (keyedMessage != null) {
76: return keyedMessage.getMessage(bundle);
77: }
78: return super .getMessage();
79: }
80:
81: public String getMessage(Locale locale) {
82: if (keyedMessage != null) {
83: return keyedMessage.getMessage(locale);
84: }
85: return super.getMessage();
86: }
87: }
|