KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mx4j > tools > stats > ValueStatisticsRecorder


1 /*
2  * Copyright (C) The MX4J Contributors.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the MX4J License version 1.0.
6  * See the terms of the MX4J License in the documentation provided with this software.
7  */

8
9 package mx4j.tools.stats;
10
11 import java.util.Date JavaDoc;
12
13 /**
14  * ValueStatisticsRecorder records statistics of an attribute
15  * based on changes on the variable value. If you want to use you have to explictly
16  * set the variable value.
17  * <p/>
18  * Example usage:
19  * <pre>
20  * ObjectName name = new ObjectName("Domain:name=value");
21  * server.createMBean("mx4j.tools.stats.ValueStatisticsRecorder", name, null);
22  * server.invoke(name, "start", null, null);
23  * // Every time the value is set the statistics are updated
24  * server.setAttribute(name, "Attribute", new Double(10));
25  * </pre>
26  *
27  * @version $Revision: 1.5 $
28  */

29 public class ValueStatisticsRecorder extends AbstractStatisticsRecorder implements ValueStatisticsRecorderMBean
30 {
31    protected Number JavaDoc value = null;
32
33    public void setValue(Number JavaDoc value)
34    {
35       this.value = value;
36       addEntry(new Date JavaDoc(), value);
37    }
38
39    public Number JavaDoc getValue()
40    {
41       return value;
42    }
43
44    public String JavaDoc toString()
45    {
46       return "ValueStatisticsRecorder";
47    }
48
49 }
50
Popular Tags