org.apache.tools.ant.taskdefs

Class Pack

Implemented Interfaces:
Cloneable
Known Direct Subclasses:
BZip2, GZip

public abstract class Pack
extends Task

Abstract Base class for pack tasks.
Since:
Ant 1.5

Field Summary

protected File
source
protected File
zipFile

Fields inherited from class org.apache.tools.ant.Task

target, taskName, taskType, wrapper

Fields inherited from class org.apache.tools.ant.ProjectComponent

description, location, project

Method Summary

void
addConfigured(ResourceCollection a)
Set the source resource.
void
execute()
validate, then hand off to the subclass
Resource
getSrcResource()
The source resource.
protected abstract void
pack()
subclasses must implement this method to do their compression
void
setDestfile(File zipFile)
the required destination file.
void
setSrc(File src)
the file to compress; required.
void
setSrcResource(Resource src)
The resource to pack; required.
void
setZipfile(File zipFile)
the required destination file.
protected boolean
supportsNonFileResources()
Whether this task can deal with non-file resources.
protected void
zipFile(File file, OutputStream zOut)
zip a file to an output stream
protected void
zipResource(Resource resource, OutputStream zOut)
zip a resource to an output stream

Methods inherited from class org.apache.tools.ant.Task

bindToOwner, execute, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType

Methods inherited from class org.apache.tools.ant.ProjectComponent

clone, getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject

Field Details

source

protected File source

zipFile

protected File zipFile

Method Details

addConfigured

public void addConfigured(ResourceCollection a)
Set the source resource.
Parameters:
a - the resource to pack as a single element Resource collection.

execute

public void execute()
            throws BuildException
validate, then hand off to the subclass
Overrides:
execute in interface Task
Throws:
BuildException - on error

getSrcResource

public Resource getSrcResource()
The source resource.
Returns:
the source.
Since:
Ant 1.7

pack

protected abstract void pack()
subclasses must implement this method to do their compression

setDestfile

public void setDestfile(File zipFile)
the required destination file.
Parameters:
zipFile - the destination file

setSrc

public void setSrc(File src)
the file to compress; required.
Parameters:
src - the source file

setSrcResource

public void setSrcResource(Resource src)
The resource to pack; required.
Parameters:
src - resource to expand

setZipfile

public void setZipfile(File zipFile)
the required destination file.
Parameters:
zipFile - the destination file

supportsNonFileResources

protected boolean supportsNonFileResources()
Whether this task can deal with non-file resources.

This implementation returns false.

Returns:
false.
Since:
Ant 1.7

zipFile

protected void zipFile(File file,
                       OutputStream zOut)
            throws IOException
zip a file to an output stream
Parameters:
file - the file to zip
zOut - the output stream

zipResource

protected void zipResource(Resource resource,
                           OutputStream zOut)
            throws IOException
zip a resource to an output stream
Parameters:
resource - the resource to zip
zOut - the output stream