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 |
tdb |
1.12 |
* @version $Id: Alert.java,v 1.11 2001/03/06 02:33:55 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 |
tdb |
1.12 |
public static final String REVISION = "$Revision: 1.11 $"; |
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 |
tdb |
1.12 |
|
64 |
|
|
/** |
65 |
|
|
* Prints a String representation of the Alert object. It |
66 |
|
|
* is designed to resemble a HashMap.toString(), such that |
67 |
|
|
* it is similar to the XMLPacket.printAll() method. |
68 |
|
|
* |
69 |
|
|
* @return a String representation of this Alert object. |
70 |
|
|
*/ |
71 |
|
|
public String printAll() { |
72 |
|
|
String result = "{"; |
73 |
|
|
result += "alertLevel="+_alertLevel+", "; |
74 |
|
|
result += "lastAlert="+_lastAlert+", "; |
75 |
|
|
result += "thresholdLevel="+_thresholdLevel+", "; |
76 |
|
|
result += "source="+_source+", "; |
77 |
|
|
result += "thresholdValue="+_thresholdValue+", "; |
78 |
|
|
result += "value="+_value+", "; |
79 |
|
|
result += "attributeName="+_attributeName+", "; |
80 |
|
|
result += "timeTillNextAlert="+_timeTillNextAlert+", "; |
81 |
|
|
result += "initialAlertTime="+_initialAlertTime; |
82 |
|
|
result += "}"; |
83 |
|
|
return result; |
84 |
|
|
} |
85 |
tdb |
1.1 |
|
86 |
|
|
/** |
87 |
|
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
88 |
|
|
* method to provide clean logging (every class should have this). |
89 |
|
|
* |
90 |
|
|
* This uses the uk.ac.ukc.iscream.util.FormatName class |
91 |
|
|
* to format the toString() |
92 |
|
|
* |
93 |
|
|
* @return the name of this class and its CVS revision |
94 |
|
|
*/ |
95 |
|
|
public String toString() { |
96 |
|
|
return FormatName.getName( |
97 |
|
|
_name, |
98 |
|
|
getClass().getName(), |
99 |
|
|
REVISION); |
100 |
|
|
} |
101 |
|
|
|
102 |
|
|
//---PRIVATE METHODS--- |
103 |
|
|
|
104 |
|
|
//---ACCESSOR/MUTATOR METHODS--- |
105 |
tdb |
1.2 |
|
106 |
|
|
/** |
107 |
|
|
* Returns the level of this packet |
108 |
|
|
*/ |
109 |
|
|
public int getLevel() { |
110 |
ajm |
1.8 |
return _alertLevel; |
111 |
|
|
} |
112 |
|
|
|
113 |
ajm |
1.9 |
public int getLastLevel() { |
114 |
|
|
return _lastAlert; |
115 |
|
|
} |
116 |
|
|
|
117 |
ajm |
1.8 |
public int getThreshold() { |
118 |
|
|
return _thresholdLevel; |
119 |
tdb |
1.2 |
} |
120 |
ajm |
1.3 |
|
121 |
tdb |
1.5 |
public String getSource() { |
122 |
|
|
return _source; |
123 |
|
|
} |
124 |
|
|
|
125 |
ajm |
1.3 |
public String getValue() { |
126 |
|
|
return _value; |
127 |
|
|
} |
128 |
|
|
|
129 |
|
|
public String getThresholdValue() { |
130 |
|
|
return _thresholdValue; |
131 |
|
|
} |
132 |
|
|
|
133 |
|
|
public String getAttributeName() { |
134 |
|
|
return _attributeName; |
135 |
|
|
} |
136 |
ajm |
1.8 |
|
137 |
|
|
public String getTimeTillNextAlert() { |
138 |
|
|
return _timeTillNextAlert; |
139 |
|
|
} |
140 |
ajm |
1.11 |
|
141 |
|
|
public long getInitialAlertTime () { |
142 |
|
|
return _initialAlertTime; |
143 |
|
|
} |
144 |
tdb |
1.1 |
|
145 |
|
|
//---ATTRIBUTES--- |
146 |
|
|
|
147 |
|
|
/** |
148 |
|
|
* This is the friendly identifier of the |
149 |
|
|
* component this class is running in. |
150 |
|
|
* eg, a Filter may be called "filter1", |
151 |
|
|
* If this class does not have an owning |
152 |
|
|
* component, a name from the configuration |
153 |
|
|
* can be placed here. This name could also |
154 |
|
|
* be changed to null for utility classes. |
155 |
|
|
*/ |
156 |
|
|
private String _name = ClientMain.NAME; |
157 |
|
|
|
158 |
|
|
/** |
159 |
|
|
* The alert level of this packet |
160 |
|
|
*/ |
161 |
ajm |
1.8 |
private int _alertLevel; |
162 |
ajm |
1.9 |
|
163 |
|
|
private int _lastAlert; |
164 |
ajm |
1.8 |
|
165 |
|
|
private int _thresholdLevel; |
166 |
ajm |
1.3 |
|
167 |
tdb |
1.5 |
private String _source; |
168 |
ajm |
1.3 |
private String _value; |
169 |
|
|
private String _thresholdValue; |
170 |
|
|
private String _attributeName; |
171 |
ajm |
1.8 |
private String _timeTillNextAlert; |
172 |
ajm |
1.11 |
|
173 |
|
|
private long _initialAlertTime; |
174 |
tdb |
1.1 |
|
175 |
|
|
//---STATIC ATTRIBUTES--- |
176 |
|
|
|
177 |
|
|
} |