コード例 #1
0
    PropertyBlock readPropertyBlock() 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(blockSize / 8);
      assert blocks.length == blockSize / 8
          : blocks.length
              + " longs were read in while i asked for what corresponds to "
              + blockSize;
      assert PropertyType.getPropertyType(blocks[0], false).calculateNumberOfBlocksUsed(blocks[0])
              == blocks.length
          : blocks.length
              + " is not a valid number of blocks for type "
              + PropertyType.getPropertyType(blocks[0], false);
      /*
       *  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(toReturn, PROPERTY_BLOCK_DYNAMIC_RECORD_ADDER) == -1) {
        return null;
      }

      return toReturn;
    }