Package ghidra.framework.model
Interface DomainFile
- 
- All Superinterfaces:
- java.lang.Comparable<DomainFile>
 - All Known Implementing Classes:
- DomainFileProxy,- GhidraFile
 
 public interface DomainFile extends java.lang.Comparable<DomainFile> DomainFileprovides a storage interface for project files. ADomainFileis an immutable reference to a file contained within a project. The state of aDomainFileobject does not track name/parent changes made to the referenced project file.
- 
- 
Field SummaryFields Modifier and Type Field Description static intDEFAULT_VERSIONUse with getDomainObject to request the default version.static java.lang.StringREAD_ONLY_PROPERTYEvent property name for Read-only setting.
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddToVersionControl(java.lang.String comment, boolean keepCheckedOut, TaskMonitor monitor)Adds this private file to version control.booleancanAddToRepository()Returns true if this private file may be added to the associated repository.booleancanCheckin()Returns true if this file may be checked-in to the associated repository.booleancanCheckout()Returns true if this file may be checked-out from the associated repository.booleancanMerge()Returns true if this file can be merged with the current versioned file.booleancanRecover()Prior to invoking getDomainObject, this method can be used to determine if unsaved changes can be recovered on the next open.booleancanSave()Return whether this domain object can be saved (i.e., updated/overwritten).voidcheckin(CheckinHandler checkinHandler, boolean okToUpgrade, TaskMonitor monitor)Performs check in to associated repository.booleancheckout(boolean exclusive, TaskMonitor monitor)Checkout this file for update.DomainFilecopyTo(DomainFolder newParent, TaskMonitor monitor)Copy this file into the newParent folder as a private file.DomainFilecopyVersionTo(int version, DomainFolder destFolder, TaskMonitor monitor)Copy a specific version of this file to the specified destFolder.voiddelete()Delete the entire database for this file, including any version files.voiddelete(int version)Deletes a specific version of a file from the versioned filesystem.booleanexists()Check for existence of domain file.ChangeSetgetChangesByOthersSinceCheckout()Returns changes made to versioned file by others since checkout was performed.ItemCheckoutStatus[]getCheckouts()Get a list of checkouts by all users for the associated versioned file.ItemCheckoutStatusgetCheckoutStatus()Get checkout status associated with a versioned file.java.util.ArrayList<?>getConsumers()Get the list of consumers (Objects) for this domain file.java.lang.StringgetContentType()Returns content-type stringDomainObjectgetDomainObject(java.lang.Object consumer, boolean okToUpgrade, boolean okToRecover, TaskMonitor monitor)Opens and returns the current domain object.java.lang.Class<? extends DomainObject>getDomainObjectClass()Returns the underlying Class for the domain object in this domain file.java.lang.StringgetFileID()Returns a unique file-IDjavax.swing.IcongetIcon(boolean disabled)Get the state based Icon image for the domain file based upon its content class.DomainObjectgetImmutableDomainObject(java.lang.Object consumer, int version, TaskMonitor monitor)Returns a new DomainObject that cannot be changed or saved to its original file.longgetLastModifiedTime()Get a long value representing the time when the data was last modified.intgetLatestVersion()Return the latest versionjava.util.Map<java.lang.String,java.lang.String>getMetadata()Returns an ordered map containting the metadata that has been associated with the corresponding domain object.java.lang.StringgetName()Get the name of the StoredObj that is associated with the data.DomainObjectgetOpenedDomainObject(java.lang.Object consumer)Returns the domainObject for this DomainFile only if it is already open.DomainFoldergetParent()Get the parent domain folder for this domain file.java.lang.StringgetPathname()Returns the path name to the domain object.ProjectLocatorgetProjectLocator()Returns the local storage location for the project that this DomainFile belongs to.DomainObjectgetReadOnlyDomainObject(java.lang.Object consumer, int version, TaskMonitor monitor)Returns a "read-only" version of the domain object.intgetVersion()Return either the latest version if the file is not checked-out or the version that was checked-out or a specific version that was requested.Version[]getVersionHistory()Returns list of all available versions.booleanisBusy()Returns true if the domain object in this domain file exists and has an open transaction.booleanisChanged()Return whether the domain object in this domain file has changed.booleanisCheckedOut()Returns true if this is a checked-out file.booleanisCheckedOutExclusive()Returns true if this a checked-out file with exclusive access.booleanisHijacked()Returns true if the file is versioned but a private copy also exists.booleanisInWritableProject()Returns true if this file is in a writable project.booleanisLatestVersion()Returns true if this file represents the latest version of the associated domain object.booleanisOpen()Returns true if there is an open domainObject for this file.booleanisReadOnly()Returns whether the object is read-only.booleanisVersionControlSupported()Returns true if the versioned filesystem can be used to store this files content type.booleanisVersioned()Return true if this is a versioned database, else falselonglength()Returns the length of this domain file.voidmerge(boolean okToUpgrade, TaskMonitor monitor)Performs merge from current version of versioned file into local checked-out file.booleanmodifiedSinceCheckout()Returns true if this is a checked-out file which has been modified since it was checked-out.DomainFilemoveTo(DomainFolder newParent)Move this file into the newParent folder.voidpackFile(java.io.File file, TaskMonitor monitor)Pack domain file into specified file.voidsave(TaskMonitor monitor)Save theDomainObjectassociated with this file.DomainFilesetName(java.lang.String newName)Set the name on this domain file.voidsetReadOnly(boolean state)Sets the object to read-only.booleantakeRecoverySnapshot()If the file has an updateable domain object with unsaved changes, generate a recovery snapshot.voidterminateCheckout(long checkoutId)Forcefully terminate a checkout for the associated versioned file.voidundoCheckout(boolean keep)Undo "checked-out" file.
 
