Class Status
- java.lang.Object
-
- org.eclipse.core.runtime.Status
-
- All Implemented Interfaces:
IStatus
- Direct Known Subclasses:
MergeStatus,ModelStatus,MultiStatus,OperationStatus,TeamStatus,ValidationStatus
public class Status extends Object implements IStatus
A concrete status implementation, suitable either for instantiating or subclassing.This class can be used without OSGi running.
For performance critical code, such as when
Statusobjects are not created for logging or error handling, there may be a small performance penalty when using static methods or constructors that automatically determine the plug-in id from the providedClassor by usingStackWalker.
-
-
Constructor Summary
Constructors Constructor Description Status(int severity, Class<?> caller, int code, String message, Throwable exception)Creates a new status object.Status(int severity, Class<?> caller, String message)Simplified constructor of a new status object; assumes that code isOKand exception isnull.Status(int severity, Class<?> caller, String message, Throwable exception)Simplified constructor of a new status object; assumes that code isOK.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 isOKand exception isnull.Status(int severity, String pluginId, String message, Throwable exception)Simplified constructor of a new status object; assumes that code isOK.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static IStatuserror(String message)Construct a new status object with severityIStatus.ERROR, codeIStatus.OK, and pluginId determined automatically from the calling class usingStackWalker.static IStatuserror(String message, Throwable exception)Construct a new status object with severityIStatus.ERROR, codeIStatus.OK, and pluginId determined automatically from the calling class usingStackWalker.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.intgetCode()Returns the plug-in-specific status code describing the outcome.ThrowablegetException()Returns the relevant low-level exception, ornullif none.StringgetMessage()Returns the message describing the outcome.StringgetPlugin()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).intgetSeverity()Returns the severity.static IStatusinfo(String message)Construct a new status object with severityIStatus.INFO, codeIStatus.OK, and pluginId determined automatically from the calling class usingStackWalker.booleanisMultiStatus()Returns whether this status is a multi-status.booleanisOK()Returns whether this status indicates everything is okay (neither info, warning, nor error).booleanmatches(int severityMask)Returns whether the severity of this status matches the given severity mask.protected voidsetCode(int code)Sets the status code.protected voidsetException(Throwable exception)Sets the exception.protected voidsetMessage(String message)Sets the message.protected voidsetPlugin(String pluginId)Sets the plug-in id.protected voidsetSeverity(int severity)Sets the severity.StringtoString()Returns a string representation of the status, suitable for debugging purposes only.static IStatuswarning(String message)Construct a new status object with severityIStatus.WARNING, codeIStatus.OK, and pluginId determined automatically from the calling class usingStackWalker.static Statuswarning(String message, Throwable exception)Construct a new status object with severityIStatus.WARNING, codeIStatus.OK, and pluginId determined automatically from the calling class usingStackWalker.
-
-
-
Constructor Detail
-
Status
public Status(int severity, Class<?> caller, int code, String message, Throwable exception)Creates a new status object. The created status has no children.- Parameters:
severity- the severity; one ofOK,ERROR,INFO,WARNING, orCANCELcaller- the relevant class to build unique identifier fromcode- the caller-specific status code, orOKmessage- a human-readable message, localized to the current localeexception- a low-level exception, ornullif not applicable- Since:
- 3.12
-
Status
public Status(int severity, String pluginId, int code, String message, Throwable exception)Creates a new status object. The created status has no children.- Parameters:
severity- the severity; one ofOK,ERROR,INFO,WARNING, orCANCELpluginId- the unique identifier of the relevant plug-incode- the plug-in-specific status code, orOKmessage- a human-readable message, localized to the current localeexception- a low-level exception, ornullif not applicable
-
Status
public Status(int severity, Class<?> caller, String message, Throwable exception)Simplified constructor of a new status object; assumes that code isOK. The created status has no children.- Parameters:
severity- the severity; one ofOK,ERROR,INFO,WARNING, orCANCELcaller- the relevant class to build unique identifier frommessage- a human-readable message, localized to the current localeexception- a low-level exception, ornullif not applicable- Since:
- 3.12
-
Status
public Status(int severity, String pluginId, String message, Throwable exception)Simplified constructor of a new status object; assumes that code isOK. The created status has no children.- Parameters:
severity- the severity; one ofOK,ERROR,INFO,WARNING, orCANCELpluginId- the unique identifier of the relevant plug-inmessage- a human-readable message, localized to the current localeexception- a low-level exception, ornullif not applicable- Since:
- org.eclipse.equinox.common 3.3
-
Status
public Status(int severity, Class<?> caller, String message)Simplified constructor of a new status object; assumes that code isOKand exception isnull. The created status has no children.- Parameters:
severity- the severity; one ofOK,ERROR,INFO,WARNING, orCANCELcaller- the relevant class to build unique identifier frommessage- a human-readable message, localized to the current locale- Since:
- 3.12
-
Status
public Status(int severity, String pluginId, String message)Simplified constructor of a new status object; assumes that code isOKand exception isnull. The created status has no children.- Parameters:
severity- the severity; one ofOK,ERROR,INFO,WARNING, orCANCELpluginId- the unique identifier of the relevant plug-inmessage- a human-readable message, localized to the current locale- Since:
- org.eclipse.equinox.common 3.3
-
-
Method Detail
-
info
public static IStatus info(String message)
Construct a new status object with severityIStatus.INFO, codeIStatus.OK, and pluginId determined automatically from the calling class usingStackWalker. The created status has no children.- Parameters:
message- a human-readable message, localized to the current locale- Returns:
- the newly created status
- Since:
- 3.15
-
warning
public static IStatus warning(String message)
Construct a new status object with severityIStatus.WARNING, codeIStatus.OK, and pluginId determined automatically from the calling class usingStackWalker. The created status has no children.- Parameters:
message- a human-readable message, localized to the current locale- Returns:
- the newly created status
- Since:
- 3.15
-
warning
public static Status warning(String message, Throwable exception)
Construct a new status object with severityIStatus.WARNING, codeIStatus.OK, and pluginId determined automatically from the calling class usingStackWalker. The created status has no children.- Parameters:
message- a human-readable message, localized to the current localeexception- a low-level exception, ornullif not applicable- Returns:
- the newly created status
- Since:
- 3.15
-
error
public static IStatus error(String message)
Construct a new status object with severityIStatus.ERROR, codeIStatus.OK, and pluginId determined automatically from the calling class usingStackWalker. The created status has no children.- Parameters:
message- a human-readable message, localized to the current locale- Returns:
- the newly created status
- Since:
- 3.15
-
error
public static IStatus error(String message, Throwable exception)
Construct a new status object with severityIStatus.ERROR, codeIStatus.OK, and pluginId determined automatically from the calling class usingStackWalker. The created status has no children.- Parameters:
message- a human-readable message, localized to the current localeexception- a low-level exception, ornullif not applicable- Returns:
- the newly created status
- Since:
- 3.15
-
getChildren
public IStatus[] getChildren()
Description copied from interface:IStatusReturns a list of status object immediately contained in this multi-status, or an empty list if this is not a multi-status.- Specified by:
getChildrenin interfaceIStatus- Returns:
- an array of status objects
- See Also:
IStatus.isMultiStatus()
-
getCode
public int getCode()
Description copied from interface:IStatusReturns the plug-in-specific status code describing the outcome.
-
getException
public Throwable getException()
Description copied from interface:IStatusReturns the relevant low-level exception, ornullif none. For example, when an operation fails because of a network communications failure, this might return thejava.io.IOExceptiondescribing the exact nature of that failure.- Specified by:
getExceptionin interfaceIStatus- Returns:
- the relevant low-level exception, or
nullif none
-
getMessage
public String getMessage()
Description copied from interface:IStatusReturns the message describing the outcome. The message is localized to the current locale.- Specified by:
getMessagein interfaceIStatus- Returns:
- a localized message
-
getPlugin
public String getPlugin()
Description copied from interface:IStatusReturns the unique identifier of the plug-in associated with this status (this is the plug-in that defines the meaning of the status code).
-
getSeverity
public int getSeverity()
Description copied from interface:IStatusReturns the severity. The severities are as follows (in descending order):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
OKif it has no children.- Specified by:
getSeverityin interfaceIStatus- Returns:
- the severity: one of
OK,ERROR,INFO,WARNING, orCANCEL - See Also:
IStatus.matches(int)
-
isMultiStatus
public boolean isMultiStatus()
Description copied from interface:IStatusReturns whether this status is a multi-status. A multi-status describes the outcome of an operation involving multiple operands.The severity of a multi-status is derived from the severities of its children; a multi-status with no children is
OKby 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.- Specified by:
isMultiStatusin interfaceIStatus- Returns:
truefor a multi-status,falseotherwise- See Also:
IStatus.getChildren()
-
isOK
public boolean isOK()
Description copied from interface:IStatusReturns whether this status indicates everything is okay (neither info, warning, nor error).
-
matches
public boolean matches(int severityMask)
Description copied from interface:IStatusReturns whether the severity of this status matches the given severity mask. Note that a status with severityOKwill never match; useisOKinstead to detect a status with a severity ofOK.- Specified by:
matchesin interfaceIStatus- Parameters:
severityMask- a mask formed by bitwise or'ing severity mask constants (ERROR,WARNING,INFO,CANCEL)- Returns:
trueif there is at least one match,falseif there are no matches- See Also:
IStatus.getSeverity(),IStatus.CANCEL,IStatus.ERROR,IStatus.WARNING,IStatus.INFO
-
setCode
protected void setCode(int code)
Sets the status code.- Parameters:
code- the plug-in-specific status code, orOK
-
setException
protected void setException(Throwable exception)
Sets the exception.- Parameters:
exception- a low-level exception, ornullif not applicable
-
setMessage
protected void setMessage(String message)
Sets the message. If null is passed, message is set to an empty string.- Parameters:
message- a human-readable message, localized to the current locale
-
setPlugin
protected void setPlugin(String pluginId)
Sets the plug-in id.- Parameters:
pluginId- the unique identifier of the relevant plug-in
-
setSeverity
protected void setSeverity(int severity)
Sets the severity.- Parameters:
severity- the severity; one ofOK,ERROR,INFO,WARNING, orCANCEL
-
-