| 1 |
tdb |
1.1 |
//---PACKAGE DECLARATION--- |
| 2 |
|
|
package uk.ac.ukc.iscream.client; |
| 3 |
|
|
|
| 4 |
|
|
//---IMPORTS--- |
| 5 |
|
|
import uk.ac.ukc.iscream.util.*; |
| 6 |
|
|
|
| 7 |
|
|
/** |
| 8 |
|
|
* Alert Object |
| 9 |
|
|
* |
| 10 |
ajm |
1.7 |
* @author $Author: ajm4 $ |
| 11 |
ajm |
1.10 |
* @version $Id: Alert.java,v 1.9 2001/03/05 12:45:51 ajm4 Exp $ |
| 12 |
tdb |
1.1 |
*/ |
| 13 |
ajm |
1.3 |
public class Alert { |
| 14 |
tdb |
1.1 |
|
| 15 |
|
|
//---FINAL ATTRIBUTES--- |
| 16 |
|
|
|
| 17 |
|
|
/** |
| 18 |
|
|
* The current CVS revision of this class |
| 19 |
|
|
*/ |
| 20 |
ajm |
1.10 |
public static final String REVISION = "$Revision: 1.9 $"; |
| 21 |
tdb |
1.4 |
|
| 22 |
ajm |
1.8 |
public static final int thresholdNORMAL = 0; |
| 23 |
|
|
public static final int thresholdLOWER = 1; |
| 24 |
|
|
public static final int thresholdUPPER = 2; |
| 25 |
ajm |
1.3 |
|
| 26 |
ajm |
1.8 |
public static final String[] thresholdLevels = {"NORMAL", "LOWER", "UPPER"}; |
| 27 |
|
|
|
| 28 |
|
|
public static final int alertOK = 0; |
| 29 |
|
|
public static final int alertNOTICE = 1; |
| 30 |
|
|
public static final int alertWARNING = 2; |
| 31 |
|
|
public static final int alertCAUTION = 3; |
| 32 |
|
|
public static final int alertCRITICAL = 4; |
| 33 |
ajm |
1.10 |
// note FINAL should be the highest alert |
| 34 |
|
|
public static final int alertFINAL = 5; |
| 35 |
ajm |
1.8 |
|
| 36 |
ajm |
1.10 |
// note FINAL should be last in this list |
| 37 |
|
|
public static final String[] alertLevels = {"OK", "NOTICE", "WARNING", "CAUTION", "CRITICAL", "FINAL"}; |
| 38 |
tdb |
1.1 |
|
| 39 |
|
|
//---STATIC METHODS--- |
| 40 |
|
|
|
| 41 |
|
|
//---CONSTRUCTORS--- |
| 42 |
|
|
|
| 43 |
|
|
/** |
| 44 |
|
|
* Construct an Alert packet at a set level. |
| 45 |
|
|
* |
| 46 |
|
|
* @param level the level of the alert |
| 47 |
|
|
*/ |
| 48 |
ajm |
1.9 |
public Alert(int alertLevel, int lastAlert, int thresholdLevel, String source, String thresholdValue, String value, String attributeName, String timeTillNextAlert) { |
| 49 |
ajm |
1.8 |
_alertLevel = alertLevel; |
| 50 |
ajm |
1.9 |
_lastAlert = lastAlert; |
| 51 |
ajm |
1.8 |
_thresholdLevel = thresholdLevel; |
| 52 |
tdb |
1.5 |
_source = source; |
| 53 |
ajm |
1.3 |
_thresholdValue = thresholdValue; |
| 54 |
|
|
_value = value; |
| 55 |
|
|
_attributeName = attributeName; |
| 56 |
ajm |
1.8 |
_timeTillNextAlert = timeTillNextAlert; |
| 57 |
tdb |
1.1 |
} |
| 58 |
|
|
|
| 59 |
|
|
//---PUBLIC METHODS--- |
| 60 |
|
|
|
| 61 |
|
|
/** |
| 62 |
|
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
| 63 |
|
|
* method to provide clean logging (every class should have this). |
| 64 |
|
|
* |
| 65 |
|
|
* This uses the uk.ac.ukc.iscream.util.FormatName class |
| 66 |
|
|
* to format the toString() |
| 67 |
|
|
* |
| 68 |
|
|
* @return the name of this class and its CVS revision |
| 69 |
|
|
*/ |
| 70 |
|
|
public String toString() { |
| 71 |
|
|
return FormatName.getName( |
| 72 |
|
|
_name, |
| 73 |
|
|
getClass().getName(), |
| 74 |
|
|
REVISION); |
| 75 |
|
|
} |
| 76 |
|
|
|
| 77 |
|
|
//---PRIVATE METHODS--- |
| 78 |
|
|
|
| 79 |
|
|
//---ACCESSOR/MUTATOR METHODS--- |
| 80 |
tdb |
1.2 |
|
| 81 |
|
|
/** |
| 82 |
|
|
* Returns the level of this packet |
| 83 |
|
|
*/ |
| 84 |
|
|
public int getLevel() { |
| 85 |
ajm |
1.8 |
return _alertLevel; |
| 86 |
|
|
} |
| 87 |
|
|
|
| 88 |
ajm |
1.9 |
public int getLastLevel() { |
| 89 |
|
|
return _lastAlert; |
| 90 |
|
|
} |
| 91 |
|
|
|
| 92 |
ajm |
1.8 |
public int getThreshold() { |
| 93 |
|
|
return _thresholdLevel; |
| 94 |
tdb |
1.2 |
} |
| 95 |
ajm |
1.3 |
|
| 96 |
tdb |
1.5 |
public String getSource() { |
| 97 |
|
|
return _source; |
| 98 |
|
|
} |
| 99 |
|
|
|
| 100 |
ajm |
1.3 |
public String getValue() { |
| 101 |
|
|
return _value; |
| 102 |
|
|
} |
| 103 |
|
|
|
| 104 |
|
|
public String getThresholdValue() { |
| 105 |
|
|
return _thresholdValue; |
| 106 |
|
|
} |
| 107 |
|
|
|
| 108 |
|
|
public String getAttributeName() { |
| 109 |
|
|
return _attributeName; |
| 110 |
|
|
} |
| 111 |
ajm |
1.8 |
|
| 112 |
|
|
public String getTimeTillNextAlert() { |
| 113 |
|
|
return _timeTillNextAlert; |
| 114 |
|
|
} |
| 115 |
tdb |
1.1 |
|
| 116 |
|
|
//---ATTRIBUTES--- |
| 117 |
|
|
|
| 118 |
|
|
/** |
| 119 |
|
|
* This is the friendly identifier of the |
| 120 |
|
|
* component this class is running in. |
| 121 |
|
|
* eg, a Filter may be called "filter1", |
| 122 |
|
|
* If this class does not have an owning |
| 123 |
|
|
* component, a name from the configuration |
| 124 |
|
|
* can be placed here. This name could also |
| 125 |
|
|
* be changed to null for utility classes. |
| 126 |
|
|
*/ |
| 127 |
|
|
private String _name = ClientMain.NAME; |
| 128 |
|
|
|
| 129 |
|
|
/** |
| 130 |
|
|
* The alert level of this packet |
| 131 |
|
|
*/ |
| 132 |
ajm |
1.8 |
private int _alertLevel; |
| 133 |
ajm |
1.9 |
|
| 134 |
|
|
private int _lastAlert; |
| 135 |
ajm |
1.8 |
|
| 136 |
|
|
private int _thresholdLevel; |
| 137 |
ajm |
1.3 |
|
| 138 |
tdb |
1.5 |
private String _source; |
| 139 |
ajm |
1.3 |
private String _value; |
| 140 |
|
|
private String _thresholdValue; |
| 141 |
|
|
private String _attributeName; |
| 142 |
ajm |
1.8 |
private String _timeTillNextAlert; |
| 143 |
tdb |
1.1 |
|
| 144 |
|
|
//---STATIC ATTRIBUTES--- |
| 145 |
|
|
|
| 146 |
|
|
} |