- 
- 
- 
Field Detail- 
DEFAULT_VERSIONstatic final int DEFAULT_VERSION Use with getDomainObject to request the default version. The default version is the private file or check-out file if one exists, or the latest version from the version controlled file system.- See Also:
- Constant Field Values
 
 - 
READ_ONLY_PROPERTYstatic final java.lang.String READ_ONLY_PROPERTY Event property name for Read-only setting.- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getNamejava.lang.String getName() Get the name of the StoredObj that is associated with the data.
 - 
existsboolean exists() Check for existence of domain file.- Returns:
- true if file exists. A proxy domain file will always return false.
 
 - 
getFileIDjava.lang.String getFileID() Returns a unique file-ID- Returns:
 
 - 
setNameDomainFile setName(java.lang.String newName) throws InvalidNameException, java.io.IOException Set the name on this domain file.- Parameters:
- newName- domain file name
- Returns:
- renamed domain file (the original DomainFile object becomes invalid since it is immutable)
- Throws:
- InvalidNameException- if newName contains illegal characters
- DuplicateFileException- if a file named newName already exists in this files domain folder.
- FileInUseException- if this file is in-use / checked-out.
- java.io.IOException- thrown if an IO or access error occurs.
 
 - 
getPathnamejava.lang.String getPathname() Returns the path name to the domain object.
 - 
getProjectLocatorProjectLocator getProjectLocator() Returns the local storage location for the project that this DomainFile belongs to.
 - 
getContentTypejava.lang.String getContentType() Returns content-type string
 - 
getDomainObjectClassjava.lang.Class<? extends DomainObject> getDomainObjectClass() Returns the underlying Class for the domain object in this domain file.
 - 
getParentDomainFolder getParent() Get the parent domain folder for this domain file.
 - 
getChangesByOthersSinceCheckoutChangeSet getChangesByOthersSinceCheckout() throws VersionException, java.io.IOException Returns changes made to versioned file by others since checkout was performed.- Returns:
- change set or null
- Throws:
- VersionException- latest version was created with a newer version of software
- java.io.IOException
 
 - 
getDomainObjectDomainObject getDomainObject(java.lang.Object consumer, boolean okToUpgrade, boolean okToRecover, TaskMonitor monitor) throws VersionException, java.io.IOException, CancelledException Opens and returns the current domain object. If the domain object is already opened, then the existing open domain object is returned.- Parameters:
- consumer- consumer of the domain object which is responsible for releasing it after use. When all the consumers using the domain object release it, then the object is closed and its resources released.
- okToUpgrade- if true, allows the system to upgrade out of data domain objects to be in compliance with the current version of Ghidra. A Version exception will be thrown if the domain object cannot be upgraded OR okToUpgrade is false and the domain object is out of date.
- okToRecover- if true, allows the system to recover unsaved file changes which resulted from a crash. If false, any existing recovery data will be deleted. This flag is only relevent if project is open for update (isInProject) and the file can be opened for update.
- monitor- permits monitoring of open progress.
- Returns:
- an open domain object can be modified and saved. (Not read-only)
- Throws:
- VersionException- if the domain object could not be read due to a version format change. If okToUpgrade is true, then a VersionException indicates that the domain object cannot be upgraded to the current format. If okToUpgrade is false, then the VersionException only means the object is not in the current format - it may or may not be possible to upgrade.
- java.io.IOException- thrown if an IO or access error occurs.
- CancelledException- if monitor cancelled operation
 
 - 
