Package ghidra.framework.store.db
Class VersionedDatabase
- java.lang.Object
-
- db.Database
-
- ghidra.framework.store.db.VersionedDatabase
-
public class VersionedDatabase extends Database
VersionedDatabasecorresponds to a versioned database.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class db.Database
Database.DBBufferFileManager
-
-
Field Summary
Fields Modifier and Type Field Description static longDEFAULT_CHECKOUT_IDintLATEST_VERSIONprotected VersionedDBListenerverDBListenerChange listener-
Fields inherited from class db.Database
bfMgr, CHANGE_FILE_PREFIX, CUMULATIVE_CHANGE_FILENAME, CUMULATIVE_MODMAP_FILENAME, currentVersion, DATABASE_FILE_PREFIX, dbDir, dbDirCreated, dbFileListener, isCheckOutCopy, isVersioned, lastModified, minVersion, syncObject, updateAllowed, VERSION_FILE_PREFIX
-
-
Constructor Summary
Constructors Constructor Description VersionedDatabase(java.io.File dbDir, BufferFile srcFile, VersionedDBListener verDBListener, long checkoutId, java.lang.String comment, TaskMonitor monitor)Construct a new "Versioned" Database from an existing srcFile.VersionedDatabase(java.io.File dbDir, VersionedDBListener verDBListener)Constructor for an existing "Versioned" Database.VersionedDatabase(java.io.File dbDir, java.io.File packedFile, VersionedDBListener verDBListener, long checkoutId, java.lang.String comment, TaskMonitor monitor)Construct a new "Versioned" Database from a packed database file
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static LocalManagedBufferFilecreateVersionedDatabase(java.io.File dbDir, int bufferSize, VersionedDBListener verDBListener, long checkoutId)Create a new database and provide the initial buffer file for writing.voiddbMoved(java.io.File dbDir)Following a move of the database directory, this method should be invoked if this instance will continue to be used.voiddeleteCurrentVersion()Delete latest version.voiddeleteMinimumVersion()Delete oldest version.intgetCurrentVersion()Returns the version number associated with the latest buffer file version.intgetMinimumVersion()Returns the version number associated with the oldest buffer file version.DBHandleopen(int version, int minChangeDataVer, TaskMonitor monitor)Open a specific version of the stored database for non-update use.LocalManagedBufferFileopenBufferFile(int version, int minChangeDataVer)Open a specific version of this database for non-update use.LocalManagedBufferFileopenBufferFileForUpdate(long checkoutId)Open the current version of this database for update use.DBHandleopenForUpdate(TaskMonitor monitor)Open the stored database for update use.voidoutput(int version, java.io.File outputFile, java.lang.String name, int filetype, java.lang.String contentType, TaskMonitor monitor)Output the current version of this database to a packed storage file.protected voidscanFiles(boolean repair)Scan files and update state.-
Methods inherited from class db.Database
deleteDir, lastModified, length, open, refresh, setSynchronizationObject
-
-
-
-
Field Detail
-
LATEST_VERSION
public final int LATEST_VERSION
- See Also:
- Constant Field Values
-
DEFAULT_CHECKOUT_ID
public static final long DEFAULT_CHECKOUT_ID
- See Also:
- Constant Field Values
-
verDBListener
protected VersionedDBListener verDBListener
Change listener
-
-
Constructor Detail
-
VersionedDatabase
public VersionedDatabase(java.io.File dbDir, VersionedDBListener verDBListener) throws java.io.IOExceptionConstructor for an existing "Versioned" Database.- Parameters:
dbDir- database directoryverDBListener-- Throws:
java.io.IOException
-
VersionedDatabase
public VersionedDatabase(java.io.File dbDir, BufferFile srcFile, VersionedDBListener verDBListener, long checkoutId, java.lang.String comment, TaskMonitor monitor) throws java.io.IOException, CancelledExceptionConstruct a new "Versioned" Database from an existing srcFile.- Parameters:
dbDir-srcFile-monitor-- Throws:
java.io.IOExceptionCancelledException
-
VersionedDatabase
public VersionedDatabase(java.io.File dbDir, java.io.File packedFile, VersionedDBListener verDBListener, long checkoutId, java.lang.String comment, TaskMonitor monitor) throws java.io.IOException, CancelledExceptionConstruct a new "Versioned" Database from a packed database file- Parameters:
dbDir-packedFile-verDBListener-checkoutId-comment-monitor-- Throws:
java.io.IOExceptionCancelledException
-
-
Method Detail
-
createVersionedDatabase
public static LocalManagedBufferFile createVersionedDatabase(java.io.File dbDir, int bufferSize, VersionedDBListener verDBListener, long checkoutId) throws java.io.IOException
Create a new database and provide the initial buffer file for writing.- Parameters:
dbDir-bufferSize-- Returns:
- initial buffer file
- Throws:
java.io.IOException
-
getMinimumVersion
public int getMinimumVersion()
Returns the version number associated with the oldest buffer file version.
-
getCurrentVersion
public int getCurrentVersion()
Returns the version number associated with the latest buffer file version.- Overrides:
getCurrentVersionin classDatabase
-
deleteMinimumVersion
public void deleteMinimumVersion() throws java.io.IOExceptionDelete oldest version.- Throws:
java.io.IOException- if an error occurs or this is the only version.
-
deleteCurrentVersion
public void deleteCurrentVersion() throws java.io.IOExceptionDelete latest version.- Throws:
java.io.IOException- if an error occurs or this is the only version.
-
openBufferFile
public LocalManagedBufferFile openBufferFile(int version, int minChangeDataVer) throws java.io.IOException
Open a specific version of this database for non-update use.- Parameters:
version- database version or LATEST_VERSION for current versionminChangeDataVer- the minimum database version whoose change data should be associated with the returned buffer file. A value of -1 indicates that change data is not required.- Returns:
- buffer file for non-update use.
- Throws:
java.io.IOException
-
open
public DBHandle open(int version, int minChangeDataVer, TaskMonitor monitor) throws java.io.IOException
Open a specific version of the stored database for non-update use. The returned handle does not support the Save operation.- Parameters:
version- database versionmonitor- task monitor (may be null)- Returns:
- database handle
- Throws:
FileInUseException- thrown if unable to obtain the required database lock(s).java.io.IOException- thrown if IO error occurs.
-
openForUpdate
public DBHandle openForUpdate(TaskMonitor monitor) throws java.io.IOException
Description copied from class:DatabaseOpen the stored database for update use.- Overrides:
openForUpdatein classDatabase- Parameters:
monitor- task monitor (may be null)- Returns:
- buffer file
- Throws:
FileInUseException- thrown if unable to obtain the required database lock(s).java.io.IOException- thrown if IO error occurs.
-
openBufferFileForUpdate
public LocalManagedBufferFile openBufferFileForUpdate(long checkoutId) throws java.io.IOException
Open the current version of this database for update use.- Parameters:
checkoutId- checkout ID- Returns:
- updateable buffer file
- Throws:
java.io.IOException- if update not permitted or other error occurs
-
dbMoved
public void dbMoved(java.io.File dbDir) throws java.io.FileNotFoundExceptionFollowing a move of the database directory, this method should be invoked if this instance will continue to be used.- Parameters:
dbDir- new database directory- Throws:
java.io.FileNotFoundException
-
scanFiles
protected void scanFiles(boolean repair) throws java.io.FileNotFoundExceptionScan files and update state.
-
output
public void output(int version, java.io.File outputFile, java.lang.String name, int filetype, java.lang.String contentType, TaskMonitor monitor) throws java.io.IOException, CancelledExceptionOutput the current version of this database to a packed storage file.- Parameters:
outputFile- packed storage file to be writtenname- database namefiletype- application file typecontentType- user content typemonitor-- Throws:
java.io.IOExceptionCancelledException
-
-