001: /*
002: * The Apache Software License, Version 1.1
003: *
004: *
005: * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
006: * reserved.
007: *
008: * Redistribution and use in source and binary forms, with or without
009: * modification, are permitted provided that the following conditions
010: * are met:
011: *
012: * 1. Redistributions of source code must retain the above copyright
013: * notice, this list of conditions and the following disclaimer.
014: *
015: * 2. Redistributions in binary form must reproduce the above copyright
016: * notice, this list of conditions and the following disclaimer in
017: * the documentation and/or other materials provided with the
018: * distribution.
019: *
020: * 3. The end-user documentation included with the redistribution,
021: * if any, must include the following acknowledgment:
022: * "This product includes software developed by the
023: * Apache Software Foundation (http://www.apache.org/)."
024: * Alternately, this acknowledgment may appear in the software itself,
025: * if and wherever such third-party acknowledgments normally appear.
026: *
027: * 4. The names "Xalan" and "Apache Software Foundation" must
028: * not be used to endorse or promote products derived from this
029: * software without prior written permission. For written
030: * permission, please contact apache@apache.org.
031: *
032: * 5. Products derived from this software may not be called "Apache",
033: * nor may "Apache" appear in their name, without prior written
034: * permission of the Apache Software Foundation.
035: *
036: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
037: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
038: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
039: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
040: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
041: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
042: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
043: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
044: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
045: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
046: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
047: * SUCH DAMAGE.
048: * ====================================================================
049: *
050: * This software consists of voluntary contributions made by many
051: * individuals on behalf of the Apache Software Foundation and was
052: * originally based on software copyright (c) 1999, Lotus
053: * Development Corporation., http://www.lotus.com. For more
054: * information on the Apache Software Foundation, please see
055: * <http://www.apache.org/>.
056: *
057: /*****************************************************************************************************
058: *
059: * Wrapper for exceptions occurring during apply XSL processing.
060: * Allows for exceptions to be returned with an associated HTTP Status Code.
061: *
062: * @author Spencer Shepard (sshepard@us.ibm.com)
063: * @author R. Adam King (rak@us.ibm.com)
064: * @author Tom Rowe (trowe@us.ibm.com)
065: *
066: *****************************************************************************************************/
067: package servlet;
068:
069: public class ApplyXSLTException extends Exception {
070:
071: /**
072: * Exception Message.
073: * @serial
074: */
075: private String myMessage = "";
076:
077: /**
078: * HTTP Status Code. Default= internal server error.
079: * @serial
080: */
081: private int myHttpStatusCode = javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
082:
083: /**
084: * Wrapped exception
085: * @serial
086: */
087: private Exception myException = null;
088:
089: /**
090: * Constructor for exception with no additional detail.
091: */
092: public ApplyXSLTException() {
093: super ();
094: }
095:
096: /**
097: * Constructor for exception with message.
098: * @param s Exception message
099: */
100: public ApplyXSLTException(String s) {
101: super ();
102: myMessage = s;
103: }
104:
105: /**
106: * Constructor for exception with HTTP status code.
107: * @param hsc Valid status code from javax.servlet.http.HttpServletResponse
108: */
109: public ApplyXSLTException(int hsc) {
110: super ();
111: myHttpStatusCode = hsc;
112: }
113:
114: /**
115: * Constructor for exception with message and HTTP status code.
116: * @param s Exception message
117: * @param hsc Valid status code from javax.servlet.http.HttpServletResponse
118: */
119: public ApplyXSLTException(String s, int hsc) {
120: super ();
121: myHttpStatusCode = hsc;
122: }
123:
124: /**
125: * Constructor for exception.
126: * @param e Exception to be wrapped.
127: */
128: public ApplyXSLTException(Exception e) {
129: super ();
130: myMessage = e.getMessage();
131: myException = e;
132: }
133:
134: /**
135: * Constructor for passed exception with message.
136: * @param s Exception message
137: * @param e Exception to be wrapped.
138: */
139: public ApplyXSLTException(String s, Exception e) {
140: super ();
141: myMessage = s;
142: myException = e;
143: }
144:
145: /**
146: * Constructor for passed exception with HTTP status code.
147: * @param e Exception to be wrapped.
148: * @param hsc Valid status code from javax.servlet.http.HttpServletResponse
149: */
150: public ApplyXSLTException(Exception e, int hsc) {
151: super ();
152: myMessage = e.getMessage();
153: myException = e;
154: myHttpStatusCode = hsc;
155: }
156:
157: /**
158: * Constructor for passed exception with HTTP status code and message.
159: * @param s Exception message
160: * @param e Exception to be wrapped.
161: * @param hsc Valid status code from javax.servlet.http.HttpServletResponse
162: */
163: public ApplyXSLTException(String s, Exception e, int hsc) {
164: super ();
165: myMessage = s;
166: myException = e;
167: myHttpStatusCode = hsc;
168: }
169:
170: /**
171: * Returns exception message.
172: * @return exception message
173: */
174: public String getMessage() {
175: return myMessage;
176: }
177:
178: /**
179: * Appends string to exception message.
180: * @param s String to be added to message
181: */
182: public void appendMessage(String s) {
183: myMessage += s;
184: }
185:
186: /**
187: * Returns the wrapped exception.
188: * @return Wrapped exception
189: */
190: public Exception getException() {
191: return myException;
192: }
193:
194: /**
195: * Returns the HTTP status code associated with the exception.
196: * @return Valid status code from javax.servlet.http.HttpServletResponse
197: */
198: public int getStatusCode() {
199: return myHttpStatusCode;
200: }
201: }
|