001: /*
002: * $Id: IncidentInfo.java,v 1.2 2005/10/10 18:01:42 rbair Exp $
003: *
004: * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
005: * Santa Clara, California 95054, U.S.A. All rights reserved.
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
020: */
021:
022: /**
023: * This is abstract class that incapsulates all the information needed
024: * to report a problem to the automated report/processing system.
025: *
026: * @author Alexander Zuev
027: * @version 1.0
028: */package org.jdesktop.swingx;
029:
030: public class IncidentInfo {
031: /**
032: * Short string that will be used as a error header
033: */
034: private String header;
035: /**
036: * Basic message that describes incident
037: */
038: private String basicErrorMessage;
039: /**
040: * Message that will fully describe the incident with all the
041: * available details
042: */
043: private String detailedErrorMessage;
044: /**
045: * Optional Throwable that will be used
046: */
047: private Throwable errorException;
048:
049: /**
050: * Main constructor that adds all the information to IncidentInfo
051: * @param header
052: * @param basicErrorMessage
053: * @param detailedErrorMesage
054: * @param errorException
055: */
056: public IncidentInfo(String header, String basicErrorMessage,
057: String detailedErrorMesage, Throwable errorException) {
058: this .header = header;
059: if (basicErrorMessage != null) {
060: this .basicErrorMessage = basicErrorMessage;
061: } else {
062: if (errorException != null) {
063: this .basicErrorMessage = errorException
064: .getLocalizedMessage();
065: } else {
066: this .basicErrorMessage = "";
067: }
068: }
069: this .detailedErrorMessage = detailedErrorMesage;
070: this .errorException = errorException;
071: }
072:
073: public IncidentInfo(String header, String basicErrorMessage,
074: String detailedErrorMessage) {
075: this (header, basicErrorMessage, detailedErrorMessage, null);
076: }
077:
078: public IncidentInfo(String header, Throwable errorException) {
079: this (header, null, null, errorException);
080: }
081:
082: /**
083: * Get the current header string
084: *
085: * @return header string
086: */
087: public String getHeader() {
088: return header;
089: }
090:
091: /**
092: * Set the current header string
093: *
094: * @param header
095: */
096: public void setHeader(String header) {
097: this .header = header;
098: }
099:
100: /**
101: * Get the basic error description
102: *
103: * @return basic error description
104: */
105: public String getBasicErrorMessage() {
106: return basicErrorMessage;
107: }
108:
109: /**
110: * Set the current basic error description
111: *
112: * @param basicErrorMessage
113: */
114: public void setBasicErrorMessage(String basicErrorMessage) {
115: this .basicErrorMessage = basicErrorMessage;
116: }
117:
118: /**
119: * Get the detailed error description
120: *
121: * @return detailed description
122: */
123: public String getDetailedErrorMessage() {
124: return detailedErrorMessage;
125: }
126:
127: /**
128: * Set the detailed description for this error
129: *
130: * @param detailedErrorMessage
131: */
132: public void setDetailedErrorMessage(String detailedErrorMessage) {
133: this .detailedErrorMessage = detailedErrorMessage;
134: }
135:
136: /**
137: * Get an exception that contains some additional information about the
138: * error if provided.
139: *
140: * @return exception or null if no exception provided
141: */
142: public Throwable getErrorException() {
143: return errorException;
144: }
145:
146: /**
147: * Set the exception that may contain additional information about the
148: * error.
149: *
150: * @param errorException
151: */
152: public void setErrorException(Throwable errorException) {
153: this.errorException = errorException;
154: }
155: }
|