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: * Base exception for all RuntimeExceptions defined within Jetspeed.
26: * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
27: */
28: public class JetspeedRuntimeException extends RuntimeException {
29:
30: public static final String KEYED_MESSAGE_BUNDLE = "org.apache.jetspeed.exception.JetspeedExceptionMessages";
31:
32: private KeyedMessage keyedMessage;
33:
34: /**
35: *
36: */
37: public JetspeedRuntimeException() {
38: super ();
39: }
40:
41: /**
42: * @param arg0
43: */
44: public JetspeedRuntimeException(String arg0) {
45: super (arg0);
46: }
47:
48: public JetspeedRuntimeException(KeyedMessage typedMessage) {
49: super (typedMessage.getMessage());
50: this .keyedMessage = typedMessage;
51: }
52:
53: /**
54: * @param arg0
55: */
56: public JetspeedRuntimeException(Throwable arg0) {
57: super (arg0);
58: }
59:
60: /**
61: * @param arg0
62: * @param arg1
63: */
64: public JetspeedRuntimeException(String arg0, Throwable arg1) {
65: super (arg0, arg1);
66: }
67:
68: public JetspeedRuntimeException(KeyedMessage keyedMessage,
69: Throwable nested) {
70: super (keyedMessage.getMessage(), nested);
71: this .keyedMessage = keyedMessage;
72: }
73:
74: public KeyedMessage getKeyedMessage() {
75: return keyedMessage;
76: }
77:
78: public String getMessage() {
79: if (keyedMessage != null) {
80: return keyedMessage.getMessage();
81: }
82: return super .getMessage();
83: }
84:
85: public String getMessage(ResourceBundle bundle) {
86: if (keyedMessage != null) {
87: return keyedMessage.getMessage(bundle);
88: }
89: return super .getMessage();
90: }
91:
92: public String getMessage(Locale locale) {
93: if (keyedMessage != null) {
94: return keyedMessage.getMessage(locale);
95: }
96: return super.getMessage();
97: }
98: }
|