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 |
* @author $Author: ajm4 $ |
11 |
* @version $Id: Alert.java,v 1.9 2001/03/05 12:45:51 ajm4 Exp $ |
12 |
*/ |
13 |
public class Alert { |
14 |
|
15 |
//---FINAL ATTRIBUTES--- |
16 |
|
17 |
/** |
18 |
* The current CVS revision of this class |
19 |
*/ |
20 |
public static final String REVISION = "$Revision: 1.9 $"; |
21 |
|
22 |
public static final int thresholdNORMAL = 0; |
23 |
public static final int thresholdLOWER = 1; |
24 |
public static final int thresholdUPPER = 2; |
25 |
|
26 |
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 |
// note FINAL should be the highest alert |
34 |
public static final int alertFINAL = 5; |
35 |
|
36 |
// note FINAL should be last in this list |
37 |
public static final String[] alertLevels = {"OK", "NOTICE", "WARNING", "CAUTION", "CRITICAL", "FINAL"}; |
38 |
|
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 |
public Alert(int alertLevel, int lastAlert, int thresholdLevel, String source, String thresholdValue, String value, String attributeName, String timeTillNextAlert) { |
49 |
_alertLevel = alertLevel; |
50 |
_lastAlert = lastAlert; |
51 |
_thresholdLevel = thresholdLevel; |
52 |
_source = source; |
53 |
_thresholdValue = thresholdValue; |
54 |
_value = value; |
55 |
_attributeName = attributeName; |
56 |
_timeTillNextAlert = timeTillNextAlert; |
57 |
} |
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 |
|
81 |
/** |
82 |
* Returns the level of this packet |
83 |
*/ |
84 |
public int getLevel() { |
85 |
return _alertLevel; |
86 |
} |
87 |
|
88 |
public int getLastLevel() { |
89 |
return _lastAlert; |
90 |
} |
91 |
|
92 |
public int getThreshold() { |
93 |
return _thresholdLevel; |
94 |
} |
95 |
|
96 |
public String getSource() { |
97 |
return _source; |
98 |
} |
99 |
|
100 |
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 |
|
112 |
public String getTimeTillNextAlert() { |
113 |
return _timeTillNextAlert; |
114 |
} |
115 |
|
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 |
private int _alertLevel; |
133 |
|
134 |
private int _lastAlert; |
135 |
|
136 |
private int _thresholdLevel; |
137 |
|
138 |
private String _source; |
139 |
private String _value; |
140 |
private String _thresholdValue; |
141 |
private String _attributeName; |
142 |
private String _timeTillNextAlert; |
143 |
|
144 |
//---STATIC ATTRIBUTES--- |
145 |
|
146 |
} |