Untar (Apache Ant API)
Description: declaration: package: org.apache.tools.ant.taskdefs, class: Untar

# Class Untar

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.tools.ant.taskdefs.Expand
org.apache.tools.ant.taskdefs.Untar

All Implemented Interfaces:
  `Cloneable`

public class Untar extends Expand
Untar a file.

PatternSets are used to select files to extract from the archive. If no patternset is used, all files are extracted.

FileSets may be used to select archived files to perform unarchival upon.

File permissions will not be restored on extracted files.

The untar task recognizes the long pathname entries used by GNU tar.

Since:
  Ant 1.1

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static final class`
  `Untar.UntarCompressionMethod`
  Valid Modes for Compression attribute to Untar Task

- ## Field Summary

  ### Fields inherited from class Expand

  `ERROR_MULTIPLE_MAPPERS, NATIVE_ENCODING`
  Modifier and Type
  Field
  Description
  `static final String`
  `ERROR_MULTIPLE_MAPPERS`
  Error message when more that one mapper is defined
  `static final String`
  `NATIVE_ENCODING`

  ### Fields inherited from class Task

  `target, taskName, taskType, wrapper`
  Modifier and Type
  Field
  Description
  `protected Target`
  `target`
  Deprecated.
  since 1.6.x.
  `protected String`
  `taskName`
  Deprecated.
  since 1.6.x.
  `protected String`
  `taskType`
  Deprecated.
  since 1.6.x.
  `protected RuntimeConfigurable`
  `wrapper`
  Deprecated.
  since 1.6.x.

  ### Fields inherited from class ProjectComponent

  `description, location, project`
  Modifier and Type
  Field
  Description
  `protected String`
  `description`
  Deprecated.
  since 1.6.x.
  `protected Location`
  `location`
  Deprecated.
  since 1.6.x.
  `protected Project`
  `project`
  Deprecated.
  since 1.6.x.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Untar()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `expandFile(FileUtils fileUtils, File srcF, File dir)`
  This method is to be overridden by extending unarchival tasks.
  `protected void`
  `expandResource(Resource srcR, File dir)`
  This method is to be overridden by extending unarchival tasks.
  `void`
  `setCompression(Untar.UntarCompressionMethod method)`
  Set decompression algorithm to use; default=none.
  `void`
  `setScanForUnicodeExtraFields(boolean b)`
  No unicode extra fields in tar.

  ### Methods inherited from class Expand

  `add, add, addFileset, addPatternset, createMapper, execute, extractFile, getAllowFilesToEscapeDest, getEncoding, getFailOnEmptyArchive, getMapper, getScanForUnicodeExtraFields, internalSetEncoding, internalSetScanForUnicodeExtraFields, setAllowFilesToEscapeDest, setDest, setEncoding, setFailOnEmptyArchive, setOverwrite, setSrc, setStripAbsolutePathSpec`
  Modifier and Type
  Method
  Description
  `void`
  `add(ResourceCollection rc)`
  Add a resource collection.
  `void`
  `add(FileNameMapper fileNameMapper)`
  A nested filenamemapper
  `void`
  `addFileset(FileSet set)`
  Add a fileset
  `void`
  `addPatternset(PatternSet set)`
  Add a patternset.
  `Mapper`
  `createMapper()`
  Defines the mapper to map source entries to destination files.
  `void`
  `execute()`
  Do the work.
  `protected void`
  `extractFile(FileUtils fileUtils, File srcF, File dir, InputStream compressedInputStream, String entryName, Date entryDate, boolean isDirectory, FileNameMapper mapper)`
  extract a file to a directory
  `Boolean`
  `getAllowFilesToEscapeDest()`
  Whether to allow the extracted file or directory to be outside of the dest directory.
  `String`
  `getEncoding()`
  `boolean`
  `getFailOnEmptyArchive()`
  Whether try ing to expand an empty archive would be an error.
  `protected FileNameMapper`
  `getMapper()`
  get a mapper for a file
  `boolean`
  `getScanForUnicodeExtraFields()`
  `protected void`
  `internalSetEncoding(String encoding)`
  Supports grand-children that want to support the attribute where the child-class doesn't (i.e.
  `protected void`
  `internalSetScanForUnicodeExtraFields(boolean b)`
  Supports grand-children that want to support the attribute where the child-class doesn't (i.e.
  `void`
  `setAllowFilesToEscapeDest(boolean b)`
  Whether to allow the extracted file or directory to be outside of the dest directory.
  `void`
  `setDest(File d)`
  Set the destination directory.
  `void`
  `setEncoding(String encoding)`
  Sets the encoding to assume for file names and comments.
  `void`
  `setFailOnEmptyArchive(boolean b)`
  Whether try ing to expand an empty archive would be an error.
  `void`
  `setOverwrite(boolean b)`
  Should we overwrite files in dest, even if they are newer than the corresponding entries in the archive?
  `void`
  `setSrc(File s)`
  Set the path to zip-file.
  `void`
  `setStripAbsolutePathSpec(boolean b)`
  Whether leading path separators should be stripped.

  ### Methods inherited from class Task

  `bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType`
  Modifier and Type
  Method
  Description
  `final void`
  `bindToOwner(Task owner)`
  Bind a task to another; use this when configuring a newly created task to do work on behalf of another.
  `Target`
  `getOwningTarget()`
  Returns the container target of this task.
  `RuntimeConfigurable`
  `getRuntimeConfigurableWrapper()`
  Returns the wrapper used for runtime configuration.
  `String`
  `getTaskName()`
  Returns the name to use in logging messages.
  `String`
  `getTaskType()`
  Return the type of task.
  `protected RuntimeConfigurable`
  `getWrapper()`
  Return the runtime configurable structure for this task.
  `protected void`
  `handleErrorFlush(String output)`
  Handles an error line by logging it with the WARN priority.
  `protected void`
  `handleErrorOutput(String output)`
  Handles an error output by logging it with the WARN priority.
  `protected void`
  `handleFlush(String output)`
  Handles output by logging it with the INFO priority.
  `protected int`
  `handleInput(byte[] buffer, int offset, int length)`
  Handle an input request by this task.
  `protected void`
  `handleOutput(String output)`
  Handles output by logging it with the INFO priority.
  `void`
  `init()`
  Called by the project to let the task initialize properly.
  `protected final boolean`
  `isInvalid()`
  Has this task been marked invalid?
  `void`
  `log(String msg)`
  Logs a message with the default (INFO) priority.
  `void`
  `log(String msg, int msgLevel)`
  Logs a message with the given priority.
  `void`
  `log(String msg, Throwable t, int msgLevel)`
  Logs a message with the given priority.
  `void`
  `log(Throwable t, int msgLevel)`
  Logs a message with the given priority.
  `void`
  `maybeConfigure()`
  Configures this task - if it hasn't been done already.
  `final void`
  `perform()`
  Performs this task if it's still valid, or gets a replacement version and performs that otherwise.
  `void`
  `reconfigure()`
  Force the task to be reconfigured from its RuntimeConfigurable.
  `void`
  `setOwningTarget(Target target)`
  Sets the target container of this task.
  `void`
  `setRuntimeConfigurableWrapper(RuntimeConfigurable wrapper)`
  Sets the wrapper to be used for runtime configuration.
  `void`
  `setTaskName(String name)`
  Sets the name to use in logging messages.
  `void`
  `setTaskType(String type)`
  Sets the name with which the task has been invoked.

  ### Methods inherited from class ProjectComponent

  `clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject`
  Modifier and Type
  Method
  Description
  `Object`
  `clone()`
  `String`
  `getDescription()`
  Returns the description of the current action.
  `Location`
  `getLocation()`
  Returns the file/location where this task was defined.
  `Project`
  `getProject()`
  Returns the project to which this component belongs.
  `void`
  `setDescription(String desc)`
  Sets a description of the current action.
  `void`
  `setLocation(Location location)`
  Sets the file/location where this task was defined.
  `void`
  `setProject(Project project)`
  Sets the project object of this component.

  ### Methods inherited from class Object

  `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Untar

    public Untar()

