01: package com.jamonapi;
02:
03: import java.util.Date;
04: import java.util.*;
05:
06: import com.jamonapi.utils.ToArray;
07: import com.jamonapi.utils.Misc;
08:
09: /** Class used to add the label, value and time invoked for the associated monitor. Used in the
10: * jamonBufferListener class.
11: *
12: * @author steve souza
13: *
14: */
15: public final class JAMonDetailValue implements ToArray {
16: // private final String label; // monitor name
17: private final MonKey key;
18: private final double value; // monitors lastValue
19: private final long time; // invocation time
20: private final double active;
21: private boolean keyToString = true;
22: private Object[] row;
23:
24: static JAMonDetailValue NULL_VALUE = new JAMonDetailValue(
25: new MonKeyImp("Null JAMonDetails Object",
26: "Null JAMonDetails Object", ""), 0, 0, 0);
27:
28: public JAMonDetailValue(MonKey key, double value, double active,
29: long time) {
30: // this.label=label;
31: this .key = key;
32: this .value = value;
33: this .active = active;
34: this .time = time;
35: }
36:
37: /** Returns label, value, time as an Object[] of 3 values. */
38: public Object[] toArray() {
39: if (row == null) {
40: if (keyToString)
41: row = new Object[] {
42: Misc.getAsString(key.getDetails()),
43: new Double(value), new Double(active),
44: new Date(time) };
45: else {
46: List list = new ArrayList();
47: Misc.addTo(list, key.getDetails());
48: list.add(new Double(value));
49: list.add(new Double(active));
50: list.add(new Date(time));
51: row = list.toArray();
52: }
53: }
54:
55: return row;
56: }
57:
58: public void setKeyToString(boolean keyToString) {
59: this .keyToString = keyToString;
60: }
61:
62: public boolean isKeyToString() {
63: return keyToString;
64: }
65:
66: }
|