Holger's Java API

## com.antelmann.io
Class Backup

    java.lang.Object
      com.antelmann.io.Backup

All Implemented Interfaces:
  LoggerProvider, Runnable

    @Todo(value="replace File with Path once switched to JDK 7")
    public class Backup

extends Object
implements Runnable, LoggerProvider

allows to easily backup directories. Copied are only those files that do not exist or have a modification date after the one that exists or have a different file length. Other existing files in the target directory remain there.

Author:
  Holger Antelmann
See Also:
  `MyFile.synchronizeDir(File)`, `BackupFrame`

Constructor Summary
`Backup(File originDir, File destinationDir)`
`Backup(File originDir, File destinationDir, FileFilter filter)`
`Backup(File originDir, File destinationDir, FileFilter filter, boolean deleteAtTarget)`
`Backup(File originDir, File destinationDir, FileFilter filter, boolean deleteAtTarget, Monitor monitor, Logger logger)`

Method Summary
`void` `cancel()` sets the embedded monitor to be disabled
`TimerTask` `createTimerTask()`
`boolean` `getDeleteAtTarget()`
`File` `getDestinationDir()`
`FileFilter` `getFilter()`
`Logger` `getLogger()` acess to the (non-null) Logger suitable for logging entries in the context of this instance
`Monitor` `getMonitor()`
`File` `getOriginDir()`
`boolean` `isAlwaysCopy()`
`boolean` `isRunning()`
`static void` `main(String[] args)`
`void` `run()` performs the backup operation
`void` `setAlwaysCopy(boolean alwaysCopy)`
`void` `setDeleteAtTarget(boolean flag)`
`void` `setDestinationDir(File destinationDir)`
`void` `setExcludeFiles(File[] excludeList)` replaces any previous filter; the path matching is case-insensitive
`void` `setFilter(FileFilter filter)`
`void` `setLogger(Logger logger)` the logger may not be set while the backup is running
`void` `setMonitor(Monitor monitor)`
`void` `setNoSubDirsFilter()` replaces any previous filter
`void` `setOriginDir(File originDir)`

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

Constructor Detail

### Backup

    public Backup(File originDir,
                  File destinationDir)

### Backup

    public Backup(File originDir,
                  File destinationDir,
                  FileFilter filter)

### Backup

    public Backup(File originDir,
                  File destinationDir,
                  FileFilter filter,
                  boolean deleteAtTarget)

### Backup

    public Backup(File originDir,
                  File destinationDir,
                  FileFilter filter,
                  boolean deleteAtTarget,
                  Monitor monitor,
                  Logger logger)

Method Detail

### setNoSubDirsFilter

    public void setNoSubDirsFilter()
                            throws IllegalStateException

  replaces any previous filter

  Throws:
    `IllegalStateException`

### setExcludeFiles

    public void setExcludeFiles(File[] excludeList)
                         throws IllegalArgumentException

  replaces any previous filter; the path matching is case-insensitive

  Throws:
    `IllegalArgumentException`

### isRunning

    public boolean isRunning()

### createTimerTask

    public TimerTask createTimerTask()

### run

    public void run()

  performs the backup operation

  Specified by:
    `run` in interface `Runnable`

### cancel

    public void cancel()

  sets the embedded monitor to be disabled

### getDeleteAtTarget

    public boolean getDeleteAtTarget()

### setDeleteAtTarget

    public void setDeleteAtTarget(boolean flag)

### isAlwaysCopy

    public boolean isAlwaysCopy()

### setAlwaysCopy

    public void setAlwaysCopy(boolean alwaysCopy)

### getMonitor

    public Monitor getMonitor()

### getLogger

    public Logger getLogger()

  Description copied from interface: `LoggerProvider`
  acess to the (non-null) Logger suitable for logging entries in the context of this instance

  Specified by:
    `getLogger` in interface `LoggerProvider`

### getFilter

    public FileFilter getFilter()

### setLogger

    public void setLogger(Logger logger)
                   throws IllegalStateException

  the logger may not be set while the backup is running

  Throws:
    `IllegalStateException`

### setMonitor

    public void setMonitor(Monitor monitor)
                    throws IllegalStateException

  Throws:
    `IllegalStateException`

### setFilter

    public void setFilter(FileFilter filter)
                   throws IllegalStateException

  Throws:
    `IllegalStateException`

### setOriginDir

    public void setOriginDir(File originDir)
                      throws IllegalStateException

  Throws:
    `IllegalStateException`

### setDestinationDir

    public void setDestinationDir(File destinationDir)
                           throws IllegalStateException

  Throws:
    `IllegalStateException`

### getOriginDir

    public File getOriginDir()

### getDestinationDir

    public File getDestinationDir()

### main

    public static void main(String[] args)
                     throws IOException

  Throws:
    `IOException`

(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads