Class SimpleChunk

java.lang.Object
de.zabuza.fastcdc4j.internal.chunking.SimpleChunk
All Implemented Interfaces:
Chunk

public final class SimpleChunk
extends java.lang.Object
implements Chunk
Implementation of a simple chunk, wrapping given data.

The getHexHash() is cached and will be generated upon construction.

Author:
Daniel Tischner <zabuza.dev@gmail.com>
  • Constructor Summary

    Constructors 
    Constructor Description
    SimpleChunk​(byte[] data, long offset, byte[] hash)
    Creates a new simple chunk.
  • Method Summary

    Modifier and Type Method Description
    byte[] getData()
    Gets the data contained in this chunk.
    byte[] getHash()
    A binary hash representation of the contained data.
    java.lang.String getHexHash()
    A hexadecimal hash representation of the contained data.
    int getLength()
    The length of this chunk, i.e. the amount of contained data.
    long getOffset()
    Gets the offset of this chunk, with respect to its source data stream.

    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.Chunk

    toChunkMetadata
  • Constructor Details

    • SimpleChunk

      public SimpleChunk​(byte[] data, long offset, byte[] hash)
      Creates a new simple chunk.

      The getHexHash() is cached and will be generated upon construction based on the given hash.

      Parameters:
      data - The data contained in this chunk, not null and not empty
      offset - The offset of this chunk, with respect to its source data stream, must be positive
      hash - A binary hash representation of the contained data. Using the algorithm specified during construction by the Chunker. Not null and not empty.
  • Method Details

    • getData

      public byte[] getData()
      Description copied from interface: Chunk
      Gets the data contained in this chunk.
      Specified by:
      getData in interface Chunk
      Returns:
      The contained data
    • getHash

      public byte[] getHash()
      Description copied from interface: Chunk
      A binary hash representation of the contained data. Using the algorithm specified during construction by the Chunker.
      Specified by:
      getHash in interface Chunk
      Returns:
      A binary hash representation
    • getHexHash

      public java.lang.String getHexHash()
      Description copied from interface: Chunk
      A hexadecimal hash representation of the contained data. Using the algorithm specified during construction by the Chunker.
      Specified by:
      getHexHash in interface Chunk
      Returns:
      A hexadecimal hash representation
    • getLength

      public int getLength()
      Description copied from interface: Chunk
      The length of this chunk, i.e. the amount of contained data.
      Specified by:
      getLength in interface Chunk
      Returns:
      Gets the length
    • getOffset

      public long getOffset()
      Description copied from interface: Chunk
      Gets the offset of this chunk, with respect to its source data stream.
      Specified by:
      getOffset in interface Chunk
      Returns:
      The offset