Source code: juju/reattore/util/StatRegistry.java
1 /* Reattore HTTP Server
2
3 Copyright (C) 2002 Michael Hope <michaelh@juju.net.nz>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 $Id: StatRegistry.java,v 1.8 2003/03/03 05:14:39 michaelh Exp $
20 */
21 package juju.reattore.util;
22
23 import java.util.*;
24
25 /** Statistic manager.
26 */
27 public class StatRegistry {
28 private static final List ALL = new ArrayList();
29
30 /** Register a new statistic with this manager.
31
32 @param stat The stat to register.
33 */
34 public static void register(Stat stat) {
35 ALL.add(stat);
36 }
37
38 /** Summarise all of the registered statistics.
39
40 @return Summaries for each stat.
41 */
42 public static String summarise() {
43 StringBuffer ret = new StringBuffer("Statistics:\n");
44
45 for (Iterator i = ALL.iterator(); i.hasNext();) {
46 Stat stat = (Stat) i.next();
47
48 ret.append(stat.format());
49 ret.append("\n");
50 }
51
52 return ret.toString();
53 }
54
55 /** Get a list of all of the stats in the registry.
56
57 @return All the stats.
58 */
59 public static List getAll() {
60 return ALL;
61 }
62 }