Top Description Fields Constructors Methods
org.apache.poi.poifs.storage

public final Class HeaderBlock

extends Object
implements HeaderBlockConstants
Class Inheritance
All Implemented Interfaces
org.apache.poi.poifs.storage.HeaderBlockConstants
Imports
java.io.IOException, .InputStream, .OutputStream, java.nio.ByteBuffer, java.util.Arrays, org.apache.poi.hssf.OldExcelFormatException, org.apache.poi.poifs.common.POIFSBigBlockSize, .POIFSConstants, org.apache.poi.poifs.filesystem.FileMagic, .NotOLE2FileException, .OfficeXmlFileException, .POIFSFileSystem, org.apache.poi.util.HexDump, .IOUtils, .IntegerField, .LittleEndian, .LittleEndianConsts, .LongField, .ShortField

The block containing the archive header

Field Summary

Modifier and TypeField and Description
private int
_bat_count

Number of big block allocation table blocks (int).

private final byte[]
_data

The data.

private static final byte
private int
_property_start

Start of the property set block (int index of the property set chain's first big block).

private int
_sbat_count

Number of small block allocation table blocks (int) (Number of MiniFAT Sectors in Microsoft parlance)

private int
_sbat_start

start of the small block allocation table (int index of small block allocation table's first big block)

private int
_xbat_count

Number of big block allocation table blocks (int) (Number of DIFAT Sectors in Microsoft parlance)

private int
_xbat_start

Big block index for extension to the big block allocation table

private final POIFSBigBlockSize
bigBlockSize

What big block size the file uses.

Constructor Summary

AccessConstructor and Description
public
HeaderBlock(InputStream
the source InputStream
stream
)

create a new HeaderBlockReader from an InputStream

public
private
HeaderBlock(byte[] data)

public
HeaderBlock(POIFSBigBlockSize bigBlockSize)

Create a single instance initialized with default values

Method Summary

Modifier and TypeMethod and Description
private static IOException
alertShortRead(int pRead)

public int[]

Returns:

BAT offset array
getBATArray
()

Returns the offsets to the first (up to) 109 BAT sectors.

public int

Returns:

number of BAT blocks
getBATCount
()

public POIFSBigBlockSize

Returns:

The Big Block size, normally 512 bytes, sometimes 4096 bytes
getBigBlockSize
()

public int

Returns:

the index of the first block of the Property Table
getPropertyStart
()

get start of Property Table

public int
public int

Returns:

start of small block (MiniFAT) allocation table
getSBATStart
()

public int

Returns:

XBAT (DIFAT) count
getXBATCount
()

public int

Returns:

XBAT (DIFAT) index
getXBATIndex
()

private static byte[]
public void
setBATArray(int[] bat_array)

Sets the offsets of the first (up to) 109 BAT sectors.

public void
setBATCount(final int count)

Sets the number of BAT blocks that are used.

public void
setPropertyStart(final int
the index of the first block of the Property Table
startBlock
)

Set start of Property Table

public void
setSBATBlockCount(final int
the number of SBAT blocks
count
)

Set count of SBAT blocks

public void
setSBATStart(final int
the index of the first big block of the small block allocation table
startBlock
)

Set start of small block allocation table

public void
setXBATCount(final int count)

Sets the number of XBAT (DIFAT) blocks used

public void
setXBATStart(final int startBlock)

Sets the first XBAT (DIFAT) block location

public void
writeData(final OutputStream
the OutputStream to which the stored data should be written
stream
)

Write the block's data to an OutputStream

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_bat_countback to summary
private int _bat_count

Number of big block allocation table blocks (int). (Number of FAT Sectors in Microsoft parlance).

_databack to summary
private final byte[] _data

The data. Only ever 512 bytes, because 4096 byte files use zeros for the extra header space.

_default_valueback to summary
private static final byte _default_value
_property_startback to summary
private int _property_start

Start of the property set block (int index of the property set chain's first big block).

_sbat_countback to summary
private int _sbat_count

Number of small block allocation table blocks (int) (Number of MiniFAT Sectors in Microsoft parlance)

_sbat_startback to summary
private int _sbat_start

start of the small block allocation table (int index of small block allocation table's first big block)

_xbat_countback to summary
private int _xbat_count

Number of big block allocation table blocks (int) (Number of DIFAT Sectors in Microsoft parlance)

_xbat_startback to summary
private int _xbat_start

Big block index for extension to the big block allocation table

bigBlockSizeback to summary
private final POIFSBigBlockSize bigBlockSize

What big block size the file uses. Most files use 512 bytes, but a few use 4096

Constructor Detail

HeaderBlockback to summary
public HeaderBlock(InputStream stream) throws IOException

create a new HeaderBlockReader from an InputStream

Parameters
stream:InputStream

the source InputStream

Exceptions
IOException:
on errors or bad data
HeaderBlockback to summary
public HeaderBlock(ByteBuffer buffer) throws IOException
HeaderBlockback to summary
private HeaderBlock(byte[] data) throws IOException
HeaderBlockback to summary
public HeaderBlock(POIFSBigBlockSize bigBlockSize)

Create a single instance initialized with default values

Method Detail

alertShortReadback to summary
private static IOException alertShortRead(int pRead)
getBATArrayback to summary
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:int[]

BAT offset array

getBATCountback to summary
public int getBATCount()
Returns:int

number of BAT blocks

getBigBlockSizeback to summary
public POIFSBigBlockSize getBigBlockSize()
Returns:POIFSBigBlockSize

The Big Block size, normally 512 bytes, sometimes 4096 bytes

getPropertyStartback to summary
public int getPropertyStart()

get start of Property Table

Returns:int

the index of the first block of the Property Table

getSBATCountback to summary
public int getSBATCount()
getSBATStartback to summary
public int getSBATStart()
Returns:int

start of small block (MiniFAT) allocation table

getXBATCountback to summary
public int getXBATCount()
Returns:int

XBAT (DIFAT) count

getXBATIndexback to summary
public int getXBATIndex()
Returns:int

XBAT (DIFAT) index

readFirst512back to summary
private static byte[] readFirst512(InputStream stream) throws IOException
setBATArrayback to summary
public void setBATArray(int[] bat_array)

Sets the offsets of the first (up to) 109 BAT sectors.

setBATCountback to summary
public void setBATCount(final int count)

Sets the number of BAT blocks that are used. This is the number used in both the BAT and XBAT.

setPropertyStartback to summary
public void setPropertyStart(final int startBlock)

Set start of Property Table

Parameters
startBlock:int

the index of the first block of the Property Table

setSBATBlockCountback to summary
public void setSBATBlockCount(final int count)

Set count of SBAT blocks

Parameters
count:int

the number of SBAT blocks

setSBATStartback to summary
public void setSBATStart(final int startBlock)

Set start of small block allocation table

Parameters
startBlock:int

the index of the first big block of the small block allocation table

setXBATCountback to summary
public void setXBATCount(final int count)

Sets the number of XBAT (DIFAT) blocks used

setXBATStartback to summary
public void setXBATStart(final int startBlock)

Sets the first XBAT (DIFAT) block location

writeDataback to summary
public void writeData(final OutputStream stream) throws IOException

Write the block's data to an OutputStream

Parameters
stream:OutputStream

the OutputStream to which the stored data should be written

Exceptions
IOException:
on problems writing to the specified stream