Package ghidra.program.database

# Class ProgramContentHandler

java.lang.Object
ghidra.framework.data.DBContentHandler<T>
ghidra.framework.data.DBWithUserDataContentHandler<ProgramDB>
ghidra.program.database.ProgramContentHandler

All Implemented Interfaces:
  `ContentHandler<ProgramDB>`, `ExtensionPoint`

public class ProgramContentHandler extends DBWithUserDataContentHandler<ProgramDB>
`ProgramContentHandler` converts between Program instantiations and FolderItem storage. This class also produces the appropriate Icon for Program files.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `PROGRAM_CONTENT_TYPE`
  `static Icon`
  `PROGRAM_ICON`

  ### Fields inherited from interface ghidra.framework.data.ContentHandler

  `MISSING_CONTENT, UNKNOWN_CONTENT`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ProgramContentHandler()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `long`
  `createFile(FileSystem fs, FileSystem userfs, String path, String name, DomainObject obj, TaskMonitor monitor)`
  Creates a new folder item within a specified file-system.
  `ChangeSet`
  `getChangeSet(FolderItem item, int fromVer, int toVer)`
  Returns the object change data which includes changes made to the specified olderVersion through to the specified newerVersion.
  `String`
  `getContentType()`
  Returns a unique content-type identifier
  `String`
  `getContentTypeDisplayString()`
  A string that is meant to be presented to the user.
  `String`
  `getDefaultToolName()`
  Returns the name of the default tool/template that should be used to open this content type.
  `ProgramDB`
  `getDomainObject(FolderItem item, FileSystem userfs, long checkoutId, boolean okToUpgrade, boolean recover, Object consumer, TaskMonitor monitor)`
  Open a folder item for update.
  `Class<ProgramDB>`
  `getDomainObjectClass()`
  Returns domain object implementation class supported.
  `Icon`
  `getIcon()`
  Returns the Icon associated with this handlers content type.
  `ProgramDB`
  `getImmutableObject(FolderItem item, Object consumer, int version, int minChangeVersion, TaskMonitor monitor)`
  Open a folder item for immutable use.
  `ProgramLinkContentHandler`
  `getLinkHandler()`
  If linking is supported return an instanceof the appropriate `LinkHandler`.
  `DomainObjectMergeManager`
  `getMergeManager(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.
  `ProgramDB`
  `getReadOnlyObject(FolderItem item, int version, boolean okToUpgrade, Object consumer, TaskMonitor monitor)`
  Open a folder item for read-only use.
  `boolean`
  `isPrivateContentType()`
  Returns true if the content type is always private (i.e., can not be added to the versioned filesystem).

  ### Methods inherited from class ghidra.framework.data.DBWithUserDataContentHandler

  `openAssociatedUserFile, removeUserDataFile, saveUserDataFile`

  ### Methods inherited from class ghidra.framework.data.DBContentHandler

  `abortCreate, createFile`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### PROGRAM_CONTENT_TYPE

    public static final String PROGRAM_CONTENT_TYPE
    See Also:
      - Constant Field Values

  - ### PROGRAM_ICON

    public static Icon PROGRAM_ICON

- ## Constructor Details

  - ### ProgramContentHandler

    public ProgramContentHandler()

- ## Method Details

  - ### createFile

    public long createFile(FileSystem fs, FileSystem userfs, String path, String name, DomainObject obj, TaskMonitor monitor) throws IOException, InvalidNameException, CancelledException
    Description copied from interface: `ContentHandler`
    Creates 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.
    Parameters:
      `fs` - the file system in which to create the folder item
      `userfs` - file system which contains associated user data
      `path` - the path of the folder item
      `name` - the name of the new folder item
      `obj` - the domain object to store in the newly created folder item
      `monitor` - the monitor that allows the user to cancel
    Returns:
      checkout ID for new item
    Throws:
      `IOException` - if an IO error occurs or an unsupported `domainObject` implementation is specified.
      `InvalidNameException` - if the specified name contains invalid characters
      `CancelledException` - if the user cancels

  - ### getImmutableObject

    public ProgramDB getImmutableObject(FolderItem item, Object consumer, int version, int minChangeVersion, TaskMonitor monitor) throws IOException, VersionException, CancelledException
    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
      `VersionException` - if unable to handle file content due to version difference which could not be handled.
      `CancelledException` - if operation is cancelled by user

  - ### getReadOnlyObject

    public ProgramDB 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

  - ### getDomainObject

    public ProgramDB getDomainObject(FolderItem item, FileSystem userfs, long checkoutId, boolean okToUpgrade, boolean recover, Object consumer, TaskMonitor monitor) throws IOException, VersionException, CancelledException
    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.
      `recover` - 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
      `VersionException` - if unable to handle file content due to version difference which could not be handled.
      `CancelledException` - if operation is cancelled by user

  - ### getChangeSet

    public ChangeSet getChangeSet(FolderItem item, int fromVer, int toVer) 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:
      `item` - versioned folder item
      `fromVer` - the older version number
      `toVer` - 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

  - ### getDomainObjectClass

    public Class<ProgramDB> getDomainObjectClass()
    Description copied from interface: `ContentHandler`
    Returns domain object implementation class supported.
    Returns:
      implementation class for the associated `DomainObjectAdapter` implementation.

  - ### getContentType

    public String getContentType()
    Description copied from interface: `ContentHandler`
    Returns a unique content-type identifier
    Returns:
      content type identifier for associated domain object(s).

  - ### getContentTypeDisplayString

    public String getContentTypeDisplayString()
    Description copied from interface: `ContentHandler`
    A string that is meant to be presented to the user.
    Returns:
      user friendly content type for associated domain object(s).

  - ### getDefaultToolName

    public String getDefaultToolName()
    Description copied from interface: `ContentHandler`
    Returns the name of the default tool/template that should be used to open this content type.
    Returns:
      associated default tool name for this content type

  - ### getIcon

    public Icon getIcon()
    Description copied from interface: `ContentHandler`
    Returns the Icon associated with this handlers content type.
    Returns:
      base icon to be used for a `DomainFile` with the associated content type.

  - ### isPrivateContentType

    public 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

  - ### getMergeManager

    public 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

  - ### getLinkHandler

    public ProgramLinkContentHandler getLinkHandler()
    Description copied from interface: `ContentHandler`
    If linking is supported return an instanceof the appropriate `LinkHandler`.
    Returns:
      corresponding link handler or null if not supported.