EMMA Coverage Report (generated Mon Mar 20 21:34:30 PST 2006)
[all classes][com.moesol.bindings.platform_sdk.component_services]

COVERAGE SUMMARY FOR SOURCE FILE [ListenerCookieTable.java]

nameclass, %method, %block, %line, %
ListenerCookieTable.java100% (1/1)100% (5/5)81%  (55/68)79%  (15/19)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ListenerCookieTable100% (1/1)100% (5/5)81%  (55/68)79%  (15/19)
removeListenerAndCookieFromTable (IUnknown$Jni, Object): int 100% (1/1)66%  (23/35)67%  (6/9)
addCookiePairToTable (Object, int): void 100% (1/1)92%  (12/13)75%  (3/4)
ListenerCookieTable (): void 100% (1/1)100% (8/8)100% (2/2)
_getListenerListSize (): int 100% (1/1)100% (4/4)100% (1/1)
cleanUpMap (IUnknown$Jni): void 100% (1/1)100% (8/8)100% (3/3)

1/*
2 * $Id: ListenerCookieTable.java,v 1.2 2005/12/01 06:10:00 hastings Exp $
3 * 
4 * Copyright (c) 2004, Moebius Solutions, Inc.
5 * All rights reserved.
6 * 
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 
11 *     Redistributions of source code must retain the above copyright
12 *     notice, this list of conditions and the following disclaimer.
13 * 
14 *     Redistributions in binary form must reproduce the above
15 *     copyright notice, this list of conditions and the following
16 *     disclaimer in the documentation and/or other materials provided
17 *     with the distribution.
18 * 
19 *     Neither the name of Moebius Solutions, Inc. nor the names of
20 *     its contributors may be used to endorse or promote products
21 *     derived from this software without specific prior written
22 *     permission.
23 * 
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
35 * OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37package com.moesol.bindings.platform_sdk.component_services;
38 
39import java.util.Hashtable;
40 
41import com.moesol.bindings.platform_sdk.component_services.IUnknown.Jni;
42 
43/**
44 * Manage the connection point cookies for an object. These tables cannot be
45 * fields in the java interface objects because two java objects may refer to
46 * the same COM object.
47 * 
48 * @author Hastings
49 */
50public class ListenerCookieTable {
51        
52        /**
53         * Exposed for unit tests.
54         * 
55         * @return number of cookies in the cookie table.
56         */
57        public int _getListenerListSize() {
58                return m_listener_cookie_table.size();
59        }
60        
61        void addCookiePairToTable(Object o, int cookie) {
62                if (o == null) {
63                        return;
64                }
65                
66                m_listener_cookie_table.put(o, new Integer(cookie));
67        }
68 
69        int removeListenerAndCookieFromTable(Jni unk, Object o) {
70                if (o == null) {
71                        return 0;
72                }
73                
74                synchronized (m_listener_cookie_table) {
75                        Integer cookie = (Integer)m_listener_cookie_table.remove(o);
76                        cleanUpMap(unk);
77                        if (cookie == null) {
78                                throw new IllegalStateException("Cookie cannot be null");
79                        }
80                        return cookie.intValue();
81                }
82        }
83        
84        private void cleanUpMap(Jni unk) {
85                if (m_listener_cookie_table.size() == 0) {
86                        EventSourceToListenerCookieTable.singleton().removeListenerCookieTable(unk);
87                }
88        }
89 
90        private Hashtable m_listener_cookie_table = new Hashtable();
91}

[all classes][com.moesol.bindings.platform_sdk.component_services]
EMMA 2.0.5312 (C) Vladimir Roubtsov