public final class BATBlock
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
BATBlock.BATBlockAndIndex |
Modifier and Type | Field and Description |
---|---|
protected POIFSBigBlockSize |
bigBlockSize
Either 512 bytes (
POIFSConstants.SMALLER_BIG_BLOCK_SIZE )
or 4096 bytes (POIFSConstants.LARGER_BIG_BLOCK_SIZE ) |
Modifier and Type | Method and Description |
---|---|
static int |
calculateMaximumSize(HeaderBlock header) |
static int |
calculateMaximumSize(POIFSBigBlockSize bigBlockSize,
int numBATs)
Calculates the maximum size of a file which is addressable given the
number of FAT (BAT) sectors specified.
|
static int |
calculateStorageRequirements(POIFSBigBlockSize bigBlockSize,
int entryCount)
Calculate how many BATBlocks are needed to hold a specified
number of BAT entries.
|
static int |
calculateXBATStorageRequirements(POIFSBigBlockSize bigBlockSize,
int entryCount)
Calculate how many XBATBlocks are needed to hold a specified
number of BAT entries.
|
static BATBlock |
createBATBlock(POIFSBigBlockSize bigBlockSize,
java.nio.ByteBuffer data)
Create a single BATBlock from the byte buffer, which must hold at least
one big block of data to be read.
|
static BATBlock[] |
createBATBlocks(POIFSBigBlockSize bigBlockSize,
int[] entries)
Create an array of BATBlocks from an array of int block
allocation table entries
|
static BATBlock |
createEmptyBATBlock(POIFSBigBlockSize bigBlockSize,
boolean isXBAT)
Creates a single BATBlock, with all the values set to empty.
|
static BATBlock[] |
createXBATBlocks(POIFSBigBlockSize bigBlockSize,
int[] entries,
int startBlock)
Create an array of XBATBlocks from an array of int block
allocation table entries
|
protected void |
doWriteData(java.io.OutputStream stream,
byte[] data)
Default implementation of write for extending classes that
contain their data in a simple array of bytes.
|
static BATBlock.BATBlockAndIndex |
getBATBlockAndIndex(int offset,
HeaderBlock header,
java.util.List<BATBlock> bats)
Returns the BATBlock that handles the specified offset,
and the relative index within it.
|
int |
getOurBlockIndex()
Retrieve where in the file we live
|
static BATBlock.BATBlockAndIndex |
getSBATBlockAndIndex(int offset,
HeaderBlock header,
java.util.List<BATBlock> sbats)
Returns the BATBlock that handles the specified offset,
and the relative index within it, for the mini stream.
|
int |
getValueAt(int relativeOffset) |
boolean |
hasFreeSectors()
Does this BATBlock have any free sectors in it, or
is it full?
|
void |
setOurBlockIndex(int index)
Record where in the file we live
|
void |
setValueAt(int relativeOffset,
int value) |
void |
writeBlocks(java.io.OutputStream stream)
Write the storage to an OutputStream
|
protected POIFSBigBlockSize bigBlockSize
POIFSConstants.SMALLER_BIG_BLOCK_SIZE
)
or 4096 bytes (POIFSConstants.LARGER_BIG_BLOCK_SIZE
)public static BATBlock createBATBlock(POIFSBigBlockSize bigBlockSize, java.nio.ByteBuffer data)
public static BATBlock createEmptyBATBlock(POIFSBigBlockSize bigBlockSize, boolean isXBAT)
public static BATBlock[] createBATBlocks(POIFSBigBlockSize bigBlockSize, int[] entries)
entries
- the array of int entriespublic static BATBlock[] createXBATBlocks(POIFSBigBlockSize bigBlockSize, int[] entries, int startBlock)
entries
- the array of int entriesstartBlock
- the start block of the array of XBAT blockspublic static int calculateStorageRequirements(POIFSBigBlockSize bigBlockSize, int entryCount)
entryCount
- the number of entriespublic static int calculateXBATStorageRequirements(POIFSBigBlockSize bigBlockSize, int entryCount)
entryCount
- the number of entriespublic static int calculateMaximumSize(POIFSBigBlockSize bigBlockSize, int numBATs)
public static int calculateMaximumSize(HeaderBlock header)
public static BATBlock.BATBlockAndIndex getBATBlockAndIndex(int offset, HeaderBlock header, java.util.List<BATBlock> bats)
public static BATBlock.BATBlockAndIndex getSBATBlockAndIndex(int offset, HeaderBlock header, java.util.List<BATBlock> sbats)
public boolean hasFreeSectors()
public int getValueAt(int relativeOffset)
public void setValueAt(int relativeOffset, int value)
public void setOurBlockIndex(int index)
public int getOurBlockIndex()
protected void doWriteData(java.io.OutputStream stream, byte[] data) throws java.io.IOException
stream
- the OutputStream to which the data should be
written.data
- the byte array of to be written.java.io.IOException
- on problems writing to the specified
stream.public void writeBlocks(java.io.OutputStream stream) throws java.io.IOException
writeBlocks
in interface BlockWritable
stream
- the OutputStream to which the stored data should
be writtenjava.io.IOException
- on problems writing to the specified
streamCopyright © 2005-2010 Potix Corporation. All Rights Reserved.