KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > demo > jmx > HistoryData


1 /*
2 @COPYRIGHT@
3 */

4 package demo.jmx;
5
6 import java.text.SimpleDateFormat JavaDoc;
7 import java.util.Date JavaDoc;
8
9 /**
10 * Basic container to hold performance metrics for time interval
11 */

12 public class HistoryData
13 {
14    private final long intervalStart;
15
16    private int counter;
17
18    public HistoryData(long intervalStart, int counter)
19    {
20       this.intervalStart = intervalStart;
21       this.counter = counter;
22    }
23
24    public long getIntervalStart()
25    {
26       return this.intervalStart;
27    }
28
29    public Date JavaDoc getTime()
30    {
31       return new Date JavaDoc(intervalStart);
32    }
33
34    public int getCounter()
35    {
36       return this.counter;
37    }
38
39    public void incrementCounter()
40    {
41       this.counter++;
42    }
43
44    public void update(int duration, String JavaDoc error)
45    {
46       this.counter++;
47    }
48
49    public String JavaDoc toString()
50    {
51       SimpleDateFormat JavaDoc df = new SimpleDateFormat JavaDoc("yyyy-MM-dd HH:mm:ss");
52       return df.format(new Date JavaDoc(intervalStart))+" : "+counter;
53    }
54 }
55
Popular Tags