Class DocumentBlock
java.lang.Object
org.docx4j.org.apache.poi.poifs.storage.DocumentBlock
- All Implemented Interfaces:
BlockWritable
public final class DocumentBlock
extends java.lang.Object
A block of document data.
- Author:
- Marc Johnson (mjohnson at apache dot org)
-
Field Summary
Fields Modifier and Type Field Description protected POIFSBigBlockSizebigBlockSizeEither 512 bytes (POIFSConstants.SMALLER_BIG_BLOCK_SIZE) or 4096 bytes (POIFSConstants.LARGER_BIG_BLOCK_SIZE) -
Constructor Summary
Constructors Constructor Description DocumentBlock(java.io.InputStream stream, POIFSBigBlockSize bigBlockSize)Create a single instance initialized with data.DocumentBlock(RawDataBlock block)create a document block from a raw data block -
Method Summary
Modifier and Type Method Description static DocumentBlock[]convert(POIFSBigBlockSize bigBlockSize, byte[] array, int size)convert a single long array into an array of DocumentBlock instancesprotected voiddoWriteData(java.io.OutputStream stream, byte[] data)Default implementation of write for extending classes that contain their data in a simple array of bytes.static DataInputBlockgetDataInputBlock(DocumentBlock[] blocks, int offset)static bytegetFillByte()booleanpartiallyRead()Was this a partially read block?intsize()Get the number of bytes read for this blockvoidwriteBlocks(java.io.OutputStream stream)Write the storage to an OutputStream
-
Field Details
-
bigBlockSize
Either 512 bytes (POIFSConstants.SMALLER_BIG_BLOCK_SIZE) or 4096 bytes (POIFSConstants.LARGER_BIG_BLOCK_SIZE)
-
-
Constructor Details
-
DocumentBlock
create a document block from a raw data block- Parameters:
block- the raw data block- Throws:
java.io.IOException
-
DocumentBlock
public DocumentBlock(java.io.InputStream stream, POIFSBigBlockSize bigBlockSize) throws java.io.IOExceptionCreate a single instance initialized with data.- Parameters:
stream- the InputStream delivering the data.- Throws:
java.io.IOException
-
-
Method Details
-
size
public int size()Get the number of bytes read for this block- Returns:
- bytes read into the block
-
partiallyRead
public boolean partiallyRead()Was this a partially read block?- Returns:
- true if the block was only partially filled with data
-
getFillByte
public static byte getFillByte()- Returns:
- the fill byte used
-
convert
convert a single long array into an array of DocumentBlock instances- Parameters:
array- the byte array to be convertedsize- the intended size of the array (which may be smaller)- Returns:
- an array of DocumentBlock instances, filled from the input array
-
getDataInputBlock
-
doWriteData
protected void doWriteData(java.io.OutputStream stream, byte[] data) throws java.io.IOExceptionDefault implementation of write for extending classes that contain their data in a simple array of bytes.- Parameters:
stream- the OutputStream to which the data should be written.data- the byte array of to be written.- Throws:
java.io.IOException- on problems writing to the specified stream.
-
writeBlocks
public void writeBlocks(java.io.OutputStream stream) throws java.io.IOExceptionWrite the storage to an OutputStream- Specified by:
writeBlocksin interfaceBlockWritable- Parameters:
stream- the OutputStream to which the stored data should be written- Throws:
java.io.IOException- on problems writing to the specified stream
-