Class DocumentBlock

java.lang.Object
loci.poi.poifs.storage.DocumentBlock
All Implemented Interfaces:
BlockWritable

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

    Constructors
    Constructor
    Description
    DocumentBlock(loci.common.RandomAccessInputStream stream, int size)
    Create a single instance initialized with data.
    DocumentBlock(RawDataBlock block, int size)
    create a document block from a raw data block
  • Method Summary

    Modifier and Type
    Method
    Description
    static DocumentBlock[]
    convert(long offset, loci.common.RandomAccessInputStream stream, int numBytes, int size, int blockSize)
    convert a single long array into an array of DocumentBlock instances
    protected void
    doWriteData(OutputStream stream, byte[] data)
    Default implementation of write for extending classes that contain their data in a simple array of bytes.
    int
     
    static byte
     
    boolean
    Was this a partially read block?
    static void
    read(DocumentBlock[] blocks, byte[] buffer, int offset, int blockSize, loci.common.RandomAccessInputStream stream)
    read data from an array of DocumentBlocks
    int
    Get the number of bytes read for this block
    void
    Write the storage to an OutputStream

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DocumentBlock

      public DocumentBlock(RawDataBlock block, int size) throws IOException
      create a document block from a raw data block
      Parameters:
      block - the raw data block
      size - the block size
      Throws:
      IOException
    • DocumentBlock

      public DocumentBlock(loci.common.RandomAccessInputStream stream, int size) throws IOException
      Create a single instance initialized with data.
      Parameters:
      stream - the InputStream delivering the data.
      Throws:
      IOException
  • Method Details

    • size

      public int size()
      Get the number of bytes read for this block
      Returns:
      bytes read into the block
    • getBigBlockSize

      public int getBigBlockSize()
    • 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(long offset, loci.common.RandomAccessInputStream stream, int numBytes, int size, int blockSize)
      convert a single long array into an array of DocumentBlock instances
      Parameters:
      offset - the offset into the array of blocks to read from
      stream - the RandomAccessInputStream to read from
      size - the intended size of the array (which may be smaller)
      numBytes - the number of bytes
      blockSize - the size of a big block
      Returns:
      an array of DocumentBlock instances, filled from the input array
    • read

      public static void read(DocumentBlock[] blocks, byte[] buffer, int offset, int blockSize, loci.common.RandomAccessInputStream stream)
      read data from an array of DocumentBlocks
      Parameters:
      blocks - the blocks to read from
      buffer - the buffer to write the data into
      offset - the offset into the array of blocks to read from
    • 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