public final class FileRepository extends Object implements Repository
NTransaction
,
Repository
Modifier and Type | Field and Description |
---|---|
private int |
baddeleted
The number of useless delete operation on repository.
|
(package private) File |
dir |
private String |
mode |
private int |
nbdeleted
The number of delete operation on repository.
|
private int |
nbloaded
The number of load operation from repository.
|
private int |
nbsaved
The number of save operation to repository.
|
private boolean |
syncOnWrite |
private boolean |
useFileOutputStream
Boolean value to force the use of FileOutputStream rather than
RandomAccessFile.
|
Constructor and Description |
---|
FileRepository() |
Modifier and Type | Method and Description |
---|---|
void |
backup(BackupFile backup)
Backups the repository (may be unimplemented).
|
private void |
backupDir(BackupFile backup,
File currentDir,
String path) |
private void |
backupFile(BackupFile backup,
File file,
String path) |
void |
close()
Closes the repository.
|
void |
commit()
Commits all changes to the repository.
|
void |
delete(String dirName,
String name)
Deletes the corresponding objects in repository.
|
private void |
deleteDir(File dir)
Delete the specified directory if it is empty.
|
int |
getNbBadDeletedObjects()
Returns the number of useless delete operation on repository.
|
int |
getNbDeletedObjects()
Returns the number of delete operation on repository.
|
int |
getNbLoadedObjects()
Returns the number of load operation from repository.
|
int |
getNbSavedObjects()
Returns the number of save operation to repository.
|
void |
init(Transaction transaction,
File dir)
Initializes the repository.
|
String[] |
list(String prefix)
Gets a list of persistent objects that name corresponds to prefix.
|
byte[] |
load(String dirName,
String name)
Loads the byte array.
|
void |
save(String dirName,
String name,
byte[] content)
Save the corresponding bytes array.
|
File dir
private int nbsaved
private int nbdeleted
private int baddeleted
private int nbloaded
private boolean useFileOutputStream
This property can be fixed only from java
launching
command, or through System.property method.
private boolean syncOnWrite
private String mode
public int getNbSavedObjects()
getNbSavedObjects
in interface Repository
public int getNbDeletedObjects()
getNbDeletedObjects
in interface Repository
public int getNbBadDeletedObjects()
getNbBadDeletedObjects
in interface Repository
public int getNbLoadedObjects()
getNbLoadedObjects
in interface Repository
public void init(Transaction transaction, File dir) throws IOException
init
in interface Repository
transaction
- the transaction object.dir
- the directory.IOException
- an error occurs.public String[] list(String prefix) throws IOException
list
in interface Repository
prefix
- the prefix.IOException
- an error occurs.public void save(String dirName, String name, byte[] content) throws IOException
save
in interface Repository
dirName
- the directory.name
- the object name.content
- the serialized object view.IOException
- an error occurs.public byte[] load(String dirName, String name) throws IOException
load
in interface Repository
dirName
- the directory.name
- the object name.IOException
- an error occurs.public void delete(String dirName, String name) throws IOException
delete
in interface Repository
dirName
- the directory.name
- the object name.IOException
- an error occurs.private final void deleteDir(File dir)
dir
- the directory to delete.public void commit() throws IOException
commit
in interface Repository
IOException
- an error occurs.public void backup(BackupFile backup) throws IOException
Repository
backup
in interface Repository
backup
- The backup file.IOException
private void backupDir(BackupFile backup, File currentDir, String path) throws IOException
IOException
private void backupFile(BackupFile backup, File file, String path) throws IOException
IOException
public void close() throws IOException
close
in interface Repository
IOException
- an error occurs.Copyright © 2023 ScalAgent D.T.. All rights reserved.