twaver.alarm
Class AlarmSeverity

java.lang.Object
  extended by twaver.alarm.AlarmSeverity
All Implemented Interfaces:
java.lang.Comparable<AlarmSeverity>

public class AlarmSeverity
extends java.lang.Object
implements java.lang.Comparable<AlarmSeverity>

告警级别,反映告警的紧急程度,默认有六种告警级别


Field Summary
static AlarmSeverity CLEARED
          清除级别
protected  int color
          告警级别颜色
static int COLOR_CLEARED
           
static int COLOR_CRITICAL
           
static int COLOR_INDETERMINATE
           
static int COLOR_MAJOR
           
static int COLOR_MINOR
           
static int COLOR_WARNING
           
static AlarmSeverity CRITICAL
          严重
protected  java.lang.String displayName
          告警级别显示名称
static AlarmSeverity INDETERMINATE
          不确定级别
static AlarmSeverity MAJOR
          重要的
static AlarmSeverity MINOR
          次要的
protected  java.lang.String name
          告警级别名称
static java.lang.String NAME_CLEARED
           
static java.lang.String NAME_CRITICAL
           
static java.lang.String NAME_INDETERMINATE
           
static java.lang.String NAME_MAJOR
           
static java.lang.String NAME_MINOR
           
static java.lang.String NAME_WARNING
           
protected  java.lang.String nickName
          告警级别昵称
static java.lang.String NICKNAME_CLEARED
           
static java.lang.String NICKNAME_CRITICAL
           
static java.lang.String NICKNAME_INDETERMINATE
           
static java.lang.String NICKNAME_MAJOR
           
static java.lang.String NICKNAME_MINOR
           
static java.lang.String NICKNAME_WARNING
           
protected  int value
          告警级别数值,默认按数值越大,级别越高
static int VALUE_CLEARED
           
static int VALUE_CRITICAL
           
static int VALUE_INDETERMINATE
           
static int VALUE_MAJOR
           
static int VALUE_MINOR
           
static int VALUE_WARNING
           
static AlarmSeverity WARNING
          警告
 
Method Summary
static void addAlarmSeverityChangeListener(AlarmSeverityChangeListener l)
          Add a severity change listener.
static void clearAlarmSeverity()
          clear all registered alarm severity, may be used when the user want to define their a new suit of alarm severity
 int compareTo(AlarmSeverity o)
           
 boolean equals(java.lang.Object object)
          By default, only object is an AlarmSeverity object and has the equal value with this alarm severity, this method will return true.
static java.util.List<AlarmSeverity> getAllNonClearedSeverities()
           
static java.util.List<AlarmSeverity> getAllSeverities()
          Get all defined alarm severities.
static AlarmSeverity getByName(java.lang.String name)
          Get the alarm severity via name.
static AlarmSeverity getByValue(int value)
          Get the alarm severity via severity value.
static AlarmSeverity getClearedAlarmSeverity()
          Gets the cleared alarm severity.
 int getColor()
          Get the color of this alarm severity.
 java.lang.String getDisplayName()
          Get the display name of this alarm severity.
 java.lang.String getName()
          Get the name of this alarm severity.
 java.lang.String getNickName()
          Get the nickname of this alarm severity.
static AlarmSeverity getNonClearedRandomSeverity()
          Get a random alarm severity, not include AlarmSeverity.CLEARED.
static AlarmSeverity getRandomSeverity()
          Generate a random alarm severity.
static java.util.Comparator<AlarmSeverity> getSeverityComparator()
          Get the alarm severity comparator object
 int getValue()
          Get the severe value of this alarm severity.
 int hashCode()
           
static AlarmSeverity higher(AlarmSeverity a1, AlarmSeverity a2)
           
static boolean isNonClearedSeverity(AlarmSeverity severity)
          Checks whether the given alarm severity is not a cleared alarm severity.
static java.util.Iterator<AlarmSeverity> iterator()
          Gets a iterator object over all defined alarm severities.
static AlarmSeverity registerAlarmSeverity(java.lang.String name, java.lang.String nickName, int value, int color, java.lang.String displayName)
          Register a new alarm severity.
static void setClearedAlarmSeverity(AlarmSeverity severity)
          Sets the appointed alarm severity as cleared alarm severity.
 void setColor(int color)
          Change the color of this alarm severity.
 void setDisplayName(java.lang.String displayName)
          Change the new display name of this alarm severity.
 void setNickName(java.lang.String nickName)
          Change the new nickname of this severity.
