org.x4juli.handlers.rolling.helper
Class GZCompressAction

java.lang.Object
  extended byorg.x4juli.global.components.AbstractComponent
      extended byorg.x4juli.handlers.rolling.helper.AbstractAction
          extended byorg.x4juli.handlers.rolling.helper.GZCompressAction
All Implemented Interfaces:
Action, Component, java.lang.Runnable

public final class GZCompressAction
extends AbstractAction

Compresses a file using GZ compression.

Logging API as a whole was originally done for Apache log4j. Juli is a port of main parts of that to complete the Java Logging APIs. All credits for initial idea, design, implementation, documentation belong to the log4j crew. This file was originally published by Curt Arnold. Please use exclusively the appropriate mailing lists for questions, remarks and contribution.

Since:
0.5
Author:
Boris Unckel

Field Summary
private  boolean deleteSource
          If true, attempt to delete file on completion.
private  java.io.File destination
          Destination file.
private  java.io.File source
          Source file.
 
Fields inherited from class org.x4juli.handlers.rolling.helper.AbstractAction
 
Fields inherited from class org.x4juli.global.components.AbstractComponent
manager, repository
 
Constructor Summary
GZCompressAction(java.io.File source, java.io.File destination, boolean deleteSource)
          Create new instance of GZCompressAction.
 
Method Summary
 boolean execute()
          Compress.
static boolean execute(java.io.File source, java.io.File destination, boolean deleteSource, ExtendedLogger logger)
          Compress a file.
protected  void reportException(java.lang.Exception ex)
          Capture exception.
 
Methods inherited from class org.x4juli.handlers.rolling.helper.AbstractAction
close, isComplete, run
 
Methods inherited from class org.x4juli.global.components.AbstractComponent
getLogger, getLoggerRepository, getMessageProperties, getNonFloodingLogger, getProperty, getProperty, getProperty, getProperty, resetErrorCount, setObjectStore
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

source

private final java.io.File source
Source file.


destination

private final java.io.File destination
Destination file.


deleteSource

private final boolean deleteSource
If true, attempt to delete file on completion.

Constructor Detail

GZCompressAction

public GZCompressAction(java.io.File source,
                        java.io.File destination,
                        boolean deleteSource)
Create new instance of GZCompressAction.

Parameters:
source - file to compress, may not be null.
destination - compressed file, may not be null.
deleteSource - if true, attempt to delete file on completion. Failure to delete does not cause an exception to be thrown or affect return value.
Method Detail

execute

public boolean execute()
                throws java.io.IOException
Compress.

Specified by:
execute in interface Action
Specified by:
execute in class AbstractAction
Returns:
true if successfully compressed.
Throws:
java.io.IOException - on IO exception.

execute

public static boolean execute(java.io.File source,
                              java.io.File destination,
                              boolean deleteSource,
                              ExtendedLogger logger)
                       throws java.io.IOException
Compress a file.

Parameters:
source - file to compress, may not be null.
destination - compressed file, may not be null.
deleteSource - if true, attempt to delete file on completion. Failure to delete does not cause an exception to be thrown or affect return value.
Returns:
true if source file compressed.
Throws:
java.io.IOException - on IO exception.

reportException

protected void reportException(java.lang.Exception ex)
Capture exception.

Overrides:
reportException in class AbstractAction
Parameters:
ex - exception.


${license_html}