001: /*
002: * This file is part of PFIXCORE.
003: *
004: * PFIXCORE is free software; you can redistribute it and/or modify
005: * it under the terms of the GNU Lesser General Public License as published by
006: * the Free Software Foundation; either version 2 of the License, or
007: * (at your option) any later version.
008: *
009: * PFIXCORE is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public License
015: * along with PFIXCORE; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: *
018: */
019:
020: package de.schlund.pfixxml.exceptionprocessor.util;
021:
022: import java.io.IOException;
023: import java.io.Serializable;
024: import java.util.ArrayList;
025: import java.util.HashMap;
026: import java.util.Iterator;
027: import java.util.List;
028:
029: import org.w3c.dom.Document;
030:
031: /**
032: * @author jh
033: *
034: * To change the template for this generated type comment go to
035: * Window - Preferences - Java - Code Generation - Code and Comments
036: */
037: public class ExceptionDataValue implements Serializable {
038: private Throwable throwable;
039: private String scheme;
040: private String servername;
041: private int port;
042: private String uri;
043: private String sessionid;
044: private String page;
045: private String servlet;
046: private String query;
047: private HashMap<String, String> requestParams;
048: private ArrayList<String> lastSteps;
049: private HashMap<String, String> sessionKeysAndValues;
050: private Integer hashCodeForThrowable;
051:
052: private String text;
053: private String subject;
054: private Document xmlpresentation;
055:
056: /**
057: * @return Returns the sessionKeysAndValues.
058: */
059: public HashMap<String, String> getSessionKeysAndValues() {
060: return sessionKeysAndValues;
061: }
062:
063: /**
064: * @param sessionKeysAndValues The sessionKeysAndValues to set.
065: */
066: public void setSessionKeysAndValues(
067: HashMap<String, String> sessionKeysAndValues) {
068: this .sessionKeysAndValues = sessionKeysAndValues;
069: }
070:
071: /**
072: * @return Returns the query.
073: */
074: public String getQuery() {
075: return query;
076: }
077:
078: /**
079: * @param query The query to set.
080: */
081: public void setQuery(String query) {
082: this .query = query;
083: }
084:
085: public void accept(ExceptionDataValueVisitor v) {
086: v.visit(this );
087: }
088:
089: /**
090: * @return Returns the page.
091: */
092: public String getPage() {
093: return page;
094: }
095:
096: /**
097: * @param page The page to set.
098: */
099: public void setPage(String page) {
100: this .page = page;
101: }
102:
103: /**
104: * @return Returns the servlet.
105: */
106: public String getServlet() {
107: return servlet;
108: }
109:
110: /**
111: * @param servlet The servlet to set.
112: */
113: public void setServlet(String servlet) {
114: this .servlet = servlet;
115: }
116:
117: public void setThrowable(Throwable th) {
118: this .throwable = th;
119: hashCodeForThrowable = null;
120: }
121:
122: public Throwable getThrowable() {
123: return this .throwable;
124: }
125:
126: public int getHashcodeForThrowable() {
127: if (hashCodeForThrowable == null) {
128: StackTraceElement[] strace = throwable.getStackTrace();
129: StringBuffer sb = new StringBuffer();
130: for (int i = 0; i < strace.length; i++) {
131: sb.append(strace[i].toString());
132: }
133: return sb.toString().hashCode();
134: }
135: return hashCodeForThrowable.intValue();
136: }
137:
138: public String toString() {
139: StringBuffer sb = new StringBuffer();
140: sb.append("[Throwable=" + printThrowable()
141: + "][hashCodeForThrowable=" + hashCodeForThrowable
142: + "]");
143: sb.append("[Scheme=" + scheme + "]");
144: sb.append("[Servername=" + servername + "]");
145: sb.append("[Port=" + port + "]");
146: sb.append("[Uri=" + uri + "]");
147: sb.append("[SessionId=" + sessionid + "]");
148: sb.append("[Servlet=" + servlet + "]");
149: sb.append("[Page=" + page + "]");
150: sb.append("[QueryString=" + query + "]");
151: sb.append("[RequestParams=[");
152: if (requestParams == null) {
153: sb.append("null]]");
154: } else {
155: for (Iterator<String> iter = requestParams.keySet()
156: .iterator(); iter.hasNext();) {
157: Object key = iter.next();
158: Object value = requestParams.get(key);
159: sb.append("[" + key + "=>" + value + "]");
160: }
161: sb.append("]");
162: }
163:
164: sb.append("[Last steps=[");
165: if (lastSteps == null) {
166: sb.append("null]]");
167: } else {
168: for (Iterator<String> iter = lastSteps.iterator(); iter
169: .hasNext();) {
170: sb.append("[" + iter.next() + "]");
171: }
172: sb.append("]");
173: }
174:
175: sb.append("[Session keys and values=[");
176: if (sessionKeysAndValues == null) {
177: sb.append("null]]");
178: } else {
179: for (Iterator<String> iter = sessionKeysAndValues.keySet()
180: .iterator(); iter.hasNext();) {
181: Object key = iter.next();
182: Object value = sessionKeysAndValues.get(key);
183: sb.append("[" + key + "=>" + value);
184: }
185: sb.append("\n");
186: }
187:
188: return sb.toString();
189: }
190:
191: private String printThrowable() {
192: StringBuffer sb = new StringBuffer();
193: sb.append("[Message=" + throwable.getMessage() + "]");
194: sb.append("[Stacktrace=");
195: StackTraceElement[] st = throwable.getStackTrace();
196: for (int i = 0; i < st.length; i++) {
197: sb.append("[" + st[i].toString() + "]");
198: }
199: sb.append("]");
200: return sb.toString();
201: }
202:
203: private void writeObject(java.io.ObjectOutputStream out)
204: throws IOException {
205: out.defaultWriteObject();
206: }
207:
208: private void readObject(java.io.ObjectInputStream in)
209: throws IOException, ClassNotFoundException {
210: in.defaultReadObject();
211: }
212:
213: /**
214: * @return Returns the port.
215: */
216: public int getPort() {
217: return port;
218: }
219:
220: /**
221: * @param port The port to set.
222: */
223: public void setPort(int port) {
224: this .port = port;
225: }
226:
227: /**
228: * @return Returns the scheme.
229: */
230: public String getScheme() {
231: return scheme;
232: }
233:
234: /**
235: * @param scheme The scheme to set.
236: */
237: public void setScheme(String scheme) {
238: this .scheme = scheme;
239: }
240:
241: /**
242: * @return Returns the servername.
243: */
244: public String getServername() {
245: return servername;
246: }
247:
248: /**
249: * @param servername The servername to set.
250: */
251: public void setServername(String servername) {
252: this .servername = servername;
253: }
254:
255: /**
256: * @return Returns the sessionid.
257: */
258: public String getSessionid() {
259: return sessionid;
260: }
261:
262: /**
263: * @param sessionid The sessionid to set.
264: */
265: public void setSessionid(String sessionid) {
266: this .sessionid = sessionid;
267: }
268:
269: /**
270: * @return Returns the uri.
271: */
272: public String getUri() {
273: return uri;
274: }
275:
276: /**
277: * @param uri The uri to set.
278: */
279: public void setUri(String uri) {
280: this .uri = uri;
281: }
282:
283: /**
284: * @return Returns the sessionKeysNValues.
285: */
286: public HashMap<String, String> getRequestParams() {
287: return requestParams;
288: }
289:
290: /**
291: * @param sessionKeysNValues The sessionKeysNValues to set.
292: */
293: public void setRequestParams(
294: HashMap<String, String> sessionKeysNValues) {
295: this .requestParams = sessionKeysNValues;
296: }
297:
298: /**
299: * @return Returns the lastSteps.
300: */
301: public List<String> getLastSteps() {
302: return lastSteps;
303: }
304:
305: /**
306: * @param lastSteps The lastSteps to set.
307: */
308: public void setLastSteps(ArrayList<String> lastSteps) {
309: this .lastSteps = lastSteps;
310: }
311:
312: public void setTextBodyRepresentation(String text) {
313: this .text = text;
314: }
315:
316: public void setTextSubjectRepresentation(String text) {
317: this .subject = text;
318: }
319:
320: public void setXMLRepresentation(Document doc) {
321: this .xmlpresentation = doc;
322: }
323:
324: public Document getXMLPresentation() {
325: return this .xmlpresentation;
326: }
327:
328: public String getTextSubject() {
329: return this .subject;
330: }
331:
332: public String getTextBody() {
333: return this.text;
334: }
335: }
|