Compress a file using the GZip algorithm.
| Package: | org.schmant.task.base |
| Category: | I/O tasks |
| Since: | 0.6 |
| EntityFS-aware? | Yes |
| Implements: | ActionTaskFactory
GeneratorTaskFactory ProcessTaskFactory |
| See also: | RecursiveProcessTF
|
Description
Compress a file using the GZip algorithm.
Required properties
Properties
| bufferSize | top |
The buffer size of the GZipOutputStream used.
- Setter method:
-
setBufferSize(int size)
where:
size– The buffer size, in bytes.
| configurators | top |
A collection of Configurator:s. Configurator:s are used to configure a task right before it is run in a TaskExecutor with properties that are not available until all of the task's dependencies have been run.
Build scripts that don't use TaskExecutor:s don't have to use Configurator:s.
- Setter method:
-
addConfigurator(Configurator cf)
where:
cf– A configurator.
Add one configurator. - Setter method:
-
addConfigurators(Collection<? extends Configurator> c)
where:
c– A collection of configurators.
Add a collection of configurators.
| logFooter | top |
The message that is logged to info level
after the task has been successfully run.
- Setter method:
-
setLogFooter(java.lang.String s)
where:
s– The footer message.
- Default value:
- Empty (no footer message is logged.)
| logHeader | top |
The message that is logged to info level
before the task is run.
- Setter method:
-
setLogHeader(java.lang.String s)
where:
s– The header message.
- Default value:
- A task class specific message.
| overwrite | top |
If an entity already exists in the target location, should it be
overwritten? If false, the task throws an error instead.
- Setter method:
-
setOverwrite(boolean b)
where:
b– Should an existing entity be overwritten?
- Default value:
false(existing entities are not overwritten).- See also:
- target
| source (required) | top |
The file to compress.
- Setter method:
-
setSource(java.lang.Object o)
where:
o– The source file. Interpreted byArgumentInterpreter.getReadableFile(java.lang.Object).
| target (required) | top |
The file that the compressed data should be put in.
- Setter method:
-
setTarget(java.lang.Object o)
where:
o– A target that can be interpreted as a FutureEntity. The target cannot be an existing directory. If the target is an existing file, the overwrite property detrermines if the existing file will be overwritten. Interpreted byArgumentInterpreter.getFutureEntity(java.lang.Object,java.lang.Object).
Set the target.
Examples
Example 1
Compress the file f in directory
dir to f.gz in the same directory.
setSource(Directories.getFile(dir, "f")).
setTarget(new FutureEntity(dir, "f.gz")).run();
Example 2
Put some text in the GZip compressed file
f.gz.
setSource(new CharSequenceReadableFile(
"NOTE:\n" +
"=====\n" +
"If you can read me, you have successfully unzipped this file.")).
setTarget(new FutureEntity(dir, "f.gz")).run();
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.