Examples of BATBlock


Examples of org.apache.poi.poifs.storage.BATBlock

    
     // We should have 21 BATs in the XBAT
     ByteBuffer xbatData = ByteBuffer.allocate(512);
     xbatData.put(fsData, (1+header.getXBATIndex())*512, 512);
     xbatData.position(0);
     BATBlock xbat = BATBlock.createBATBlock(POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS, xbatData);
     for(int i=0; i<21; i++) {
        assertTrue(xbat.getValueAt(i) != POIFSConstants.UNUSED_BLOCK);
     }
     for(int i=21; i<127; i++) {
        assertEquals(POIFSConstants.UNUSED_BLOCK, xbat.getValueAt(i));
     }
     assertEquals(POIFSConstants.END_OF_CHAIN, xbat.getValueAt(127));
    
    
     // Load the blocks and check with that
     RawDataBlockList blockList = new RawDataBlockList(inp, POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS);
     assertEquals(fsData.length / 512, blockList.blockCount() + 1); // Header not counted
View Full Code Here

Examples of org.apache.poi.poifs.storage.BATBlock

      NPOIFSFileSystem fs = new NPOIFSFileSystem();
      NPOIFSStream stream = new NPOIFSStream(fs);
     
      // Check our filesystem has a BAT and the Properties
      assertEquals(2, fs.getFreeBlock());
      BATBlock bat = fs.getBATBlockAndIndex(0).getBlock();
      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
      assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
      assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(2));
     
      // Check the stream as-is
      assertEquals(POIFSConstants.END_OF_CHAIN, stream.getStartBlock());
      try {
         stream.getBlockIterator();
         fail("Shouldn't be able to get an iterator before writing");
      } catch(IllegalStateException e) {}
     
      // Write in two blocks
      byte[] data = new byte[512+20];
      for(int i=0; i<512; i++) {
         data[i] = (byte)(i%256);
      }
      for(int i=512; i<data.length; i++) {
         data[i] = (byte)(i%256 + 100);
      }
      stream.updateContents(data);
     
      // Check now
      assertEquals(4, fs.getFreeBlock());
      bat = fs.getBATBlockAndIndex(0).getBlock();
      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, bat.getValueAt(0));
      assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(1));
      assertEquals(3,                           bat.getValueAt(2));
      assertEquals(POIFSConstants.END_OF_CHAIN, bat.getValueAt(3));
      assertEquals(POIFSConstants.UNUSED_BLOCK, bat.getValueAt(4));
     
     
      Iterator<ByteBuffer> it = stream.getBlockIterator();
      assertEquals(true, it.hasNext());
      ByteBuffer b = it.next();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.