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 [ComClassFactory.java]

nameclass, %method, %block, %line, %
ComClassFactory.java100% (1/1)44%  (4/9)27%  (36/135)24%  (7.9/33)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ComClassFactory100% (1/1)44%  (4/9)27%  (36/135)24%  (7.9/33)
CreateInstance (IUnknown, Object []): void 0%   (0/1)0%   (0/19)0%   (0/5)
LockServer (boolean): void 0%   (0/1)0%   (0/1)0%   (0/1)
checkAggregation (IUnknown, Object []): void 0%   (0/1)0%   (0/17)0%   (0/4)
createInner (IUnknown): ComObject 0%   (0/1)0%   (0/19)0%   (0/5)
isAggregation (IUnknown): boolean 0%   (0/1)0%   (0/6)0%   (0/1)
create (): ComObject 100% (1/1)12%  (5/41)10%  (1/10)
<static initializer> 100% (1/1)92%  (11/12)91%  (0.9/1)
ComClassFactory (Class): void 100% (1/1)100% (6/6)100% (3/3)
thunkedCreateInstance (Object, IUnknown, ByteBuffer): IUnknown 100% (1/1)100% (14/14)100% (3/3)

1/*
2 * $Id: ComClassFactory.java,v 1.7 2006/02/01 18:54:35 adamp Exp $
3 *
4 * (c) Copyright, Moebius Solutions, Inc., 2004
5 *
6 *                       All Rights Reserved
7 *
8 * This material may be reproduced by or for the U. S. Government
9 * pursuant to the copyright license under the clause at
10 * DFARS 252.227-7014 (OCT 2001).
11 */
12package com.moesol.bindings.platform_sdk.component_services;
13 
14import java.nio.ByteBuffer;
15import java.util.logging.Level;
16import java.util.logging.Logger;
17 
18public class ComClassFactory extends ComObject implements IClassFactory {
19    private static final Logger s_logger = Logger.getLogger(ComClassFactory.class.getName());
20        private final Class m_factory_for_class;
21        
22        public ComClassFactory(Class factory_for_class) {
23                m_factory_for_class = factory_for_class;
24        }
25 
26        public void CreateInstance(IUnknown pUnkOuter, Object[] out_iface) {
27                checkAggregation(pUnkOuter, out_iface);
28                
29                if (!isAggregation(pUnkOuter)) {
30                        create().QueryInterface(out_iface);
31                } else {
32                        createInner(pUnkOuter).QueryInterface(out_iface);
33                }
34        }
35 
36        public void LockServer(boolean fLock) {
37                // TODO Auto-generated method stub
38        }
39 
40        /**
41         * @param pUnkOuter
42         * @return
43         */
44        private boolean isAggregation(IUnknown pUnkOuter) {
45                return pUnkOuter != null;
46        }
47        
48        /**
49         * @param pUnkOuter
50         * @param out_iface
51         */
52        private void checkAggregation(IUnknown pUnkOuter, Object[] out_iface) {
53                if (isAggregation(pUnkOuter) && !(out_iface instanceof IUnknown[])) {
54                        // can't ask for anything other than IUnknown when aggregating
55                        s_logger.log(Level.FINE, "asked for non IUnknown interface while creating an aggregated object");
56                        throw new COMException(HRESULT.CLASS_E_NOAGGREGATION);
57                }
58        }
59 
60        private ComObject createInner(IUnknown unkOuter) {
61                ComObject inner = new ComObject();
62                inner.m_iunknown_support.aggregate(create());
63                
64                ComIUnknownOuter outer = new ComIUnknownOuter(unkOuter);
65                outer.aggregate(inner);
66                return inner;
67        }
68 
69        private ComObject create() {
70                try {
71                        return (ComObject)m_factory_for_class.newInstance();
72                } catch (ClassCastException e) {
73                        s_logger.log(Level.INFO, "caught", e);
74                        throw new COMException(COM.mapExceptionToHRESULT(e));
75                } catch (InstantiationException e) {
76                        s_logger.log(Level.INFO, "caught", e);
77                        throw new COMException(COM.mapExceptionToHRESULT(e));
78                } catch (IllegalAccessException e) {
79                        s_logger.log(Level.INFO, "caught", e);
80                        throw new COMException(COM.mapExceptionToHRESULT(e));
81                }
82        }
83 
84        static IUnknown thunkedCreateInstance(Object oFactory, IUnknown pUnkOuter, ByteBuffer bb_iid) {
85                ComClassFactory factory = (ComClassFactory)oFactory;
86                GUID iid = new GUID(bb_iid);
87                return factory.create().m_iunknown_support.queryInterface(iid);
88        }
89}
90 
91 

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