KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > config > ExceptionConfig


1 /*
2  * $Id: ExceptionConfig.java 54929 2004-10-16 16:38:42Z germuska $
3  *
4  * Copyright 1999-2004 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
19
20 package org.apache.struts.config;
21
22
23 import java.io.Serializable JavaDoc;
24
25
26 /**
27  * <p>A JavaBean representing the configuration information of an
28  * <code>&lt;exception&gt;</code> element from a Struts
29  * configuration file.</p>
30  *
31  * @version $Rev: 54929 $ $Date: 2004-10-16 17:38:42 +0100 (Sat, 16 Oct 2004) $
32  * @since Struts 1.1
33  */

34
35 public class ExceptionConfig implements Serializable JavaDoc {
36
37
38     // ----------------------------------------------------- Instance Variables
39

40
41     /**
42      * Has this component been completely configured?
43      */

44     protected boolean configured = false;
45
46
47     // ------------------------------------------------------------- Properties
48

49
50     /**
51      * The servlet context attribute under which the message resources bundle
52      * to be used for this exception is located. If not set, the default
53      * message resources for the current module is assumed.
54      */

55     protected String JavaDoc bundle = null;
56
57     public String JavaDoc getBundle() {
58         return (this.bundle);
59     }
60
61     public void setBundle(String JavaDoc bundle) {
62         if (configured) {
63             throw new IllegalStateException JavaDoc("Configuration is frozen");
64         }
65         this.bundle = bundle;
66     }
67
68
69     /**
70      * The fully qualified Java class name of the exception handler class
71      * which should be instantiated to handle this exception.
72      */

73     protected String JavaDoc handler = "org.apache.struts.action.ExceptionHandler";
74
75     public String JavaDoc getHandler() {
76         return (this.handler);
77     }
78
79     public void setHandler(String JavaDoc handler) {
80         if (configured) {
81             throw new IllegalStateException JavaDoc("Configuration is frozen");
82         }
83         this.handler = handler;
84     }
85
86
87     /**
88      * The message resources key specifying the error message
89      * associated with this exception.
90      */

91     protected String JavaDoc key = null;
92
93     public String JavaDoc getKey() {
94         return (this.key);
95     }
96
97     public void setKey(String JavaDoc key) {
98         if (configured) {
99             throw new IllegalStateException JavaDoc("Configuration is frozen");
100         }
101         this.key = key;
102     }
103
104
105     /**
106      * The module-relative path of the resource to forward to if this
107      * exception occurs during an <code>Action</code>.
108      */

109     protected String JavaDoc path = null;
110
111     public String JavaDoc getPath() {
112         return (this.path);
113     }
114
115     public void setPath(String JavaDoc path) {
116         if (configured) {
117             throw new IllegalStateException JavaDoc("Configuration is frozen");
118         }
119         this.path = path;
120     }
121
122
123     /**
124      * The scope in which we should expose the ActionError for this exception
125      * handler.
126      */

127     protected String JavaDoc scope = "request";
128
129     public String JavaDoc getScope() {
130         return (this.scope);
131     }
132
133     public void setScope(String JavaDoc scope) {
134         if (configured) {
135             throw new IllegalStateException JavaDoc("Configuration is frozen");
136         }
137         this.scope = scope;
138     }
139
140
141     /**
142      * The fully qualified Java class name of the exception that is to be
143      * handled by this handler.
144      */

145     protected String JavaDoc type = null;
146
147     public String JavaDoc getType() {
148         return (this.type);
149     }
150
151     public void setType(String JavaDoc type) {
152         if (configured) {
153             throw new IllegalStateException JavaDoc("Configuration is frozen");
154         }
155         this.type = type;
156     }
157
158
159     // --------------------------------------------------------- Public Methods
160

161
162     /**
163      * Freeze the configuration of this component.
164      */

165     public void freeze() {
166
167         configured = true;
168
169     }
170
171
172     /**
173      * Return a String representation of this object.
174      */

175     public String JavaDoc toString() {
176
177         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("ExceptionConfig[");
178         sb.append("type=");
179         sb.append(this.type);
180         if (this.bundle != null) {
181             sb.append(",bundle=");
182             sb.append(this.bundle);
183         }
184         sb.append(",key=");
185         sb.append(this.key);
186         sb.append(",path=");
187         sb.append(this.path);
188         sb.append(",scope=");
189         sb.append(this.scope);
190         sb.append("]");
191         return (sb.toString());
192
193     }
194
195
196 }
197
Popular Tags