KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > servlet > ApplyXSLTException


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Xalan" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 1999, Lotus
53  * Development Corporation., http://www.lotus.com. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  *
57 /*****************************************************************************************************
58  *
59  * Wrapper for exceptions occurring during apply XSL processing.
60  * Allows for exceptions to be returned with an associated HTTP Status Code.
61  *
62  * @author Spencer Shepard (sshepard@us.ibm.com)
63  * @author R. Adam King (rak@us.ibm.com)
64  * @author Tom Rowe (trowe@us.ibm.com)
65  *
66  *****************************************************************************************************/

67 package servlet;
68
69 public class ApplyXSLTException extends Exception JavaDoc {
70
71     /**
72       * Exception Message.
73       * @serial
74       */

75     private String JavaDoc myMessage = "";
76
77     /**
78       * HTTP Status Code. Default= internal server error.
79       * @serial
80       */

81     private int myHttpStatusCode = javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
82
83     /**
84       * Wrapped exception
85       * @serial
86       */

87     private Exception JavaDoc myException = null;
88
89     /**
90       * Constructor for exception with no additional detail.
91       */

92     public ApplyXSLTException()
93     {
94         super();
95     }
96
97     /**
98       * Constructor for exception with message.
99       * @param s Exception message
100       */

101     public ApplyXSLTException(String JavaDoc s)
102     {
103         super();
104     myMessage = s;
105     }
106
107     /**
108       * Constructor for exception with HTTP status code.
109       * @param hsc Valid status code from javax.servlet.http.HttpServletResponse
110       */

111     public ApplyXSLTException(int hsc)
112     {
113     super();
114     myHttpStatusCode = hsc;
115     }
116
117     /**
118       * Constructor for exception with message and HTTP status code.
119       * @param s Exception message
120       * @param hsc Valid status code from javax.servlet.http.HttpServletResponse
121       */

122     public ApplyXSLTException(String JavaDoc s, int hsc)
123     {
124     super();
125     myHttpStatusCode = hsc;
126     }
127
128     /**
129       * Constructor for exception.
130       * @param e Exception to be wrapped.
131       */

132     public ApplyXSLTException(Exception JavaDoc e)
133     {
134     super();
135     myMessage = e.getMessage();
136     myException = e;
137     }
138
139     /**
140       * Constructor for passed exception with message.
141       * @param s Exception message
142       * @param e Exception to be wrapped.
143       */

144     public ApplyXSLTException (String JavaDoc s, Exception JavaDoc e)
145     {
146     super();
147     myMessage = s;
148     myException = e;
149     }
150
151     /**
152       * Constructor for passed exception with HTTP status code.
153       * @param e Exception to be wrapped.
154       * @param hsc Valid status code from javax.servlet.http.HttpServletResponse
155       */

156     public ApplyXSLTException(Exception JavaDoc e, int hsc)
157     {
158     super();
159     myMessage = e.getMessage();
160     myException = e;
161     myHttpStatusCode = hsc;
162     }
163
164     /**
165       * Constructor for passed exception with HTTP status code and message.
166       * @param s Exception message
167       * @param e Exception to be wrapped.
168       * @param hsc Valid status code from javax.servlet.http.HttpServletResponse
169       */

170     public ApplyXSLTException(String JavaDoc s, Exception JavaDoc e, int hsc)
171     {
172     super();
173     myMessage = s;
174     myException = e;
175     myHttpStatusCode = hsc;
176     }
177
178     /**
179       * Returns exception message.
180       * @return exception message
181       */

182     public String JavaDoc getMessage()
183     {
184     return myMessage;
185     }
186
187     /**
188       * Appends string to exception message.
189       * @param s String to be added to message
190       */

191     public void appendMessage(String JavaDoc s)
192     {
193     myMessage += s;
194     }
195
196     /**
197       * Returns the wrapped exception.
198       * @return Wrapped exception
199       */

200     public Exception JavaDoc getException()
201     {
202     return myException;
203     }
204
205     /**
206       * Returns the HTTP status code associated with the exception.
207       * @return Valid status code from javax.servlet.http.HttpServletResponse
208       */

209     public int getStatusCode()
210     {
211     return myHttpStatusCode;
212     }
213 }
214
215
Popular Tags