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 |
tdb |
1.2 |
* @author $Author: tdb1 $ |
11 |
ajm |
1.3 |
* @version $Id: Alert.java,v 1.2 2001/02/28 00:07:58 tdb1 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.3 |
public static final String REVISION = "$Revision: 1.2 $"; |
21 |
tdb |
1.1 |
|
22 |
|
|
// DEFINE MORE ALERT LEVELS HERE |
23 |
tdb |
1.2 |
public static final int OK = 0; |
24 |
ajm |
1.3 |
public static final int WARNING = 1; |
25 |
|
|
public static final int FATAL = 2; |
26 |
|
|
|
27 |
|
|
public static final String[] alerts = {"OK", "WARNING", "FATAL"}; |
28 |
tdb |
1.1 |
|
29 |
|
|
//---STATIC METHODS--- |
30 |
|
|
|
31 |
|
|
//---CONSTRUCTORS--- |
32 |
|
|
|
33 |
|
|
/** |
34 |
|
|
* Construct an Alert packet at a set level. |
35 |
|
|
* |
36 |
|
|
* @param level the level of the alert |
37 |
|
|
*/ |
38 |
ajm |
1.3 |
public Alert(int level, String thresholdValue, String value, String attributeName) { |
39 |
tdb |
1.1 |
_level = level; |
40 |
ajm |
1.3 |
_thresholdValue = thresholdValue; |
41 |
|
|
_value = value; |
42 |
|
|
_attributeName = attributeName; |
43 |
tdb |
1.1 |
} |
44 |
|
|
|
45 |
|
|
//---PUBLIC METHODS--- |
46 |
|
|
|
47 |
|
|
/** |
48 |
|
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
49 |
|
|
* method to provide clean logging (every class should have this). |
50 |
|
|
* |
51 |
|
|
* This uses the uk.ac.ukc.iscream.util.FormatName class |
52 |
|
|
* to format the toString() |
53 |
|
|
* |
54 |
|
|
* @return the name of this class and its CVS revision |
55 |
|
|
*/ |
56 |
|
|
public String toString() { |
57 |
|
|
return FormatName.getName( |
58 |
|
|
_name, |
59 |
|
|
getClass().getName(), |
60 |
|
|
REVISION); |
61 |
|
|
} |
62 |
|
|
|
63 |
|
|
//---PRIVATE METHODS--- |
64 |
|
|
|
65 |
|
|
//---ACCESSOR/MUTATOR METHODS--- |
66 |
tdb |
1.2 |
|
67 |
|
|
/** |
68 |
|
|
* Returns the level of this packet |
69 |
|
|
*/ |
70 |
|
|
public int getLevel() { |
71 |
|
|
return _level; |
72 |
|
|
} |
73 |
ajm |
1.3 |
|
74 |
|
|
public String getValue() { |
75 |
|
|
return _value; |
76 |
|
|
} |
77 |
|
|
|
78 |
|
|
public String getThresholdValue() { |
79 |
|
|
return _thresholdValue; |
80 |
|
|
} |
81 |
|
|
|
82 |
|
|
public String getAttributeName() { |
83 |
|
|
return _attributeName; |
84 |
|
|
} |
85 |
tdb |
1.1 |
|
86 |
|
|
//---ATTRIBUTES--- |
87 |
|
|
|
88 |
|
|
/** |
89 |
|
|
* This is the friendly identifier of the |
90 |
|
|
* component this class is running in. |
91 |
|
|
* eg, a Filter may be called "filter1", |
92 |
|
|
* If this class does not have an owning |
93 |
|
|
* component, a name from the configuration |
94 |
|
|
* can be placed here. This name could also |
95 |
|
|
* be changed to null for utility classes. |
96 |
|
|
*/ |
97 |
|
|
private String _name = ClientMain.NAME; |
98 |
|
|
|
99 |
|
|
/** |
100 |
|
|
* The alert level of this packet |
101 |
|
|
*/ |
102 |
|
|
private int _level; |
103 |
ajm |
1.3 |
|
104 |
|
|
private String _value; |
105 |
|
|
private String _thresholdValue; |
106 |
|
|
private String _attributeName; |
107 |
tdb |
1.1 |
|
108 |
|
|
//---STATIC ATTRIBUTES--- |
109 |
|
|
|
110 |
|
|
} |