View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package edu.internet2.middleware.grouperInstallerExt.org.apache.commons.compress.compressors.deflate;
21  
22  import java.util.zip.Deflater;
23  
24  /**
25   * Parameters for the Deflate compressor.
26   * @since 1.9
27   */
28  public class DeflateParameters {
29  
30      private boolean zlibHeader = true;
31      private int compressionLevel = Deflater.DEFAULT_COMPRESSION;
32  
33      /**
34       * Whether or not the zlib header shall be written (when
35       * compressing) or expected (when decompressing).
36       */
37      public boolean withZlibHeader() {
38          return zlibHeader;
39      }
40  
41      /**
42       * Sets the zlib header presence parameter.
43       *
44       * <p>This affects whether or not the zlib header will be written
45       * (when compressing) or expected (when decompressing).</p>
46       *
47       * @param zlibHeader
48       */
49      public void setWithZlibHeader(boolean zlibHeader) {
50          this.zlibHeader = zlibHeader;
51      }
52  
53      /**
54       * The compression level.
55       * @see #setCompressionLevel
56       */
57      public int getCompressionLevel() {
58          return compressionLevel;
59      }
60  
61      /**
62       * Sets the compression level.
63       *
64       * @param compressionLevel the compression level (between 0 and 9)
65       * @see Deflater#NO_COMPRESSION
66       * @see Deflater#BEST_SPEED
67       * @see Deflater#DEFAULT_COMPRESSION
68       * @see Deflater#BEST_COMPRESSION
69       */
70      public void setCompressionLevel(int compressionLevel) {
71          if (compressionLevel < -1 || compressionLevel > 9) {
72              throw new IllegalArgumentException("Invalid Deflate compression level: " + compressionLevel);
73          }
74          this.compressionLevel = compressionLevel;
75      }
76  
77  }