com.izforge.izpack.compressor
Class PackCompressorBase

java.lang.Object
  extended bycom.izforge.izpack.compressor.PackCompressorBase
All Implemented Interfaces:
PackCompressor
Direct Known Subclasses:
BZip2PackCompressor, DefaultPackCompressor, RawPackCompressor

public abstract class PackCompressorBase
extends java.lang.Object
implements PackCompressor

IzPack will be able to support different compression methods for the packs included in the installation jar file. This abstract class implements the interface PackCompressor for the common needed methods.

Author:
Klaus Bartz

Field Summary
private  Compiler compiler
           
private  java.lang.reflect.Constructor constructor
           
protected  java.lang.String[] containerPaths
           
protected  java.lang.String[][] decoderClassNames
          Should contain all full qualified (use dots, not slashes) names of the class files.
protected  java.lang.String decoderMapper
           
protected  java.lang.String encoderClassName
           
protected  java.lang.String[] formatNames
           
private  int level
           
protected  java.lang.Class[] paramsClasses
           
 
Constructor Summary
PackCompressorBase()
           
 
Method Summary
 java.lang.String[] getCompressionFormatSymbols()
          Returns all symbolic names which are used for this compressor.
 int getCompressionLevel()
          Returns the compression level to be used.
 java.lang.String[] getContainerPaths()
          Returns the path where the compiler can find the classes; normaly this is a path to a jar file.
 java.lang.String[][] getDecoderClassNames()
          Returns the qualified names of all needed classes for decoding.
 java.lang.String getDecoderMapperName()
          Returns the qualified name of the class which should be used as InputStream in the installer.
 java.lang.String getEncoderClassName()
          Returns the qualified name of the encoding output stream.
protected  java.io.OutputStream getOutputInstance(java.io.OutputStream slave)
          Returns a newly created instance of the output stream which should be used by this pack compressor.
 void loadClass(java.lang.String className)
          Loads the given class from the previos setted container paths.
 boolean needsBufferedOutputStream()
          Returns whether a buffered output stream should be used intermediate between the output stream of this compressor and the destination.
protected  java.lang.Object[] resolveConstructorParams(java.io.OutputStream slave)
          This method will be used to support different constructor signatures.
 void setCompiler(Compiler compiler)
          Receives the current used compiler.
 void setCompressionLevel(int level)
          Receives the compression level to be used.
 boolean useStandardCompression()
          Returns whether the standard comression should be used with this pack compressor or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.izforge.izpack.compressor.PackCompressor
getOutputStream
 

Field Detail

formatNames

protected java.lang.String[] formatNames

containerPaths

protected java.lang.String[] containerPaths

decoderMapper

protected java.lang.String decoderMapper

decoderClassNames

protected java.lang.String[][] decoderClassNames
Should contain all full qualified (use dots, not slashes) names of the class files. Regex will be suported in the manner of String.match.
Example:
"org.apache.tools.bzip2.CBZip2InputStream.*"
Do not forget the dot before the asterix. For an other example see class BZip2PackCompressor.


encoderClassName

protected java.lang.String encoderClassName

paramsClasses

protected java.lang.Class[] paramsClasses

compiler

private Compiler compiler

constructor

private java.lang.reflect.Constructor constructor

level

private int level
Constructor Detail

PackCompressorBase

public PackCompressorBase()
Method Detail

getContainerPaths

public java.lang.String[] getContainerPaths()
Description copied from interface: PackCompressor
Returns the path where the compiler can find the classes; normaly this is a path to a jar file. If no additional classes are needed, this method should return null.

Specified by:
getContainerPaths in interface PackCompressor
Returns:
the path where the compiler can find the classes

getEncoderClassName

public java.lang.String getEncoderClassName()
Description copied from interface: PackCompressor
Returns the qualified name of the encoding output stream. The class file should be placed in the container which will be referred by the method getContainerPath.

