001/* 002 * $Id: PackCompressor.java,v 1.3 2005/08/29 03:18:22 jponge Exp $ 003 * IzPack - Copyright 2001-2005 Julien Ponge, All Rights Reserved. 004 * 005 * http://www.izforge.com/izpack/ 006 * http://developer.berlios.de/projects/izpack/ 007 * 008 * Copyright 2005 Klaus Bartz 009 * 010 * Licensed under the Apache License, Version 2.0 (the "License"); 011 * you may not use this file except in compliance with the License. 012 * You may obtain a copy of the License at 013 * 014 * http://www.apache.org/licenses/LICENSE-2.0 015 * 016 * Unless required by applicable law or agreed to in writing, software 017 * distributed under the License is distributed on an "AS IS" BASIS, 018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 019 * See the License for the specific language governing permissions and 020 * limitations under the License. 021 */ 022package com.izforge.izpack.compressor; 023 024import java.io.OutputStream; 025 026import com.izforge.izpack.compiler.Compiler; 027 028 029/** 030 * IzPack will be able to support different compression methods for the 031 * packs included in the installation jar file. 032 * This interface declares the handler of one compression format. 033 * 034 * @author Klaus Bartz 035 */ 036 037public interface PackCompressor 038{ 039 040 /** 041 * Returns a newly created output stream which write method 042 * writes the given input encoded to the defined output stream. 043 * Attention! This method will be returned a valid output stream 044 * only if it is used in the IzPack compiler, or if this pack compressor 045 * needs no external classes. A call in the 046 * installation should be throw if external classes are used. 047 * The implementation should load the needed classes via reflection 048 * because classes are not present in the installation. 049 * @param os output stream to be used as listener 050 * @return a newly created encoding output stream 051 * @throws Exception 052 */ 053 OutputStream getOutputStream(OutputStream os) throws Exception; 054 055 /** 056 * Returns all symbolic names which are used for this compressor. 057 * @return all symbolic names which are used for this compressor 058 */ 059 String []getCompressionFormatSymbols(); 060 061 /** 062 * Returns the path where the compiler can find the classes; 063 * normaly this is a path to a jar file. 064 * If no additional classes are needed, this method should return null. 065 * @return the path where the compiler can find the classes 066 */ 067 String[] getContainerPaths(); 068 069 /** 070 * Returns the qualified names of all needed classes for decoding. 071 * All class files should be placed in the container which will 072 * be referred by the method getContainerPath. 073 * If no additional classes are needed, this method should return null. 074 * @return qualified names of all needed classes for decoding 075 */ 076 String[][] getDecoderClassNames(); 077 078 /** 079 * Returns the qualified name of the encoding output stream. 080 * The class file should be placed in the container which will 081 * be referred by the method getContainerPath. 082 * @return qualified name of the encoding output stream 083 */ 084 String getEncoderClassName(); 085 086 /** 087 * Returns the qualified name of the class which should be used 088 * as InputStream in the installer. This class mapps the "real" 089 * decoder or - if useable - the decoder name will be returned self. 090 * If useStandardCompression is true, this method returns null. 091 * @return the qualified name of the class which should be used 092 * as InputStream in the installer 093 */ 094 String getDecoderMapperName(); 095 /** 096 * Returns whether the standard comression should be used with 097 * this pack compressor or not. If this method returns true, 098 * the returns values of the methods getContainerPath and 099 * getDecoderClassNames are not valid (should be null). 100 * @return whether the standard comression should be used or not 101 */ 102 boolean useStandardCompression(); 103 104 /** 105 * Receives the current used compiler. 106 * Needed at loading encoder classes and error handling. 107 * @param compiler current active compiler 108 */ 109 void setCompiler(Compiler compiler); 110 111 /** 112 * Returns whether a buffered output stream should be used 113 * intermediate between the output stream of this compressor 114 * and the destination. 115 * @return wether a buffered output stream should be used 116 * intermediate between the output stream of this compressor 117 * and the destination. 118 */ 119 boolean needsBufferedOutputStream(); 120 121 /** 122 * Receives the compression level to be used. 123 * @param level compression level to be used 124 */ 125 void setCompressionLevel(int level); 126 127 /** 128 * Returns the compression level to be used. 129 * @return the compression level to be used 130 */ 131 int getCompressionLevel(); 132 133 134 135}