Class RefactoringStatus
RefactoringStatus
object represents the outcome of a
condition checking operation. It manages a list of
RefactoringStatusEntry
objects. Each RefactoringStatusEntry
object describes one particular problem detected during
condition checking.
Additionally a problem severity is managed. Severities are ordered as follows:
OK
< INFO
< WARNING
<
ERROR
< FATAL
. The status's problem severity is the maximum
of the severities of all entries. If the status doesn't have any entry the status's
severity is OK
.
Note: this class is not intended to be extended by clients.
- Since:
- 3.0
- See Also:
- Restriction:
- This class is not intended to be subclassed by clients.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Status severity constant (value 3) indicating this status represents an error.static final int
Status severity constant (value 4) indicating this status represents a fatal error.static final int
Status severity constant (value 1) indicating this status is informational only.static final int
Status severity constant (value 0) indicating this status represents the nominal case.static final int
Status severity constant (value 2) indicating this status represents a warning. -
Constructor Summary
ConstructorDescriptionCreates a new refactoring status with an empty list of status entries and a severity ofOK
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEntry
(int severity, String msg, RefactoringStatusContext context, String pluginId, int code) Adds a new entry filled with the given arguments to this status.void
addEntry
(int severity, String msg, RefactoringStatusContext context, String pluginId, int code, Object data) Adds a new entry filled with the given arguments to this status.void
addEntry
(RefactoringStatusEntry entry) Adds the givenRefactoringStatusEntry
.void
Adds anERROR
entry filled with the given message to this status.void
addError
(String msg, RefactoringStatusContext context) Adds anERROR
entry filled with the given message and context to this status.void
addFatalError
(String msg) Adds aFATAL
entry filled with the given message to this status.void
addFatalError
(String msg, RefactoringStatusContext context) Adds aFATAL
entry filled with the given message and status to this status.void
Adds anINFO
entry filled with the given message to this status.void
addInfo
(String msg, RefactoringStatusContext context) Adds anINFO
entry filled with the given message and context to this status.void
addWarning
(String msg) Adds aWARNING
entry filled with the given message to this status.void
addWarning
(String msg, RefactoringStatusContext context) Adds aWARNING
entry filled with the given message and context to this status.static RefactoringStatus
Creates a newRefactoringStatus
from the givenIStatus
.static RefactoringStatus
createErrorStatus
(String msg) Creates a newRefactoringStatus
with oneERROR
entry filled with the given message.static RefactoringStatus
createErrorStatus
(String msg, RefactoringStatusContext context) Creates aRefactoringStatus
with oneERROR
entry fill with the given message and context.static RefactoringStatus
Creates a newRefactoringStatus
with oneFATAL
entry filled with the given message.static RefactoringStatus
createFatalErrorStatus
(String msg, RefactoringStatusContext context) Creates aRefactoringStatus
with oneFATAL
entry fill with the given message and context.static RefactoringStatus
createInfoStatus
(String msg) Creates a newRefactoringStatus
with oneINFO
entry filled with the given message.static RefactoringStatus
createInfoStatus
(String msg, RefactoringStatusContext context) Creates a newRefactoringStatus
with oneINFO
entry filled with the given message and context.static RefactoringStatus
createStatus
(int severity, String msg, RefactoringStatusContext context, String pluginId, int code, Object data) Creates a newRefactoringStatus
with one entry filled with the given arguments.static RefactoringStatus
Creates a newRefactoringStatus
with oneWARNING
entry filled with the given message.static RefactoringStatus
createWarningStatus
(String msg, RefactoringStatusContext context) Creates aRefactoringStatus
with oneWARNING
entry fill with the given message and context.Returns the list of refactoring status entries.getEntries
(IRefactoringStatusEntryComparator comparator, RefactoringStatusEntry entry) Returns a list of refactoring status entries which are considered equal to the specified status entry.getEntryAt
(int index) Returns theRefactoringStatusEntry
at the specified index.getEntryMatchingCode
(String pluginId, int code) Returns the first entry managed by this refactoring status that matches the given plug-in identifier and code.getEntryMatchingSeverity
(int severity) Returns the first entry which severity is equal or greater than the given severity.Returns the entry with the highest severity.getMessageMatchingSeverity
(int severity) Returns the first message which severity is equal or greater than the given severity.int
Returns the severity.boolean
Returns whether the status has entries or not.boolean
hasError()
Returnstrue
if the current severity isFATAL
orERROR
.boolean
Returnstrue
if the current severity isFATAL
.boolean
hasInfo()
Returnstrue
if the current severity isFATAL
,ERROR
,WARNING
orINFO
.boolean
Returnstrue
if the current severity isFATAL
,ERROR
orWARNING
.boolean
isOK()
Returns whether the status's severity isOK
or not.void
merge
(RefactoringStatus other) Merges the receiver and the parameter statuses.toString()
-
Field Details
-
OK
public static final int OKStatus severity constant (value 0) indicating this status represents the nominal case.- See Also:
-
INFO
public static final int INFOStatus severity constant (value 1) indicating this status is informational only.- See Also:
-
WARNING
public static final int WARNINGStatus severity constant (value 2) indicating this status represents a warning.Use this severity if the refactoring can be performed, but you assume that the user could not be aware of problems or confusions resulting from the execution.
- See Also:
-
ERROR
public static final int ERRORStatus severity constant (value 3) indicating this status represents an error.Use this severity if the refactoring can be performed, but the refactoring will not be behavior preserving and/or the partial execution will lead to an inconsistent state (e.g. compile errors).
- See Also:
-
FATAL
public static final int FATALStatus severity constant (value 4) indicating this status represents a fatal error.Use this severity if the refactoring cannot be performed, and execution would lead to major problems. Note that this completely blocks the user from performing this refactoring. It is often preferable to use an
ERROR
status and allow a partial execution (e.g. if just one reference to a refactored element cannot be updated).- See Also:
-
-
Constructor Details
-
RefactoringStatus
public RefactoringStatus()Creates a new refactoring status with an empty list of status entries and a severity ofOK
.
-
-
Method Details
-
getSeverity
public int getSeverity()Returns the severity.- Returns:
- the severity.
-
getEntries
Returns the list of refactoring status entries.- Returns:
- the list of refactoring status entries. Returns an empty array if no entries are managed.
-
getEntries
public RefactoringStatusEntry[] getEntries(IRefactoringStatusEntryComparator comparator, RefactoringStatusEntry entry) Returns a list of refactoring status entries which are considered equal to the specified status entry.- Parameters:
comparator
- the comparator to determine whether two status entries are considered equalentry
- the refactoring status entry to compare the entries of this status with- Returns:
- the list of refactoring status entries that are considered equal to the specified one, in no particular order. Returns an empty array if no entries are managed or none of them matches.
- Since:
- 3.1
-
hasEntries
public boolean hasEntries()Returns whether the status has entries or not.- Returns:
true
if the status as any entries; otherwisefalse
is returned.
-
getEntryAt
Returns theRefactoringStatusEntry
at the specified index.- Parameters:
index
- the index of the entry to return- Returns:
- the entry at the specified index
- Throws:
IndexOutOfBoundsException
- if the index is out of range
-
getEntryMatchingCode
Returns the first entry managed by this refactoring status that matches the given plug-in identifier and code. If more than one entry exists that matches the criteria the first one in the list of entries is returned. Returnsnull
if no entry matches.- Parameters:
pluginId
- the entry's plug-in identifiercode
- the entry's code- Returns:
- the entry that matches the given plug-in identifier and
code;
null
otherwise
-
getEntryMatchingSeverity
Returns the first entry which severity is equal or greater than the given severity. If more than one entry exists that matches the criteria the first one is returned. Returnsnull
if no entry matches.- Parameters:
severity
- the severity to search for. Must be one ofFATAL
,ERROR
,WARNING
orINFO
- Returns:
- the entry that matches the search criteria
-
getEntryWithHighestSeverity
Returns the entry with the highest severity. If there is more than one entry that matches the first one found in the list of entries is returned.- Returns:
- the entry with the highest severity or
null
if no entries are present - Since:
- 3.1
-
getMessageMatchingSeverity
Returns the first message which severity is equal or greater than the given severity. If more than one entry exists that matches the criteria the first one is returned. Returnsnull
if no entry matches.- Parameters:
severity
- the severity to search for. Must be one ofFATAL
,ERROR
,WARNING
orINFO
- Returns:
- the message of the entry that matches the search criteria
-
createStatus
public static RefactoringStatus createStatus(int severity, String msg, RefactoringStatusContext context, String pluginId, int code, Object data) Creates a newRefactoringStatus
with one entry filled with the given arguments.- Parameters:
severity
- the severitymsg
- the messagecontext
- the context. Can benull
pluginId
- the plug-in identifier. Can benull
if argumentcode
equalsNO_CODE
code
- the problem code. Must be eitherNO_CODE
or a positive integerdata
- application specific data- Returns:
- the newly created refactoring status
- See Also:
-
createInfoStatus
Creates a newRefactoringStatus
with oneINFO
entry filled with the given message.- Parameters:
msg
- the message of the info entry- Returns:
- the refactoring status
- See Also:
-
createInfoStatus
Creates a newRefactoringStatus
with oneINFO
entry filled with the given message and context.- Parameters:
msg
- the message of the info entrycontext
- the context of the info entry- Returns:
- the refactoring status
- See Also:
-
createWarningStatus
Creates a newRefactoringStatus
with oneWARNING
entry filled with the given message.- Parameters:
msg
- the message of the warning entry- Returns:
- the refactoring status
- See Also:
-
createWarningStatus
Creates aRefactoringStatus
with oneWARNING
entry fill with the given message and context.- Parameters:
msg
- the message of the warning entrycontext
- the context of the warning entry- Returns:
- the refactoring status
- See Also:
-
createErrorStatus
Creates a newRefactoringStatus
with oneERROR
entry filled with the given message.- Parameters:
msg
- the message of the error entry- Returns:
- the refactoring status
- See Also:
-
createErrorStatus
Creates aRefactoringStatus
with oneERROR
entry fill with the given message and context.- Parameters:
msg
- the message of the error entrycontext
- the context of the error entry- Returns:
- the refactoring status
- See Also:
-
createFatalErrorStatus
Creates a newRefactoringStatus
with oneFATAL
entry filled with the given message.- Parameters:
msg
- the message of the fatal entry- Returns:
- the refactoring status
- See Also:
-
createFatalErrorStatus
public static RefactoringStatus createFatalErrorStatus(String msg, RefactoringStatusContext context) Creates aRefactoringStatus
with oneFATAL
entry fill with the given message and context.- Parameters:
msg
- the message of the fatal entrycontext
- the context of the fatal entry- Returns:
- the refactoring status
- See Also:
-
create
Creates a newRefactoringStatus
from the givenIStatus
. An OK status is mapped to an OK refactoring status, an information status is mapped to a warning refactoring status, a warning status is mapped to an error refactoring status and an error or cancel status is mapped to a fatal refactoring status. An unknown status is converted into a fatal error status as well. If the status is aMultiStatus
then the first level of children of the status will be added as refactoring status entries to the created refactoring status.- Parameters:
status
- the status to create a refactoring status from- Returns:
- the refactoring status
- Since:
- 3.2
- See Also:
-
merge
Merges the receiver and the parameter statuses. The resulting list of entries in the receiver will contain entries from both. The resulting severity in the receiver will be the more severe of its current severity and the parameter's severity. Merging withnull
is allowed - it has no effect.- Parameters:
other
- the refactoring status to merge with
-
addInfo
Adds anINFO
entry filled with the given message to this status. If the current severity isOK
it will be changed toINFO
. It will remain unchanged otherwise.- Parameters:
msg
- the message of the info entry- See Also:
-
addInfo
Adds anINFO
entry filled with the given message and context to this status. If the current severity isOK
it will be changed toINFO
. It will remain unchanged otherwise.- Parameters:
msg
- the message of the info entrycontext
- the context of the info entry- See Also:
-
addWarning
Adds aWARNING
entry filled with the given message to this status. If the current severity isOK
orINFO
it will be changed toWARNING
. It will remain unchanged otherwise.- Parameters:
msg
- the message of the warning entry- See Also:
-
addWarning
Adds aWARNING
entry filled with the given message and context to this status. If the current severity isOK
orINFO
it will be changed toWARNING
. It will remain unchanged otherwise.- Parameters:
msg
- the message of the warning entrycontext
- the context of the warning entry- See Also:
-
addError
Adds anERROR
entry filled with the given message to this status. If the current severity isOK
,INFO
orWARNING
it will be changed toERROR
. It will remain unchanged otherwise.- Parameters:
msg
- the message of the error entry- See Also:
-
addError
Adds anERROR
entry filled with the given message and context to this status. If the current severity isOK
,INFO
orWARNING
it will be changed toERROR
. It will remain unchanged otherwise.- Parameters:
msg
- the message of the error entrycontext
- the context of the error entry- See Also:
-
addFatalError
Adds aFATAL
entry filled with the given message to this status. The severity of this status will changed toFATAL
.- Parameters:
msg
- the message of the fatal entry- See Also:
-
addFatalError
Adds aFATAL
entry filled with the given message and status to this status. The severity of this status will changed toFATAL
.- Parameters:
msg
- the message of the fatal entrycontext
- the context of the fatal entry- See Also:
-
addEntry
public void addEntry(int severity, String msg, RefactoringStatusContext context, String pluginId, int code) Adds a new entry filled with the given arguments to this status. The severity of this status is set to the maximum offSeverity
andseverity
.- Parameters:
severity
- the severity of the entrymsg
- the message of the entrycontext
- the context of the entry. Can benull
pluginId
- the plug-in identifier of the entry. Can benull
if argumentcode
equalsNO_CODE
code
- the problem code of the entry. Must be eitherNO_CODE
or a positive integer
-
addEntry
public void addEntry(int severity, String msg, RefactoringStatusContext context, String pluginId, int code, Object data) Adds a new entry filled with the given arguments to this status. The severity of this status is set to the maximum offSeverity
andseverity
.- Parameters:
severity
- the severity of the entrymsg
- the message of the entrycontext
- the context of the entry. Can benull
pluginId
- the plug-in identifier of the entry. Can benull
if argumentcode
equalsNO_CODE
code
- the problem code of the entry. Must be eitherNO_CODE
or a positive integerdata
- application specific data of the entry
-
addEntry
Adds the givenRefactoringStatusEntry
. The severity of this status is set to the maximum offSeverity
and the severity of the entry.- Parameters:
entry
- theRefactoringStatusEntry
to be added
-
isOK
public boolean isOK()Returns whether the status's severity isOK
or not.- Returns:
true
if the severity isOK
; otherwisefalse
is returned
-
hasFatalError
public boolean hasFatalError()Returnstrue
if the current severity isFATAL
.- Returns:
true
if the current severity isFATAL
; otherwisefalse
is returned
-
hasError
public boolean hasError()Returnstrue
if the current severity isFATAL
orERROR
.- Returns:
true
if the current severity isFATAL
orERROR
; otherwisefalse
is returned
-
hasWarning
public boolean hasWarning()Returnstrue
if the current severity isFATAL
,ERROR
orWARNING
.- Returns:
true
if the current severity isFATAL
,ERROR
orWARNING
; otherwisefalse
is returned
-
hasInfo
public boolean hasInfo()Returnstrue
if the current severity isFATAL
,ERROR
,WARNING
orINFO
.- Returns:
true
if the current severity isFATAL
,ERROR
,WARNING
orINFO
; otherwisefalse
is returned
-
toString
-