- ## Method Details

  - ### setCompression

    public void setCompression(Untar.UntarCompressionMethod method)
    Set decompression algorithm to use; default=none. Allowable values are
    - none - no compression
    - gzip - Gzip compression
    - bzip2 - Bzip2 compression
    - xz - XZ compression, requires XZ for Java
    Parameters:
      `method` - compression method

  - ### setScanForUnicodeExtraFields

    public void setScanForUnicodeExtraFields(boolean b)
    No unicode extra fields in tar.
    Overrides:
      `setScanForUnicodeExtraFields` in class `Expand`
    Parameters:
      `b` - boolean
    Since:
      Ant 1.8.0

  - ### expandFile

    protected void expandFile(FileUtils fileUtils, File srcF, File dir)
    Description copied from class: `Expand`
    This method is to be overridden by extending unarchival tasks.
    Overrides:
      `expandFile` in class `Expand`
    Parameters:
      `fileUtils` - the fileUtils
      `srcF` - the source file
      `dir` - the destination directory
    See Also:
      - Expand.expandFile(FileUtils, File, File)

  - ### expandResource

    protected void expandResource(Resource srcR, File dir)
    This method is to be overridden by extending unarchival tasks.
    Overrides:
      `expandResource` in class `Expand`
    Parameters:
      `srcR` - the source resource
      `dir` - the destination directory
    Since:
      Ant 1.7