Compress a file using the LZMA algorithm.
Task package: | org.at4j |
Java package: | org.schmant.task.at4j.lzma |
Category: | I/O tasks |
Since: | 0.8 |
EntityFS-aware? | Yes* |
Implements: | ActionTaskFactory GeneratorTaskFactory ProcessTaskFactory |
Produces: | The interpreted target property. The exact type depends on the type used for the target. |
See also: | GZipTF BZip2TF |
Description:
Compress a file using the LZMA algorithm.
The target property is optional if the source
file is of a type that implements Named. If the target is not set,
the compressed data will be written to a file with the same name as the source
file plus the extension .lzma
.
Warning: LZMA compression does not seem to work reliably. Sometimes,
when compressing, it seems to want to allocate too much (very much) memory,
and that often leads to an OutOfMemoryError
. Avoid using this task
until the issue is fixed.
Note: If another task created the file to compress, it may be easier to use a LzmaNewWritableFileProxy directly with that task instead instead of using a separate LZMA task for the compression.
Note 2: There is no task for decompressing LZMA compressed files. Use a LzmaReadableFile or a LzmaReadableFileProxy instead.
Required properties
Properties
deleteSourceFile | top |
If this property is set to true
, the source
file will be deleted after compressing it. This requires that the source file is
a Java File or an EntityFS EFile. If it is not, this task
does not delete the file and logs a warning.
- Setter method:
setDeleteSourceFile(boolean b)
parameters:b
– Should the source file be deleted?
logFooter | top |
The message that is logged to info
level
after the task has been successfully run.
- Setter method:
setLogFooter(String s)
parameters:s
– The footer message.- Default value:
- Empty (no footer message is logged.)
- See also:
- logHeader
logHeader | top |
The message that is logged to info
level
before the task is run.
- Setter method:
setLogHeader(String s)
parameters:s
– The header message.- Default value:
- A task class specific message.
- See also:
- logFooter
lzmaCompressionSettings | top |
The settings to use for the compression. See the At4J Programmer's Guide for details.
- Setter method:
setLzmaCompressionSettings(LzmaOutputStreamSettings settings)
parameters:settings
– The settings- Default value:
- The default LZMA compression settings used by LzmaOutputStream.
overwriteStrategy | top |
The overwrite strategy decides how the task will react if there already is an entity (file or directory) in a location where it wants to create a new entity.
If the strategy is to not overwrite existing entities, the task will fail when it cannot create the entities that it wants to create.
Non-empty directories are never overwritten, regardless of the chosen strategy.
- Setter method:
setOverwrite(boolean b)
Setting this to a value ofparameters:true
means that the DoOverwriteAndLogWarning strategy is used. A value of false gives the DontOverwriteAndThrowException strategy.b
– Should an existing entity be overwritten?- Setter method:
setOverwriteStrategy(OverwriteStrategy strat)
Set the overwrite strategy.parameters:strat
– The overwrite strategy.- Default value:
- DontOverwriteAndThrowException
- See also:
- target
reportLevel | top |
This property is used to change the Report level for all task created by this task factory. The report level is changed for the thread running the task when the it is run, and is restored to its previous level when the it is done.
- Setter method:
setReportLevel(Level l)
Set the report levelparameters:l
– The new report level.
source (required) | top |
The file to compress.
- Setter method:
setSource(Object o)
parameters:
target (required) | top |
The file that the compressed data should be put in.
- Setter method:
setTarget(Object o)
Set the target.parameters:o
– A target that can be interpreted as an existing or non-existing file. If the target is an existing file or directory, the overwriteStrategy property determines what will happen.
Interpreted byInterpretAsNewWritableFileStrategy
.
traceLogging | top |
If trace logging is enabled for a task, it reports its configuration before it is run.
Trace logging may also be enabled globally for all tasks by calling TraceMode.setTraceMode(boolean).
- Setter method:
setTraceLogging(boolean b)
Enable or disable trace logging.parameters:b
– Enable trace logging?
Examples
Example 1
Compress the file f
in directory
dir
to f.lzma
in the same directory.
JavaScript
* An EntityFS-aware task is implemented using EntityFS. This means that it uses the filter settings of DirectoryView:s and also that it often can work with other file system implementations than File-based, such as the RAM file system.