static void setSeverityComparator(java.util.Comparator<AlarmSeverity> severityComparator)
          Set the alarm severity comparator object.
static int size()
          Gets the count of defined alarm severities.
 java.lang.String toString()
          Returns the name of this alarm severity.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NAME_CRITICAL

public static final java.lang.String NAME_CRITICAL
See Also:
Constant Field Values

NAME_MAJOR

public static final java.lang.String NAME_MAJOR
See Also:
Constant Field Values

NAME_MINOR

public static final java.lang.String NAME_MINOR
See Also:
Constant Field Values

NAME_WARNING

public static final java.lang.String NAME_WARNING
See Also:
Constant Field Values

NAME_INDETERMINATE

public static final java.lang.String NAME_INDETERMINATE
See Also:
Constant Field Values

NAME_CLEARED

public static final java.lang.String NAME_CLEARED
See Also:
Constant Field Values

NICKNAME_INDETERMINATE

public static final java.lang.String NICKNAME_INDETERMINATE
See Also:
Constant Field Values

NICKNAME_CRITICAL

public static final java.lang.String NICKNAME_CRITICAL
See Also:
Constant Field Values

NICKNAME_MAJOR

public static final java.lang.String NICKNAME_MAJOR
See Also:
Constant Field Values

NICKNAME_MINOR

public static final java.lang.String NICKNAME_MINOR
See Also:
Constant Field Values

NICKNAME_WARNING

public static final java.lang.String NICKNAME_WARNING
See Also:
Constant Field Values

NICKNAME_CLEARED

public static final java.lang.String NICKNAME_CLEARED
See Also:
Constant Field Values

VALUE_CRITICAL

public static final int VALUE_CRITICAL
See Also:
Constant Field Values

VALUE_MAJOR

public static final int VALUE_MAJOR
See Also:
Constant Field Values

VALUE_MINOR

public static final int VALUE_MINOR
See Also:
Constant Field Values

VALUE_WARNING

public static final int VALUE_WARNING
See Also:
Constant Field Values

VALUE_INDETERMINATE

public static final int VALUE_INDETERMINATE
See Also:
Constant Field Values

VALUE_CLEARED

public static final int VALUE_CLEARED
See Also:
Constant Field Values

COLOR_CRITICAL

public static final int COLOR_CRITICAL
See Also:
Constant Field Values

COLOR_MAJOR

public static final int COLOR_MAJOR
See Also:
Constant Field Values

COLOR_MINOR

public static final int COLOR_MINOR
See Also:
Constant Field Values

COLOR_WARNING

public static final int COLOR_WARNING
See Also:
Constant Field Values

COLOR_INDETERMINATE

public static final int COLOR_INDETERMINATE
See Also:
Constant Field Values

COLOR_CLEARED

public static final int COLOR_CLEARED
See Also:
Constant Field Values

INDETERMINATE

public static AlarmSeverity INDETERMINATE
不确定级别


CRITICAL

public static AlarmSeverity CRITICAL
严重


MAJOR

public static AlarmSeverity MAJOR
重要的


MINOR

public static AlarmSeverity MINOR
次要的


WARNING

public static AlarmSeverity WARNING
警告


CLEARED

public static AlarmSeverity CLEARED
清除级别


value

protected final int value
告警级别数值,默认按数值越大,级别越高


name

protected final java.lang.String name
告警级别名称


color

protected int color
告警级别颜色


nickName

protected java.lang.String nickName
告警级别昵称


displayName

protected java.lang.String displayName
告警级别显示名称

Method Detail

addAlarmSeverityChangeListener

public static void addAlarmSeverityChangeListener(AlarmSeverityChangeListener l)
Add a severity change listener. The listener will be called if any alarm severity definition changed.

Parameters:
l - AlarmSeverityChangeListener the listener

setClearedAlarmSeverity

public static void setClearedAlarmSeverity(AlarmSeverity severity)
Sets the appointed alarm severity as cleared alarm severity. By default, CLEARED is cleared alarm severity.

Parameters:
severity - the appointed alarm severity.

getClearedAlarmSeverity

public static AlarmSeverity getClearedAlarmSeverity()
Gets the cleared alarm severity.

Returns:
the cleared alarm severity.
See Also:
setClearedAlarmSeverity(AlarmSeverity)

