Examples of HeaderBlock


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

        throws IOException
    {
        this();
        boolean success = false;

        HeaderBlock header_block;
        RawDataBlockList data_blocks;
        try {
            // read the header block from the stream
            header_block = new HeaderBlock(stream);
            bigBlockSize = header_block.getBigBlockSize();

            // read the rest of the stream into blocks
            data_blocks = new RawDataBlockList(stream, bigBlockSize);
            success = true;
        } finally {
            closeInputStream(stream, success);
        }


        // set up the block allocation table (necessary for the
        // data_blocks to be manageable
        new BlockAllocationTableReader(header_block.getBigBlockSize(),
                                       header_block.getBATCount(),
                                       header_block.getBATArray(),
                                       header_block.getXBATCount(),
                                       header_block.getXBATIndex(),
                                       data_blocks);

        // get property table from the document
        PropertyTable properties =
            new PropertyTable(header_block, data_blocks);

        // init documents
        processProperties(
            SmallBlockTableReader.getSmallDocumentBlocks(
                  bigBlockSize, data_blocks, properties.getRoot(),
                header_block.getSBATStart()
            ),
            data_blocks,
            properties.getRoot().getChildren(),
            null,
            header_block.getPropertyStart()
        );

        // For whatever reason CLSID of root is always 0.
        getRoot().setStorageClsid(properties.getRoot().getStorageClsid());
    }
View Full Code Here

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

  public static void viewFile(final String filename) throws Exception {
    InputStream inp = new FileInputStream(filename);
   
    // Header
    HeaderBlock header_block = new HeaderBlock(inp);
    displayHeader(header_block);
   
    // Raw blocks
      POIFSBigBlockSize bigBlockSize = header_block.getBigBlockSize();
      RawDataBlockList data_blocks = new RawDataBlockList(inp, bigBlockSize);
      displayRawBlocksSummary(data_blocks);
     
      // Main FAT Table
      BlockAllocationTableReader batReader =
         new BlockAllocationTableReader(
            header_block.getBigBlockSize(),
            header_block.getBATCount(),
            header_block.getBATArray(),
            header_block.getXBATCount(),
            header_block.getXBATIndex(),
            data_blocks);
      displayBATReader(batReader);

      // Properties Table
      PropertyTable properties =
         new PropertyTable(header_block, data_blocks);
     
      // Mini Fat
      BlockList sbat =
         SmallBlockTableReader.getSmallDocumentBlocks(
               bigBlockSize, data_blocks, properties.getRoot(),
               header_block.getSBATStart()
         );
   }
View Full Code Here

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

    private POIFSBigBlockSize bigBlockSize =
       POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS;

    private NPOIFSFileSystem(boolean newFS)
    {
        _header         = new HeaderBlock(bigBlockSize);
        _property_table = new NPropertyTable(_header);
        _mini_store     = new NPOIFSMiniStore(this, _property_table.getRoot(), new ArrayList<BATBlock>(), _header);
        _xbat_blocks    = new ArrayList<BATBlock>();
        _bat_blocks     = new ArrayList<BATBlock>();
        _root           = null;
View Full Code Here

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

          // Get the header
          ByteBuffer headerBuffer = ByteBuffer.allocate(POIFSConstants.SMALLER_BIG_BLOCK_SIZE);
          IOUtils.readFully(channel, headerBuffer);
         
          // Have the header processed
          _header = new HeaderBlock(headerBuffer);
         
          // Now process the various entries
          readCoreContents();
       } catch(IOException e) {
          if(closeChannelOnError) {
View Full Code Here

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

           // Get the header
           ByteBuffer headerBuffer = ByteBuffer.allocate(POIFSConstants.SMALLER_BIG_BLOCK_SIZE);
           IOUtils.readFully(channel, headerBuffer);
          
           // Have the header processed
           _header = new HeaderBlock(headerBuffer);
          
           // Sanity check the block count
           BlockAllocationTableReader.sanityCheckBlockCount(_header.getBATCount());
  
           // We need to buffer the whole file into memory when
View Full Code Here

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

     byte[] fsData = baos.toByteArray();
    
    
     // Check the header was written properly
     InputStream inp = new ByteArrayInputStream(fsData);
     HeaderBlock header = new HeaderBlock(inp);
     assertEquals(109+21, header.getBATCount());
     assertEquals(1, header.getXBATCount());
    
    
     // 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
     new BlockAllocationTableReader(header.getBigBlockSize(),
            header.getBATCount(),
            header.getBATArray(),
            header.getXBATCount(),
            header.getXBATIndex(),
            blockList);
      assertEquals(fsData.length / 512, blockList.blockCount() + 1); // Header not counted
     
     // Now load it and check
     fs = null;
View Full Code Here

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

  public void test4KBlocks() throws Exception {
      POIDataSamples _samples = POIDataSamples.getPOIFSInstance();
     InputStream inp = _samples.openResourceAsStream("BlockSize4096.zvi");
    
     // First up, check that we can process the header properly
      HeaderBlock header_block = new HeaderBlock(inp);
      POIFSBigBlockSize bigBlockSize = header_block.getBigBlockSize();
      assertEquals(4096, bigBlockSize.getBigBlockSize());
     
      // Check the fat info looks sane
      assertEquals(1, header_block.getBATArray().length);
      assertEquals(1, header_block.getBATCount());
      assertEquals(0, header_block.getXBATCount());
     
      // Now check we can get the basic fat
      RawDataBlockList data_blocks = new RawDataBlockList(inp, bigBlockSize);

    
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.