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.
|
Status(int severity,
String pluginId,
String message)
Simplified constructor of a new status object; assumes that code is
OK and
exception is null . |
Status(int severity,
String pluginId,
String message,
Throwable exception)
Simplified constructor of a new status object; assumes that code is
OK . |
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 CANCEL
pluginId
- the unique identifier of the relevant plug-incode
- the plug-in-specific status code, or OK
message
- a human-readable message, localized to the
current localeexception
- a low-level exception, or null
if not
applicablepublic Status(int severity, String pluginId, String message, Throwable exception)
OK
.
The created status has no children.severity
- the severity; one of OK
, ERROR
,
INFO
, WARNING
, or CANCEL
pluginId
- the unique identifier of the relevant plug-inmessage
- a human-readable message, localized to the
current localeexception
- a low-level exception, or null
if not
applicablepublic Status(int severity, String pluginId, String message)
OK
and
exception is null
. The created status has no children.severity
- the severity; one of OK
, ERROR
,
INFO
, WARNING
, or CANCEL
pluginId
- the unique identifier of the relevant plug-inmessage
- a human-readable message, localized to the
current localepublic IStatus[] getChildren()
IStatus
getChildren
in interface IStatus
IStatus.isMultiStatus()
public int getCode()
IStatus
public Throwable getException()
IStatus
null
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 IStatus
null
if nonepublic String getMessage()
IStatus
getMessage
in interface IStatus
public String getPlugin()
IStatus
public int getSeverity()
IStatus
CANCEL
- 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 IStatus
OK
, ERROR
,
INFO
, WARNING
, or CANCEL
IStatus.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 IStatus
true
for a multi-status,
false
otherwiseIStatus.getChildren()
public boolean isOK()
IStatus
public boolean matches(int severityMask)
IStatus
OK
will never match; use isOK
instead to detect
a status with a severity of OK
.matches
in interface IStatus
severityMask
- 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.INFO
protected void setCode(int code)
code
- the plug-in-specific status code, or OK
protected 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 CANCEL
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.