Package ghidra.app.util.opinion
Class Loaded<T extends DomainObject>
java.lang.Object
ghidra.app.util.opinion.Loaded<T>
- Type Parameters:
T- The type ofDomainObjectthat was loaded
A loaded
DomainObject produced by a Loader. In addition to storing the loaded
DomainObject, it also stores the Loader's desired name and project folder path
for the loaded DomainObject, should it get saved to a project.
NOTE: If an object of this type is marked as discardable, it should
be released and not saved.
-
Constructor Summary
ConstructorsConstructorDescriptionLoaded(T domainObject, DomainFile domainFile) Creates aLoadedview on an existingDomainFile.Creates a newLoadedobject -
Method Summary
Modifier and TypeMethodDescriptionGets the loadedDomainObjectgetName()Gets the name of the loadedDomainObject.Gets the project folder path this will get saved to during asave(Project, MessageLog, TaskMonitor)operation.voidNotify the loadedDomainObjectthat the specified consumer is no longer using it.save(Project project, MessageLog messageLog, TaskMonitor monitor) Saves the loadedDomainObjectto the givenProjectat this object's project folder path, using this object's name.voidsetDiscard(boolean discard) Sets whether or not thisLoadedDomainObjectshould be discarded (not saved)voidsetProjectFolderPath(String projectFolderPath) Sets the project folder path this will get saved to during asave(Project, MessageLog, TaskMonitor)operation.booleanChecks to see if thisLoadedDomainObjectshould be discarded (not saved)toString()
-
Constructor Details
-
Loaded
Creates a newLoadedobject- Parameters:
domainObject- The loadedDomainObjectname- The name of the loadedDomainObject. If asave(Project, MessageLog, TaskMonitor)occurs, this will attempted to be used for the resultingDomainFile's name.projectFolderPath- The project folder path this will get saved to during asave(Project, MessageLog, TaskMonitor)operation. If null or empty, the root project folder will be used.
-
Loaded
- Parameters:
domainObject- The loadedDomainObjectdomainFile- TheDomainFileto be loaded
-
-
Method Details
-
getDomainObject
Gets the loadedDomainObject- Returns:
- The loaded
DomainObject
-
getName
Gets the name of the loadedDomainObject. If asave(Project, MessageLog, TaskMonitor)occurs, this will attempted to be used for the resultingDomainFile's name.- Returns:
- the name of the loaded
DomainObject
-
getProjectFolderPath
Gets the project folder path this will get saved to during asave(Project, MessageLog, TaskMonitor)operation.NOTE: The returned path will always end with a "/".
- Returns:
- the project folder path
-
setProjectFolderPath
Sets the project folder path this will get saved to during asave(Project, MessageLog, TaskMonitor)operation.- Parameters:
projectFolderPath- The project folder path this will get saved to during asave(Project, MessageLog, TaskMonitor)operation. If null or empty, the root project folder will be used.
-
release
Notify the loadedDomainObjectthat the specified consumer is no longer using it. When the last consumer invokes this method, the loadedDomainObjectwill be closed and will become invalid.- Parameters:
consumer- the consumer
-
save
public DomainFile save(Project project, MessageLog messageLog, TaskMonitor monitor) throws CancelledException, ClosedException, IOException Saves the loadedDomainObjectto the givenProjectat this object's project folder path, using this object's name.If a
DomainFilealready exists with the same desired name and project folder path, the desired name will get a counter value appended to it to avoid a naming conflict. Therefore, it should not be assumed that the returnedDomainFilewill have the same name as a call togetName().- Parameters:
project- TheProjectto save tomessageLog- The logmonitor- A cancelable task monitor- Returns:
- The
DomainFilewhere the save happened - Throws:
CancelledException- if the operation was cancelledClosedException- if the loadedDomainObjectwas already closedIOException- If there was an IO-related error, an invalid name was specified, or it was already successfully saved and still exists
-
getSavedDomainFile
- Returns:
- The loaded
DomainObject's associated savedDomainFile, or null if was not saved - Throws:
FileNotFoundException- If the loadedDomainObjectwas saved but the associatedDomainFileno longer exists- See Also:
-
shouldDiscard
public boolean shouldDiscard()Checks to see if thisLoadedDomainObjectshould be discarded (not saved)- Returns:
- True if this
LoadedDomainObjectshould be discarded; otherwise, false
-
setDiscard
public void setDiscard(boolean discard) Sets whether or not thisLoadedDomainObjectshould be discarded (not saved)- Parameters:
discard- True if thisLoadedDomainObjectshould be discarded; otherwise, false
-
toString
-