FileDocCategorySizeDatePackage
SmallBlockTableWriter.javaAPI DocApache Poi 3.0.14267Mon Jan 01 12:39:36 GMT 2007org.apache.poi.poifs.storage

SmallBlockTableWriter

public class SmallBlockTableWriter extends Object implements BlockWritable, BATManaged
This class implements storage for writing the small blocks used by small documents.
author
Marc Johnson (mjohnson at apache dot org)

Fields Summary
private BlockAllocationTableWriter
_sbat
private List
_small_blocks
private int
_big_block_count
private RootProperty
_root
Constructors Summary
public SmallBlockTableWriter(List documents, RootProperty root)
Creates new SmallBlockTable

param
documents a List of POIFSDocument instances
param
root the Filesystem's root property

        _sbat         = new BlockAllocationTableWriter();
        _small_blocks = new ArrayList();
        _root         = root;
        Iterator iter = documents.iterator();

        while (iter.hasNext())
        {
            POIFSDocument   doc    = ( POIFSDocument ) iter.next();
            BlockWritable[] blocks = doc.getSmallBlocks();

            if (blocks.length != 0)
            {
                doc.setStartBlock(_sbat.allocateSpace(blocks.length));
                for (int j = 0; j < blocks.length; j++)
                {
                    _small_blocks.add(blocks[ j ]);
                }
            }
        }
        _sbat.simpleCreateBlocks();
        _root.setSize(_small_blocks.size());
        _big_block_count = SmallDocumentBlock.fill(_small_blocks);
    
Methods Summary
public intcountBlocks()
Return the number of BigBlock's this instance uses

return
count of BigBlock instances

        return _big_block_count;
    
public org.apache.poi.poifs.storage.BlockAllocationTableWritergetSBAT()
Get the SBAT

return
the Small Block Allocation Table

        return _sbat;
    
public intgetSBATBlockCount()
Get the number of SBAT blocks

return
number of SBAT big blocks

	return (_big_block_count + 15) / 16;
    
public voidsetStartBlock(int start_block)
Set the start block for this instance

param
start_block

        _root.setStartBlock(start_block);
    
public voidwriteBlocks(java.io.OutputStream stream)
Write the storage to an OutputStream

param
stream the OutputStream to which the stored data should be written
exception
IOException on problems writing to the specified stream

        Iterator iter = _small_blocks.iterator();

        while (iter.hasNext())
        {
            (( BlockWritable ) iter.next()).writeBlocks(stream);
        }