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