getRandomSeverity

public static AlarmSeverity getRandomSeverity()
Generate a random alarm severity.

Returns:
AlarmSeverity alarm severity

getNonClearedRandomSeverity

public static AlarmSeverity getNonClearedRandomSeverity()
Get a random alarm severity, not include AlarmSeverity.CLEARED.

Returns:
AlarmSeverity the random alarm severity

isNonClearedSeverity

public static boolean isNonClearedSeverity(AlarmSeverity severity)
Checks whether the given alarm severity is not a cleared alarm severity.

Parameters:
severity - the alarm severity to be checked.
Returns:
True if the given alarm severity is not a cleared alarm severity, false otherwise.

registerAlarmSeverity

public static AlarmSeverity registerAlarmSeverity(java.lang.String name,
                                                  java.lang.String nickName,
                                                  int value,
                                                  int color,
                                                  java.lang.String displayName)
Register a new alarm severity. if a old alarm severity with the same name of the new alarm severity is registered before, then exception will be throw.

Parameters:
name - alarm severity's name
nickName - alarm severity's nickname
value - alarm severity's value
color - alarm severity's render color
Returns:
the new create alarm severity

clearAlarmSeverity

public static void clearAlarmSeverity()
clear all registered alarm severity, may be used when the user want to define their a new suit of alarm severity


getAllSeverities

public static java.util.List<AlarmSeverity> getAllSeverities()
Get all defined alarm severities.

Returns:
Collection the all defined alarm severities.

getAllNonClearedSeverities

public static java.util.List<AlarmSeverity> getAllNonClearedSeverities()

iterator

public static java.util.Iterator<AlarmSeverity> iterator()
Gets a iterator object over all defined alarm severities.

Returns:
a iterator object over all defined alarm severities.

size

public static int size()
Gets the count of defined alarm severities.

Returns:
the count of defined alarm severities.

getByName

public static AlarmSeverity getByName(java.lang.String name)
Get the alarm severity via name.

Parameters:
name - String the severity name
Returns:
AlarmSeverity the alarm severity equals to the given name

getByValue

public static AlarmSeverity getByValue(int value)
Get the alarm severity via severity value. This value indicate how severe the severity is.

Parameters:
value - int the alarm severity value.
Returns:
AlarmSeverity alarm severity which value equals to the given value.

getColor

public int getColor()
Get the color of this alarm severity.

Returns:
Color the color of this alarm severity.

getName

public java.lang.String getName()
Get the name of this alarm severity.

Returns:
String the alarm severity name.

getNickName

public java.lang.String getNickName()
Get the nickname of this alarm severity.

Returns:
String the nickname of this alarm severity.

getValue

public int getValue()
Get the severe value of this alarm severity.

Returns:
int the severe value of this alarm severity.

setColor

public void setColor(int color)
Change the color of this alarm severity. If this color changed, all user graphical interfaces will be changed automatically.

Parameters:
color - int the new severity color

setDisplayName

public void setDisplayName(java.lang.String displayName)
Change the new display name of this alarm severity.

Parameters:
displayName - String the new display name

setNickName

public void setNickName(java.lang.String nickName)
Change the new nickname of this severity.

Parameters:
nickName - String the new nickname of this severity.

equals

public boolean equals(java.lang.Object object)
By default, only object is an AlarmSeverity object and has the equal value with this alarm severity, this method will return true.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Returns the name of this alarm severity.

Overrides:
toString in class java.lang.Object

getDisplayName

public java.lang.String getDisplayName()
Get the display name of this alarm severity.

Returns:
String the display name of this alarm severity.

compareTo

public int compareTo(AlarmSeverity o)
Specified by:
compareTo in interface java.lang.Comparable<AlarmSeverity>

higher

public static AlarmSeverity higher(AlarmSeverity a1,
                                   AlarmSeverity a2)

getSeverityComparator

public static java.util.Comparator<AlarmSeverity> getSeverityComparator()
Get the alarm severity comparator object

Returns:
Comparator the alarm severity comparator object

setSeverityComparator

public static void setSeverityComparator(java.util.Comparator<AlarmSeverity> severityComparator)
Set the alarm severity comparator object. By default, TWaver use severity value to compare different severities. Use this method to change to a new severity comparator.

Parameters:
severityComparator - Comparator the new alarm severity comparator
See Also:
AlarmSeverityComparator.ASCENDING