001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019 020package org.apache.commons.compress.compressors.gzip; 021 022import java.util.zip.Deflater; 023 024/** 025 * Parameters for the GZIP compressor. 026 * 027 * @since 1.7 028 */ 029public class GzipParameters { 030 031 private int compressionLevel = Deflater.DEFAULT_COMPRESSION; 032 private long modificationTime; 033 private String filename; 034 private String comment; 035 private int operatingSystem = 255; // Unknown OS by default 036 037 public int getCompressionLevel() { 038 return compressionLevel; 039 } 040 041 /** 042 * Sets the compression level. 043 * 044 * @param compressionLevel the compression level (between 0 and 9) 045 * @see Deflater#NO_COMPRESSION 046 * @see Deflater#BEST_SPEED 047 * @see Deflater#DEFAULT_COMPRESSION 048 * @see Deflater#BEST_COMPRESSION 049 */ 050 public void setCompressionLevel(final int compressionLevel) { 051 if (compressionLevel < -1 || compressionLevel > 9) { 052 throw new IllegalArgumentException("Invalid gzip compression level: " + compressionLevel); 053 } 054 this.compressionLevel = compressionLevel; 055 } 056 057 public long getModificationTime() { 058 return modificationTime; 059 } 060 061 /** 062 * Sets the modification time of the compressed file. 063 * 064 * @param modificationTime the modification time, in milliseconds 065 */ 066 public void setModificationTime(final long modificationTime) { 067 this.modificationTime = modificationTime; 068 } 069 070 public String getFilename() { 071 return filename; 072 } 073 074 /** 075 * Sets the name of the compressed file. 076 * 077 * @param filename the name of the file without the directory path 078 */ 079 public void setFilename(final String filename) { 080 this.filename = filename; 081 } 082 083 public String getComment() { 084 return comment; 085 } 086 087 public void setComment(final String comment) { 088 this.comment = comment; 089 } 090 091 public int getOperatingSystem() { 092 return operatingSystem; 093 } 094 095 /** 096 * Sets the operating system on which the compression took place. 097 * The defined values are: 098 * <ul> 099 * <li>0: FAT filesystem (MS-DOS, OS/2, NT/Win32)</li> 100 * <li>1: Amiga</li> 101 * <li>2: VMS (or OpenVMS)</li> 102 * <li>3: Unix</li> 103 * <li>4: VM/CMS</li> 104 * <li>5: Atari TOS</li> 105 * <li>6: HPFS filesystem (OS/2, NT)</li> 106 * <li>7: Macintosh</li> 107 * <li>8: Z-System</li> 108 * <li>9: CP/M</li> 109 * <li>10: TOPS-20</li> 110 * <li>11: NTFS filesystem (NT)</li> 111 * <li>12: QDOS</li> 112 * <li>13: Acorn RISCOS</li> 113 * <li>255: Unknown</li> 114 * </ul> 115 * 116 * @param operatingSystem the code of the operating system 117 */ 118 public void setOperatingSystem(final int operatingSystem) { 119 this.operatingSystem = operatingSystem; 120 } 121}