Package org.apache.commons.compress.compressors.lz77support

# Class Parameters.Builder

java.lang.Object
org.apache.commons.compress.compressors.lz77support.Parameters.Builder

Enclosing class:
  Parameters

public static class Parameters.Builder extends Object
Builder for `Parameters` instances.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Parameters`
  `build()`
  Creates the `Parameters` instance.
  `Parameters.Builder`
  `tunedForCompressionRatio()`
  Changes the default setting for "nice back-reference length" and "maximum number of candidates" for improved compression ratio at the cost of compression speed.
  `Parameters.Builder`
  `tunedForSpeed()`
  Changes the default setting for "nice back-reference length" and "maximum number of candidates" for improved compression speed at the cost of compression ratio.
  `Parameters.Builder`
  `withLazyMatching(boolean lazy)`
  Sets whether lazy matching should be performed.
  `Parameters.Builder`
  `withLazyThreshold(int threshold)`
  Sets the threshold for lazy matching.
  `Parameters.Builder`
  `withMaxBackReferenceLength(int maxBackReferenceLength)`
  Sets the maximal length of a back-reference.
  `Parameters.Builder`
  `withMaxLiteralLength(int maxLiteralLength)`
  Sets the maximal length of a literal block.
  `Parameters.Builder`
  `withMaxNumberOfCandidates(int maxCandidates)`
  Sets the maximum number of back-reference candidates that should be consulted.
  `Parameters.Builder`
  `withMaxOffset(int maxOffset)`
  Sets the maximal offset of a back-reference.
  `Parameters.Builder`
  `withMinBackReferenceLength(int minBackReferenceLength)`
  Sets the minimal length of a back-reference.
  `Parameters.Builder`
  `withNiceBackReferenceLength(int niceLen)`
  Sets the "nice length" of a back-reference.

  ### Methods inherited from class java.lang.Object

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

- ## Method Details

  - ### build

    public Parameters build()
    Creates the `Parameters` instance.
    Returns:
      the configured `Parameters` instance.

  - ### tunedForCompressionRatio

    public Parameters.Builder tunedForCompressionRatio()
    Changes the default setting for "nice back-reference length" and "maximum number of candidates" for improved compression ratio at the cost of compression speed.

    Use this method after configuring "maximum back-reference length".

    Returns:
      the builder

  - ### tunedForSpeed

    public Parameters.Builder tunedForSpeed()
    Changes the default setting for "nice back-reference length" and "maximum number of candidates" for improved compression speed at the cost of compression ratio.

    Use this method after configuring "maximum back-reference length".

    Returns:
      the builder

  - ### withLazyMatching

    public Parameters.Builder withLazyMatching(boolean lazy)
    Sets whether lazy matching should be performed.

    Lazy matching means that after a back-reference for a certain position has been found the compressor will try to find a longer match for the next position.

    Lazy matching is enabled by default and disabled when tuning for speed.

    Parameters:
      `lazy` - whether lazy matching should be performed
    Returns:
      the builder

  - ### withLazyThreshold

    public Parameters.Builder withLazyThreshold(int threshold)
    Sets the threshold for lazy matching.

    Even if lazy matching is enabled it will not be performed if the length of the back-reference found for the current position is longer than this value.

    Parameters:
      `threshold` - the threshold for lazy matching
    Returns:
      the builder

  - ### withMaxBackReferenceLength

    public Parameters.Builder withMaxBackReferenceLength(int maxBackReferenceLength)
    Sets the maximal length of a back-reference.

    It is recommended to not use this method directly but rather tune a pre-configured builder created by a format specific factory like `SnappyCompressorOutputStream.createParameterBuilder(int)`.

    Parameters:
      `maxBackReferenceLength` - maximal length of a back-reference found. A value smaller than `minBackReferenceLength` is interpreted as `minBackReferenceLength`. `maxBackReferenceLength` is capped at `windowSize - 1`.
    Returns:
      the builder

  - ### withMaxLiteralLength

    public Parameters.Builder withMaxLiteralLength(int maxLiteralLength)
    Sets the maximal length of a literal block.

    It is recommended to not use this method directly but rather tune a pre-configured builder created by a format specific factory like `SnappyCompressorOutputStream.createParameterBuilder(int)`.

    Parameters:
      `maxLiteralLength` - maximal length of a literal block. Negative numbers and 0 as well as values bigger than `windowSize` are interpreted as `windowSize`.
    Returns:
      the builder

  - ### withMaxNumberOfCandidates

    public Parameters.Builder withMaxNumberOfCandidates(int maxCandidates)
    Sets the maximum number of back-reference candidates that should be consulted.

    This settings can be used to tune the tradeoff between compression speed and compression ratio.

    Parameters:
      `maxCandidates` - maximum number of back-reference candidates
    Returns:
      the builder

  - ### withMaxOffset

    public Parameters.Builder withMaxOffset(int maxOffset)
    Sets the maximal offset of a back-reference.

    It is recommended to not use this method directly but rather tune a pre-configured builder created by a format specific factory like `SnappyCompressorOutputStream.createParameterBuilder(int)`.

    Parameters:
      `maxOffset` - maximal offset of a back-reference. A non-positive value as well as values bigger than `windowSize - 1` are interpreted as `windowSize - 1` .
    Returns:
      the builder

  - ### withMinBackReferenceLength

    public Parameters.Builder withMinBackReferenceLength(int minBackReferenceLength)
    Sets the minimal length of a back-reference.

    Ensures `maxBackReferenceLength` is not smaller than `minBackReferenceLength`.

    It is recommended to not use this method directly but rather tune a pre-configured builder created by a format specific factory like `SnappyCompressorOutputStream.createParameterBuilder(int)`.

    Parameters:
      `minBackReferenceLength` - the minimal length of a back-reference found. A true minimum of 3 is hard-coded inside of this implementation but bigger lengths can be configured.
    Returns:
      the builder
    Throws:
      `IllegalArgumentException` - if `windowSize` is smaller than `minBackReferenceLength`.

  - ### withNiceBackReferenceLength

    public Parameters.Builder withNiceBackReferenceLength(int niceLen)
    Sets the "nice length" of a back-reference.

    When a back-references if this size has been found, stop searching for longer back-references.

    This settings can be used to tune the tradeoff between compression speed and compression ratio.

    Parameters:
      `niceLen` - the "nice length" of a back-reference
    Returns:
      the builder