1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.statistics.impl;
18
19 import java.util.ArrayList;
20 import java.util.Iterator;
21 import java.util.List;
22 import java.util.Map;
23
24 import org.apache.jetspeed.statistics.AggregateStatistics;
25
26 /***
27 * AggregateStatisticsImpl
28 *
29 * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer </a>
30 * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
31 * @version $Id: $
32 */
33 public class AggregateStatisticsImpl implements AggregateStatistics
34 {
35
36 private float avgProcessingTime;
37
38 private float maxProcessingTime;
39
40 private float minProcessingTime;
41
42 private float stddevProcessingTime;
43
44 private int hitcount;
45
46 private List statlist;
47
48 public AggregateStatisticsImpl()
49 {
50 statlist = new ArrayList();
51 }
52
53 public void addRow(Map row)
54 {
55 statlist.add(row);
56 }
57
58
59
60
61
62
63 public float getAvgProcessingTime()
64 {
65 return this.avgProcessingTime;
66 }
67
68
69
70
71
72
73 public int getHitCount()
74 {
75 return this.hitcount;
76 }
77
78
79
80
81
82
83 public float getMaxProcessingTime()
84 {
85 return this.maxProcessingTime;
86 }
87
88
89
90
91
92
93 public float getMinProcessingTime()
94 {
95 return this.minProcessingTime;
96 }
97
98
99
100
101
102
103
104 public void setHitCount(int hitCount)
105 {
106
107 this.hitcount = hitCount;
108 }
109
110
111
112
113
114
115 public void setMaxProcessingTime(float time)
116 {
117 this.maxProcessingTime = Math.round(time);
118 }
119
120
121
122
123
124
125 public void setMinProcessingTime(float time)
126 {
127 this.minProcessingTime = Math.round(time);
128 }
129
130
131
132
133 public void setAvgProcessingTime(float time)
134 {
135 this.avgProcessingTime = Math.round(time);
136
137 }
138
139
140 public String toString()
141 {
142 String s = "hit count = " + this.hitcount + "\n";
143 s = s + "max time = " + this.maxProcessingTime + "\n";
144 s = s + "min time = " + this.minProcessingTime + "\n";
145 s = s + "avg time = " + this.avgProcessingTime + "\n";
146 s = s + "stddev = " + this.stddevProcessingTime + "\n";
147 String listStr ="";
148 Iterator it = this.statlist.iterator();
149 int count = 0;
150 int size = statlist.size();
151 int max = 5;
152 while((it.hasNext()) && (count++<max)) {
153 Object o = it.next();
154 listStr = listStr+"\t"+o+"\n";
155 }
156 if(size > max) {
157 s = s + "\tlist (top "+max+"):\n"+listStr;
158 } else {
159 s = s + "\tlist ("+size+" entries):\n"+listStr;
160 }
161 return s;
162 }
163
164 /***
165 * @return Returns the statlist.
166 */
167 public List getStatlist()
168 {
169 return statlist;
170 }
171
172 /***
173 * @param statlist
174 * The statlist to set.
175 */
176 public void setStatlist(List statlist)
177 {
178 this.statlist = statlist;
179 }
180 }