Class FixedSizeChunkerCore

java.lang.Object
de.zabuza.fastcdc4j.internal.chunking.FixedSizeChunkerCore
All Implemented Interfaces:
IterativeStreamChunkerCore

public final class FixedSizeChunkerCore
extends java.lang.Object
implements IterativeStreamChunkerCore
Implementation of an iterative stream chunker core that splits data into chunks of equal size, known as Fixed-Size-Chunking.
Author:
Daniel Tischner <zabuza.dev@gmail.com>
  • Constructor Summary

    Constructors 
    Constructor Description
    FixedSizeChunkerCore​(int chunkSize)
    Creates a new core.
  • Method Summary

    Modifier and Type Method Description
    byte[] readNextChunk​(java.io.InputStream stream, long size, long currentOffset)
    Reads the next chunk from the given data stream.

    Methods inherited from class java.lang.Object

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

    • FixedSizeChunkerCore

      public FixedSizeChunkerCore​(int chunkSize)
      Creates a new core.
      Parameters:
      chunkSize - The fixed chunk size to use for splitting, must be positive and not zero
  • Method Details

    • readNextChunk

      public byte[] readNextChunk​(java.io.InputStream stream, long size, long currentOffset)
      Description copied from interface: IterativeStreamChunkerCore
      Reads the next chunk from the given data stream. The stream is consumed by exactly the length of the provided chunk. The stream is safe to be read byte by byte, it provides buffering methods if necessary.
      Specified by:
      readNextChunk in interface IterativeStreamChunkerCore
      Parameters:
      stream - The data stream to chunk, not null
      size - Remaining data available in the stream that are subject to be chunked, must be positive and not zero
      currentOffset - Current offset in the given stream, in regards to its original start, must be positive and less than size
      Returns:
      The chunk that was read