EMMA Coverage Report (generated Tue May 01 18:46:53 CEST 2007)
[all classes][dk.deepthought.sidious.util]

COVERAGE SUMMARY FOR SOURCE FILE [SidiousMap.java]

nameclass, %method, %block, %line, %
SidiousMap.java100% (1/1)80%  (4/5)78%  (51/65)91%  (14,5/16)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SidiousMap100% (1/1)80%  (4/5)78%  (51/65)91%  (14,5/16)
size (): int 0%   (0/1)0%   (0/4)0%   (0/1)
get (SuperLinkID): PlanRequester 100% (1/1)78%  (18/23)95%  (4,8/5)
put (SuperLinkID, PlanRequester): PlanRequester 100% (1/1)79%  (19/24)95%  (4,8/5)
SidiousMap (): void 100% (1/1)100% (8/8)100% (3/3)
remove (SuperLinkID): void 100% (1/1)100% (6/6)100% (2/2)

1package dk.deepthought.sidious.util;
2 
3import java.util.HashMap;
4import java.util.Map;
5 
6import net.jcip.annotations.ThreadSafe;
7import dk.deepthought.sidious.supportsystem.PlanRequester;
8import dk.deepthought.sidious.supportsystem.SuperLinkID;
9 
10/**
11 * This class implements the <code>synchronized</code> access functionality of
12 * a <code>HashMap</code>.
13 * 
14 * @see java.util.HashMap
15 * 
16 * @author Deepthought
17 * 
18 */
19@ThreadSafe
20public class SidiousMap {
21 
22        /**
23         * Internal map instance.
24         */
25        private final Map<SuperLinkID, PlanRequester> map = new HashMap<SuperLinkID, PlanRequester>();
26 
27        /**
28         * Empty default constructor.
29         */
30        public SidiousMap() {
31        }
32 
33        /**
34         * Returns the PlanRequester to which the specified id is mapped in this
35         * identity map, or <code>null</code> if the map contains no mapping for
36         * this id.
37         * 
38         * @param id
39         *            the id whose associated requester is to be returned
40         * @return the requester to which this map maps the specified id, or
41         *         <code>null</code> if the map contains no mapping for this id
42         */
43        public PlanRequester get(SuperLinkID id) {
44                PlanRequester planRequester = null;
45                synchronized (map) {
46                        planRequester = map.get(id);
47                }
48                return planRequester;
49        }
50 
51        /**
52         * Associates the specified id with the specified requester in this map. If
53         * the map previously contained a mapping for this id, the old requester is
54         * replaced.
55         * 
56         * @param id
57         *            key with which the specified requester is to be associated
58         * @param requester
59         *            value to be associated with the specified id
60         * @return the value previously associated with the id, <code>null</code>
61         *         if the map did not previously contain a mapping for this id.
62         */
63        public PlanRequester put(SuperLinkID id,
64                        PlanRequester requester) {
65                PlanRequester old = null;
66                synchronized (map) {
67                        old = map.put(id, requester);
68                }
69                return old;
70        }
71 
72        /**
73         * Removes the mapping for this key from this map if it is present.
74         * 
75         * @param id
76         *            the id for whic to remove the mapping
77         */
78        public synchronized void remove(SuperLinkID id) {
79                map.remove(id);
80        }
81 
82        /**
83         * Returns the number of key-value mappings in this sidious map.
84         * 
85         * @return the number of key-value mappings in this map.
86         */
87        public synchronized int size() {
88                return map.size();
89        }
90 
91}

[all classes][dk.deepthought.sidious.util]
EMMA 2.0.5312 (C) Vladimir Roubtsov