KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > util > ModuleException


1 /*
2  * $Id: ModuleException.java 164530 2005-04-25 03:11:07Z niallp $
3  *
4  * Copyright 1999-2005 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.struts.util;
19
20 import org.apache.struts.action.ActionError;
21 import org.apache.struts.action.ActionMessage;
22
23 /**
24  * Used for specialized exception handling.
25  */

26 public class ModuleException extends Exception JavaDoc {
27     
28     protected String JavaDoc property = null;
29     
30     /**
31      * @deprecated Use message instead.
32      */

33     protected ActionError error = null;
34     
35     /**
36      * The ActionMessage associated with this exception.
37      * @since Struts 1.2
38      */

39     protected ActionMessage message = null;
40
41     /**
42      * Construct an module exception with no replacement values.
43      *
44      * @param key Message key for this error message
45      */

46     public ModuleException(String JavaDoc key) {
47         super(key);
48         error = new ActionError(key);
49         message = new ActionMessage(key);
50     }
51
52     /**
53      * Construct an module exception with the specified replacement values.
54      *
55      * @param key Message key for this error message
56      * @param value First replacement value
57      */

58     public ModuleException(String JavaDoc key, Object JavaDoc value) {
59         super(key);
60         error = new ActionError(key, value);
61         message = new ActionMessage(key, value);
62     }
63
64     /**
65      * Construct an module exception with the specified replacement values.
66      *
67      * @param key Message key for this error message
68      * @param value0 First replacement value
69      * @param value1 Second replacement value
70      */

71     public ModuleException(String JavaDoc key, Object JavaDoc value0, Object JavaDoc value1) {
72         super(key);
73         error = new ActionError(key, value0, value1);
74         message = new ActionMessage(key, value0, value1);
75     }
76
77     /**
78      * Construct an module exception with the specified replacement values.
79      *
80      * @param key Message key for this error message
81      * @param value0 First replacement value
82      * @param value1 Second replacement value
83      * @param value2 Third replacement value
84      */

85     public ModuleException(String JavaDoc key, Object JavaDoc value0, Object JavaDoc value1, Object JavaDoc value2) {
86         super(key);
87         error = new ActionError(key, value0, value1, value2);
88         message = new ActionMessage(key, value0, value1, value2);
89     }
90
91     /**
92      * Construct an module exception with the specified replacement values.
93      *
94      * @param key Message key for this error message
95      * @param value0 First replacement value
96      * @param value1 Second replacement value
97      * @param value2 Third replacement value
98      * @param value3 Fourth replacement value
99      */

100     public ModuleException(String JavaDoc key, Object JavaDoc value0, Object JavaDoc value1, Object JavaDoc value2, Object JavaDoc value3) {
101         super(key);
102         error = new ActionError(key, value0, value1, value2, value3);
103         message = new ActionMessage(key, value0, value1, value2, value3);
104     }
105
106     /**
107      * Construct an action error with the specified replacement values.
108      *
109      * @param key Message key for this message
110      * @param values Array of replacement values
111      */

112     public ModuleException(String JavaDoc key, Object JavaDoc[] values) {
113         super(key);
114         error = new ActionError(key, values);
115         message = new ActionMessage(key, values);
116     }
117     
118     /**
119      * Returns the property associated with the exception.
120      * @return Value of property.
121      */

122     public String JavaDoc getProperty() {
123         return (property != null) ? property : message.getKey();
124     }
125
126     /**
127      * Set the property associated with the exception.
128      * It can be a name of the edit field, which 'caused' the exception.
129      */

130     public void setProperty(String JavaDoc property) {
131         this.property = property;
132     }
133
134     /**
135      * Returns the error associated with the exception.
136      * @return Value of property error.
137      * @deprecated Use getActionMessage() instead. This will be removed
138      * after Struts 1.2.
139      */

140     public ActionError getError() {
141         return error;
142     }
143     
144     /**
145      * Returns the error associated with the exception.
146      * @return Value of property error.
147      * @since Struts 1.2
148      */

149     public ActionMessage getActionMessage() {
150         return this.message;
151     }
152 }
153
Popular Tags