uk.org.simonsite.log4j.appender
Class LogFileCompressionStrategy

java.lang.Object
  extended by uk.org.simonsite.log4j.appender.LogFileCompressionStrategy
Direct Known Subclasses:
GzipFileCompressionStrategy, ZipFileCompressionStrategy

abstract class LogFileCompressionStrategy
extends Object

Responsible for providing compression strategy instances (via factory methods), implementing template methods used by specific strategies, and the creation of compressed backup files.

Version:
1.6
Author:
Simon Park

Field Summary
(package private) static LogFileCompressionStrategy DEFAULT
           
(package private) static LogFileCompressionStrategy GZIP
           
(package private) static LogFileCompressionStrategy ZIP
           
 
Constructor Summary
LogFileCompressionStrategy()
           
 
Method Summary
(package private)  File compress(File backupFile, AppenderRollingProperties properties)
          Template method responsible for file compression checks, file creation, and delegation to specific strategy implementations.
(package private) abstract  boolean compress(File backupFile, File deflatedFile, AppenderRollingProperties properties)
          Compress the backup file as per the implemented algorithm.
(package private) static boolean existsFor(AppenderRollingProperties properties)
           
(package private) static LogFileCompressionStrategy findCompressionStrategy(AppenderRollingProperties properties)
           
(package private) abstract  String getAlgorithmName()
           
(package private) abstract  boolean isCompressed(File backupFile)
           
(package private)  boolean isRequiredStrategy(AppenderRollingProperties properties)
           
(package private) static LogFileCompressionStrategy[] strategies()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZIP

static final LogFileCompressionStrategy ZIP

GZIP

static final LogFileCompressionStrategy GZIP

DEFAULT

static final LogFileCompressionStrategy DEFAULT
Constructor Detail

LogFileCompressionStrategy

LogFileCompressionStrategy()
Method Detail

existsFor

static final boolean existsFor(AppenderRollingProperties properties)

findCompressionStrategy

static final LogFileCompressionStrategy findCompressionStrategy(AppenderRollingProperties properties)

strategies

static final LogFileCompressionStrategy[] strategies()

compress

abstract boolean compress(File backupFile,
                          File deflatedFile,
                          AppenderRollingProperties properties)
Compress the backup file as per the implemented algorithm.

Parameters:
backupFile - The file to be compressed.
deflatedFile - The target file to which the compressed stream will be written.
properties - The appender's configuration.
Returns:
true if compression was successful

getAlgorithmName

abstract String getAlgorithmName()
Returns:
The name to be used in the suffix of the compressed file.

isCompressed

abstract boolean isCompressed(File backupFile)

isRequiredStrategy

final boolean isRequiredStrategy(AppenderRollingProperties properties)
Parameters:
properties - The appender's configuration.
Returns:
true if the algorithm name of this strategy matches the configured name.

compress

final File compress(File backupFile,
                    AppenderRollingProperties properties)
Template method responsible for file compression checks, file creation, and delegation to specific strategy implementations.

Parameters:
backupFile - The file to be compressed.
properties - The appender's configuration.
Returns:
The compressed file object, or null if compression could not be performed.