getOpenedDomainObjectDomainObject getOpenedDomainObject(java.lang.Object consumer) Returns the domainObject for this DomainFile only if it is already open.- Parameters:
- consumer- the consumer that will use the object.
- Returns:
- the already opened domainObject or null if it is not currently open.
 
 - 
getReadOnlyDomainObjectDomainObject getReadOnlyDomainObject(java.lang.Object consumer, int version, TaskMonitor monitor) throws VersionException, java.io.IOException, CancelledException Returns a "read-only" version of the domain object. "Read-only" means that the domain object cannot be saved back into its original domain object. It can still be modified and saved to a new domain file. The domain object will be assigned a temporary domain file that will not allow a "save" operation. The user must do a "save as" to a new filename.- Parameters:
- consumer- consumer of the domain object which is responsible for releasing it after use.
- version- the domain object version requested. DEFAULT_VERSION should be specified to open the current version.
- monitor- permits monitoring of open progress.
- Returns:
- a new domain object that is disassociated from its original domain file.
- Throws:
- VersionException- if the domain object could not be read due to a version format change.
- java.io.FileNotFoundException- if the stored file/version was not found.
- java.io.IOException- thrown if an IO or access error occurs.
- CancelledException- if monitor cancelled operation
 
 - 
getImmutableDomainObjectDomainObject getImmutableDomainObject(java.lang.Object consumer, int version, TaskMonitor monitor) throws VersionException, java.io.IOException, CancelledException Returns a new DomainObject that cannot be changed or saved to its original file.- Parameters:
- consumer- consumer of the domain object which is responsible for releasing it after use.
- version- the domain object version requested. DEFAULT_VERSION should be specified to open the current version.
- monitor- permits monitoring of open progress.
- Returns:
- a new domain object that is disassociated from its original domain file and cannot be modified
- Throws:
- VersionException- if the domain object could not be read due to a version format change.
- java.io.FileNotFoundException- if the stored file/version was not found.
- java.io.IOException- thrown if an IO or access error occurs.
- CancelledException- if monitor cancelled operation
 
 - 
savevoid save(TaskMonitor monitor) throws java.io.IOException, CancelledException Save theDomainObjectassociated with this file.- Parameters:
- monitor- monitor for the task that is doing the save on the file
- Throws:
- FileInUseException- if the file is open for update by someone else, or a transient-read is in progress.
- java.io.IOException- thrown if an IO error occurs.
- CancelledException- if monitor cancelled operation
 
 - 
canSaveboolean canSave() Return whether this domain object can be saved (i.e., updated/overwritten).- Returns:
- true if the user is the owner AND the file is in the active project AND the file is not read-only.
 
 - 
canRecoverboolean canRecover() Prior to invoking getDomainObject, this method can be used to determine if unsaved changes can be recovered on the next open.- Returns:
- true if recovery data exists.
 
 - 
takeRecoverySnapshotboolean takeRecoverySnapshot() throws java.io.IOExceptionIf the file has an updateable domain object with unsaved changes, generate a recovery snapshot.- Returns:
- true if snapshot successful or not needed, false if file is busy which prevents snapshot, or snapshot was cancelled.
- Throws:
- java.io.IOException
 
 - 
isInWritableProjectboolean isInWritableProject() Returns true if this file is in a writable project.
 - 
getLastModifiedTimelong getLastModifiedTime() Get a long value representing the time when the data was last modified.
 - 
getIconjavax.swing.Icon getIcon(boolean disabled) Get the state based Icon image for the domain file based upon its content class.- Parameters:
- disabled- true if the icon return should be rendered as not enabled
- Returns:
- image icon
 
 - 
isCheckedOutboolean isCheckedOut() Returns true if this is a checked-out file.
 - 
isCheckedOutExclusiveboolean isCheckedOutExclusive() Returns true if this a checked-out file with exclusive access.
 - 
modifiedSinceCheckoutboolean modifiedSinceCheckout() Returns true if this is a checked-out file which has been modified since it was checked-out.
 - 
canCheckoutboolean canCheckout() Returns true if this file may be checked-out from the associated repository. User's with read-only repository access will not have checkout ability.
 - 
