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.10 2001/03/06 01:40:24 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.10 $"; |
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 |
// not OK and FINAL MUST be present...at the beginning and the end |
29 |
|
30 |
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 |
// note FINAL should be the highest alert |
36 |
public static final int alertFINAL = 5; |
37 |
|
38 |
// note FINAL should be last in this list |
39 |
public static final String[] alertLevels = {"OK", "NOTICE", "WARNING", "CAUTION", "CRITICAL", "FINAL"}; |
40 |
|
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 |
public Alert(int alertLevel, int lastAlert, int thresholdLevel, String source, String thresholdValue, String value, String attributeName, String timeTillNextAlert, long initialAlertTime) { |
51 |
_alertLevel = alertLevel; |
52 |
_lastAlert = lastAlert; |
53 |
_thresholdLevel = thresholdLevel; |
54 |
_source = source; |
55 |
_thresholdValue = thresholdValue; |
56 |
_value = value; |
57 |
_attributeName = attributeName; |
58 |
_timeTillNextAlert = timeTillNextAlert; |
59 |
_initialAlertTime = initialAlertTime; |
60 |
} |
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 |
|
84 |
/** |
85 |
* Returns the level of this packet |
86 |
*/ |
87 |
public int getLevel() { |
88 |
return _alertLevel; |
89 |
} |
90 |
|
91 |
public int getLastLevel() { |
92 |
return _lastAlert; |
93 |
} |
94 |
|
95 |
public int getThreshold() { |
96 |
return _thresholdLevel; |
97 |
} |
98 |
|
99 |
public String getSource() { |
100 |
return _source; |
101 |
} |
102 |
|
103 |
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 |
|
115 |
public String getTimeTillNextAlert() { |
116 |
return _timeTillNextAlert; |
117 |
} |
118 |
|
119 |
public long getInitialAlertTime () { |
120 |
return _initialAlertTime; |
121 |
} |
122 |
|
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 |
private int _alertLevel; |
140 |
|
141 |
private int _lastAlert; |
142 |
|
143 |
private int _thresholdLevel; |
144 |
|
145 |
private String _source; |
146 |
private String _value; |
147 |
private String _thresholdValue; |
148 |
private String _attributeName; |
149 |
private String _timeTillNextAlert; |
150 |
|
151 |
private long _initialAlertTime; |
152 |
|
153 |
//---STATIC ATTRIBUTES--- |
154 |
|
155 |
} |