Class BlockStore
java.lang.Object
org.docx4j.org.apache.poi.poifs.filesystem.BlockStore
- Direct Known Subclasses:
NPOIFSFileSystem,NPOIFSMiniStore
public abstract class BlockStore
extends java.lang.Object
This abstract class describes a way to read, store, chain
and free a series of blocks (be they Big or Small ones)
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classBlockStore.ChainLoopDetectorUsed to detect if a chain has a loop in it, so we can bail out with an error rather than spinning away for ever... -
Constructor Summary
Constructors Constructor Description BlockStore() -
Method Summary
Modifier and Type Method Description protected abstract java.nio.ByteBuffercreateBlockIfNeeded(int offset)Extends the file if required to hold blocks up to the specified offset, and return the block from there.protected abstract BATBlock.BATBlockAndIndexgetBATBlockAndIndex(int offset)Returns the BATBlock that handles the specified offset, and the relative index within itprotected abstract java.nio.ByteBuffergetBlockAt(int offset)Load the block at the given offset.protected abstract intgetBlockStoreBlockSize()Returns the size of the blocks managed through the block store.protected abstract BlockStore.ChainLoopDetectorgetChainLoopDetector()Creates a Detector for loops in the chainprotected abstract intgetFreeBlock()Finds a free block, and returns its offset.protected abstract intgetNextBlock(int offset)Works out what block follows the specified one.protected abstract voidsetNextBlock(int offset, int nextBlock)Changes the record of what block follows the specified one.
-
Constructor Details
-
BlockStore
public BlockStore()
-
-
Method Details
-
getBlockStoreBlockSize
protected abstract int getBlockStoreBlockSize()Returns the size of the blocks managed through the block store. -
getBlockAt
protected abstract java.nio.ByteBuffer getBlockAt(int offset) throws java.io.IOExceptionLoad the block at the given offset.- Throws:
java.io.IOException
-
createBlockIfNeeded
protected abstract java.nio.ByteBuffer createBlockIfNeeded(int offset) throws java.io.IOExceptionExtends the file if required to hold blocks up to the specified offset, and return the block from there.- Throws:
java.io.IOException
-
getBATBlockAndIndex
Returns the BATBlock that handles the specified offset, and the relative index within it -
getNextBlock
protected abstract int getNextBlock(int offset)Works out what block follows the specified one. -
setNextBlock
protected abstract void setNextBlock(int offset, int nextBlock)Changes the record of what block follows the specified one. -
getFreeBlock
protected abstract int getFreeBlock() throws java.io.IOExceptionFinds a free block, and returns its offset. This method will extend the file/stream if needed, and if doing so, allocate new FAT blocks to address the extra space.- Throws:
java.io.IOException
-
getChainLoopDetector
Creates a Detector for loops in the chain- Throws:
java.io.IOException
-