1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.log4j.chainsaw;
19
20 import java.util.ArrayList;
21 import java.util.HashMap;
22 import java.util.Iterator;
23 import java.util.List;
24 import java.util.Map;
25
26 import org.apache.log4j.spi.LoggingEvent;
27
28
29 /***
30 * A container class that contains a group of events split up
31 * into branches based on Identifiers
32 * @author Paul Smith <psmith@apache.org>
33 * @author Scott Deboy <sdeboy@apache.org>
34 *
35 */
36 class ChainsawEventBatch {
37 private Map identEventMap = new HashMap();
38
39 ChainsawEventBatch() {
40 }
41
42 /***
43 * @param ident
44 * @param e
45 */
46 void addEvent(String ident, LoggingEvent e) {
47 List events = (List)identEventMap.get(ident);
48
49 if (events == null) {
50 events = new ArrayList();
51 identEventMap.put(ident, events);
52 }
53
54 events.add(e);
55 }
56
57 /***
58 * Returns an iterator of Identifier strings that this payload contains.
59 *
60 * The values returned from this iterator can be used to query the
61 *
62 * @return Iterator
63 */
64 Iterator identifierIterator() {
65 return identEventMap.keySet().iterator();
66 }
67
68 /***
69 * Returns a Collection of LoggingEvent objects that
70 * are bound to the identifier
71 * @param identifier
72 * @return Collection of LoggingEvent instances
73 */
74 List entrySet(String identifier) {
75 return (List) identEventMap.get(identifier);
76 }
77 }