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

COVERAGE SUMMARY FOR SOURCE FILE [DispatchJavaCommon.java]

nameclass, %method, %block, %line, %
DispatchJavaCommon.java100% (1/1)100% (19/19)91%  (158/173)88%  (49.5/56)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DispatchJavaCommon100% (1/1)100% (19/19)91%  (158/173)88%  (49.5/56)
getTypelibClass (Class): Class 100% (1/1)53%  (16/30)46%  (5.6/12)
<static initializer> 100% (1/1)92%  (11/12)91%  (0.9/1)
DispatchJavaCommon (): void 100% (1/1)100% (3/3)100% (2/2)
copyInfoFromTypelibClass (Class): void 100% (1/1)100% (26/26)100% (5/5)
fillLibraryInfo (Class): void 100% (1/1)100% (17/17)100% (7/7)
getIntField (Class, String): int 100% (1/1)100% (8/8)100% (2/2)
getLcid (): int 100% (1/1)100% (3/3)100% (1/1)
getLibid (): GUID 100% (1/1)100% (3/3)100% (1/1)
getMajorVersion (): int 100% (1/1)100% (3/3)100% (1/1)
getMinorVersion (): int 100% (1/1)100% (3/3)100% (1/1)
getObjectField (Class, String): Object 100% (1/1)100% (8/8)100% (2/2)
getOldStyleTypelibClass (Class): Class 100% (1/1)100% (28/28)100% (8/8)
getUuid (): GUID 100% (1/1)100% (3/3)100% (1/1)
reportTypelibException (Exception): void 100% (1/1)100% (6/6)100% (2/2)
setLcid (int): void 100% (1/1)100% (4/4)100% (2/2)
setLibid (GUID): void 100% (1/1)100% (4/4)100% (2/2)
setMajorVersion (int): void 100% (1/1)100% (4/4)100% (2/2)
setMinorVersion (int): void 100% (1/1)100% (4/4)100% (2/2)
setUuid (GUID): void 100% (1/1)100% (4/4)100% (2/2)

1/*
2 * $Id: DispatchJavaCommon.java,v 1.3 2006/03/01 19:21:07 hastings 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;
13 
14import java.lang.reflect.Field;
15import java.util.logging.Level;
16import java.util.logging.Logger;
17 
18import com.moesol.bindings.platform_sdk.component_services.GUID;
19 
20/**
21 * Help the JNI code recover the LIBID, major version, minor version, and lcid
22 * for a class.
23 * 
24 * @author Hastings
25 *
26 */
27public class DispatchJavaCommon {
28        private static final Logger s_logger = Logger.getLogger(DispatchJavaCommon.class.getName());
29        
30        private GUID m_libid;
31        private int m_major;
32        private int m_minor;
33        private int m_lcid;
34 
35        protected GUID m_uuid;
36 
37        protected DispatchJavaCommon() {
38        }
39 
40        protected void fillLibraryInfo(Class c) throws ClassNotFoundException, SecurityException, IllegalArgumentException, NoSuchFieldException, IllegalAccessException {
41                Class tc = getTypelibClass(c);
42                if (tc == null) {
43                        tc = getOldStyleTypelibClass(c);
44                        if (tc == null) {
45                                return;
46                        }
47                }
48                copyInfoFromTypelibClass(tc);
49        }
50        
51        private Class getOldStyleTypelibClass(Class c) {
52                Package p = c.getPackage();
53                String typelib = p.getName() + ".TYPELIB";
54                Class tc = null;
55                try {
56                        tc = Class.forName(typelib);
57                } catch (ClassNotFoundException e) {
58                        s_logger.log(Level.INFO, "No TYPELIB for {0}", c.getName());
59                }
60                return tc;
61        }
62 
63        private Class getTypelibClass(Class c) {
64                Class tc = null;
65                try {
66                        tc = (Class)getObjectField(c, "TYPELIB");
67                } catch (SecurityException e) {
68                        reportTypelibException(e);
69                } catch (IllegalArgumentException e) {
70                        reportTypelibException(e);
71                } catch (NoSuchFieldException e) {
72                        reportTypelibException(e);
73                } catch (IllegalAccessException e) {
74                        reportTypelibException(e);
75                }
76                return tc;
77        }
78 
79        private void reportTypelibException(Exception e) {
80                s_logger.log(Level.INFO, "Exception trying to find TYPELIB field, will try old style TYPELIB class", e);
81        }
82 
83        /**
84         * @param tc
85         * @throws NoSuchFieldException
86         * @throws IllegalAccessException
87         */
88        private void copyInfoFromTypelibClass(Class tc) throws NoSuchFieldException, IllegalAccessException {
89                setLibid((GUID)getObjectField(tc, "UUID"));
90                setMajorVersion(getIntField(tc, "MAJOR_VERSION"));
91                setMinorVersion(getIntField(tc, "MINOR_VERSION"));
92                setLcid(getIntField(tc, "LCID"));
93        }
94 
95        private int getIntField(Class tc, String string) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
96                Field f = tc.getField(string);
97                return f.getInt(tc);
98        }
99 
100        protected Object getObjectField(Class tc, String string) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
101                Field f = tc.getField(string);
102                return f.get(tc);
103        }
104 
105        public GUID getLibid() {
106                return m_libid;
107        }
108 
109        public void setLibid(GUID v) {
110                m_libid = v;
111        }
112 
113        public int getMajorVersion() {
114                return m_major;
115        }
116 
117        public void setMajorVersion(int v) {
118                m_major = v;
119        }
120 
121        public int getMinorVersion() {
122                return m_minor;
123        }
124 
125        public void setMinorVersion(int v) {
126                m_minor = v;
127        }
128 
129        public int getLcid() {
130                return m_lcid;
131        }
132 
133        public void setLcid(int v) {
134                m_lcid = v;
135        }
136 
137        public GUID getUuid() {
138                return m_uuid;
139        }
140 
141        public void setUuid(GUID v) {
142                m_uuid = v;
143        }
144 
145}

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