org.jtheque.core.managers.file
Class FileManager

java.lang.Object
  extended by org.jtheque.core.managers.file.FileManager
All Implemented Interfaces:
ActivableManager, IFileManager, IManager

public final class FileManager
extends java.lang.Object
implements IFileManager

A FileManager implementation.

Author:
Baptiste Wicht

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jtheque.core.managers.file.IFileManager
IFileManager.JTDVersion, IFileManager.XmlBackupVersion
 
Field Summary
 
Fields inherited from interface org.jtheque.core.managers.file.IFileManager
CONTENT, JTCATEGORYSEPARATOR, JTINTERNSEPARATOR, JTKEY, NOCONTENT, UTFNULL
 
Constructor Summary
FileManager()
          Construct a new FileManager.
 
Method Summary
 void backup(FileType format, java.io.File file)
          Backup to a File with a specific format.
 void close()
          Close the manager.
 java.lang.String formatUTFToRead(java.lang.String utf)
          Format an UTF string after read it in a file to get the good value.
 java.lang.String formatUTFToWrite(java.lang.String utf)
          Format an UTF string before insert it in a file to be sure that it isn't empty.
 java.util.List<BackupReader> getBackupReaders(FileType format)
          Return all the backupers of a specific format.
 void init()
          Init the manager.
 boolean isBackupPossible(FileType format)
          Indicate if the backup is possible for the specified file type.
 boolean isEnabled()
          Indicate if the manager is enabled or not.
 boolean isRestorePossible(FileType format)
          Indicate if the restore is possible for the specified file type.
 void preInit()
          Pre-init the manager.
 void registerBackupReader(FileType format, BackupReader reader)
          Register a new BackupReader.
 void registerBackupWriter(FileType format, BackupWriter writer)
          Register a new BackupWriter.
 void restore(FileType format, java.io.File file)
          Restore the data from a File with a specific format.
 void setBackupers(Backuper[] backupers)
          Set the backupers.
 void setEnabled(boolean enabled)
          Enable or disable the manager.
 void setRestorers(Restorer[] restorers)
          Set the restorers.
 void unregisterBackupReader(FileType format, BackupReader reader)
          Unregister a BackupReader.
 void unregisterBackupWriter(FileType format, BackupWriter writer)
          Unregister a BackupWriter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileManager

public FileManager()
Construct a new FileManager.

Method Detail

isEnabled

public boolean isEnabled()
Description copied from interface: ActivableManager
Indicate if the manager is enabled or not.

Specified by:
isEnabled in interface ActivableManager
Returns:
true if the manager is enabled else false.

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: ActivableManager
Enable or disable the manager.

Specified by:
setEnabled in interface ActivableManager
Parameters:
enabled - true if we want enable the manager else false.

preInit

public void preInit()
Description copied from interface: IManager
Pre-init the manager. This operation is called before modules preplug.

Specified by:
preInit in interface IManager

close

public void close()
           throws ManagerException
Description copied from interface: IManager
Close the manager.

Specified by:
close in interface IManager
Throws:
ManagerException - If an error occurs during the close process.

init

public void init()
          throws ManagerException
Description copied from interface: IManager
Init the manager. This operation is called after modules preplug but before module plug.

Specified by:
init in interface IManager
Throws:
ManagerException - If an error occurs during the init process.

backup

public void backup(FileType format,
                   java.io.File file)
            throws org.jtheque.utils.io.FileException
Description copied from interface: IFileManager
Backup to a File with a specific format.

Specified by:
backup in interface IFileManager
Parameters:
format - The format of the backup.
file - The file to backup to.
Throws:
org.jtheque.utils.io.FileException - Thrown when an error occurs during the backup process.

restore

public void restore(FileType format,
                    java.io.File file)
             throws org.jtheque.utils.io.FileException
Description copied from interface: IFileManager
Restore the data from a File with a specific format.

Specified by:
restore in interface IFileManager
Parameters:
format - The format of the backup.
file - The file to restore from.
Throws:
org.jtheque.utils.io.FileException - Thrown when an error occurs during the restore process.

registerBackupWriter

public void registerBackupWriter(FileType format,
                                 BackupWriter writer)
Description copied from interface: IFileManager
Register a new BackupWriter.

Specified by:
registerBackupWriter in interface IFileManager
Parameters:
format - The format the BackupWriter manage.
writer - The writer to register.

formatUTFToWrite

public java.lang.String formatUTFToWrite(java.lang.String utf)
Description copied from interface: IFileManager
Format an UTF string before insert it in a file to be sure that it isn't empty.

Specified by:
formatUTFToWrite in interface IFileManager
Parameters:
utf - The UTF string.
Returns:
The UTF String if it isn't empty or UTFNULL.

formatUTFToRead

public java.lang.String formatUTFToRead(java.lang.String utf)
Description copied from interface: IFileManager
Format an UTF string after read it in a file to get the good value.

Specified by:
formatUTFToRead in interface IFileManager
Parameters:
utf - The UTF string.
Returns:
The UTF String if it isn't empty or UTFNULL.

registerBackupReader

public void registerBackupReader(FileType format,
                                 BackupReader reader)
Description copied from interface: IFileManager
Register a new BackupReader.

Specified by:
registerBackupReader in interface IFileManager
Parameters:
format - The format the BackupReader manage.
reader - The reader to register.

unregisterBackupReader

public void unregisterBackupReader(FileType format,
                                   BackupReader reader)
Description copied from interface: IFileManager
Unregister a BackupReader.

Specified by:
unregisterBackupReader in interface IFileManager
Parameters:
format - The format the BackupReader manage.
reader - The reader to unregister.

unregisterBackupWriter

public void unregisterBackupWriter(FileType format,
                                   BackupWriter writer)
Description copied from interface: IFileManager
Unregister a BackupWriter.

Specified by:
unregisterBackupWriter in interface IFileManager
Parameters:
format - The format the BackupWriter manage.
writer - The writer to unregister.

getBackupReaders

public java.util.List<BackupReader> getBackupReaders(FileType format)
Description copied from interface: IFileManager
Return all the backupers of a specific format.

Specified by:
getBackupReaders in interface IFileManager
Parameters:
format - The format.
Returns:
All the BackupReader.

isBackupPossible

public boolean isBackupPossible(FileType format)
Description copied from interface: IFileManager
Indicate if the backup is possible for the specified file type.

Specified by:
isBackupPossible in interface IFileManager
Parameters:
format - The file type to test.
Returns:
true if the backup is possible with this file type else false.

isRestorePossible

public boolean isRestorePossible(FileType format)
Description copied from interface: IFileManager
Indicate if the restore is possible for the specified file type.

Specified by:
isRestorePossible in interface IFileManager
Parameters:
format - The file type to test.
Returns:
true if the restore is possible with this file type else false.

setBackupers

public void setBackupers(Backuper[] backupers)
Set the backupers. This is not for use, this is only for Spring Injection.

Parameters:
backupers - The backupers to set.

setRestorers

public void setRestorers(Restorer[] restorers)
Set the restorers. This is not for use, this is only for Spring Injection.

Parameters:
restorers - The restorers to set.


Copyright © 2009 JTheque. All Rights Reserved.