public class Status extends Object implements IStatus
This class can be used without OSGi running.
| Modifier and Type | Field and Description |
|---|---|
static IStatus |
CANCEL_STATUS
A standard CANCEL status with no message.
|
static IStatus |
OK_STATUS
A standard OK status with an "ok" message.
|
| Constructor and Description |
|---|
Status(int severity,
String pluginId,
int code,
String message,
Throwable exception)
Creates a new status object.
|
| Modifier and Type | Method and Description |
|---|---|
IStatus[] |
getChildren()
Returns a list of status object immediately contained in this
multi-status, or an empty list if this is not a multi-status.
|
int |
getCode()
Returns the plug-in-specific status code describing the outcome.
|
Throwable |
getException()
Returns the relevant low-level exception, or
null if none. |
String |
getMessage()
Returns the message describing the outcome.
|
String |
getPlugin()
Returns the unique identifier of the plug-in associated with this status
(this is the plug-in that defines the meaning of the status code).
|
int |
getSeverity()
Returns the severity.
|
boolean |
isMultiStatus()
Returns whether this status is a multi-status.
|
boolean |
isOK()
Returns whether this status indicates everything is okay
(neither info, warning, nor error).
|
boolean |
matches(int severityMask)
Returns whether the severity of this status matches the given
severity mask.
|
protected void |
setCode(int code)
Sets the status code.
|
protected void |
setException(Throwable exception)
Sets the exception.
|
protected void |
setMessage(String message)
Sets the message.
|
protected void |
setPlugin(String pluginId)
Sets the plug-in id.
|
protected void |
setSeverity(int severity)
Sets the severity.
|
String |
toString()
Returns a string representation of the status, suitable
for debugging purposes only.
|
public static final IStatus OK_STATUS
public static final IStatus CANCEL_STATUS
public Status(int severity,
String pluginId,
int code,
String message,
Throwable exception)
severity - the severity; one of OK, ERROR,
INFO, WARNING, or CANCELpluginId - the unique identifier of the relevant plug-incode - the plug-in-specific status code, or OKmessage - a human-readable message, localized to the
current localeexception - a low-level exception, or null if not
applicablepublic IStatus[] getChildren()
IStatusgetChildren in interface IStatusIStatus.isMultiStatus()public int getCode()
IStatuspublic Throwable getException()
IStatusnull if none.
For example, when an operation fails because of a network communications
failure, this might return the java.io.IOException
describing the exact nature of that failure.getException in interface IStatusnull if nonepublic String getMessage()
IStatusgetMessage in interface IStatuspublic String getPlugin()
IStatuspublic int getSeverity()
IStatusCANCEL - cancelation occurredERROR - a serious error (most severe)WARNING - a warning (less severe)INFO - an informational ("fyi") message (least severe)OK - everything is just fine
The severity of a multi-status is defined to be the maximum
severity of any of its children, or OK if it has
no children.
getSeverity in interface IStatusOK, ERROR,
INFO, WARNING, or CANCELIStatus.matches(int)public boolean isMultiStatus()
IStatus
The severity of a multi-status is derived from the severities
of its children; a multi-status with no children is
OK by definition.
A multi-status carries a plug-in identifier, a status code,
a message, and an optional exception. Clients may treat
multi-status objects in a multi-status unaware way.
isMultiStatus in interface IStatustrue for a multi-status,
false otherwiseIStatus.getChildren()public boolean isOK()
IStatuspublic boolean matches(int severityMask)
IStatusOK
will never match; use isOK instead to detect
a status with a severity of OK.matches in interface IStatusseverityMask - a mask formed by bitwise or'ing severity mask
constants (ERROR, WARNING,
INFO, CANCEL)true if there is at least one match,
false if there are no matchesIStatus.getSeverity(),
IStatus.CANCEL,
IStatus.ERROR,
IStatus.WARNING,
IStatus.INFOprotected void setCode(int code)
code - the plug-in-specific status code, or OKprotected void setException(Throwable exception)
exception - a low-level exception, or null if not
applicableprotected void setMessage(String message)
message - a human-readable message, localized to the
current localeprotected void setPlugin(String pluginId)
pluginId - the unique identifier of the relevant plug-inprotected void setSeverity(int severity)
severity - the severity; one of OK, ERROR,
INFO, WARNING, or CANCELGuidelines for using Eclipse APIs. Copyright (c) IBM Corp. and others 2000, 2006. All rights reserved.