private PropertyType getType( boolean force ) { return valueBlocks == null ? null : force ? PropertyType.getPropertyTypeOrNull( valueBlocks[0] ) : PropertyType.getPropertyTypeOrThrow( valueBlocks[0] ); }
/** * Reads blocks[] and constructs {@link PropertyBlock} instances from them, making that abstraction * available to the outside. Done the first time any PropertyBlock is needed or manipulated. */ private void ensureBlocksLoaded() { if ( !blocksLoaded ) { assert blockRecordsCursor == 0; // We haven't loaded the blocks yet, please do so now int index = 0; while ( index < blocksCursor ) { PropertyType type = PropertyType.getPropertyTypeOrThrow( blocks[index] ); PropertyBlock block = new PropertyBlock(); int length = type.calculateNumberOfBlocksUsed( blocks[index] ); block.setValueBlocks( Arrays.copyOfRange( blocks, index, index + length ) ); blockRecords[blockRecordsCursor++] = block; index += length; } blocksLoaded = true; } }
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; }
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; }
private PropertyType getType( boolean force ) { return valueBlocks == null ? null : force ? PropertyType.getPropertyTypeOrNull( valueBlocks[0] ) : PropertyType.getPropertyTypeOrThrow( valueBlocks[0] ); }
/** * Reads blocks[] and constructs {@link PropertyBlock} instances from them, making that abstraction * available to the outside. Done the first time any PropertyBlock is needed or manipulated. */ private void ensureBlocksLoaded() { if ( !blocksLoaded ) { assert blockRecordsCursor == 0; // We haven't loaded the blocks yet, please do so now int index = 0; while ( index < blocksCursor ) { PropertyType type = PropertyType.getPropertyTypeOrThrow( blocks[index] ); PropertyBlock block = new PropertyBlock(); int length = type.calculateNumberOfBlocksUsed( blocks[index] ); block.setValueBlocks( Arrays.copyOfRange( blocks, index, index + length ) ); blockRecords[blockRecordsCursor++] = block; index += length; } blocksLoaded = true; } }
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; }
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; }