}
else if ( inUseFlag != Record.NOT_IN_USE.byteValue() )
{
throw new IOException( "Illegal in use flag: " + inUseFlag );
}
DynamicRecord record = new DynamicRecord( id );
record.setInUse( inUse, type );
if ( inUse )
{
record.setPrevBlock( buffer.getLong() );
int nrOfBytes = buffer.getInt();
record.setNextBlock( buffer.getLong() );
buffer.clear();
buffer.limit( nrOfBytes );
if ( byteChannel.read( buffer ) != buffer.limit() )
{
return null;
}
buffer.flip();
byte data[] = new byte[nrOfBytes];
buffer.get( data );
record.setData( data );
}
return record;
}