Package ghidra.program.database
Class DataTypeArchiveDB
- java.lang.Object
-
- ghidra.framework.data.DomainObjectAdapter
-
- ghidra.framework.data.DomainObjectAdapterDB
-
- ghidra.program.database.DataTypeArchiveDB
-
- All Implemented Interfaces:
DBConstants
,ErrorHandler
,DataTypeManagerOwner
,DomainObject
,Undoable
,UndoableDomainObject
,DataTypeManagerDomainObject
,DataTypeArchive
,DataTypeArchiveChangeManager
public class DataTypeArchiveDB extends DomainObjectAdapterDB implements DataTypeArchive, DataTypeArchiveChangeManager
Database implementation for Data Type Archive.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ARCHIVE_INFO
Name of data type archive information property liststatic java.lang.String
ARCHIVE_SETTINGS
Name of data type archive settings property liststatic java.lang.String
CREATED_WITH_GHIDRA_VERSION
Name of Ghidra version propertystatic java.lang.String
DATE_CREATED
Name of date created propertystatic java.util.Date
JANUARY_1_1970
A date from January 1, 1970-
Fields inherited from class ghidra.framework.data.DomainObjectAdapterDB
changeSet, dbh, NUM_UNDOS, options
-
Fields inherited from class ghidra.framework.data.DomainObjectAdapter
changed, changeSupportMap, DEFAULT_NAME, lock, metadata, name, temporary
-
Fields inherited from interface ghidra.program.model.listing.DataTypeArchive
DATA_TYPE_ARCHIVE_INFO, DATA_TYPE_ARCHIVE_SETTINGS
-
Fields inherited from interface ghidra.program.util.DataTypeArchiveChangeManager
DOCR_CATEGORY_ADDED, DOCR_CATEGORY_MOVED, DOCR_CATEGORY_REMOVED, DOCR_CATEGORY_RENAMED, DOCR_CUSTOM_FORMAT_ADDED, DOCR_CUSTOM_FORMAT_REMOVED, DOCR_DATA_TYPE_ADDED, DOCR_DATA_TYPE_CHANGED, DOCR_DATA_TYPE_MOVED, DOCR_DATA_TYPE_REMOVED, DOCR_DATA_TYPE_RENAMED, DOCR_DATA_TYPE_REPLACED, DOCR_DATA_TYPE_SETTING_CHANGED
-
Fields inherited from interface db.DBConstants
CREATE, READ_ONLY, UPDATE, UPGRADE
-
Fields inherited from interface ghidra.framework.model.DomainObject
DO_DOMAIN_FILE_CHANGED, DO_OBJECT_CLOSED, DO_OBJECT_ERROR, DO_OBJECT_RENAMED, DO_OBJECT_RESTORED, DO_OBJECT_SAVED, DO_PROPERTY_CHANGED, undoLock
-
-
Constructor Summary
Constructors Constructor Description DataTypeArchiveDB(DBHandle dbh, int openMode, TaskMonitor monitor, java.lang.Object consumer)
Constructs a new DataTypeArchiveDBDataTypeArchiveDB(DomainFolder folder, java.lang.String name, java.lang.Object consumer)
Constructs a new DataTypeArchiveDB within a project folder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
categoryAdded(long categoryID, int type, java.lang.Object oldValue, java.lang.Object newValue)
Notification that a category was added.void
categoryChanged(long categoryID, int type, java.lang.Object oldValue, java.lang.Object newValue)
Notification that a category was changed.protected void
clearCache(boolean all)
void
dataTypeAdded(long dataTypeID, int type, java.lang.Object oldValue, java.lang.Object newValue)
Notification that a data type was added.void
dataTypeChanged(long dataTypeID, int type, java.lang.Object oldValue, java.lang.Object newValue)
notification the a data type has changedghidra.program.database.DataTypeArchiveDBChangeSet
getChanges()
Get the data type archive changes since the last save as a set of addresses.java.util.Date
getCreationDate()
Returns the creation date of this data type archive.DataTypeManager
getDataTypeManager()
Gets the associated data type manager.int
getDefaultPointerSize()
Gets the default pointer size as it may be stored within the data type archive.java.lang.String
getDescription()
Returns a word or short phrase that best describes or categorizes the object in terms that a user will understand.java.util.Map<java.lang.String,java.lang.String>
getMetadata()
Returns a map containing all the stored metadata associated with this domain object.void
invalidate()
Invalidates any caching in a data type archive.boolean
isChangeable()
Returns true if changes are permitted.protected boolean
propertyChanged(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
Notification of property changeprotected void
setChanged(boolean b)
void
setChanged(int type, java.lang.Object oldValue, java.lang.Object newValue)
Mark the state this Data Type Archive as having changed and generate the event.protected void
setDomainFile(DomainFile df)
void
setName(java.lang.String newName)
Set the name for this domain object.void
setObjChanged(int type, java.lang.Object affectedObj, java.lang.Object oldValue, java.lang.Object newValue)
Mark the state of a Program as having changed and generate the event.void
updateID()
protected void
updateMetadata()
This method is called before a save, saveAs, or saveToPackedFile to update common meta data-
Methods inherited from class ghidra.framework.data.DomainObjectAdapterDB
addSynchronizedDomainObject, addTransactionListener, canLock, canRedo, canSave, canUndo, clearUndo, clearUndo, close, dbError, endTransaction, flushWriteCache, forceLock, getChangeSet, getCurrentTransaction, getDBHandle, getOptions, getOptionsNames, getRedoName, getSynchronizedDomainObjects, getUndoName, getUndoStackDepth, getUserData, hasTerminatedTransaction, invalidateWriteCache, isChanged, isClosed, isLocked, loadMetadata, lock, performPropertyListAlterations, redo, releaseSynchronizedDomainObject, removeTransactionListener, save, saveMetadata, saveToPackedFile, startTransaction, startTransaction, undo, unlock
-
Methods inherited from class ghidra.framework.data.DomainObjectAdapter
addCloseListener, addConsumer, addListener, checkExclusiveAccess, createPrivateEventQueue, fatalErrorOccurred, fireEvent, flushEvents, flushPrivateEventQueue, getAssociatedUserFilesystem, getChangeStatus, getConsumerList, getContentHandler, getDomainFile, getLock, getModificationNumber, getName, hasExclusiveAccess, isSendingEvents, isTemporary, isUsedBy, release, removeCloseListener, removeListener, removePrivateEventQueue, setDefaultContentClass, setEventsEnabled, setTemporary, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ghidra.framework.model.DomainObject
addCloseListener, addConsumer, addListener, canLock, canSave, createPrivateEventQueue, flushEvents, flushPrivateEventQueue, forceLock, getConsumerList, getDomainFile, getModificationNumber, getName, getOptions, getOptionsNames, hasExclusiveAccess, isChanged, isClosed, isLocked, isSendingEvents, isTemporary, isUsedBy, lock, release, removeCloseListener, removeListener, removePrivateEventQueue, save, saveToPackedFile, setEventsEnabled, setTemporary, unlock
-
Methods inherited from interface ghidra.framework.model.Undoable
addTransactionListener, canRedo, canUndo, clearUndo, getRedoName, getUndoName, redo, removeTransactionListener, undo
-
Methods inherited from interface ghidra.framework.model.UndoableDomainObject
addSynchronizedDomainObject, endTransaction, getCurrentTransaction, getSynchronizedDomainObjects, hasTerminatedTransaction, releaseSynchronizedDomainObject, startTransaction, startTransaction
-
-
-
-
Field Detail
-
ARCHIVE_INFO
public static final java.lang.String ARCHIVE_INFO
Name of data type archive information property list- See Also:
- Constant Field Values
-
ARCHIVE_SETTINGS
public static final java.lang.String ARCHIVE_SETTINGS
Name of data type archive settings property list- See Also:
- Constant Field Values
-
DATE_CREATED
public static final java.lang.String DATE_CREATED
Name of date created property- See Also:
- Constant Field Values
-
CREATED_WITH_GHIDRA_VERSION
public static final java.lang.String CREATED_WITH_GHIDRA_VERSION
Name of Ghidra version property- See Also:
- Constant Field Values
-
JANUARY_1_1970
public static final java.util.Date JANUARY_1_1970
A date from January 1, 1970
-
-
Constructor Detail
-
DataTypeArchiveDB
public DataTypeArchiveDB(DomainFolder folder, java.lang.String name, java.lang.Object consumer) throws java.io.IOException, DuplicateNameException, InvalidNameException
Constructs a new DataTypeArchiveDB within a project folder.- Parameters:
folder
- folder within which the project archive will be createdname
- the name of the data type archiveconsumer
- the object that is using this data type archive.- Throws:
java.io.IOException
- if there is an error accessing the database.InvalidNameException
DuplicateNameException
-
DataTypeArchiveDB
public DataTypeArchiveDB(DBHandle dbh, int openMode, TaskMonitor monitor, java.lang.Object consumer) throws java.io.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:
java.io.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 Detail
-
setDomainFile
protected void setDomainFile(DomainFile df)
- Overrides:
setDomainFile
in classDomainObjectAdapter
- See Also:
DomainObjectAdapter.setDomainFile(ghidra.framework.model.DomainFile)
-
propertyChanged
protected boolean propertyChanged(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
Description copied from class:DomainObjectAdapterDB
Notification of property change- Overrides:
propertyChanged
in classDomainObjectAdapterDB
- Returns:
- true if change is OK, false value should be reverted
- See Also:
DomainObjectAdapterDB.propertyChanged(java.lang.String, java.lang.Object, java.lang.Object)
-
getDataTypeManager
public DataTypeManager getDataTypeManager()
Description copied from interface:DataTypeManagerOwner
Gets the associated data type manager.- Specified by:
getDataTypeManager
in interfaceDataTypeManagerOwner
- Returns:
- the data type manager.
- See Also:
Program.getDataTypeManager()
-
getCreationDate
public java.util.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 interfaceDataTypeArchive
- Returns:
- the creation date of this data type archive
- See Also:
Program.getCreationDate()
-
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 interfaceDataTypeArchive
- Returns:
- default pointer size.
- See Also:
ghidra.program.model.listing.Program#getDefaultStoredPointerSize()
-
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 interfaceDataTypeArchive
- Returns:
- set of changed addresses within program.
- See Also:
Program.getChanges()
-
dataTypeChanged
public void dataTypeChanged(long dataTypeID, int type, java.lang.Object oldValue, java.lang.Object newValue)
notification the a data type has changed- Parameters:
dataTypeID
- the id of the data type that changed.type
- the type of the change (moved, renamed, etc.)oldValue
- the old data type.newValue
- the new data type.
-
dataTypeAdded
public void dataTypeAdded(long dataTypeID, int type, java.lang.Object oldValue, java.lang.Object newValue)
Notification that a data type was added.- Parameters:
dataTypeID
- the id if the data type that was added.type
- should always be DATATYPE_ADDEDoldValue
- always nullnewValue
- the data type added.
-
categoryChanged
public void categoryChanged(long categoryID, int type, java.lang.Object oldValue, java.lang.Object newValue)
Notification that a category was changed.- Parameters:
categoryID
- the id of the data type that was added.type
- the type of changedoldValue
- old value depends on the type.newValue
- new value depends on the type.
-
categoryAdded
public void categoryAdded(long categoryID, int type, java.lang.Object oldValue, java.lang.Object newValue)
Notification that a category was added.- Parameters:
categoryID
- the id of the data type that was added.type
- the type of changed (should always be CATEGORY_ADDED)oldValue
- always nullnewValue
- new value depends on the type.
-
setChanged
public void setChanged(int type, java.lang.Object oldValue, java.lang.Object newValue)
Mark the state this Data Type Archive as having changed and generate the event. Any or all parameters may be null.- Specified by:
setChanged
in interfaceDataTypeArchive
- Specified by:
setChanged
in interfaceDataTypeArchiveChangeManager
- Parameters:
type
- event typeoldValue
- original valuenewValue
- new value
-
setObjChanged
public void setObjChanged(int type, java.lang.Object affectedObj, java.lang.Object oldValue, java.lang.Object newValue)
Mark the state of a Program as having changed and generate the event. Any or all parameters may be null. NOTE: ChangeSet data will not be updated since this a very generic change not related to a specific address.- Specified by:
setObjChanged
in interfaceDataTypeArchive
- Specified by:
setObjChanged
in interfaceDataTypeArchiveChangeManager
- Parameters:
type
- event typeaffectedObj
- object that is the subject of the eventoldValue
- original value or an Object that is related to the eventnewValue
- new value or an Object that is related to the the event
-
setName
public void setName(java.lang.String newName)
Description copied from interface:DomainObject
Set the name for this domain object.- Specified by:
setName
in interfaceDomainObject
- Overrides:
setName
in classDomainObjectAdapter
- Parameters:
newName
- object name- See Also:
DomainObject.setName(java.lang.String)
-
getDescription
public java.lang.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 interfaceDomainObject
- Specified by:
getDescription
in classDomainObjectAdapter
- See Also:
DomainObject.getDescription()
-
clearCache
protected void clearCache(boolean all)
- Overrides:
clearCache
in classDomainObjectAdapterDB
- See Also:
ghidra.framework.data.DomainObjectAdapterDB#clearCache()
-
invalidate
public void invalidate()
Description copied from interface:DataTypeArchive
Invalidates any caching in a data type archive. NOTE: Over-using this method can adversely affect system performance.- Specified by:
invalidate
in interfaceDataTypeArchive
- See Also:
Program.invalidate()
-
isChangeable
public boolean isChangeable()
Description copied from interface:DomainObject
Returns true if changes are permitted.- Specified by:
isChangeable
in interfaceDomainObject
- See Also:
DomainObject.isChangeable()
-
setChanged
protected void setChanged(boolean b)
- Overrides:
setChanged
in classDomainObjectAdapterDB
-
getMetadata
public java.util.Map<java.lang.String,java.lang.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 interfaceDomainObject
- Overrides:
getMetadata
in classDomainObjectAdapter
- Returns:
- a map containing all the stored metadata associated with this domain object.
-
updateMetadata
protected void updateMetadata() throws java.io.IOException
Description copied from class:DomainObjectAdapterDB
This method is called before a save, saveAs, or saveToPackedFile to update common meta data- Overrides:
updateMetadata
in classDomainObjectAdapterDB
- Throws:
java.io.IOException
-
updateID
public void updateID()
- Specified by:
updateID
in interfaceDataTypeArchive
-
-