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

COVERAGE SUMMARY FOR SOURCE FILE [UnsignedByteBuffer.java]

nameclass, %method, %block, %line, %
UnsignedByteBuffer.java100% (1/1)54%  (15/28)52%  (97/187)50%  (22.9/46)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class UnsignedByteBuffer100% (1/1)54%  (15/28)52%  (97/187)50%  (22.9/46)
capacity (): int 0%   (0/1)0%   (0/4)0%   (0/1)
clear (): BufferMarker 0%   (0/1)0%   (0/6)0%   (0/2)
flip (): BufferMarker 0%   (0/1)0%   (0/6)0%   (0/2)
get (): short 0%   (0/1)0%   (0/9)0%   (0/2)
get (short []): void 0%   (0/1)0%   (0/14)0%   (0/3)
hasRemaining (): boolean 0%   (0/1)0%   (0/4)0%   (0/1)
hashCode (): int 0%   (0/1)0%   (0/4)0%   (0/1)
isReadOnly (): boolean 0%   (0/1)0%   (0/4)0%   (0/1)
limit (int): BufferMarker 0%   (0/1)0%   (0/10)0%   (0/2)
mark (): BufferMarker 0%   (0/1)0%   (0/6)0%   (0/2)
order (ByteOrder): void 0%   (0/1)0%   (0/6)0%   (0/2)
position (int): BufferMarker 0%   (0/1)0%   (0/10)0%   (0/2)
reset (): BufferMarker 0%   (0/1)0%   (0/6)0%   (0/2)
equals (Object): boolean 100% (1/1)89%  (8/9)88%  (0.9/1)
UnsignedByteBuffer (ByteBuffer): void 100% (1/1)100% (6/6)100% (3/3)
allocate (int): UnsignedByteBuffer 100% (1/1)100% (6/6)100% (1/1)
compareTo (Object): int 100% (1/1)100% (9/9)100% (2/2)
get (int): short 100% (1/1)100% (8/8)100% (1/1)
getByteBuffer (): ByteBuffer 100% (1/1)100% (3/3)100% (1/1)
limit (): int 100% (1/1)100% (4/4)100% (1/1)
makeUnsigned (short): short 100% (1/1)100% (5/5)100% (1/1)
position (): int 100% (1/1)100% (7/7)100% (1/1)
put (int, short): void 100% (1/1)100% (8/8)100% (2/2)
put (short []): void 100% (1/1)100% (14/14)100% (3/3)
put (short): void 100% (1/1)100% (7/7)100% (2/2)
remaining (): int 100% (1/1)100% (4/4)100% (1/1)
rewind (): BufferMarker 100% (1/1)100% (6/6)100% (2/2)
sizeof (): int 100% (1/1)100% (2/2)100% (1/1)

1/*
2 * $Id: UnsignedByteBuffer.java,v 1.2 2005/12/16 22:32:46 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.nio;
13 
14import java.nio.ByteBuffer;
15import java.nio.ByteOrder;
16 
17import com.moesol.bindings.NativeStructure;
18 
19 
20/**
21 * Help getting bytes back as unsigned.
22 * 
23 * @author Hastings
24 */
25public class UnsignedByteBuffer implements BufferMarker, Comparable {
26 
27        private final ByteBuffer m_byte_buffer;
28 
29        public UnsignedByteBuffer(ByteBuffer b) {
30                m_byte_buffer = b;
31        }
32        public static UnsignedByteBuffer allocate(int capacity) {
33                return new UnsignedByteBuffer(ByteBuffer.allocate(capacity));
34        }
35 
36        public short get() {
37                short r = m_byte_buffer.get();
38                return makeUnsigned(r);
39        }
40        public short get(int offset) {
41                return makeUnsigned(m_byte_buffer.get(offset));
42        }
43        public void get(short[] result) {
44                for (int i = 0; i < result.length; i++) {
45                        result[i] = get();
46                }
47        }
48        
49        public void put(short v) {
50                m_byte_buffer.put((byte)v);
51        }
52        public void put(int offset, short v) {
53                m_byte_buffer.put(offset, (byte)v);
54        }
55        public void put(short[] values) {
56                for (int i = 0; i < values.length; i++) {
57                        put(values[i]);
58                }
59        }
60        
61        /**
62         * @param r
63     * @return unsigned short
64         */
65        private short makeUnsigned(short r) {
66                return (short)(r & 0xFF);
67        }
68 
69        /**
70     * @return shorts remaining
71         */
72        public int remaining() {
73                return m_byte_buffer.remaining();
74        }
75        
76        /**
77     * @return number of shorts in this buffer
78         */
79        public int limit() {
80                return m_byte_buffer.limit();
81        }
82        
83        /**
84     * @return number of shorts this buffer could store
85         */
86        public int capacity() {
87                return m_byte_buffer.capacity();
88        }
89        /**
90     * @param bo
91         */
92        public void order(ByteOrder bo) {
93                m_byte_buffer.order(bo);
94        }
95        public BufferMarker flip() {
96                m_byte_buffer.flip();
97                return this;
98        }
99        /**
100     * @return underlying byte buffer
101         */
102        public ByteBuffer getByteBuffer() {
103                return m_byte_buffer;
104        }
105        
106        public int compareTo(Object o) {
107                UnsignedByteBuffer other = (UnsignedByteBuffer)o;
108                return m_byte_buffer.compareTo(other.getByteBuffer());
109        }
110        
111        private int sizeof() {
112                return NativeStructure.getUnsignedByteSize();
113        }
114        public int position() {
115                return m_byte_buffer.position() / sizeof();
116        }
117        public BufferMarker position(int newPosition) {
118                m_byte_buffer.position(newPosition * sizeof());
119                return this;
120        }
121        public BufferMarker limit(int newLimit) {
122                m_byte_buffer.limit(newLimit * sizeof());
123                return this;
124        }
125        public BufferMarker mark() {
126                m_byte_buffer.mark();
127                return this;
128        }
129        public BufferMarker reset() {
130                m_byte_buffer.reset();
131                return this;
132        }
133        public BufferMarker clear() {
134                m_byte_buffer.clear();
135                return this;
136        }
137        public BufferMarker rewind() {
138                m_byte_buffer.rewind();
139                return this;
140        }
141        public boolean hasRemaining() {
142                return m_byte_buffer.hasRemaining();
143        }
144        public boolean isReadOnly() {
145                return m_byte_buffer.isReadOnly();
146        }
147 
148        public boolean equals(Object arg0) {
149                return 0 == compareTo(arg0);
150        }
151 
152        public int hashCode() {
153                return m_byte_buffer.hashCode();
154        }
155 
156}

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