Top Description Inners Constructors Methods
org.apache.poi.poifs.filesystem

public abstract Class BlockStore

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.poi.poifs.filesystem.POIFSFileSystem, org.apache.poi.poifs.filesystem.POIFSMiniStore
Imports
java.io.IOException, java.nio.ByteBuffer, org.apache.poi.poifs.storage.BATBlock.BATBlockAndIndex

This abstract class describes a way to read, store, chain and free a series of blocks (be they Big or Small ones)

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
BlockStore.ChainLoopDetector

Used 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

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected abstract ByteBuffer
createBlockIfNeeded(final int offset)

Extends the file if required to hold blocks up to the specified offset, and return the block from there.

protected abstract BATBlock.BATBlockAndIndex
getBATBlockAndIndex(final int offset)

Returns the BATBlock that handles the specified offset, and the relative index within it

protected abstract ByteBuffer
getBlockAt(final int offset)

Load the block at the given offset.

protected abstract int
getBlockStoreBlockSize()

Returns the size of the blocks managed through the block store.

protected abstract BlockStore.ChainLoopDetector
getChainLoopDetector()

Creates a Detector for loops in the chain

protected abstract int
getFreeBlock()

Finds a free block, and returns its offset.

protected abstract int
getNextBlock(final int offset)

Works out what block follows the specified one.

protected abstract void
releaseBuffer(ByteBuffer
the buffer
buffer
)

Releases a mmap-ed buffer, which you are sure won't be used again

protected abstract void
setNextBlock(final int offset, final int nextBlock)

Changes the record of what block follows the specified one.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

BlockStoreback to summary
public BlockStore()

Method Detail

createBlockIfNeededback to summary
protected abstract ByteBuffer createBlockIfNeeded(final int offset) throws IOException

Extends the file if required to hold blocks up to the specified offset, and return the block from there.

getBATBlockAndIndexback to summary
protected abstract BATBlock.BATBlockAndIndex getBATBlockAndIndex(final int offset)

Returns the BATBlock that handles the specified offset, and the relative index within it

getBlockAtback to summary
protected abstract ByteBuffer getBlockAt(final int offset) throws IOException

Load the block at the given offset.

getBlockStoreBlockSizeback to summary
protected abstract int getBlockStoreBlockSize()

Returns the size of the blocks managed through the block store.

getChainLoopDetectorback to summary
protected abstract BlockStore.ChainLoopDetector getChainLoopDetector() throws IOException

Creates a Detector for loops in the chain

getFreeBlockback to summary
protected abstract int getFreeBlock() throws IOException

Finds 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.

getNextBlockback to summary
protected abstract int getNextBlock(final int offset)

Works out what block follows the specified one.

releaseBufferback to summary
protected abstract void releaseBuffer(ByteBuffer buffer)

Releases a mmap-ed buffer, which you are sure won't be used again

Parameters
buffer:ByteBuffer

the buffer

setNextBlockback to summary
protected abstract void setNextBlock(final int offset, final int nextBlock)

Changes the record of what block follows the specified one.

org.apache.poi.poifs.filesystem back to summary

protected Class BlockStore.ChainLoopDetector

extends Object
Class Inheritance

Used to detect if a chain has a loop in it, so we can bail out with an error rather than spinning away for ever...

Field Summary

Modifier and TypeField and Description
private final boolean[]

Constructor Summary

AccessConstructor and Description
protected
ChainLoopDetector(long rawSize)

Method Summary

Modifier and TypeMethod and Description
protected void
claim(int offset)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

used_blocksback to summary
private final boolean[] used_blocks

Constructor Detail

ChainLoopDetectorback to summary
protected ChainLoopDetector(long rawSize)

Method Detail

claimback to summary
protected void claim(int offset)