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
FieldsModifier and TypeFieldDescriptionstatic final intStatus severity constant (value 3) indicating this status represents an error.static final intStatus severity constant (value 4) indicating this status represents a fatal error.static final intStatus severity constant (value 1) indicating this status is informational only.static final intStatus severity constant (value 0) indicating this status represents the nominal case.static final intStatus severity constant (value 2) indicating this status represents a warning. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new refactoring status with an empty list of status entries and a severity ofOK. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEntry(int severity, String msg, RefactoringStatusContext context, String pluginId, int code) Adds a new entry filled with the given arguments to this status.voidaddEntry(int severity, String msg, RefactoringStatusContext context, String pluginId, int code, Object data) Adds a new entry filled with the given arguments to this status.voidaddEntry(RefactoringStatusEntry entry) Adds the givenRefactoringStatusEntry.voidAdds anERRORentry filled with the given message to this status.voidaddError(String msg, RefactoringStatusContext context) Adds anERRORentry filled with the given message and context to this status.voidaddFatalError(String msg) Adds aFATALentry filled with the given message to this status.voidaddFatalError(String msg, RefactoringStatusContext context) Adds aFATALentry filled with the given message and status to this status.voidAdds anINFOentry filled with the given message to this status.voidaddInfo(String msg, RefactoringStatusContext context) Adds anINFOentry filled with the given message and context to this status.voidaddWarning(String msg) Adds aWARNINGentry filled with the given message to this status.voidaddWarning(String msg, RefactoringStatusContext context) Adds aWARNINGentry filled with the given message and context to this status.static RefactoringStatusCreates a newRefactoringStatusfrom the givenIStatus.static RefactoringStatuscreateErrorStatus(String msg) Creates a newRefactoringStatuswith oneERRORentry filled with the given message.static RefactoringStatuscreateErrorStatus(String msg, RefactoringStatusContext context) Creates aRefactoringStatuswith oneERRORentry fill with the given message and context.static RefactoringStatusCreates a newRefactoringStatuswith oneFATALentry filled with the given message.static RefactoringStatuscreateFatalErrorStatus(String msg, RefactoringStatusContext context) Creates aRefactoringStatuswith oneFATALentry fill with the given message and context.static RefactoringStatuscreateInfoStatus(String msg) Creates a newRefactoringStatuswith oneINFOentry filled with the given message.static RefactoringStatuscreateInfoStatus(String msg, RefactoringStatusContext context) Creates a newRefactoringStatuswith oneINFOentry filled with the given message and context.static RefactoringStatuscreateStatus(int severity, String msg, RefactoringStatusContext context, String pluginId, int code, Object data) Creates a newRefactoringStatuswith one entry filled with the given arguments.static RefactoringStatusCreates a newRefactoringStatuswith oneWARNINGentry filled with the given message.static RefactoringStatuscreateWarningStatus(String msg, RefactoringStatusContext context) Creates aRefactoringStatuswith oneWARNINGentry 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 theRefactoringStatusEntryat 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.intReturns the severity.booleanReturns whether the status has entries or not.booleanhasError()Returnstrueif the current severity isFATALorERROR.booleanReturnstrueif the current severity isFATAL.booleanhasInfo()Returnstrueif the current severity isFATAL,ERROR,WARNINGorINFO.booleanReturnstrueif the current severity isFATAL,ERRORorWARNING.booleanisOK()Returns whether the status's severity isOKor not.voidmerge(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
ERRORstatus 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:
trueif the status as any entries; otherwisefalseis returned.
-
getEntryAt
Returns theRefactoringStatusEntryat 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. Returnsnullif 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;
nullotherwise
-
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. Returnsnullif no entry matches.- Parameters:
severity- the severity to search for. Must be one ofFATAL,ERROR,WARNINGorINFO- 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
nullif 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. Returnsnullif no entry matches.- Parameters:
severity- the severity to search for. Must be one ofFATAL,ERROR,WARNINGorINFO- 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 newRefactoringStatuswith one entry filled with the given arguments.- Parameters:
severity- the severitymsg- the messagecontext- the context. Can benullpluginId- the plug-in identifier. Can benullif argumentcodeequalsNO_CODEcode- the problem code. Must be eitherNO_CODEor a positive integerdata- application specific data- Returns:
- the newly created refactoring status
- See Also:
-
createInfoStatus
Creates a newRefactoringStatuswith oneINFOentry filled with the given message.- Parameters:
msg- the message of the info entry- Returns:
- the refactoring status
- See Also:
-
createInfoStatus
Creates a newRefactoringStatuswith oneINFOentry 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 newRefactoringStatuswith oneWARNINGentry filled with the given message.- Parameters:
msg- the message of the warning entry- Returns:
- the refactoring status
- See Also:
-
createWarningStatus
Creates aRefactoringStatuswith oneWARNINGentry 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 newRefactoringStatuswith oneERRORentry filled with the given message.- Parameters:
msg- the message of the error entry- Returns:
- the refactoring status
- See Also:
-
createErrorStatus
Creates aRefactoringStatuswith oneERRORentry 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 newRefactoringStatuswith oneFATALentry 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 aRefactoringStatuswith oneFATALentry 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 newRefactoringStatusfrom 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 aMultiStatusthen 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 withnullis allowed - it has no effect.- Parameters:
other- the refactoring status to merge with
-
addInfo
Adds anINFOentry filled with the given message to this status. If the current severity isOKit will be changed toINFO. It will remain unchanged otherwise.- Parameters:
msg- the message of the info entry- See Also:
-
addInfo
Adds anINFOentry filled with the given message and context to this status. If the current severity isOKit 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 aWARNINGentry filled with the given message to this status. If the current severity isOKorINFOit will be changed toWARNING. It will remain unchanged otherwise.- Parameters:
msg- the message of the warning entry- See Also:
-
addWarning
Adds aWARNINGentry filled with the given message and context to this status. If the current severity isOKorINFOit 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 anERRORentry filled with the given message to this status. If the current severity isOK,INFOorWARNINGit will be changed toERROR. It will remain unchanged otherwise.- Parameters:
msg- the message of the error entry- See Also:
-
addError
Adds anERRORentry filled with the given message and context to this status. If the current severity isOK,INFOorWARNINGit 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 aFATALentry 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 aFATALentry 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 offSeverityandseverity.- Parameters:
severity- the severity of the entrymsg- the message of the entrycontext- the context of the entry. Can benullpluginId- the plug-in identifier of the entry. Can benullif argumentcodeequalsNO_CODEcode- the problem code of the entry. Must be eitherNO_CODEor 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 offSeverityandseverity.- Parameters:
severity- the severity of the entrymsg- the message of the entrycontext- the context of the entry. Can benullpluginId- the plug-in identifier of the entry. Can benullif argumentcodeequalsNO_CODEcode- the problem code of the entry. Must be eitherNO_CODEor a positive integerdata- application specific data of the entry
-
addEntry
Adds the givenRefactoringStatusEntry. The severity of this status is set to the maximum offSeverityand the severity of the entry.- Parameters:
entry- theRefactoringStatusEntryto be added
-
isOK
public boolean isOK()Returns whether the status's severity isOKor not.- Returns:
trueif the severity isOK; otherwisefalseis returned
-
hasFatalError
public boolean hasFatalError()Returnstrueif the current severity isFATAL.- Returns:
trueif the current severity isFATAL; otherwisefalseis returned
-
hasError
public boolean hasError()Returnstrueif the current severity isFATALorERROR.- Returns:
trueif the current severity isFATALorERROR; otherwisefalseis returned
-
hasWarning
public boolean hasWarning()Returnstrueif the current severity isFATAL,ERRORorWARNING.- Returns:
trueif the current severity isFATAL,ERRORorWARNING; otherwisefalseis returned
-
hasInfo
public boolean hasInfo()Returnstrueif the current severity isFATAL,ERROR,WARNINGorINFO.- Returns:
trueif the current severity isFATAL,ERROR,WARNINGorINFO; otherwisefalseis returned
-
toString
-