001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 * 017 */ 018package org.apache.commons.compress.archivers.sevenz; 019 020/** 021 * Combines a SevenZMethod with configuration options for the method. 022 * 023 * <p>The exact type and interpretation of options depends on the 024 * method being configured. Currently supported are:</p> 025 * 026 * <table summary="Options"> 027 * <tr><th>Method</th><th>Option Type</th><th>Description</th></tr> 028 * <tr><td>BZIP2</td><td>Number</td><td>Block Size - an number between 1 and 9</td></tr> 029 * <tr><td>DEFLATE</td><td>Number</td><td>Compression Level - an number between 1 and 9</td></tr> 030 * <tr><td>LZMA2</td><td>Number</td><td>Dictionary Size - a number between 4096 and 768 MiB (768 << 20)</td></tr> 031 * <tr><td>LZMA2</td><td>org.tukaani.xz.LZMA2Options</td><td>Whole set of LZMA2 options.</td></tr> 032 * <tr><td>DELTA_FILTER</td><td>Number</td><td>Delta Distance - a number between 1 and 256</td></tr> 033 * </table> 034 * 035 * @Immutable 036 * @since 1.8 037 */ 038public class SevenZMethodConfiguration { 039 private final SevenZMethod method; 040 private final Object options; 041 042 /** 043 * Doesn't configure any additional options. 044 * @param method the method to use 045 */ 046 public SevenZMethodConfiguration(final SevenZMethod method) { 047 this(method, null); 048 } 049 050 /** 051 * Specifies and method plus configuration options. 052 * @param method the method to use 053 * @param options the options to use 054 * @throws IllegalArgumentException if the method doesn't understand the options specified. 055 */ 056 public SevenZMethodConfiguration(final SevenZMethod method, final Object options) { 057 this.method = method; 058 this.options = options; 059 if (options != null && !Coders.findByMethod(method).canAcceptOptions(options)) { 060 throw new IllegalArgumentException("The " + method + " method doesn't support options of type " 061 + options.getClass()); 062 } 063 } 064 065 /** 066 * The specified method. 067 * @return the method 068 */ 069 public SevenZMethod getMethod() { 070 return method; 071 } 072 073 /** 074 * The specified options. 075 * @return the options 076 */ 077 public Object getOptions() { 078 return options; 079 } 080 081}