private PropertyBlock readPropertyBlock( ReadableChannel channel ) throws IOException { PropertyBlock toReturn = new PropertyBlock(); byte blockSize = channel.get(); // the size is stored in bytes // 1 assert blockSize > 0 && blockSize % 8 == 0 : blockSize + " is not a valid block size value"; // Read in blocks long[] blocks = readLongs( channel, blockSize / 8 ); assert blocks.length == blockSize / 8 : blocks.length + " longs were read in while i asked for what corresponds to " + blockSize; assert PropertyType.getPropertyTypeOrThrow( blocks[0] ).calculateNumberOfBlocksUsed( blocks[0] ) == blocks.length : blocks.length + " is not a valid number of blocks for type " + PropertyType.getPropertyTypeOrThrow( blocks[0] ); /* * Ok, now we may be ready to return, if there are no DynamicRecords. So * we start building the Object */ toReturn.setValueBlocks( blocks ); /* * Read in existence of DynamicRecords. Remember, this has already been * read in the buffer with the blocks, above. */ if ( readDynamicRecords( channel, toReturn, PROPERTY_BLOCK_DYNAMIC_RECORD_ADDER ) == -1 ) { return null; } return toReturn; }
private PropertyBlock readPropertyBlock( ReadableChannel channel ) throws IOException { PropertyBlock toReturn = new PropertyBlock(); byte blockSize = channel.get(); // the size is stored in bytes // 1 assert blockSize > 0 && blockSize % 8 == 0 : blockSize + " is not a valid block size value"; // Read in blocks long[] blocks = readLongs( channel, blockSize / 8 ); assert blocks.length == blockSize / 8 : blocks.length + " longs were read in while i asked for what corresponds to " + blockSize; assert PropertyType.getPropertyTypeOrThrow( blocks[0] ).calculateNumberOfBlocksUsed( blocks[0] ) == blocks.length : blocks.length + " is not a valid number of blocks for type " + PropertyType.getPropertyTypeOrThrow( blocks[0] ); /* * Ok, now we may be ready to return, if there are no DynamicRecords. So * we start building the Object */ toReturn.setValueBlocks( blocks ); /* * Read in existence of DynamicRecords. Remember, this has already been * read in the buffer with the blocks, above. */ if ( readDynamicRecords( channel, toReturn, PROPERTY_BLOCK_DYNAMIC_RECORD_ADDER ) == -1 ) { return null; } return toReturn; }