public class BackupManager
extends java.lang.Object
BackupInstance
and registers new ones.
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,BackupInstance> |
mBackupList
This
Map ensures quick accessibility of all scheduled backups. |
private java.text.DateFormat |
mDateFormatter
This
DateFormat instance formats the Date
for the case when the backup name was not specified. |
private java.util.List<java.lang.String> |
mFailedToLoad
The names of the backups that failed to load for any reason are stored here.
|
Constructor and Description |
---|
BackupManager()
The
BackupManager constructor. |
Modifier and Type | Method and Description |
---|---|
boolean |
backupExists(java.lang.String name)
Check whether a backup with the specified name exists in the
BackupManager or not. |
boolean |
backupFileExists(java.lang.String name)
Check whether a backup file with the specified name exists or not.
|
void |
deleteBackup(java.lang.String name)
Attempts to delete a backup.
|
private void |
deserializeBackupList()
This method attempts to load all backups that were previously saved to disc.
|
void |
registerNewBackup(BackupInstanceFramework framework)
This method is used to schedule a new backup
according to rules specified by the
BackupInstanceFramework
and implements all the logic to be able to do so. |
private void |
serializeBackup(java.lang.String key)
This method takes a backup name and saves it to the disc as
a serialized instance of
BackupInstance . |
private void |
serializeBackupList()
This method takes the
mBackupList and saves it to the disc as separate
serialized instances of BackupInstance . |
void |
synchronize()
Synchronizes all scheduled backups
|
void |
synchronize(java.lang.String name)
Synchronizes only a specified backup.
|
void |
updateView(BackupViewer view)
This method is used to provide information about backups to a view
that implements the
BackupViewer interface. |
private java.text.DateFormat mDateFormatter
DateFormat
instance formats the Date
for the case when the backup name was not specified. It is used in the construction of
a default unique name that is still human readable.private java.util.Map<java.lang.String,BackupInstance> mBackupList
Map
ensures quick accessibility of all scheduled backups.private java.util.List<java.lang.String> mFailedToLoad
public BackupManager()
BackupManager
constructor.
It creates the directory into which the scheduled backups are serialized
or it loads backups that are already scheduled.public void registerNewBackup(BackupInstanceFramework framework)
BackupInstanceFramework
and implements all the logic to be able to do so.framework
- instance of BackupInstanceFramework
public boolean backupExists(java.lang.String name)
BackupManager
or not.name
- name to be checkedtrue
, if it exists, false
if it doesn'tpublic boolean backupFileExists(java.lang.String name)
name
- name of the backup filetrue
, if it exists, false
if it doesn'tpublic void synchronize()
public void synchronize(java.lang.String name)
name
- name of the backup to be updatedpublic void updateView(BackupViewer view)
BackupViewer
interface.view
- instance of a class that implemets the BackupViewer
interface.public void deleteBackup(java.lang.String name)
name
- backup nameprivate void serializeBackup(java.lang.String key)
BackupInstance
.key
- the backup nameprivate void serializeBackupList()
mBackupList
and saves it to the disc as separate
serialized instances of BackupInstance
.private void deserializeBackupList()