Specified by:
getEncoderClassName in interface PackCompressor
Returns:
qualified name of the encoding output stream

getDecoderClassNames

public java.lang.String[][] getDecoderClassNames()
Description copied from interface: PackCompressor
Returns the qualified names of all needed classes for decoding. All class files should be placed in the container which will be referred by the method getContainerPath. If no additional classes are needed, this method should return null.

Specified by:
getDecoderClassNames in interface PackCompressor
Returns:
qualified names of all needed classes for decoding

useStandardCompression

public boolean useStandardCompression()
Description copied from interface: PackCompressor
Returns whether the standard comression should be used with this pack compressor or not. If this method returns true, the returns values of the methods getContainerPath and getDecoderClassNames are not valid (should be null).

Specified by:
useStandardCompression in interface PackCompressor
Returns:
whether the standard comression should be used or not

getCompressionFormatSymbols

public java.lang.String[] getCompressionFormatSymbols()
Description copied from interface: PackCompressor
Returns all symbolic names which are used for this compressor.

Specified by:
getCompressionFormatSymbols in interface PackCompressor
Returns:
all symbolic names which are used for this compressor

getDecoderMapperName

public java.lang.String getDecoderMapperName()
Description copied from interface: PackCompressor
Returns the qualified name of the class which should be used as InputStream in the installer. This class mapps the "real" decoder or - if useable - the decoder name will be returned self. If useStandardCompression is true, this method returns null.

Specified by:
getDecoderMapperName in interface PackCompressor
Returns:
the qualified name of the class which should be used as InputStream in the installer

setCompiler

public void setCompiler(Compiler compiler)
Description copied from interface: PackCompressor
Receives the current used compiler. Needed at loading encoder classes and error handling.

Specified by:
setCompiler in interface PackCompressor
Parameters:
compiler - current active compiler

setCompressionLevel

public void setCompressionLevel(int level)
Description copied from interface: PackCompressor
Receives the compression level to be used.

Specified by:
setCompressionLevel in interface PackCompressor
Parameters:
level - compression level to be used

getCompressionLevel

public int getCompressionLevel()
Description copied from interface: PackCompressor
Returns the compression level to be used.

Specified by:
getCompressionLevel in interface PackCompressor
Returns:
the compression level to be used

needsBufferedOutputStream

public boolean needsBufferedOutputStream()
Description copied from interface: PackCompressor
Returns whether a buffered output stream should be used intermediate between the output stream of this compressor and the destination.

Specified by:
needsBufferedOutputStream in interface PackCompressor
Returns:
wether a buffered output stream should be used intermediate between the output stream of this compressor and the destination.

loadClass

public void loadClass(java.lang.String className)
               throws java.lang.Exception
Loads the given class from the previos setted container paths.

Parameters:
className - full qualified name of the class to be loaded
Throws:
java.lang.Exception

getOutputInstance

protected java.io.OutputStream getOutputInstance(java.io.OutputStream slave)
                                          throws java.lang.Exception
Returns a newly created instance of the output stream which should be used by this pack compressor. This method do not declare the return value as FilterOutputStream although there must be an constructor with a slave output stream as argument. This is done in this way because some encoding streams from third party are only implemented as "normal" output stream.

Parameters:
slave - output stream to be used as slave
Returns:
a newly created instance of the output stream which should be used by this pack compressor
Throws:
java.lang.Exception

resolveConstructorParams

protected java.lang.Object[] resolveConstructorParams(java.io.OutputStream slave)
                                               throws java.lang.Exception
This method will be used to support different constructor signatures. The default is
XXXOutputStream( OutputStream slave )
if level is -1 or
XXXOutputStream( OutputStream slave, int level )
if level is other than -1.
If the signature of the used output stream will be other, overload this method in the derived pack compressor class.

Parameters:
slave - output stream to be used as slave
Returns:
the constructor params as Object [] to be used as construction of the constructor via reflection
Throws:
java.lang.Exception