001: package com.jamonapi;
002:
003: /**
004: * Main workhorse for monitors. For display gets info from key, monitor, and range.
005: *
006: * Created on January 21, 2006, 6:08 PM
007: */
008:
009: import java.util.List;
010:
011: class MonitorImp extends Monitor implements RowData {
012:
013: MonitorImp(MonInternals monData) {
014: super (monData);
015: }
016:
017: private static final MonKey NULL_MON_KEY = new NullMonKey();
018:
019: MonitorImp() {
020: this (NULL_MON_KEY, null, null, false);
021: }
022:
023: // inherited by FrequencyDist
024: MonitorImp(MonKey key, RangeImp range, ActivityStats activityStats,
025: boolean isTimeMonitor) {
026: this .monData.key = key;
027: this .monData.range = range;
028: this .monData.activityStats = activityStats;
029: this .monData.isTimeMonitor = isTimeMonitor;
030: }
031:
032: public List getBasicHeader(List header) {
033: monData.key.getBasicHeader(header);
034: getThisData(header);
035:
036: return header;
037: }
038:
039: private List getThisData(List header) {
040: header.add(monData.name + "Hits");
041: header.add(monData.name + "Avg");
042: header.add(monData.name + "Total");
043: header.add(monData.name + "StdDev");
044: header.add(monData.name + "LastValue");
045: header.add(monData.name + "Min");
046: header.add(monData.name + "Max");
047: header.add(monData.name + "Active");
048: header.add(monData.name + "AvgActive");
049: header.add(monData.name + "MaxActive");
050: header.add(monData.name + "FirstAccess");
051: header.add(monData.name + "LastAccess");
052: header.add(monData.name + "Enabled");
053: header.add(monData.name + "Primary");
054: header.add(monData.name + "HasListeners");
055: return header;
056: }
057:
058: public List getHeader(List header) {
059: monData.key.getHeader(header);
060: getThisData(header);
061:
062: if (monData.range != null)
063: monData.range.getHeader(header);
064:
065: return header;
066: }
067:
068: public List getDisplayHeader(List header) {
069: monData.key.getDisplayHeader(header);
070: getThisData(header);
071:
072: if (monData.range != null)
073: monData.range.getDisplayHeader(header);
074:
075: return header;
076: }
077:
078: public List getBasicRowData(List rowData) {
079: monData.key.getBasicRowData(rowData);
080: return getThisRowData(rowData);
081: }
082:
083: private List getThisRowData(List rowData) {
084: rowData.add(new Double(getHits()));
085: rowData.add(new Double(getAvg()));
086: rowData.add(new Double(getTotal()));
087: rowData.add(new Double(getStdDev()));
088: rowData.add(new Double(getLastValue()));
089: rowData.add(new Double(getMin()));
090: rowData.add(new Double(getMax()));
091: rowData.add(new Double(getActive()));
092: rowData.add(new Double(getAvgActive()));
093: rowData.add(new Double(getMaxActive()));
094: rowData.add(getFirstAccess());
095: rowData.add(getLastAccess());
096: rowData.add(new Boolean(isEnabled()));
097: rowData.add(new Boolean(isPrimary()));
098: rowData.add(new Boolean(hasListeners()));
099:
100: return rowData;
101:
102: }
103:
104: public List getRowData(List rowData) {
105: monData.key.getRowData(rowData);
106: getThisRowData(rowData);
107:
108: if (monData.range != null)
109: monData.range.getRowData(rowData);
110:
111: return rowData;
112:
113: }
114:
115: public List getRowDisplayData(List rowData) {
116: monData.key.getRowDisplayData(rowData);
117: getThisRowData(rowData);
118:
119: if (monData.range != null)
120: monData.range.getRowDisplayData(rowData);
121:
122: return rowData;
123: }
124:
125: public RangeHolder getRangeHolder() {
126: RangeImp r = (RangeImp) getRange();
127: if (r != null)
128: return r.getRangeHolder();
129: else
130: return null;
131: }
132:
133: void setActivityStats(ActivityStats activityStats) {
134: this .monData.activityStats = activityStats;
135: }
136:
137: private static class NullMonKey implements MonKey {
138:
139: public Object getDetails() {
140: return "";
141: }
142:
143: public String getRangeKey() {
144: return "";
145: }
146:
147: public Object getValue(String primaryKey) {
148: return "";
149: }
150:
151: public List getBasicHeader(List header) {
152: return header;
153: }
154:
155: public List getBasicRowData(List rowData) {
156: return rowData;
157: }
158:
159: public List getDisplayHeader(List header) {
160: return header;
161: }
162:
163: public List getHeader(List header) {
164: return header;
165: }
166:
167: public List getRowData(List rowData) {
168: return rowData;
169: }
170:
171: public List getRowDisplayData(List rowData) {
172: return rowData;
173: }
174:
175: public void setDetails(Object details) {
176:
177: }
178:
179: }
180:
181: }
|