Class IterativeStreamChunker

java.lang.Object
de.zabuza.fastcdc4j.internal.chunking.IterativeStreamChunker
All Implemented Interfaces:
Chunker

public final class IterativeStreamChunker
extends java.lang.Object
implements Chunker
Implementation of a chunker that iteratively chunks the stream by using a given IterativeStreamChunkerCore as core for the chunking behavior.
Author:
Daniel Tischner <zabuza.dev@gmail.com>
  • Constructor Summary

    Constructors 
    Constructor Description
    IterativeStreamChunker​(IterativeStreamChunkerCore core, java.lang.String hashMethod)
    Creates a new chunker.
  • Method Summary

    Modifier and Type Method Description
    java.lang.Iterable<Chunk> chunk​(java.io.InputStream stream, long size)
    Chunks the given stream into chunks.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface de.zabuza.fastcdc4j.external.chunking.Chunker

    chunk, chunk, chunk
  • Constructor Details

    • IterativeStreamChunker

      public IterativeStreamChunker​(IterativeStreamChunkerCore core, java.lang.String hashMethod)
      Creates a new chunker.
      Parameters:
      core - The core to use for chunking, not null
      hashMethod - The hash method to use for hashing the data of a chunk, has to be supported and accepted by MessageDigest
  • Method Details

    • chunk

      public java.lang.Iterable<Chunk> chunk​(java.io.InputStream stream, long size)
      Description copied from interface: Chunker
      Chunks the given stream into chunks. The stream is consumed and populates the resulting iterable lazily as it is consumed.

      Chunks own their bytes, so it is preferable to process them directly and avoid first collecting all of them.

      Specified by:
      chunk in interface Chunker
      Parameters:
      stream - The data stream to chunk, not null
      size - The amount of bytes available in the stream that are subject to be chunked, the stream must offer at least that many bytes. Must be positive and not zero.
      Returns:
      The chunks of the stream, lazily populated