public int getBytes(int index, byte[] dst, int off, int len)
    {
        int count = Math.min(len, size - index);

        if (buf.hasArray()) {
            System.arraycopy(buf.array(), buf.arrayOffset() + index, dst, off, count);
        }
        else {
            ByteBuffer dup = buf.duplicate();
            dup.position(index);
            dup.get(dst, off, count);
        }

        return count;
    }
@Test
    public void testGetBytesLength()
    {
        final Msg msg = initMsg();

        final byte[] dst = new byte[5];
        msg.getBytes(2, dst, 0, 2);
        assertThat(dst, is(new byte[] { 2, 3, 0, 0, 0 }));
    }