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.
(给定指定的 FAT (BAT) 扇区数,计算可寻址文件的最大大小。)
|
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.
(从字节缓冲区创建单个 BATBlock,该缓冲区必须至少保存一个要读取的大数据块。)
|
static BATBlock |
createEmptyBATBlock(POIFSBigBlockSize bigBlockSize, boolean isXBAT)
Creates a single BATBlock, with all the values set to empty.
(创建一个 BATBlock,所有值都设置为空。)
|
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.
(返回处理指定偏移量的 BATBlock 以及其中的相对索引。)
|
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.
(返回处理迷你流的指定偏移量的 BATBlock 以及其中的相对索引。)
|
int |
getUsedSectors(boolean isAnXBAT)
How many sectors in this block are taken? Note that calling
hasFreeSectors() is much quicker
(这个块中有多少扇区被占用?请注意,调用 hasFreeSectors() 更快)
|
int |
getValueAt(int relativeOffset) |
boolean |
hasFreeSectors()
Does this BATBlock have any free sectors in it, or is it full?
(这个 BATBlock 中是否有任何空闲扇区,还是已满?)
|
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
(将块的数据写入 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 quicker
(这个块中有多少扇区被占用?请注意,调用 hasFreeSectors() 更快)
public 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).
(这个块有多少被占用?这会向上计数扇区数,包括最后使用的扇区。请注意,这与 getUsedSectors(boolean) 不同,后者可能更小,因为它不计算在其后有已使用扇区的未使用扇区(即碎片)。)
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
(接口 BlockWritable 中的 writeBlocks)
stream
- the OutputStream to which the stored data should be written
(stream - 存储数据应写入的 OutputStream)
java.io.IOException
- on problems writing to the specified stream
(java.io.IOException - 关于写入指定流的问题)
public void writeData(java.nio.ByteBuffer block)
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.