class BackupInstance
extends java.lang.Object
implements java.io.Serializable
BackupManager class
manages, creates and serializes instances of this class.
| Modifier and Type | Field and Description |
|---|---|
private java.util.Map<java.lang.String,java.lang.Long> |
mBackupIndex
This is the file index.
|
private java.lang.String |
mDirBackup
Path to the directory where the copies are stored as
String. |
private java.lang.String |
mDirOriginal
Path to the original directory as
String. |
private boolean |
mKeepAll
Specifies whether a complete file history should be kept or not.
|
private java.util.Date |
mLastSynchronization
This is the
Date of last synchronization of this BackupInstance. |
private java.lang.String |
mName
The backup name.
|
private boolean |
mShallow
Specifies whether the backup is shallow or not.
|
| Constructor and Description |
|---|
BackupInstance(BackupInstanceFramework framework)
The class constructor.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
addBackupToIndex(java.nio.file.Path original_path,
java.nio.file.attribute.FileTime last_modified)
Indexes a path.
|
(package private) void |
backupDirectory(java.nio.file.Path dir,
java.nio.file.attribute.FileTime last_modified)
Creates a backup of a directory.
|
(package private) void |
backupFile(java.nio.file.Path file,
java.nio.file.attribute.FileTime last_modified)
Creates a backup of a file.
|
(package private) java.nio.file.Path |
dirBackup()
This method returns the path to the directory
where the backed up data are to be created.
|
(package private) java.nio.file.Path |
dirOriginal()
This method returns path to the original file or directory.
|
(package private) boolean |
isBackupCreated(java.nio.file.Path path)
Checks if a backup of an original file/directory exists.
|
(package private) boolean |
isPathIndexed(java.nio.file.Path path)
Checks if the input path is indexed.
|
(package private) boolean |
isShallow() |
(package private) java.util.Date |
lastSyncDate()
This method returns the date of last synchronization.
|
(package private) void |
removeBackupFromIndex(java.nio.file.Path original_path)
|
private void |
removeDeleted()
Calls the
DeleteFileVisitor to delete files
that are no longer present in the original directory. |
(package private) java.nio.file.Path |
retrieveBackupPath(java.nio.file.Path original_path)
This method, together with
retrieveOriginalpath(java.nio.file.Path),
provides the program with the ability
to rebuild the directory tree of the original location in the backup directory. |
(package private) java.nio.file.attribute.FileTime |
retrieveLastBackupTime(java.nio.file.Path path)
Fetches the last modified time known when the file/directory was last indexed.
|
(package private) java.nio.file.Path |
retrieveOriginalpath(java.nio.file.Path backup_path)
This method, together with
retrieveBackupPath(java.nio.file.Path)
, provides the program with the ability
to rebuild the directory tree of the original location in the backup directory. |
(package private) void |
rewriteLastModified(java.nio.file.Path backup_dir,
java.nio.file.attribute.FileTime last_modified)
Set last modified time for a directory.
|
(package private) void |
synchronize()
This method is used to synchronize the backup directory with the original.
|
private java.lang.String mName
private java.lang.String mDirOriginal
String.private java.lang.String mDirBackup
String.private boolean mShallow
private boolean mKeepAll
private java.util.Map<java.lang.String,java.lang.Long> mBackupIndex
Long value attached to each file.
It represents the last modified date of the file when it was last backed up.private java.util.Date mLastSynchronization
Date of last synchronization of this BackupInstance.BackupInstance(BackupInstanceFramework framework)
BackupInstanceFramework
that serves as a template for the serializable
BackupInstance object.framework - instance of
BackupInstanceFrameworkvoid synchronize()
BackupInstanceFramework
instance that was passed to the class constructor.java.util.Date lastSyncDate()
Datejava.nio.file.Path dirOriginal()
Path to the original.java.nio.file.Path dirBackup()
Path to the backup directory.boolean isShallow()
java.nio.file.Path retrieveBackupPath(java.nio.file.Path original_path)
retrieveOriginalpath(java.nio.file.Path),
provides the program with the ability
to rebuild the directory tree of the original location in the backup directory.
Path that is located within the original directory
and transforms it into a Path pointing to the same location in the backup directory.original_path - a Path located somewhere in the original directoryPath in the backup directoryjava.nio.file.Path retrieveOriginalpath(java.nio.file.Path backup_path)
retrieveBackupPath(java.nio.file.Path)
, provides the program with the ability
to rebuild the directory tree of the original location in the backup directory.
Path that is located within the backup directory
and transforms it into a Path pointing to the same location in the original directory.backup_path - a path located somewhere in the backup directoryvoid addBackupToIndex(java.nio.file.Path original_path,
java.nio.file.attribute.FileTime last_modified)
retrieveBackupPath(java.nio.file.Path) method).original_path - instance of Path pointing to file/directory to be indexed.last_modified - instance of FileTime
specifying the time of last modification of the original file/directoryvoid removeBackupFromIndex(java.nio.file.Path original_path)
addBackupToIndex(java.nio.file.Path, java.nio.file.attribute.FileTime).
Removes the path from the index.original_path - instance of Path that points to the original
to be removed from index.boolean isPathIndexed(java.nio.file.Path path)
path - the path to be checked.true, if it is indexed, false if it isn'tjava.nio.file.attribute.FileTime retrieveLastBackupTime(java.nio.file.Path path)
path - input pathFileTime
specifying the time of last modification of the original file/directory
when it was last indexed.boolean isBackupCreated(java.nio.file.Path path)
path - the path to be checked.true, if backup exists, false if it doesn'tvoid backupDirectory(java.nio.file.Path dir,
java.nio.file.attribute.FileTime last_modified)
dir - Path to the directory that is being backed.last_modified - known last modified time in the form of FileTime instancevoid backupFile(java.nio.file.Path file,
java.nio.file.attribute.FileTime last_modified)
file - Path to the file that is being backed.last_modified - known last modified time in the form of
FileTime instancevoid rewriteLastModified(java.nio.file.Path backup_dir,
java.nio.file.attribute.FileTime last_modified)
BackupFileVisitor
to set correct last modified times for directories in the backup location.
backup_dir - location in the backup directorylast_modified - last modified time of the original directory (located somewhere in the backup path)private void removeDeleted()
throws java.io.IOException
DeleteFileVisitor to delete files
that are no longer present in the original directory.java.io.IOException