Package org.oddjob.io

Class DeleteJob

java.lang.Object
org.oddjob.io.DeleteJob
All Implemented Interfaces:
Serializable, Callable<Integer>

public class DeleteJob extends Object implements Callable<Integer>, Serializable
Author:
Rob Gordon
See Also:

Description

Delete a file or directory, or files and directories.

Unless the force property is set, this job will cause an exception if an attempt is made to delete a non empty directory.

Example

Delete all files from a directory. The directory is the first of Oddjob's arguments.
<oddjob id="this">

    <job>

        <delete id="delete">

            <files>

                <files files="${this.args[0]}/*"/>

            </files>

        </delete>

    </job>

</oddjob>
  • Constructor Details

    • DeleteJob

      public DeleteJob()
  • Method Details

    • call

      public Integer call() throws IOException, InterruptedException
      Specified by:
      call in interface Callable<Integer>
      Throws:
      IOException
      InterruptedException
    • deleteFile

      protected void deleteFile(File fileToDelete) throws IOException
      Throws:
      IOException
    • isRoot

      protected boolean isRoot(File fileToDelete)
    • reset

      public void reset()
    • getName

      public String getName()
      Get the name.
      Returns:
      The name.
    • setName

      public void setName(String name)
      Set the name
      Parameters:
      name - The name.
    • getFiles

      public File[] getFiles()
      Get the files.
      Returns:
      The files.
    • setFiles

      public void setFiles(File[] files)
      Set the files.
      Parameters:
      files - The files.
    • isForce

      public boolean isForce()
      Getter for force property.
      Returns:
      The force property.
    • setForce

      public void setForce(boolean force)
      Setter for force property.
      Parameters:
      force - The force property.
    • setLogEvery

      public void setLogEvery(int logEvery)
    • getLogEvery

      public int getLogEvery()
    • setReallyRoot

      public void setReallyRoot(boolean reallyRoot)
    • isReallyRoot

      public boolean isReallyRoot()
    • getFileCount

      public int getFileCount()
    • getDirCount

      public int getDirCount()
    • getErrorCount

      public int getErrorCount()
    • getMaxErrors

      public int getMaxErrors()
    • setMaxErrors

      public void setMaxErrors(int maxErrors)
    • toString

      public String toString()
      Overrides:
      toString in class Object