ComponentWithBrowseButton - optional remove listener on hide
[fedora-idea.git] / platform / platform-impl / src / com / intellij / errorreport / bean / ExceptionBean.java
blob5f12509cb6bafd30f296f293bbf95b3e8a6dc5f1
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.errorreport.bean;
18 import org.jetbrains.annotations.NonNls;
20 import java.io.ByteArrayOutputStream;
21 import java.io.PrintStream;
22 import java.math.BigInteger;
23 import java.security.MessageDigest;
24 import java.security.NoSuchAlgorithmException;
25 import java.util.Date;
27 /**
28 * Created by IntelliJ IDEA.
29 * User: stathik
30 * Date: May 19, 2003
31 * Time: 9:07:26 PM
32 * To change this template use Options | File Templates.
34 public class ExceptionBean {
35 private String hashCode;
36 private String message;
37 private Date date;
38 private String stackTrace;
39 private int itnThreadId;
40 private String buildNumber;
41 private String productCode;
42 private boolean scrambled;
44 public static final int NO_EAP_THREAD = -1;
46 private String exceptionClass = "";
48 public String getExceptionClass() { return exceptionClass; }
50 protected ExceptionBean (ExceptionBean e) {
51 hashCode = e.hashCode;
52 message = e.message;
53 date = e.date;
54 stackTrace = e.stackTrace;
55 itnThreadId = e.itnThreadId;
56 buildNumber = e.buildNumber;
57 productCode = e.productCode;
58 scrambled = e.scrambled;
61 public ExceptionBean() {
64 public ExceptionBean (Throwable throwable) {
65 if (throwable != null) {
66 exceptionClass = throwable.getClass().getName();
68 message = throwable.getMessage();
70 ByteArrayOutputStream baos = new ByteArrayOutputStream();
71 throwable.printStackTrace(new PrintStream (baos, true));
72 stackTrace = baos.toString();
74 try {
75 hashCode = md5(stackTrace, "stack-trace");
76 } catch (NoSuchAlgorithmException e) {
77 hashCode = null;
82 private static String md5 (String buffer, @NonNls String key)
83 throws NoSuchAlgorithmException {
84 MessageDigest md5 = MessageDigest.getInstance("MD5");
85 md5.update(buffer.getBytes());
86 byte [] code = md5.digest(key.getBytes());
87 BigInteger bi = new BigInteger(code).abs();
88 return bi.abs().toString(16);
91 public String getStackTrace() {
92 return stackTrace;
95 public void setStackTrace(String stackTrace) {
96 this.stackTrace = stackTrace;
99 public String getHashCode() {
100 return hashCode;
103 public void setHashCode(String hashCode) {
104 this.hashCode = hashCode;
107 public Date getDate() {
108 return date;
111 public void setDate(Date date) {
112 this.date = date;
115 public String getBuildNumber() {
116 return buildNumber;
119 public void setBuildNumber(String buildNumber) {
120 this.buildNumber = buildNumber;
123 public String getProductCode() {
124 return productCode;
127 public void setProductCode(String productCode) {
128 this.productCode = productCode;
131 public String getMessage() {
132 return message;
135 public void setMessage(String message) {
136 this.message = message;
139 public int getItnThreadId() {
140 return itnThreadId;
143 public void setItnThreadId(int itnThreadId) {
144 this.itnThreadId = itnThreadId;
147 public boolean isScrambled() {
148 return scrambled;
151 public void setScrambled(boolean scrambled) {
152 this.scrambled = scrambled;