Package org.apache.commons.compress.compressors.gzip

# Class GzipParameters

java.lang.Object
org.apache.commons.compress.compressors.gzip.GzipParameters

public class GzipParameters extends Object
Parameters for the GZIP compressor.

Since:
  1.7
See Also:
  - `GzipCompressorInputStream`
  - `GzipCompressorOutputStream`
  - RFC 1952 GZIP File Format Specification

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `GzipParameters.OS`
  Enumerates OS types.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GzipParameters()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  `int`
  `getBufferSize()`
  Gets size of the buffer used to retrieve compressed data.
  `String`
  `getComment()`
  Gets an arbitrary user-defined comment.
  `int`
  `getCompressionLevel()`
  Gets the compression level.
  `int`
  `getDeflateStrategy()`
  Gets the deflater strategy.
  `ExtraField`
  `getExtraField()`
  Gets the Extra subfields from the header.
  `String`
  `getFilename()`
  Deprecated.
  Use `getFileName()`.
  `String`
  `getFileName()`
  Gets the file name.
  `Charset`
  `getFileNameCharset()`
  Gets the Charset to use for writing file names and comments.
  `boolean`
  `getHeaderCRC()`
  Returns if the header CRC is to be added (when writing) or was present (when reading).
  `Instant`
  `getModificationInstant()`
  Gets the most recent modification time (MTIME) of the original file being compressed.
  `long`
  `getModificationTime()`
  Gets the most recent modification time (MTIME) of the original file being compressed, in seconds since 00:00:00 GMT, Jan. 1, 1970.
  `int`
  `getOperatingSystem()`
  Gets the OS code type.
  `GzipParameters.OS`
  `getOS()`
  Gets the OS type.
  `long`
  `getTrailerCrc()`
  Gets the trailer CRC value.
  `long`
  `getTrailerISize()`
  Gets the trailer ISIZE value.
  `int`
  `hashCode()`
  `void`
  `setBufferSize(int bufferSize)`
  Sets size of the buffer used to retrieve compressed data from `Deflater` and write to underlying `OutputStream`.
  `void`
  `setComment(String comment)`
  Sets an arbitrary user-defined comment.
  `void`
  `setCompressionLevel(int compressionLevel)`
  Sets the compression level.
  `void`
  `setDeflateStrategy(int deflateStrategy)`
  Sets the deflater strategy.
  `void`
  `setExtraField(ExtraField extra)`
  Sets the extra subfields.
  `void`
  `setFilename(String fileName)`
  Deprecated.
  Use `setFileName(String)`.
  `void`
  `setFileName(String fileName)`
  Sets the name of the compressed file.
  `void`
  `setFileNameCharset(Charset charset)`
  Sets the Charset to use for writing file names and comments, where null maps to `GzipUtils.GZIP_ENCODING`.
  `void`
  `setHeaderCRC(boolean headerCRC)`
  Establishes the presence of the header flag FLG.FHCRC and its headers CRC16 value.
  `void`
  `setModificationInstant(Instant modificationTime)`
  Sets the modification time (MTIME) of the compressed file.
  `void`
  `setModificationTime(long modificationTimeSeconds)`
  Sets the modification time (MTIME) of the compressed file, in seconds since 00:00:00 GMT, Jan. 1, 1970.
  `void`
  `setOperatingSystem(int operatingSystem)`
  Sets the operating system on which the compression took place.
  `void`
  `setOS(GzipParameters.OS os)`
  Sets the operating system on which the compression took place.
  `String`
  `toString()`

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

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### GzipParameters

    public GzipParameters()

