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