1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package net.sf.jour.statistic;
22
23 import java.util.*;
24
25
26 import org.apache.log4j.Logger;
27
28 /***
29 * TODO Add docs
30 *
31 * Created on 13.12.2004
32 * Contributing Author(s):
33 *
34 * Misha Lifschitz <mishalifschitz at users.sourceforge.net> (Inital implementation)
35 * Vlad Skarzhevskyy <vlads at users.sourceforge.net> (Inital implementation)
36 *
37 * @author vlads
38 * @version $Revision: 1.2 $ ($Author: vlads $) $Date: 2004/12/15 08:00:40 $
39 */
40 public class AccumulationItmesList extends AccumulationItem implements AccumulationList {
41
42 protected static final Logger log = Logger.getLogger(AccumulationItmesList.class);
43
44 private Map items;
45
46
47
48
49 private boolean simpleAccumulation = false;
50
51
52 public AccumulationItmesList() {
53 items = new HashMap();
54 }
55
56 /***
57 * Allow inherited overwite the new Accumulations types
58 */
59 public Accumulation createAccumulation(Object key) {
60 return new AccumulationItem();
61 }
62
63 public void onNewAccumulation(Object key, Accumulation accumulation) {
64
65 }
66
67 public void reset() {
68 super.reset();
69 this.items = new HashMap();
70 }
71
72
73
74
75 public void add(Object key, Object num) {
76 if (!this.simpleAccumulation) {
77 Accumulation accumulation = getItem(key);
78 if (accumulation == null) {
79 accumulation = createAccumulation(key);
80 onNewAccumulation(key, accumulation);
81 items.put(key, accumulation);
82 }
83 accumulation.add(num);
84 }
85 super.add(num);
86 }
87
88
89
90
91 public Set getKeys() {
92
93 return items.keySet();
94 }
95
96
97
98
99 public Accumulation getItem(Object key) {
100 return (Accumulation)items.get(key);
101 }
102
103 }