canCheckinboolean canCheckin() Returns true if this file may be checked-in to the associated repository.
 - 
canMergeboolean canMerge() Returns true if this file can be merged with the current versioned file.
 - 
canAddToRepositoryboolean canAddToRepository() Returns true if this private file may be added to the associated repository.
 - 
setReadOnlyvoid setReadOnly(boolean state) throws java.io.IOExceptionSets the object to read-only. This method may only be invoked for private files (i.e., not versioned).- Parameters:
- state- if true file will be read-only and may not be updated, if false the file may be updated.
- Throws:
- java.io.IOException- thrown if an IO error occurs.
 
 - 
isReadOnlyboolean isReadOnly() Returns whether the object is read-only. From a framework point of view a read-only object can never be changed.
 - 
isVersionControlSupportedboolean isVersionControlSupported() Returns true if the versioned filesystem can be used to store this files content type.
 - 
isVersionedboolean isVersioned() Return true if this is a versioned database, else false
 - 
isHijackedboolean isHijacked() Returns true if the file is versioned but a private copy also exists.
 - 
getLatestVersionint getLatestVersion() Return the latest version- Throws:
- java.io.IOException- thrown if an IO or access error occurs.
 
 - 
isLatestVersionboolean isLatestVersion() Returns true if this file represents the latest version of the associated domain object.
 - 
getVersionint getVersion() Return either the latest version if the file is not checked-out or the version that was checked-out or a specific version that was requested.
 - 
getVersionHistoryVersion[] getVersionHistory() throws java.io.IOException Returns list of all available versions.- Throws:
- java.io.IOException
 
 - 
addToVersionControlvoid addToVersionControl(java.lang.String comment, boolean keepCheckedOut, TaskMonitor monitor) throws java.io.IOException, CancelledExceptionAdds this private file to version control.- Parameters:
- comment- new version comment
- keepCheckedOut- if true, the file will be initially checked-out
- monitor- progress monitor
- Throws:
- FileInUseException- if this file is in-use.
- java.io.IOException- thrown if an IO or access error occurs. Also thrown if file is not private.
- CancelledException- if the monitor cancelled the operation
 
 - 
checkoutboolean checkout(boolean exclusive, TaskMonitor monitor) throws java.io.IOException, CancelledExceptionCheckout this file for update. If this file is already private, this method does nothing.- Parameters:
- exclusive- if true an exclusive checkout will be requested
- monitor- progress monitor
- Returns:
- true if checkout successful, false if an exclusive checkout was not possible due to other users having checkouts of this file. A request for a non-exclusive checkout will never return false.
- Throws:
- java.io.IOException- thrown if an IO or access error occurs.
- CancelledException- if task monitor cancelled operation.
 
 - 
checkinvoid checkin(CheckinHandler checkinHandler, boolean okToUpgrade, TaskMonitor monitor) throws java.io.IOException, VersionException, CancelledException Performs check in to associated repository. File must be checked-out and modified since checkout.- Parameters:
- checkinHandler- provides user input data to complete checkin process.
- okToUpgrade- if true an upgrade will be performed if needed
- monitor- the TaskMonitor.
- Throws:
- java.io.IOException- if an IO or access error occurs
- VersionException- if unable to handle domain object version in versioned filesystem. If okToUpgrade was false, check exception to see if it can be upgraded sometime after doing a checkout.
- CancelledException- if task monitor cancelled operation
 
 - 
mergevoid merge(boolean okToUpgrade, TaskMonitor monitor) throws java.io.IOException, VersionException, CancelledExceptionPerforms merge from current version of versioned file into local checked-out file.- Parameters:
- okToUpgrade- if true an upgrade will be performed if needed
- monitor- task monitor
- Throws:
- java.io.IOException- if an IO or access error occurs
- VersionException- if unable to handle domain object version in versioned filesystem. If okToUpgrade was false, check exception to see if it can be upgraded
- CancelledException- if task monitor cancelled operation
 
 - 
undoCheckoutvoid undoCheckout(boolean keep) throws java.io.IOExceptionUndo "checked-out" file. The original repository file is restored.- Parameters:
- keep- if true, the private database will be renamed with a .keep extension.
- Throws:
- FileInUseException- if this file is in-use / checked-out.
- java.io.IOException- thrown if file is not checked-out or an IO / access error occurs.
 
 - 
