KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > actions > StatusInfo


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.debug.internal.ui.actions;
12
13 import org.eclipse.core.runtime.Assert;
14 import org.eclipse.core.runtime.IStatus;
15 import org.eclipse.debug.internal.ui.DebugUIPlugin;
16
17 /**
18  * A settable IStatus.
19  * Can be an error, warning, info or ok. For error, info and warning states,
20  * a message describes the problem.
21  */

22 public class StatusInfo implements IStatus {
23     
24     private String JavaDoc fStatusMessage;
25     private int fSeverity;
26     
27     /**
28      * Creates a status set to OK (no message)
29      */

30     public StatusInfo() {
31         this(OK, null);
32     }
33
34     /**
35      * Creates a status .
36      * @param severity The status severity: ERROR, WARNING, INFO and OK.
37      * @param message The message of the status. Applies only for ERROR,
38      * WARNING and INFO.
39      */

40     public StatusInfo(int severity, String JavaDoc message) {
41         fStatusMessage= message;
42         fSeverity= severity;
43     }
44     
45     /**
46      * Returns if the status' severity is OK.
47      */

48     public boolean isOK() {
49         return fSeverity == IStatus.OK;
50     }
51
52     /**
53      * Returns if the status' severity is WARNING.
54      */

55     public boolean isWarning() {
56         return fSeverity == IStatus.WARNING;
57     }
58
59     /**
60      * Returns if the status' severity is INFO.
61      */

62     public boolean isInfo() {
63         return fSeverity == IStatus.INFO;
64     }
65
66     /**
67      * Returns if the status' severity is ERROR.
68      */

69     public boolean isError() {
70         return fSeverity == IStatus.ERROR;
71     }
72     
73     /**
74      * @see IStatus#getMessage
75      */

76     public String JavaDoc getMessage() {
77         return fStatusMessage;
78     }
79     
80     /**
81      * Sets the status to ERROR.
82      * @param The error message (can be empty, but not null)
83      */

84     public void setError(String JavaDoc errorMessage) {
85         Assert.isNotNull(errorMessage);
86         fStatusMessage= errorMessage;
87         fSeverity= IStatus.ERROR;
88     }
89
90     /**
91      * Sets the status to WARNING.
92      * @param The warning message (can be empty, but not null)
93      */

94     public void setWarning(String JavaDoc warningMessage) {
95         Assert.isNotNull(warningMessage);
96         fStatusMessage= warningMessage;
97         fSeverity= IStatus.WARNING;
98     }
99
100     /**
101      * Sets the status to INFO.
102      * @param The info message (can be empty, but not null)
103      */

104     public void setInfo(String JavaDoc infoMessage) {
105         Assert.isNotNull(infoMessage);
106         fStatusMessage= infoMessage;
107         fSeverity= IStatus.INFO;
108     }
109
110     /**
111      * Sets the status to OK.
112      */

113     public void setOK() {
114         fStatusMessage= null;
115         fSeverity= IStatus.OK;
116     }
117     
118     /*
119      * @see IStatus#matches(int)
120      */

121     public boolean matches(int severityMask) {
122         return (fSeverity & severityMask) != 0;
123     }
124
125     /**
126      * Returns always <code>false</code>.
127      * @see IStatus#isMultiStatus()
128      */

129     public boolean isMultiStatus() {
130         return false;
131     }
132
133     /*
134      * @see IStatus#getSeverity()
135      */

136     public int getSeverity() {
137         return fSeverity;
138     }
139
140     /*
141      * @see IStatus#getPlugin()
142      */

143     public String JavaDoc getPlugin() {
144         return DebugUIPlugin.getUniqueIdentifier();
145     }
146
147     /**
148      * Returns always <code>null</code>.
149      * @see IStatus#getException()
150      */

151     public Throwable JavaDoc getException() {
152         return null;
153     }
154
155     /**
156      * Returns always the error severity.
157      * @see IStatus#getCode()
158      */

159     public int getCode() {
160         return fSeverity;
161     }
162
163     /**
164      * Returns always <code>null</code>.
165      * @see IStatus#getChildren()
166      */

167     public IStatus[] getChildren() {
168         return new IStatus[0];
169     }
170
171 }
172
Popular Tags