- ## Method Details

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`

  - ### getBufferSize

    public int getBufferSize()
    Gets size of the buffer used to retrieve compressed data.
    Returns:
      The size of the buffer used to retrieve compressed data.
    Since:
      1.21
    See Also:
      - `setBufferSize(int)`

  - ### getComment

    public String getComment()
    Gets an arbitrary user-defined comment.
    Returns:
      a user-defined comment.

  - ### getCompressionLevel

    public int getCompressionLevel()
    Gets the compression level.
    Returns:
      the compression level.
    See Also:
      - `Deflater.NO_COMPRESSION`
      - `Deflater.BEST_SPEED`
      - `Deflater.DEFAULT_COMPRESSION`
      - `Deflater.BEST_COMPRESSION`

  - ### getDeflateStrategy

    public int getDeflateStrategy()
    Gets the deflater strategy.
    Returns:
      the deflater strategy, `Deflater.DEFAULT_STRATEGY` by default.
    Since:
      1.23
    See Also:
      - `setDeflateStrategy(int)`
      - `Deflater.setStrategy(int)`

  - ### getExtraField

    public ExtraField getExtraField()
    Gets the Extra subfields from the header.
    Returns:
      the extra subfields from the header.
    Since:
      1.28.0

  - ### getFilename

    @Deprecated public String getFilename()
    Deprecated.
    Use `getFileName()`.
    Gets the file name.
    Returns:
      the file name.

  - ### getFileName

    public String getFileName()
    Gets the file name.
    Returns:
      the file name.
    Since:
      1.25.0

  - ### getFileNameCharset

    public Charset getFileNameCharset()
    Gets the Charset to use for writing file names and comments.

    The default value is `GzipUtils.GZIP_ENCODING`.

    Returns:
      the Charset to use for writing file names and comments.
    Since:
      1.28.0

  - ### getHeaderCRC

    public boolean getHeaderCRC()
    Returns if the header CRC is to be added (when writing) or was present (when reading).
    Returns:
      true is header CRC will be added (on write) or was found (after read).
    Since:
      1.28.0

  - ### getModificationInstant

    public Instant getModificationInstant()
    Gets the most recent modification time (MTIME) of the original file being compressed.
    Returns:
      the most recent modification time.
    Since:
      1.28.0

  - ### getModificationTime

    public long getModificationTime()
    Gets the most recent modification time (MTIME) of the original file being compressed, in seconds since 00:00:00 GMT, Jan. 1, 1970.

    The time is in Unix format, for example, seconds since 00:00:00 GMT, Jan. 1, 1970. (Note that this may cause problems for MS-DOS and other systems that use local rather than Universal time.) If the compressed data did not come from a file, MTIME is set to the time at which compression started. MTIME = 0 means no time stamp is available.

    Returns:
      the most recent modification time in seconds since 00:00:00 GMT, Jan. 1, 1970.

  - ### getOperatingSystem

    public int getOperatingSystem()
    Gets the OS code type.
    Returns:
      the OS code type.

  - ### getOS

    public GzipParameters.OS getOS()
    Gets the OS type.
    Returns:
      the OS type.
    Since:
      1.28.0

  - ### getTrailerCrc

    public long getTrailerCrc()
    Gets the trailer CRC value.
    Returns:
      the trailer CRC value.
    Since:
      1.28.0

  - ### getTrailerISize

    public long getTrailerISize()
    Gets the trailer ISIZE value.
    Returns:
      the trailer ISIZE value.
    Since:
      1.28.0

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### setBufferSize

    public void setBufferSize(int bufferSize)
    Sets size of the buffer used to retrieve compressed data from `Deflater` and write to underlying `OutputStream`.
    Parameters:
      `bufferSize` - the bufferSize to set. Must be a positive type.
    Since:
      1.21

  - ### setComment

    public void setComment(String comment)
    Sets an arbitrary user-defined comment.
    Parameters:
      `comment` - a user-defined comment.
    Throws:
      `IllegalArgumentException` - if the encoded bytes would contain a nul byte '\0' reserved for gzip field termination.

  - ### setCompressionLevel

    public void setCompressionLevel(int compressionLevel)
    Sets the compression level.
    Parameters:
      `compressionLevel` - the compression level (between 0 and 9)
    See Also:
      - `Deflater.NO_COMPRESSION`
      - `Deflater.BEST_SPEED`
      - `Deflater.DEFAULT_COMPRESSION`
      - `Deflater.BEST_COMPRESSION`

  - ### setDeflateStrategy

    public void setDeflateStrategy(int deflateStrategy)
    Sets the deflater strategy.
    Parameters:
      `deflateStrategy` - the new compression strategy
    Since:
      1.23
    See Also:
      - `Deflater.setStrategy(int)`

  - ### setExtraField

    public void setExtraField(ExtraField extra)
    Sets the extra subfields. Note that a non-null extra will appear in the gzip header regardless of the presence of subfields, while a null extra will not appear at all.
    Parameters:
      `extra` - the series of extra sub fields.
    Since:
      1.28.0

  - ### setFilename

    @Deprecated public void setFilename(String fileName)
    Deprecated.
    Use `setFileName(String)`.
    Sets the name of the compressed file.
    Parameters:
      `fileName` - the name of the file without the directory path
    Throws:
      `IllegalArgumentException` - if the encoded bytes would contain a nul byte '\0' reserved for gzip field termination.

  - ### setFileName

    public void setFileName(String fileName)
    Sets the name of the compressed file.
    Parameters:
      `fileName` - the name of the file without the directory path
    Throws:
      `IllegalArgumentException` - if the encoded bytes would contain a nul byte '\0' reserved for gzip field termination.

  - ### setFileNameCharset

    public void setFileNameCharset(Charset charset)
    Sets the Charset to use for writing file names and comments, where null maps to `GzipUtils.GZIP_ENCODING`.

    Setting a value other than `GzipUtils.GZIP_ENCODING` is not compliant with the RFC 1952 GZIP File Format Specification. Use at your own risk of interoperability issues.

    The default value is `GzipUtils.GZIP_ENCODING`.

    Parameters:
      `charset` - the Charset to use for writing file names and comments, null maps to `GzipUtils.GZIP_ENCODING`.
    Since:
      1.28.0

  - ### setHeaderCRC

    public void setHeaderCRC(boolean headerCRC)
    Establishes the presence of the header flag FLG.FHCRC and its headers CRC16 value.
    Parameters:
      `headerCRC` - when true, the header CRC16 (actually low 16 buts of a CRC32) is calculated and inserted in the gzip header on write; on read it means the field was present.
    Since:
      1.28.0

  - ### setModificationInstant

    public void setModificationInstant(Instant modificationTime)
    Sets the modification time (MTIME) of the compressed file.
    Parameters:
      `modificationTime` - the modification time, in milliseconds
    Since:
      1.28.0

  - ### setModificationTime

    public void setModificationTime(long modificationTimeSeconds)
    Sets the modification time (MTIME) of the compressed file, in seconds since 00:00:00 GMT, Jan. 1, 1970.

    The time is in Unix format, for example, seconds since 00:00:00 GMT, Jan. 1, 1970. (Note that this may cause problems for MS-DOS and other systems that use local rather than Universal time.) If the compressed data did not come from a file, MTIME is set to the time at which compression started. MTIME = 0 means no time stamp is available.

    Parameters:
      `modificationTimeSeconds` - the modification time, in seconds.

  - ### setOperatingSystem

    public void setOperatingSystem(int operatingSystem)
    Sets the operating system on which the compression took place. The defined values are:
    - 0: FAT file system (MS-DOS, OS/2, NT/Win32)
    - 1: Amiga
    - 2: VMS (or OpenVMS)
    - 3: Unix
    - 4: VM/CMS
    - 5: Atari TOS
    - 6: HPFS file system (OS/2, NT)
    - 7: Macintosh
    - 8: Z-System
    - 9: CP/M
    - 10: TOPS-20
    - 11: NTFS file system (NT)
    - 12: QDOS
    - 13: Acorn RISCOS
    - 255: Unknown
    Parameters:
      `operatingSystem` - the code of the operating system

  - ### setOS

    public void setOS(GzipParameters.OS os)
    Sets the operating system on which the compression took place.
    Parameters:
      `os` - operating system, null maps to `GzipParameters.OS.UNKNOWN`.
    Since:
      1.28.0

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`