KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > AnalysisError


1 package edu.umd.cs.findbugs;
2
3 import java.util.ArrayList JavaDoc;
4
5 /**
6  * Object recording a recoverable error that occurred during analysis.
7  *
8  * @author David Hovemeyer
9  */

10 public class AnalysisError {
11     private String JavaDoc message;
12     private String JavaDoc exceptionMessage;
13     private String JavaDoc[] stackTrace;
14     
15     /**
16      * Constructor.
17      *
18      * @param message message describing the error
19      */

20     public AnalysisError(String JavaDoc message) {
21         this(message, null);
22     }
23     
24     /**
25      * Constructor.
26      *
27      * @param message message describing the error
28      * @param exception exception which is the cause of the error
29      */

30     public AnalysisError(String JavaDoc message, Throwable JavaDoc exception) {
31         this.message = message;
32         if (exception != null) {
33             exceptionMessage = exception.toString();
34             StackTraceElement JavaDoc[] exceptionStackTrace = exception.getStackTrace();
35             ArrayList JavaDoc<String JavaDoc> arr = new ArrayList JavaDoc<String JavaDoc>();
36             for (StackTraceElement JavaDoc aExceptionStackTrace : exceptionStackTrace) {
37                 arr.add(aExceptionStackTrace.toString());
38             }
39             stackTrace = arr.toArray(new String JavaDoc[arr.size()]);
40         }
41     }
42
43     /**
44      * Set the message describing the error.
45      *
46      * @param message message describing the error
47      */

48     public void setMessage(String JavaDoc message) {
49         this.message = message;
50     }
51     
52     /**
53      * Get the message describing the error.
54      */

55     public String JavaDoc getMessage() {
56         return message;
57     }
58
59     /**
60      * Set the exception message. This is the value returned by
61      * calling toString() on the original exception object.
62      *
63      * @param exceptionMessage the exception message
64      */

65     public void setExceptionMessage(String JavaDoc exceptionMessage) {
66         this.exceptionMessage = exceptionMessage;
67     }
68     
69     /**
70      * Get the exception message. This is the value returned by
71      * calling toString() on the original exception object.
72      */

73     public String JavaDoc getExceptionMessage() {
74         return exceptionMessage;
75     }
76
77     /**
78      * Set the stack trace elements.
79      * These are the strings returned by calling toString()
80      * on each StackTraceElement in the original exception.
81      *
82      * @param stackTraceList the stack trace elements
83      */

84     public void setStackTrace(String JavaDoc[] stackTraceList) {
85         stackTrace = stackTraceList;
86     }
87
88     /**
89      * Get the stack trace elements.
90      * These are the strings returned by calling toString()
91      * on each StackTraceElement in the original exception.
92      */

93     public String JavaDoc[] getStackTrace() {
94         return stackTrace;
95     }
96 }
97
Popular Tags