Class CommonsCompressAction
- java.lang.Object
-
- org.apache.logging.log4j.core.appender.rolling.action.AbstractAction
-
- org.apache.logging.log4j.core.appender.rolling.action.CommonsCompressAction
-
- All Implemented Interfaces:
java.lang.Runnable,Action
public final class CommonsCompressAction extends AbstractAction
Compresses a file using bzip2 compression.
-
-
Field Summary
Fields Modifier and Type Field Description private static intBUF_SIZEprivate booleandeleteSourceIf true, attempt to delete file on completion.private java.io.FiledestinationDestination file.private java.lang.StringnameCompressor name.private java.io.FilesourceSource file.-
Fields inherited from class org.apache.logging.log4j.core.appender.rolling.action.AbstractAction
LOGGER
-
-
Constructor Summary
Constructors Constructor Description CommonsCompressAction(java.lang.String name, java.io.File source, java.io.File destination, boolean deleteSource)Creates new instance of Bzip2CompressAction.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanexecute()Compresses.static booleanexecute(java.lang.String name, java.io.File source, java.io.File destination, boolean deleteSource)Compresses a file.java.io.FilegetDestination()java.lang.StringgetName()java.io.FilegetSource()booleanisDeleteSource()protected voidreportException(java.lang.Exception ex)Reports exception.java.lang.StringtoString()-
Methods inherited from class org.apache.logging.log4j.core.appender.rolling.action.AbstractAction
close, isComplete, isInterrupted, run
-
-
-
-
Field Detail
-
BUF_SIZE
private static final int BUF_SIZE
- See Also:
- Constant Field Values
-
name
private final java.lang.String name
Compressor name. One of "gz", "bzip2", "xz", "pack200" or "deflate".
-
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
-
CommonsCompressAction
public CommonsCompressAction(java.lang.String name, java.io.File source, java.io.File destination, boolean deleteSource)Creates new instance of Bzip2CompressAction.- Parameters:
name- the compressor name. One of "gz", "bzip2", "xz", "pack200", or "deflate".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.IOExceptionCompresses.- Specified by:
executein interfaceAction- Specified by:
executein classAbstractAction- Returns:
- true if successfully compressed.
- Throws:
java.io.IOException- on IO exception.
-
execute
public static boolean execute(java.lang.String name, java.io.File source, java.io.File destination, boolean deleteSource) throws java.io.IOExceptionCompresses a file.- Parameters:
name- the compressor name, i.e. "gz", "bzip2", "xz", "pack200", or "deflate".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)
Reports exception.- Overrides:
reportExceptionin classAbstractAction- Parameters:
ex- exception.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getName
public java.lang.String getName()
-
getSource
public java.io.File getSource()
-
getDestination
public java.io.File getDestination()
-
isDeleteSource
public boolean isDeleteSource()
-
-