org.apache.commons.compress
Class CompressorFactory

java.lang.Object
  extended by org.apache.commons.compress.CompressorFactory

public abstract class CompressorFactory
extends Object

Compressor-Factory. Use CompressorFactory.TYPE.getInstance() for an new Compressor-Instance.


Field Summary
static CompressorFactory BZIP2
          BZIP2 Compressor Factory
 
Method Summary
abstract  Compressor getInstance()
          Returns a compressor
static Compressor getInstance(File file)
          Returns an archiver, filled with an existing archive.
static Compressor getInstance(String compressorName)
          Returns an empty Compressor, if an matching compressor could be found within this factory.
static void registerCompressor(Class clazz)
          Registers a new archiver in the factory.
static void registerCompressor(String className)
          Registers a new archiver in the factory.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BZIP2

public static CompressorFactory BZIP2
BZIP2 Compressor Factory

Method Detail

registerCompressor

public static void registerCompressor(String className)
                               throws ClassNotFoundException,
                                      CompressException
Registers a new archiver in the factory. The archiver must implement the archiver interface.

Parameters:
className - full qualified archiver implementation
Throws:
ClassNotFoundException - if the new archiver class could not be found
ArchiveException - if the new archiver does not implement the archiver interface
CompressException

registerCompressor

public static void registerCompressor(Class clazz)
                               throws CompressException
Registers a new archiver in the factory. The archiver must implement the archiver interface and must be an concrete implementation

Parameters:
clazz - full qualified archiver implementation
Throws:
ArchiveException - if the new archiver does not implement the archiver interface
CompressException

getInstance

public abstract Compressor getInstance()
Returns a compressor

Returns:
the compressor

getInstance

public static Compressor getInstance(String compressorName)
                              throws CompressException
Returns an empty Compressor, if an matching compressor could be found within this factory. If two implementations with the same name are registered, the first matching implementation will be instanciated.

Returns:
the compressor, or null, if no matching compressor could be found
Throws:
CompressException - if the compressor could not be created

getInstance

public static Compressor getInstance(File file)
                              throws CompressException
Returns an archiver, filled with an existing archive. Uses the byte header to identify the archiver. If no corresponding archiver could be found, a filename extension check will be done.

Parameters:
file - an existing archive
Returns:
an archiver, filled with the archive
Throws:
CompressException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011 Apache Software Foundation. All Rights Reserved.