Class HeaderBlock
java.lang.Object
org.docx4j.org.apache.poi.poifs.storage.HeaderBlock
- All Implemented Interfaces:
HeaderBlockConstants
The block containing the archive header
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intNumber of big block allocation table blocks (int).private final byte[]The data.private static final byteprivate static org.slf4j.Loggerprivate intStart of the property set block (int index of the property set chain's first big block).private intNumber of small block allocation table blocks (int) (Number of MiniFAT Sectors in Microsoft parlance)private intstart of the small block allocation table (int index of small block allocation table's first big block)private intNumber of big block allocation table blocks (int) (Number of DIFAT Sectors in Microsoft parlance)private intBig block index for extension to the big block allocation tableprivate final POIFSBigBlockSizeWhat big block size the file uses.Fields inherited from interface org.docx4j.org.apache.poi.poifs.storage.HeaderBlockConstants
_bat_array_offset, _bat_count_offset, _max_bats_in_header, _property_start_offset, _sbat_block_count_offset, _sbat_start_offset, _signature, _signature_offset, _xbat_count_offset, _xbat_start_offset -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateHeaderBlock(byte[] data) HeaderBlock(InputStream stream) create a new HeaderBlockReader from an InputStreamHeaderBlock(ByteBuffer buffer) HeaderBlock(POIFSBigBlockSize bigBlockSize) Create a single instance initialized with default values -
Method Summary
Modifier and TypeMethodDescriptionprivate static IOExceptionalertShortRead(int pRead, int expectedReadSize) int[]Returns the offsets to the first (up to) 109 BAT sectors.intintget start of Property Tableintintintintprivate static StringlongToHex(long value) private static byte[]readFirst512(InputStream stream) voidsetBATArray(int[] bat_array) Sets the offsets of the first (up to) 109 BAT sectors.voidsetBATCount(int count) Sets the number of BAT blocks that are used.voidsetPropertyStart(int startBlock) Set start of Property TablevoidsetSBATBlockCount(int count) Set count of SBAT blocksvoidsetSBATStart(int startBlock) Set start of small block allocation tablevoidsetXBATCount(int count) Sets the number of XBAT (DIFAT) blocks usedvoidsetXBATStart(int startBlock) Sets the first XBAT (DIFAT) block location(package private) voidwriteData(OutputStream stream) Write the block's data to an OutputStream
-
Field Details
-
_logger
private static org.slf4j.Logger _logger -
bigBlockSize
What big block size the file uses. Most files use 512 bytes, but a few use 4096 -
_bat_count
private int _bat_countNumber of big block allocation table blocks (int). (Number of FAT Sectors in Microsoft parlance). -
_property_start
private int _property_startStart of the property set block (int index of the property set chain's first big block). -
_sbat_start
private int _sbat_startstart of the small block allocation table (int index of small block allocation table's first big block) -
_sbat_count
private int _sbat_countNumber of small block allocation table blocks (int) (Number of MiniFAT Sectors in Microsoft parlance) -
_xbat_start
private int _xbat_startBig block index for extension to the big block allocation table -
_xbat_count
private int _xbat_countNumber of big block allocation table blocks (int) (Number of DIFAT Sectors in Microsoft parlance) -
_data
private final byte[] _dataThe data. Only ever 512 bytes, because 4096 byte files use zeros for the extra header space. -
_default_value
private static final byte _default_value- See Also:
-
-
Constructor Details
-
HeaderBlock
create a new HeaderBlockReader from an InputStream- Parameters:
stream- the source InputStream- Throws:
IOException- on errors or bad data
-
HeaderBlock
- Throws:
IOException
-
HeaderBlock
- Throws:
IOException
-
HeaderBlock
Create a single instance initialized with default values
-
-
Method Details
-
readFirst512
- Throws:
IOException
-
longToHex
-
alertShortRead
-
getPropertyStart
public int getPropertyStart()get start of Property Table- Returns:
- the index of the first block of the Property Table
-
setPropertyStart
public void setPropertyStart(int startBlock) Set start of Property Table- Parameters:
startBlock- the index of the first block of the Property Table
-
getSBATStart
public int getSBATStart()- Returns:
- start of small block (MiniFAT) allocation table
-
getSBATCount
public int getSBATCount() -
setSBATStart
public void setSBATStart(int startBlock) Set start of small block allocation table- Parameters:
startBlock- the index of the first big block of the small block allocation table
-
setSBATBlockCount
public void setSBATBlockCount(int count) Set count of SBAT blocks- Parameters:
count- the number of SBAT blocks
-
getBATCount
public int getBATCount()- Returns:
- number of BAT blocks
-
setBATCount
public void setBATCount(int count) Sets the number of BAT blocks that are used. This is the number used in both the BAT and XBAT. -
getBATArray
public int[] getBATArray()Returns the offsets to the first (up to) 109 BAT sectors. Any additional BAT sectors are held in the XBAT (DIFAT) sectors in a chain.- Returns:
- BAT offset array
-
setBATArray
public void setBATArray(int[] bat_array) Sets the offsets of the first (up to) 109 BAT sectors. -
getXBATCount
public int getXBATCount()- Returns:
- XBAT (DIFAT) count
-
setXBATCount
public void setXBATCount(int count) Sets the number of XBAT (DIFAT) blocks used -
getXBATIndex
public int getXBATIndex()- Returns:
- XBAT (DIFAT) index
-
setXBATStart
public void setXBATStart(int startBlock) Sets the first XBAT (DIFAT) block location -
getBigBlockSize
- Returns:
- The Big Block size, normally 512 bytes, sometimes 4096 bytes
-
writeData
Write the block's data to an OutputStream- Parameters:
stream- the OutputStream to which the stored data should be written- Throws:
IOException- on problems writing to the specified stream
-