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

nameclass, %method, %block, %line, %
LastHRESULT.java100% (1/1)86%  (6/7)88%  (30/34)83%  (10/12)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class LastHRESULT100% (1/1)86%  (6/7)88%  (30/34)83%  (10/12)
setLastHRESULT (int): void 0%   (0/1)0%   (0/4)0%   (0/2)
<static initializer> 100% (1/1)100% (5/5)100% (1/1)
LastHRESULT (): void 100% (1/1)100% (3/3)100% (2/2)
hresult (): int 100% (1/1)100% (8/8)100% (2/2)
hresult (int): void 100% (1/1)100% (9/9)100% (3/3)
initialValue (): Object 100% (1/1)100% (3/3)100% (1/1)
instance (): LastHRESULT 100% (1/1)100% (2/2)100% (1/1)

1/*
2 * $Id: LastHRESULT.java,v 1.2 2005/11/16 21:48:12 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.platform_sdk.component_services;
13 
14/**
15 * Provide access to the raw value for the last HRESULT returned by a
16 * COM interface call generated by tlb2java. The tlb2java code generator
17 * transforms the return type of all [dual] methods so that the [retval] parameter
18 * is instead used as the return value. If there is no [retval] parameter
19 * void is returned. The original HRESULT is checked for a failure bit
20 * and if set a COMException is thrown.
21 *  
22 * Occasionally, the HRESULT encodes additional information
23 * beyond success and failure. For example, IEnumVARIANT::Next is documented
24 * as returning S_OK, if all elements requested are retrieved, but S_FALSE
25 * if there are no errors but fewer elements than requested are returned.
26 * 
27 * In these cases you can use LastHRESULT to get the actual HRESULT.
28 * <pre>
29 *     LastHRESULT.instance().hresult();
30 * </pre>
31 * This returns the last HRESULT returned by the last COM call on this thread.
32 * 
33 * @author Robert
34 */
35public class LastHRESULT extends ThreadLocal {
36    private static final LastHRESULT s_instance = new LastHRESULT();
37    public static LastHRESULT instance() {
38        return s_instance;
39    }
40    private LastHRESULT() {
41    }
42    
43    /**
44     * The initial value is an array of size one to hold the thread local
45     * HRESULT.
46     */
47    protected Object initialValue() {
48        return new int[1];
49    }
50    
51    /**
52     * Set the thread local HRESULT.
53     * @param v
54     */
55    public void hresult(int v) {
56        int[] tl = (int[])get();
57        tl[0] = v;
58    }
59    
60    /**
61     * Get the thread local HRESULT. 
62     * @return this threads HRESULT
63     */
64    public int hresult() {
65        int[] tl = (int[])get();
66        return tl[0];
67    }
68    
69    /**
70     * Called from JNI code to set the last HRESULT
71     * without having to call instance() from JNI.
72     * Reduces the JNI crossings.
73     * 
74     * @param hr
75     */
76    static void setLastHRESULT(int hr) {
77            instance().hresult(hr);
78    }
79}

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