Class LinkHandler<T extends DomainObjectAdapterDB>

java.lang.Object
ghidra.framework.data.DBContentHandler<T>
ghidra.framework.data.LinkHandler<T>
Type Parameters:
T - URLLinkObject implementation class
All Implemented Interfaces:
ContentHandler<T>, ExtensionPoint
Direct Known Subclasses:
DataTypeArchiveLinkContentHandler, FolderLinkContentHandler, ProgramLinkContentHandler

public abstract class LinkHandler<T extends DomainObjectAdapterDB> extends DBContentHandler<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.
  • Field Details

  • Constructor Details

    • LinkHandler

      public LinkHandler()
  • Method Details

    • createLink

      protected final void createLink(URL ghidraUrl, LocalFileSystem fs, String folderPath, String linkFilename) throws IOException, InvalidNameException
      Create a link file using the specified URL
      Parameters:
      ghidraUrl - link URL (must be a Ghidra URL - see GhidraURL).
      fs - filesystem where link file should be created
      folderPath - folder path which should contain link file
      linkFilename - link filename
      Throws:
      IOException - if an IO error occurs
      InvalidNameException - if invalid folderPath or linkFilename specified
    • getReadOnlyObject

      public final T getReadOnlyObject(FolderItem item, int version, boolean okToUpgrade, Object consumer, TaskMonitor monitor) throws IOException, VersionException, CancelledException
      Description copied from interface: ContentHandler
      Open a folder item for read-only use. While changes are permitted on the returned object, the original folder item may not be overwritten / updated.
      Parameters:
      item - stored folder item
      version - 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 object
      monitor - the monitor that allows the user to cancel
      Returns:
      read-only domain object
      Throws:
      IOException - if an IO or folder item access error occurs
      VersionException - 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: ContentHandler
      Open a folder item for immutable use. If any changes are attempted on the returned object, an IllegalStateException state exception may be thrown.
      Parameters:
      item - stored folder item
      consumer - consumer of the returned object
      version - 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 occurs
      CancelledException - if operation is cancelled by user
      VersionException - if unable to handle file content due to version difference which could not be handled.
    • 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: ContentHandler
      Open a folder item for update. Changes made to the returned object may be saved to the original folder item.
      Parameters:
      item - stored folder item
      userfs - file system which contains associated user data
      checkoutId - 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 object
      monitor - cancelable task monitor
      Returns:
      updateable domain object
      Throws:
      IOException - if an IO or folder item access error occurs
      CancelledException - if operation is cancelled by user
      VersionException - 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: ContentHandler
      Returns the object change data which includes changes made to the specified olderVersion through to the specified newerVersion.
      Parameters:
      versionedFolderItem - versioned folder item
      olderVersion - the older version number
      newerVersion - 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: ContentHandler
      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.
      Parameters:
      resultsObj - object to which merge results should be written
      sourceObj - object which contains user's changes to be merged
      originalObj - object which corresponds to checked-out version state
      latestObj - 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: ContentHandler
      Returns true if the content type is always private (i.e., can not be added to the versioned filesystem).
      Returns:
      true if private content type, else false
    • getURL

      public static URL getURL(DomainFile linkFile) throws IOException
      Get the link URL which corresponds to the specified link file. See DomainFile.isLinkFile().
      Parameters:
      linkFile - link-file domain file
      Returns:
      link URL
      Throws:
      MalformedURLException - if link is bad or unsupported.
      IOException - if IO error or supported link file not specified
    • getIcon

      public abstract Icon getIcon()
      Get the base icon for this link-file which does not include the link overlay icon.
      Returns:
      base icon to be used for a DomainFile with the associated content type.