HistoryData.java
01 /**
02  *
03  * All content copyright (c) 2003-2008 Terracotta, Inc.,
04  * except as may otherwise be noted in a separate copyright notice.
05  * All rights reserved.
06  *
07  */
08 package demo.jmx;
09 
10 import java.text.SimpleDateFormat;
11 import java.util.Date;
12 
13 /**
14  *  Basic container to hold performance metrics for time interval
15  *
16  *@author    Terracotta, Inc.
17  */
18 public class HistoryData {
19    private final long intervalStart;
20 
21    private int counter;
22 
23    public HistoryData(long intervalStart, int counter) {
24       this.intervalStart = intervalStart;
25       this.counter = counter;
26    }
27 
28    public long getIntervalStart() {
29       return this.intervalStart;
30    }
31 
32    public Date getTime() {
33       return new Date(intervalStart);
34    }
35 
36    public int getCounter() {
37       return this.counter;
38    }
39 
40    public void incrementCounter() {
41       this.counter++;
42    }
43 
44    public void update(int duration, String error) {
45       this.counter++;
46    }
47 
48    public String toString() {
49       SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
50       return df.format(new Date(intervalStart)) " : " + counter;
51    }
52 }