Package loci.poi.poifs.storage
Class SmallDocumentBlock
java.lang.Object
loci.poi.poifs.storage.SmallDocumentBlock
- All Implemented Interfaces:
BlockWritable,ListManagedBlock
Storage for documents that are too small to use regular
DocumentBlocks for their data
- Author:
- Marc Johnson (mjohnson at apache dot org)
-
Method Summary
Modifier and TypeMethodDescriptionstatic intcalcSize(int size) Calculate the storage size of a set of SmallDocumentBlocksstatic SmallDocumentBlock[]convert(byte[] array, int size) convert a single long array into an array of SmallDocumentBlock instancesstatic SmallDocumentBlock[]convert(BlockWritable[] store, int size) Factory for creating SmallDocumentBlocks from DocumentBlocksstatic Listextract(ListManagedBlock[] blocks, int size) create a list of SmallDocumentBlock's from raw datastatic intfill out a List of SmallDocumentBlocks so that it fully occupies a set of big blocksintbyte[]getData()Get the data from the blockstatic voidread(BlockWritable[] blocks, byte[] buffer, int offset) read data from an array of SmallDocumentBlocksvoidwriteBlocks(OutputStream stream) Write the storage to an OutputStream
-
Method Details
-
getBigBlockSize
public int getBigBlockSize() -
convert
convert a single long array into an array of SmallDocumentBlock instances- Parameters:
array- the byte array to be convertedsize- the intended size of the array (which may be smaller)- Returns:
- an array of SmallDocumentBlock instances, filled from the array
-
fill
fill out a List of SmallDocumentBlocks so that it fully occupies a set of big blocks- Parameters:
blocks- the List to be filled out- Returns:
- number of big blocks the list encompasses
-
convert
public static SmallDocumentBlock[] convert(BlockWritable[] store, int size) throws IOException, ArrayIndexOutOfBoundsException Factory for creating SmallDocumentBlocks from DocumentBlocks- Parameters:
store- the original DocumentBlockssize- the total document size- Returns:
- an array of new SmallDocumentBlocks instances
- Throws:
IOException- on errors reading from the DocumentBlocksArrayIndexOutOfBoundsException- if, somehow, the store contains less data than size indicates
-
extract
create a list of SmallDocumentBlock's from raw data- Parameters:
blocks- the raw data containing the SmallDocumentBlock data- Returns:
- a List of SmallDocumentBlock's extracted from the input
- Throws:
IOException
-
read
read data from an array of SmallDocumentBlocks- Parameters:
blocks- the blocks to read frombuffer- the buffer to write the data intooffset- the offset into the array of blocks to read from
-
calcSize
public static int calcSize(int size) Calculate the storage size of a set of SmallDocumentBlocks- Parameters:
size- number of SmallDocumentBlocks- Returns:
- total size
-
writeBlocks
Write the storage to an OutputStream- Specified by:
writeBlocksin interfaceBlockWritable- Parameters:
stream- the OutputStream to which the stored data should be written- Throws:
IOException- on problems writing to the specified stream
-
getData
Get the data from the block- Specified by:
getDatain interfaceListManagedBlock- Returns:
- the block's data as a byte array
- Throws:
IOException- if there is no data
-