Package ghidra.framework.data
Class LinkHandler<T extends DomainObjectAdapterDB>
java.lang.Object
ghidra.framework.data.LinkHandler<T>
- Type Parameters:
T-URLLinkObjectimplementation class
- All Implemented Interfaces:
ContentHandler<T>,ExtensionPoint
- Direct Known Subclasses:
DataTypeArchiveLinkContentHandler,DBTraceLinkContentHandler,FolderLinkContentHandler,ProgramLinkContentHandler
public abstract class LinkHandler<T extends DomainObjectAdapterDB>
extends Object
implements ContentHandler<T>
NOTE: ALL ContentHandler implementations MUST END IN "ContentHandler". If not,
the ClassSearcher will not find them.
LinkHandler defines an application interface for handling domain files which are
shortcut links to another supported content type.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumLinkHandler.LinkStatusprovides a link evaluation for its ulimate type or if it is considered broken. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Icon16x16 link icon where link is placed in lower-left cornerstatic final StringLegacy linkPath metadata key for database storageFields inherited from interface ghidra.framework.data.ContentHandler
MISSING_CONTENT, UNKNOWN_CONTENT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal longcreateFile(FileSystem fs, FileSystem userfs, String path, String name, DomainObject domainObject, TaskMonitor monitor) Creates a new folder item within a specified file-system.protected final voidcreateLink(String linkPath, LocalFileSystem fs, String folderPath, String linkFilename) Create a link file using the specified URLstatic DomainFilefollowInternalLinkage(DomainFile file, Consumer<LinkHandler.LinkStatus> statusConsumer, Consumer<String> errorConsumer) Follow the internal linkage, if any, for the specified file.static StringgetAbsoluteLinkPath(DomainFile linkFile) Get the Ghidra URL or absolute normalized link-path from a link file.final ChangeSetgetChangeSet(FolderItem versionedFolderItem, int olderVersion, int newerVersion) Returns the object change data which includes changes made to the specified olderVersion through to the specified newerVersion.final TgetDomainObject(FolderItem item, FileSystem userfs, long checkoutId, boolean okToUpgrade, boolean okToRecover, Object consumer, TaskMonitor monitor) Open a folder item for update.abstract IcongetIcon()Get the base icon for this link-file which does not include the link overlay icon.getImmutableObject(FolderItem item, Object consumer, int version, int minChangeVersion, TaskMonitor monitor) Open a folder item for immutable use.static LinkHandler.LinkStatusgetLinkFileStatus(DomainFile file, Consumer<String> errorConsumer) Determine the link status for the specifiedlink-file.LinkHandler<?> If linking is supported return an instanceof the appropriateLinkHandler.static URLgetLinkURL(DomainFile linkFile) Get the link URL which corresponds to the specified link file's link-path.final DomainObjectMergeManagergetMergeManager(DomainObject resultsObj, DomainObject sourceObj, DomainObject originalObj, DomainObject latestObj) Get an instance of a suitable merge manager to be used during the merge of a Versioned object which has been modified by another user since it was last merged or checked-out.final TgetReadOnlyObject(FolderItem item, int version, boolean okToUpgrade, Object consumer, TaskMonitor monitor) Open a folder item for read-only use.final booleanReturns true if the content type is always private (i.e., can not be added to the versioned filesystem).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ghidra.framework.data.ContentHandler
canResetDBSourceFile, getContentType, getContentTypeDisplayString, getDefaultToolName, getDomainObjectClass, resetDBSourceFile
-
Field Details
-
URL_METADATA_KEY
Legacy linkPath metadata key for database storage- See Also:
-
LINK_ICON
16x16 link icon where link is placed in lower-left corner
-
-
Constructor Details
-
LinkHandler
public LinkHandler()
-
-
Method Details
-
getLinkHandler
Description copied from interface:ContentHandlerIf linking is supported return an instanceof the appropriateLinkHandler.- Specified by:
getLinkHandlerin interfaceContentHandler<T extends DomainObjectAdapterDB>- Returns:
- corresponding link handler or null if not supported.
-
createLink
protected final void createLink(String linkPath, LocalFileSystem fs, String folderPath, String linkFilename) throws IOException, InvalidNameException Create a link file using the specified URL- Parameters:
linkPath- link path or Ghidra URL.fs- filesystem where link file should be createdfolderPath- folder path which should contain link filelinkFilename- link filename- Throws:
IOException- if an IO error occursInvalidNameException- if invalid folderPath or linkFilename specified
-
createFile
public final long createFile(FileSystem fs, FileSystem userfs, String path, String name, DomainObject domainObject, TaskMonitor monitor) throws IOException, InvalidNameException, CancelledException Description copied from interface:ContentHandlerCreates a new folder item within a specified file-system. If fs is versioned, the resulting item is marked as checked-out within the versioned file-system. The specified domainObj will become associated with the newly created database.- Specified by:
createFilein interfaceContentHandler<T extends DomainObjectAdapterDB>- Parameters:
fs- the file system in which to create the folder itemuserfs- file system which contains associated user datapath- the path of the folder itemname- the name of the new folder itemdomainObject- the domain object to store in the newly created folder itemmonitor- the monitor that allows the user to cancel- Returns:
- checkout ID for new item
- Throws:
IOException- if an IO error occurs or an unsupporteddomainObjectimplementation is specified.InvalidNameException- if the specified name contains invalid charactersCancelledException- if the user cancels
-
getDomainObject
public final T getDomainObject(FolderItem item, FileSystem userfs, long checkoutId, boolean okToUpgrade, boolean okToRecover, Object consumer, TaskMonitor monitor) throws IOException, CancelledException, VersionException Description copied from interface:ContentHandlerOpen a folder item for update. Changes made to the returned object may be saved to the original folder item.- Specified by:
getDomainObjectin interfaceContentHandler<T extends DomainObjectAdapterDB>- Parameters:
item- stored folder itemuserfs- file system which contains associated user datacheckoutId- an appropriate checout ID required to update the specified folder item.okToUpgrade- if true a version upgrade to the content will be done if necessary.okToRecover- if true an attempt to recover any unsaved changes resulting from a crash will be attempted.consumer- consumer of the returned objectmonitor- cancelable task monitor- Returns:
- updateable domain object
- Throws:
IOException- if an IO or folder item access error occursCancelledException- if operation is cancelled by userVersionException- if unable to handle file content due to version difference which could not be handled.
-
getReadOnlyObject
public final T getReadOnlyObject(FolderItem item, int version, boolean okToUpgrade, Object consumer, TaskMonitor monitor) throws IOException, VersionException, CancelledException Description copied from interface:ContentHandlerOpen a folder item for read-only use. While changes are permitted on the returned object, the original folder item may not be overwritten / updated.- Specified by:
getReadOnlyObjectin interfaceContentHandler<T extends DomainObjectAdapterDB>- Parameters:
item- stored folder itemversion- version of the stored folder item to be opened. DomainFile.DEFAULT_VERSION should be specified when not opening a specific file version.okToUpgrade- if true a version upgrade to the content will be done if necessary.consumer- consumer of the returned objectmonitor- the monitor that allows the user to cancel- Returns:
- read-only domain object
- Throws:
IOException- if an IO or folder item access error occursVersionException- if unable to handle file content due to version difference which could not be handled.CancelledException- if operation is cancelled by user
-
getImmutableObject
public T getImmutableObject(FolderItem item, Object consumer, int version, int minChangeVersion, TaskMonitor monitor) throws IOException, CancelledException, VersionException Description copied from interface:ContentHandlerOpen a folder item for immutable use. If any changes are attempted on the returned object, an IllegalStateException state exception may be thrown.- Specified by:
getImmutableObjectin interfaceContentHandler<T extends DomainObjectAdapterDB>- Parameters:
item- stored folder itemconsumer- consumer of the returned objectversion- version of the stored folder item to be opened. DomainFile.DEFAULT_VERSION (-1) should be specified when not opening a specific file version.minChangeVersion- the minimum version which should be included in the change set for the returned object. A value of -1 indicates the default change set.monitor- the monitor that allows the user to cancel- Returns:
- immutable domain object
- Throws:
IOException- if an IO or folder item access error occursCancelledException- if operation is cancelled by userVersionException- if unable to handle file content due to version difference which could not be handled.
-
getChangeSet
public final ChangeSet getChangeSet(FolderItem versionedFolderItem, int olderVersion, int newerVersion) throws VersionException, IOException Description copied from interface:ContentHandlerReturns the object change data which includes changes made to the specified olderVersion through to the specified newerVersion.- Specified by:
getChangeSetin interfaceContentHandler<T extends DomainObjectAdapterDB>- Parameters:
versionedFolderItem- versioned folder itemolderVersion- the older version numbernewerVersion- the newer version number- Returns:
- the set of changes that were made
- Throws:
VersionException- if a database version change prevents reading of data.IOException- if an IO or folder item access error occurs or change set was produced by newer version of software and can not be read
-
getMergeManager
public final DomainObjectMergeManager getMergeManager(DomainObject resultsObj, DomainObject sourceObj, DomainObject originalObj, DomainObject latestObj) Description copied from interface:ContentHandlerGet an instance of a suitable merge manager to be used during the merge of a Versioned object which has been modified by another user since it was last merged or checked-out.- Specified by:
getMergeManagerin interfaceContentHandler<T extends DomainObjectAdapterDB>- Parameters:
resultsObj- object to which merge results should be writtensourceObj- object which contains user's changes to be mergedoriginalObj- object which corresponds to checked-out version statelatestObj- object which corresponds to latest version with which the sourceObj must be merged.- Returns:
- merge manager
-
isPrivateContentType
public final boolean isPrivateContentType()Description copied from interface:ContentHandlerReturns true if the content type is always private (i.e., can not be added to the versioned filesystem).- Specified by:
isPrivateContentTypein interfaceContentHandler<T extends DomainObjectAdapterDB>- Returns:
- true if private content type, else false
-
getIcon
Get the base icon for this link-file which does not include the link overlay icon.- Specified by:
getIconin interfaceContentHandler<T extends DomainObjectAdapterDB>- Returns:
- base icon to be used for a
DomainFilewith the associated content type.
-
getLinkURL
Get the link URL which corresponds to the specified link file's link-path. If link-path was originally specified as an internal path it will be transformed into a URL. SeeDomainFile.isLink().- Parameters:
linkFile- link-file domain file which may correspond to a linked-folder or file.- Returns:
- link URL or null if invalid link-URL or a non-link-file is specified
- Throws:
IOException- if linkFile has an invalid relative link-path that failed to normalize
-
getAbsoluteLinkPath
Get the Ghidra URL or absolute normalized link-path from a link file. Path normalization eliminates any path element of "./" or "../". A local folder-link path will always end with a "/" path separator. Path normalization is not performed on Ghidra URLs.- Parameters:
linkFile- link file- Returns:
- Ghidra URL or absolute normalized link-path from a link file
- Throws:
IOException- if linkFile has an invalid relative link-path that failed to normalize
-
getLinkFileStatus
public static LinkHandler.LinkStatus getLinkFileStatus(DomainFile file, Consumer<String> errorConsumer) Determine the link status for the specifiedlink-file. If a status isLinkHandler.LinkStatus.BROKENand anerrorConsumerhas been specified the error details will be reported.- Parameters:
file- domain fileerrorConsumer- broken link error consumer (may be null)- Returns:
- link status
-
followInternalLinkage
public static DomainFile followInternalLinkage(DomainFile file, Consumer<LinkHandler.LinkStatus> statusConsumer, Consumer<String> errorConsumer) Follow the internal linkage, if any, for the specified file. Any broken linkage details will be reported to the specifiederrorConsumer.- Parameters:
file- domain file to be checkedstatusConsumer- link status consumer (required)errorConsumer- broken link error consumer (may be null)- Returns:
- the final
DomainFilewithin the same project or null if file specified was not a link-file. A broken link will return the last valid link-file in chain.
-