public final class BATBlock extends java.lang.Object implements BlockWritable
Modifier and Type | Class and Description |
---|---|
static class |
BATBlock.BATBlockAndIndex |
Modifier and Type | Method and Description |
---|---|
static long |
calculateMaximumSize(HeaderBlock header) |
static long |
calculateMaximumSize(POIFSBigBlockSize bigBlockSize,
int numBATs)
Calculates the maximum size of a file which is addressable given the
number of FAT (BAT) sectors specified.
|
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 |
createEmptyBATBlock(POIFSBigBlockSize bigBlockSize,
boolean isXBAT)
Creates a single BATBlock, with all the values set to empty.
|
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 |
getOccupiedSize()
How much of this block is occupied?.
|
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 |
getUsedSectors(boolean isAnXBAT)
How many sectors in this block are taken?
Note that calling
hasFreeSectors() is much quicker |
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 block's data to an OutputStream
|
void |
writeData(java.nio.ByteBuffer block) |
public static BATBlock createBATBlock(POIFSBigBlockSize bigBlockSize, java.nio.ByteBuffer data)
public static BATBlock createEmptyBATBlock(POIFSBigBlockSize bigBlockSize, boolean isXBAT)
public static long calculateMaximumSize(POIFSBigBlockSize bigBlockSize, int numBATs)
public static long 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 getUsedSectors(boolean isAnXBAT)
hasFreeSectors()
is much quickerpublic int getOccupiedSize()
getUsedSectors(boolean)
which
could be smaller as it does not count unused sectors where there are
used ones after it (i.e. fragmentation).public int getValueAt(int relativeOffset)
public void setValueAt(int relativeOffset, int value)
public void setOurBlockIndex(int index)
public int getOurBlockIndex()
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
streampublic void writeData(java.nio.ByteBuffer block)
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.