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

COVERAGE SUMMARY FOR SOURCE FILE [NativeArrayOfStructs.java]

nameclass, %method, %block, %line, %
NativeArrayOfStructs.java0%   (0/1)0%   (0/3)0%   (0/30)0%   (0/10)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class NativeArrayOfStructs0%   (0/1)0%   (0/3)0%   (0/30)0%   (0/10)
NativeArrayOfStructs (ByteBuffer): void 0%   (0/1)0%   (0/6)0%   (0/3)
_getByteBuffer (): ByteBuffer 0%   (0/1)0%   (0/3)0%   (0/1)
getElementSlice (int, int): ByteBuffer 0%   (0/1)0%   (0/21)0%   (0/6)

1/*
2 * $Id: NativeArrayOfStructs.java,v 1.5 2006/03/04 06:04:54 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.nio.ByteBuffer;
15 
16/**
17 * Wrap native bytes that represent native arrays of structs.
18 * This class avoids making copies of the underlying bytes.
19 * 
20 * @author Hastings
21 */
22public class NativeArrayOfStructs {
23        /**
24         * Create a new native array of structs on bb.
25         */
26        public NativeArrayOfStructs(ByteBuffer bb) {
27                m_byte_buffer = bb;
28        }
29        
30    /**
31     * Gets a slice of the array. Modifying the returned slice
32     * modifies the underlying structure as well.
33     * 
34     * @param index zero based element index of slice start
35     * @param sizeof size in bytes of one element
36     * @return new slice for element
37     */
38    protected ByteBuffer getElementSlice(int index, int sizeof) {
39            int offset = index * sizeof;
40                ByteBuffer dup = m_byte_buffer.duplicate();
41        dup.position(offset);
42        ByteBuffer slice = dup.slice();
43        slice.limit(sizeof);
44        return slice;
45    }
46    
47    public ByteBuffer _getByteBuffer() {
48            return m_byte_buffer;
49    }
50 
51        private ByteBuffer m_byte_buffer; // usually a non-direct byte buffer
52}

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