Move (Apache Ant API)
Keywords: org.apache.tools.ant.taskdefs.Move class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tools.ant.taskdefs
Class Move

    java.lang.Object
      org.apache.tools.ant.ProjectComponent
          org.apache.tools.ant.Task
              org.apache.tools.ant.taskdefs.Copy
                  org.apache.tools.ant.taskdefs.Move

public class Move
extends Copy

Moves a file or directory to a new file or directory. By default, the destination file is overwritten if it already exists. When overwrite is turned off, then files are only moved if the source file is newer than the destination file, or when the destination file does not exist.

Source files and directories are only deleted when the file or directory has been copied to the destination successfully. Filtering also works.

This implementation is based on Arnout Kuiper's initial design document, the following mailing list discussions, and the copyfile/copydir tasks.

Since:
  Ant 1.2
Version:
  $Revision: 1.25.2.4 $
Author:
  Glenn McAllister glennm@ca.ibm.com, Magesh Umasankar

Field Summary

Fields inherited from class org.apache.tools.ant.taskdefs.Copy
`completeDirMap, destDir, destFile, dirCopyMap, file, fileCopyMap, filesets, filtering, flatten, forceOverwrite, includeEmpty, mapperElement, preserveLastModified, verbosity`

Fields inherited from class org.apache.tools.ant.Task
`description, location, target, taskName, taskType, wrapper`

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

Constructor Summary
`Move()`

Method Summary
`protected void` | `deleteDir(java.io.File d)` Go and delete the directory tree.
`protected void` | `doFileOperations()` Actually does the file (and possibly empty directory) copies.
`protected boolean` | `okToDelete(java.io.File d)` Its only ok to delete a directory tree if there are no files in it.
`protected boolean` | `renameFile(java.io.File sourceFile, java.io.File destFile, boolean filtering, boolean overwrite)` Attempts to rename a file from a source to a destination.

Methods inherited from class org.apache.tools.ant.taskdefs.Copy
`addFileset, buildMap, createFilterChain, createFilterSet, createMapper, execute, getEncoding, getFileUtils, getFilterChains, getFilterSets, getPreserveLastModified, scan, setEncoding, setFailOnError, setFile, setFiltering, setFlatten, setIncludeEmptyDirs, setOverwrite, setPreserveLastModified, setPreserveLastModified, setTodir, setTofile, setVerbose, validateAttributes`

Methods inherited from class org.apache.tools.ant.Task
`getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, handleErrorFlush, handleErrorOutput, handleFlush, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName`

Methods inherited from class org.apache.tools.ant.ProjectComponent
`getProject, setProject`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Move

    public Move()

Method Detail

### doFileOperations

    protected void doFileOperations()

  Description copied from class: `Copy`
  Actually does the file (and possibly empty directory) copies. This is a good method for subclasses to override.

  Overrides:
    `doFileOperations` in class `Copy`

### okToDelete

    protected boolean okToDelete(java.io.File d)

  Its only ok to delete a directory tree if there are no files in it.

  Returns:
    true if a deletion can go ahead

### deleteDir

    protected void deleteDir(java.io.File d)

  Go and delete the directory tree.

### renameFile

    protected boolean renameFile(java.io.File sourceFile,
                                 java.io.File destFile,
                                 boolean filtering,
                                 boolean overwrite)
                          throws java.io.IOException,
                                 BuildException

  Attempts to rename a file from a source to a destination. If overwrite is set to true, this method overwrites existing file even if the destination file is newer. Otherwise, the source file is renamed only if the destination file is older than it. Method then checks if token filtering is used. If it is, this method returns false assuming it is the responsibility to the copyFile method.

  Throws:
    `java.io.IOException`
    `BuildException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.