terminateCheckoutvoid terminateCheckout(long checkoutId) throws java.io.IOExceptionForcefully terminate a checkout for the associated versioned file. The user must be the owner of the checkout or have admin priviledge on the versioned filesystem (i.e., repository).- Parameters:
- checkoutId- checkout ID
- Throws:
- java.io.IOException- if an IO or access error occurs
 
 - 
getCheckoutsItemCheckoutStatus[] getCheckouts() throws java.io.IOException Get a list of checkouts by all users for the associated versioned file.- Returns:
- list of checkouts
- Throws:
- java.io.IOException- if an IO or access error occurs
 
 - 
getCheckoutStatusItemCheckoutStatus getCheckoutStatus() throws java.io.IOException Get checkout status associated with a versioned file.- Returns:
- checkout status or null if not checked-out to current associated project.
- Throws:
- java.io.IOException- if an IO or access error occurs
 
 - 
deletevoid delete() throws java.io.IOExceptionDelete the entire database for this file, including any version files.- Throws:
- FileInUseException- if this file is in-use / checked-out.
- UserAccessException- if the user does not have permission to delete the file.
- java.io.IOException- thrown if an IO or access error occurs.
 
 - 
deletevoid delete(int version) throws java.io.IOExceptionDeletes a specific version of a file from the versioned filesystem.- Parameters:
- version- specific version to be deleted. The version must either be the oldest or latest, or -1 which will attempt to remove all versions. When deleting the latest version, this method could take a long time to return since the previous version must be reconstructed within the versioned filesystem.
- Throws:
- java.io.IOException- if an IO error occurs, including the inability to delete a version because this item is checked-out, the user does not have permission, or the specified version is not the oldest or latest.
 
 - 
moveToDomainFile moveTo(DomainFolder newParent) throws java.io.IOException Move this file into the newParent folder.- Parameters:
- newParent- new parent folder within the same project
- Returns:
- the newly relocated domain file (the original DomainFile object becomes invalid since it is immutable)
- Throws:
- DuplicateFileException- if a file with the same name already exists in newParent folder.
- FileInUseException- if this file is in-use / checked-out.
- java.io.IOException- thrown if an IO or access error occurs.
 
 - 
copyToDomainFile copyTo(DomainFolder newParent, TaskMonitor monitor) throws java.io.IOException, CancelledException Copy this file into the newParent folder as a private file.- Parameters:
- newParent- new parent folder
- monitor- task monitor
- Returns:
- newly created domain file
- Throws:
- FileInUseException- if this file is in-use / checked-out.
- java.io.IOException- thrown if an IO or access error occurs.
- CancelledException- if task monitor cancelled operation.
 
 - 
copyVersionToDomainFile copyVersionTo(int version, DomainFolder destFolder, TaskMonitor monitor) throws java.io.IOException, CancelledException Copy a specific version of this file to the specified destFolder.- Parameters:
- version- version to copy
- destFolder- destination parent folder
- monitor- task monitor
- Throws:
- java.io.IOException- thrown if an IO or access error occurs.
- CancelledException- if task monitor cancelled operation.
 
 - 
getConsumersjava.util.ArrayList<?> getConsumers() Get the list of consumers (Objects) for this domain file.- Returns:
- empty array list if there are no consumers
 
 - 
isChangedboolean isChanged() Return whether the domain object in this domain file has changed.
 - 
isOpenboolean isOpen() Returns true if there is an open domainObject for this file.
 - 
isBusyboolean isBusy() Returns true if the domain object in this domain file exists and has an open transaction.
 - 
packFilevoid packFile(java.io.File file, TaskMonitor monitor) throws java.io.IOException, CancelledExceptionPack domain file into specified file. Specified file will be overwritten if it already exists.- Parameters:
- file- destination file
- monitor-
- Throws:
- java.io.IOException
- CancelledException- if monitor cancels operation
 
 - 
getMetadatajava.util.Map<java.lang.String,java.lang.String> getMetadata() Returns an ordered map containting the metadata that has been associated with the corresponding domain object. The map contains key,value pairs and are ordered by their insertion order.- Returns:
- a map containting the metadata that has been associated with the corresponding domain object.
 
 - 
lengthlong length() throws java.io.IOExceptionReturns the length of this domain file. This size is the minimum disk space used for storing this file, but does not account for additional storage space used to tracks changes, etc.- Returns:
- file length
- Throws:
- java.io.IOException- thrown if IO or access error occurs
 
 
- 
 
-