Class DocumentBlock

java.lang.Object
org.docx4j.org.apache.poi.poifs.storage.DocumentBlock
All Implemented Interfaces:
BlockWritable

public final class DocumentBlock extends Object
A block of document data.
Author:
Marc Johnson (mjohnson at apache dot org)
  • Field Details

  • Constructor Details

  • 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

      public static DocumentBlock[] convert(POIFSBigBlockSize bigBlockSize, byte[] array, int size)
      convert a single long array into an array of DocumentBlock instances
      Parameters:
      array - the byte array to be converted
      size - the intended size of the array (which may be smaller)
      Returns:
      an array of DocumentBlock instances, filled from the input array
    • getDataInputBlock

      public static DataInputBlock getDataInputBlock(DocumentBlock[] blocks, int offset)
    • doWriteData

      protected void doWriteData(OutputStream stream, byte[] data) throws IOException
      Default 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:
      IOException - on problems writing to the specified stream.
    • writeBlocks

      public void writeBlocks(OutputStream stream) throws IOException
      Write the storage to an OutputStream
      Specified by:
      writeBlocks in interface BlockWritable
      Parameters:
      stream - the OutputStream to which the stored data should be written
      Throws:
      IOException - on problems writing to the specified stream