Package com.nfbsoftware.util
Class Severity
java.lang.Object
com.nfbsoftware.util.Severity
0 = (reserved error)
1 = Fatal
2 = Error
3 = Warning
4 = Informational
5 = Success
6 = Debug
7 = (reserved success)
- Author:
- Brendan Clemenzi
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intSeverity level is "DEBUG"; this is considered a success, but also will provide debug information.static final intSeverity level is "ERROR"; this is considered a failure.static final intSeverity level is "FATAL"; this is considered a failure.static final intSeverity level is "INFORMATIONAL"; this is considered a success.static final intSeverity level is "SUCCESS"; this is considered a success.static final intSeverity level is "WARNING"; this is considered a failure. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intReturns a string representing the severity of the code.static StringasString(int severity) Returns a string representing the severity of the code.static booleanatOrAbove(int severity, int threshold) Returns true if the severity is at or above the threshold.static booleanisFailure(int severity) Returns true if the severity of the code is one of the types of severities representing an "error" (which are Warning, Error, Fatal)static booleanisSuccess(int severity) Returns true if the severity of the code is one of the types of severities representing a "success (which are Success, Informational, Debug)
-
Field Details
-
FATAL
public static final int FATALSeverity level is "FATAL"; this is considered a failure.- See Also:
-
ERROR
public static final int ERRORSeverity level is "ERROR"; this is considered a failure.- See Also:
-
WARNING
public static final int WARNINGSeverity level is "WARNING"; this is considered a failure.- See Also:
-
INFORMATIONAL
public static final int INFORMATIONALSeverity level is "INFORMATIONAL"; this is considered a success.- See Also:
-
SUCCESS
public static final int SUCCESSSeverity level is "SUCCESS"; this is considered a success.- See Also:
-
DEBUG
public static final int DEBUGSeverity level is "DEBUG"; this is considered a success, but also will provide debug information.- See Also:
-
-
Constructor Details
-
Severity
public Severity()
-
-
Method Details
-
asString
Returns a string representing the severity of the code.- Parameters:
severity- The severity's integer level.- Returns:
- The first letter of the corresponding Severity level; if the integer does not match any of the severity levels it will return "E" for ERROR.
-
asInt
Returns a string representing the severity of the code.- Parameters:
severityStr- A single letter representation of the Severity levels.- Returns:
- The corresponding int value of the letter. It will return the ERROR value if there are no matches.
-
isFailure
public static boolean isFailure(int severity) Returns true if the severity of the code is one of the types of severities representing an "error" (which are Warning, Error, Fatal)- Parameters:
severity- The integer value of the Severity level- Returns:
- Whether or not the severity is a failure.
-
isSuccess
public static boolean isSuccess(int severity) Returns true if the severity of the code is one of the types of severities representing a "success (which are Success, Informational, Debug)- Parameters:
severity- The integer value of the Severity level- Returns:
- Whether or not the severity is a success.
-
atOrAbove
public static boolean atOrAbove(int severity, int threshold) Returns true if the severity is at or above the threshold. To be "above" implies the same or greater degree of error severity.
Example: int sev = Severity.INFORMATIONAL;
Severity.above(sev, Severity.WARNING) is false
Severity.above(sev, Severity.DEBNUG) is true
NOTE: Because of the way the severity levels are ordered, higher severities are actually lower integers. However, this should be irrelevant to the application since it should not try to do its own comparison of these values.- Parameters:
severity- The int Severity level.threshold- The int threshold level.- Returns:
- true if the severity is at or above the threshold.
-