Class DataTypeArchiveDB

All Implemented Interfaces:
ErrorHandler, DataTypeManagerOwner, DomainObject, DataTypeManagerDomainObject, DataTypeArchive

public class DataTypeArchiveDB extends DomainObjectAdapterDB implements DataTypeArchive
Database implementation for Data Type Archive.
  • Field Details

    • ARCHIVE_INFO

      public static final String ARCHIVE_INFO
      Name of data type archive information property list
      See Also:
    • ARCHIVE_SETTINGS

      public static final String ARCHIVE_SETTINGS
      Name of data type archive settings property list
      See Also:
    • DATE_CREATED

      public static final String DATE_CREATED
      Name of date created property
      See Also:
    • CREATED_WITH_GHIDRA_VERSION

      public static final String CREATED_WITH_GHIDRA_VERSION
      Name of Ghidra version property
      See Also:
    • JANUARY_1_1970

      public static final Date JANUARY_1_1970
      A date from January 1, 1970
  • Constructor Details

    • DataTypeArchiveDB

      public DataTypeArchiveDB(DomainFolder folder, String name, Object consumer) throws IOException, DuplicateNameException, InvalidNameException
      Constructs a new DataTypeArchiveDB within a project folder.
      Parameters:
      folder - folder within which the project archive will be created
      name - the name of the data type archive
      consumer - the object that is using this data type archive.
      Throws:
      IOException - if there is an error accessing the database.
      InvalidNameException
      DuplicateNameException
    • DataTypeArchiveDB

      public DataTypeArchiveDB(DBHandle dbh, OpenMode openMode, TaskMonitor monitor, Object consumer) throws IOException, VersionException, CancelledException
      Constructs a new DataTypeArchiveDB
      Parameters:
      dbh - a handle to an open data type archive database.
      openMode - one of: READ_ONLY: the original database will not be modified UPDATE: the database can be written to. UPGRADE: the database is upgraded to the latest schema as it is opened.
      monitor - TaskMonitor that allows the open to be canceled.
      consumer - the object that keeping the program open.
      Throws:
      IOException - if an error accessing the database occurs.
      VersionException - if database version does not match implementation, UPGRADE may be possible.
      CancelledException - if instantiation is canceled by monitor
  • Method Details

    • close

      protected void close()
      Overrides:
      close in class DomainObjectAdapterDB
    • setDomainFile

      protected void setDomainFile(DomainFile df)
      Description copied from class: DomainObjectAdapter
      Set the DomainFile associated with this instance.
      Overrides:
      setDomainFile in class DomainObjectAdapter
      Parameters:
      df - domain file
    • propertyChanged

      protected boolean propertyChanged(String propertyName, Object oldValue, Object newValue)
      Description copied from class: DomainObjectAdapterDB
      Notification of property change
      Overrides:
      propertyChanged in class DomainObjectAdapterDB
      Returns:
      true if change is OK, false value should be reverted
    • getDataTypeManager

      public DataTypeManager getDataTypeManager()
      Description copied from interface: DataTypeManagerOwner
      Gets the associated data type manager.
      Specified by:
      getDataTypeManager in interface DataTypeManagerOwner
      Returns:
      the data type manager.
      See Also:
    • getCreationDate

      public Date getCreationDate()
      Description copied from interface: DataTypeArchive
      Returns the creation date of this data type archive. existed, then Jan 1, 1970 is returned.
      Specified by:
      getCreationDate in interface DataTypeArchive
      Returns:
      the creation date of this data type archive
      See Also:
    • getDefaultPointerSize

      public int getDefaultPointerSize()
      Description copied from interface: DataTypeArchive
      Gets the default pointer size as it may be stored within the data type archive.
      Specified by:
      getDefaultPointerSize in interface DataTypeArchive
      Returns:
      default pointer size.
      See Also:
    • getChanges

      public ghidra.program.database.DataTypeArchiveDBChangeSet getChanges()
      Description copied from interface: DataTypeArchive
      Get the data type archive changes since the last save as a set of addresses.
      Specified by:
      getChanges in interface DataTypeArchive
      Returns:
      set of changed addresses within program.
      See Also:
    • dataTypeChanged

      public void dataTypeChanged(long dataTypeID, ProgramEvent eventType, boolean isAutoResponseChange, Object oldValue, Object newValue)
      notification the a data type has changed
      Parameters:
      dataTypeID - the id of the data type that changed.
      eventType - the type of the change (moved, renamed, etc.)
      isAutoResponseChange - true if change is an auto-response change caused by another datatype's change (e.g., size, alignment), else false in which case this change will be added to archive change-set to aid merge conflict detection.
      oldValue - the old data type.
      newValue - the new data type.
    • dataTypeAdded

      public void dataTypeAdded(long dataTypeID, ProgramEvent eventType, Object oldValue, Object newValue)
      Notification that a data type was added.
      Parameters:
      dataTypeID - the id if the data type that was added.
      eventType - should always be DATATYPE_ADDED
      oldValue - always null
      newValue - the data type added.
    • categoryChanged

      public void categoryChanged(long categoryID, ProgramEvent eventType, Object oldValue, Object newValue)
      Notification that a category was changed.
      Parameters:
      categoryID - the id of the data type that was added.
      eventType - the type of change
      oldValue - old value depends on the type.
      newValue - new value depends on the type.
    • categoryAdded

      public void categoryAdded(long categoryID, ProgramEvent eventType, Object oldValue, Object newValue)
      Notification that a category was added.
      Parameters:
      categoryID - the id of the data type that was added.
      eventType - the type of change (should always be CATEGORY_ADDED)
      oldValue - always null
      newValue - new value depends on the type.
    • setChanged

      public void setChanged(ProgramEvent eventType, Object oldValue, Object newValue)
      Mark the state this Data Type Archive as having changed and generate the event. Any or all parameters may be null.
      Parameters:
      eventType - event type
      oldValue - original value
      newValue - new value
    • setName

      public void setName(String newName)
      Description copied from interface: DomainObject
      Set the name for this domain object.
      Specified by:
      setName in interface DomainObject
      Overrides:
      setName in class DomainObjectAdapter
      Parameters:
      newName - object name
    • getDescription

      public String getDescription()
      Description copied from interface: DomainObject
      Returns a word or short phrase that best describes or categorizes the object in terms that a user will understand.
      Specified by:
      getDescription in interface DomainObject
      Specified by:
      getDescription in class DomainObjectAdapter
      Returns:
      the description
    • clearCache

      protected void clearCache(boolean all)
      Overrides:
      clearCache in class DomainObjectAdapterDB
    • invalidate

      public void invalidate()
      Description copied from class: DomainObjectAdapter
      Invalidates any caching in a program and generate a DomainObjectEvent.RESTORED event. NOTE: Over-using this method can adversely affect system performance.
      Specified by:
      invalidate in interface DataTypeArchive
      Overrides:
      invalidate in class DomainObjectAdapterDB
    • isChangeable

      public boolean isChangeable()
      Description copied from interface: DomainObject
      Returns true if changes are permitted.
      Specified by:
      isChangeable in interface DomainObject
      Returns:
      true if changes are permitted.
    • setChanged

      protected void setChanged(boolean b)
      Overrides:
      setChanged in class DomainObjectAdapterDB
    • getMetadata

      public Map<String,String> getMetadata()
      Description copied from interface: DomainObject
      Returns a map containing all the stored metadata associated with this domain object. The map contains key,value pairs and are ordered by their insertion order.
      Specified by:
      getMetadata in interface DomainObject
      Overrides:
      getMetadata in class DomainObjectAdapter
      Returns:
      a map containing all the stored metadata associated with this domain object.
    • updateMetadata

      protected void updateMetadata() throws IOException
      Description copied from class: DomainObjectAdapterDB
      This method is called before a save, saveAs, or saveToPackedFile to update common meta data
      Overrides:
      updateMetadata in class DomainObjectAdapterDB
      Throws:
      IOException
    • updateID

      public void updateID()
      Specified by:
      updateID in interface DataTypeArchive