@Override
    @Nullable
    public final Data readData() throws IOException {
        byte[] bytes = readByteArray();
        return bytes == null ? null : new HeapData(bytes);
    }
@Test
    public void testReadData() throws Exception {
        byte[] bytesBE = {0, 0, 0, 0, 0, 0, 0, 8, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, -1, -1, -1, -1};
        byte[] bytesLE = {0, 0, 0, 0, 8, 0, 0, 0, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, -1, -1, -1, -1};
        in.init((byteOrder == BIG_ENDIAN ? bytesBE : bytesLE), 0);

        in.position(bytesLE.length - 4);
        Data nullData = readData(in);
        in.position(0);
        Data theZeroLengthArray = readData(in);
        in.position(4);
        Data data = readData(in);

        assertNull(nullData);
        assertEquals(0, theZeroLengthArray.getType());
        assertArrayEquals(new byte[0], theZeroLengthArray.toByteArray());
        assertArrayEquals(new byte[]{-1, -1, -1, -1, 0, 0, 0, 0}, data.toByteArray());
    }