org.apache.commons.vfs2.tasks
Class AbstractSyncTask

java.lang.Object
  extended by Task
      extended by org.apache.commons.vfs2.tasks.VfsTask
          extended by org.apache.commons.vfs2.tasks.AbstractSyncTask
Direct Known Subclasses:
CopyTask

public abstract class AbstractSyncTask
extends VfsTask

An abstract file synchronization task. Scans a set of source files and folders, and a destination folder, and performs actions on missing and out-of-date files. Specifically, performs actions on the following:

Author:
Commons VFS team

Nested Class Summary
static class AbstractSyncTask.SourceInfo
          Information about a source file.
 
Constructor Summary
AbstractSyncTask()
           
 
Method Summary
 void addConfiguredSrc(AbstractSyncTask.SourceInfo srcInfo)
          Adds a nested <src> element.
protected  boolean detectMissingSourceFiles()
          Check if this task cares about destination files with a missing source file.
 void execute()
          Executes this task.
protected  void handleMissingSourceFile(FileObject destFile)
          Handles a destination for which there is no corresponding source file.
protected  void handleOutOfDateFile(FileObject srcFile, FileObject destFile)
          Handles an out-of-date file (a file where the destination file either doesn't exist, or is older than the source file).
protected  void handleUpToDateFile(FileObject srcFile, FileObject destFile)
          Handles an up-to-date file (where the destination file exists and is newer than the source file).
 boolean isFailonerror()
          Sets whether we should fail if there was an error or not.
protected  void logOrDie(java.lang.String message, int level)
           
 void setDestDir(java.lang.String destDir)
          Sets the destination directory.
 void setDestFile(java.lang.String destFile)
          Sets the destination file.
 void setFailonerror(boolean failonerror)
          Sets whether we should fail if there was an error or not.
 void setIncludes(java.lang.String filesList)
          Sets the files to includes.
 void setSrc(java.lang.String srcFile)
          Sets the source file.
 void setSrcDir(java.lang.String srcDir)
          Sets the source directory.
 void setSrcDirIsBase(boolean srcDirIsBase)
          Sets whether the source directory should be consider as the base directory.
 
Methods inherited from class org.apache.commons.vfs2.tasks.VfsTask
closeManager, resolveFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSyncTask

public AbstractSyncTask()
Method Detail

setDestFile

public void setDestFile(java.lang.String destFile)
Sets the destination file.

Parameters:
destFile - The destination file name.

setDestDir

public void setDestDir(java.lang.String destDir)
Sets the destination directory.

Parameters:
destDir - The destination directory.

setSrc

public void setSrc(java.lang.String srcFile)
Sets the source file.

Parameters:
srcFile - The source file name.

setSrcDir

public void setSrcDir(java.lang.String srcDir)
Sets the source directory.

Parameters:
srcDir - The source directory.

setSrcDirIsBase

public void setSrcDirIsBase(boolean srcDirIsBase)
Sets whether the source directory should be consider as the base directory.

Parameters:
srcDirIsBase - true if the source directory is the base directory.

setFailonerror

public void setFailonerror(boolean failonerror)
Sets whether we should fail if there was an error or not.

Parameters:
failonerror - true if the operation should fail if there is an error.

isFailonerror

public boolean isFailonerror()
Sets whether we should fail if there was an error or not.

Returns:
true if the operation should fail if there was an error.

setIncludes

public void setIncludes(java.lang.String filesList)
Sets the files to includes.

Parameters:
filesList - The list of files to include.

addConfiguredSrc

public void addConfiguredSrc(AbstractSyncTask.SourceInfo srcInfo)
                      throws BuildException
Adds a nested <src> element.

Parameters:
srcInfo - A nested source element.
Throws:
BuildException - if the SourceInfo doesn't reference a file.

execute

public void execute()
             throws BuildException
Executes this task.

Throws:
BuildException - if an error occurs.

logOrDie

protected void logOrDie(java.lang.String message,
                        int level)

handleOutOfDateFile

protected void handleOutOfDateFile(FileObject srcFile,
                                   FileObject destFile)
                            throws java.lang.Exception
Handles an out-of-date file (a file where the destination file either doesn't exist, or is older than the source file). This implementation does nothing.

Throws:
java.lang.Exception

handleUpToDateFile

protected void handleUpToDateFile(FileObject srcFile,
                                  FileObject destFile)
                           throws java.lang.Exception
Handles an up-to-date file (where the destination file exists and is newer than the source file). This implementation does nothing.

Throws:
java.lang.Exception

handleMissingSourceFile

protected void handleMissingSourceFile(FileObject destFile)
                                throws java.lang.Exception
Handles a destination for which there is no corresponding source file. This implementation does nothing.

Throws:
java.lang.Exception

detectMissingSourceFiles

protected boolean detectMissingSourceFiles()
Check if this task cares about destination files with a missing source file. This implementation returns false.