Package ghidra.program.model.data
Class DataTypeImpl
- java.lang.Object
-
- ghidra.program.model.data.AbstractDataType
-
- ghidra.program.model.data.DataTypeImpl
-
- All Implemented Interfaces:
DataType
,java.util.EventListener
,javax.swing.event.ChangeListener
- Direct Known Subclasses:
ArrayDataType
,BuiltIn
,DefaultDataType
,GenericDataType
,MissingBuiltInDataType
public abstract class DataTypeImpl extends AbstractDataType implements javax.swing.event.ChangeListener
Base implementation for dataTypes.
-
-
Field Summary
Fields Modifier and Type Field Description protected Settings
defaultSettings
-
Fields inherited from class ghidra.program.model.data.AbstractDataType
categoryPath, dataMgr, name
-
Fields inherited from interface ghidra.program.model.data.DataType
CONFLICT_SUFFIX, DEFAULT, NO_LAST_CHANGE_TIME, NO_SOURCE_SYNC_TIME, VOID
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DataTypeImpl(CategoryPath path, java.lang.String name, DataTypeManager dataMgr)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addParent(DataType dt)
Inform this data type that it has the given parent
TODO: This method is reserved for internal DB use and should be removed from the public DataType interface!!boolean
equals(java.lang.Object obj)
int
getAlignment()
Gets the alignment to be used when aligning this data type within another data type.Settings
getDefaultSettings()
Gets the default settings for this data type.long
getLastChangeTime()
Get the timestamp corresponding to the last time this type was changed within its data type managerlong
getLastChangeTimeInSourceArchive()
Get the timestamp corresponding to the last time this type was sync'd within its source archiveDataType[]
getParents()
java.lang.String
getPathName()
Returns the full category path name that includes this dataType's name.SettingsDefinition[]
getSettingsDefinitions()
Gets a list of all the settingsDefinitions used by this data type.SourceArchive
getSourceArchive()
Get the source archive where this type originatedUniversalID
getUniversalID()
Get the universal ID for this data type.java.lang.Class<?>
getValueClass(Settings settings)
Get the Class of the value to be returned by this data type.int
hashCode()
protected void
notifyDeleted()
Notify any parents that I am deleted.protected void
notifyNameChanged(java.lang.String oldName)
Notify any parents that my name has changed.protected void
notifyReplaced(DataType replacement)
Notify any parents that I have been replaced.protected void
notifySizeChanged()
Notify any parent data types that my size has changed.void
removeParent(DataType dt)
Remove a parent data type
TODO: This method is reserved for internal DB use and should be removed from the public DataType interface!!void
replaceWith(DataType dataType)
For dataTypes that support change, this method replaces the internals of this dataType with the internals of the given dataType.void
setDefaultSettings(Settings settings)
Set the default settings for this data type.void
setDescription(java.lang.String description)
Sets a String briefly describing this DataType.void
setLastChangeTime(long lastChangeTime)
Sets the lastChangeTime for this dataType.void
setLastChangeTimeInSourceArchive(long lastChangeTimeInSourceArchive)
Sets the lastChangeTimeInSourceArchive for this dataType.void
setSourceArchive(SourceArchive archive)
Set the source archive where this type originatedvoid
stateChanged(javax.swing.event.ChangeEvent e)
-
Methods inherited from class ghidra.program.model.data.AbstractDataType
dataTypeDeleted, dataTypeNameChanged, dataTypeReplaced, dataTypeSizeChanged, dependsOn, getCategoryPath, getDataOrganization, getDataTypeManager, getDataTypePath, getDefaultAbbreviatedLabelPrefix, getDefaultLabelPrefix, getDefaultLabelPrefix, getDefaultOffcutLabelPrefix, getDisplayName, getDocs, getMnemonic, getName, isDeleted, isDynamicallySized, isNotYetDefined, setCategoryPath, setName, setNameAndCategory, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ghidra.program.model.data.DataType
clone, copy, getDescription, getLength, getRepresentation, getValue, isEquivalent
-
-
-
-
Field Detail
-
defaultSettings
protected Settings defaultSettings
-
-
Constructor Detail
-
DataTypeImpl
protected DataTypeImpl(CategoryPath path, java.lang.String name, DataTypeManager dataMgr)
-
-
Method Detail
-
getValueClass
public java.lang.Class<?> getValueClass(Settings settings)
Description copied from interface:DataType
Get the Class of the value to be returned by this data type.- Specified by:
getValueClass
in interfaceDataType
- Parameters:
settings
- the relevant settings to use or null for default.- Returns:
- Class of the value to be returned by this data type or null if it can vary or is unspecified. Types which correspond to a string or char array will return the String class.
-
getDefaultSettings
public Settings getDefaultSettings()
Description copied from interface:DataType
Gets the default settings for this data type.- Specified by:
getDefaultSettings
in interfaceDataType
- Returns:
- the default settings for this dataType.
-
getSettingsDefinitions
public SettingsDefinition[] getSettingsDefinitions()
Description copied from interface:DataType
Gets a list of all the settingsDefinitions used by this data type.- Specified by:
getSettingsDefinitions
in interfaceDataType
- Returns:
- a list of the settingsDefinitions used by this data type.
-
stateChanged
public void stateChanged(javax.swing.event.ChangeEvent e)
- Specified by:
stateChanged
in interfacejavax.swing.event.ChangeListener
-
setDefaultSettings
public void setDefaultSettings(Settings settings)
Description copied from interface:DataType
Set the default settings for this data type.
TODO: This method is reserved for internal DB use and should be removed from the public DataType interface!!- Specified by:
setDefaultSettings
in interfaceDataType
- Parameters:
settings
- the settings to be used as this dataTypes default settings.
-
getPathName
public java.lang.String getPathName()
Description copied from interface:DataType
Returns the full category path name that includes this dataType's name. If the category is null, then this just returns the dataType's name.- Specified by:
getPathName
in interfaceDataType
- Overrides:
getPathName
in classAbstractDataType
-
getAlignment
public int getAlignment()
Description copied from interface:DataType
Gets the alignment to be used when aligning this data type within another data type.- Specified by:
getAlignment
in interfaceDataType
- Returns:
- this data type's alignment.
-
addParent
public void addParent(DataType dt)
Description copied from interface:DataType
Inform this data type that it has the given parent
TODO: This method is reserved for internal DB use and should be removed from the public DataType interface!!- Specified by:
addParent
in interfaceDataType
- Overrides:
addParent
in classAbstractDataType
- Parameters:
dt
- parent data type
-
removeParent
public void removeParent(DataType dt)
Description copied from interface:DataType
Remove a parent data type
TODO: This method is reserved for internal DB use and should be removed from the public DataType interface!!- Specified by:
removeParent
in interfaceDataType
- Overrides:
removeParent
in classAbstractDataType
- Parameters:
dt
- parent data type
-
getParents
public DataType[] getParents()
- Specified by:
getParents
in interfaceDataType
- Overrides:
getParents
in classAbstractDataType
- Returns:
- an array of parents of this data type
-
notifySizeChanged
protected void notifySizeChanged()
Notify any parent data types that my size has changed.
-
notifyNameChanged
protected void notifyNameChanged(java.lang.String oldName)
Notify any parents that my name has changed.- Parameters:
oldName
-
-
notifyDeleted
protected void notifyDeleted()
Notify any parents that I am deleted.
-
notifyReplaced
protected void notifyReplaced(DataType replacement)
Notify any parents that I have been replaced.- Parameters:
replacement
- replacement data type
-
getLastChangeTime
public long getLastChangeTime()
Description copied from interface:DataType
Get the timestamp corresponding to the last time this type was changed within its data type manager- Specified by:
getLastChangeTime
in interfaceDataType
- Overrides:
getLastChangeTime
in classAbstractDataType
- Returns:
- timestamp of last change within data type manager
-
getLastChangeTimeInSourceArchive
public long getLastChangeTimeInSourceArchive()
Description copied from interface:DataType
Get the timestamp corresponding to the last time this type was sync'd within its source archive- Specified by:
getLastChangeTimeInSourceArchive
in interfaceDataType
- Overrides:
getLastChangeTimeInSourceArchive
in classAbstractDataType
- Returns:
- timestamp of last sync with source archive
-
getSourceArchive
public SourceArchive getSourceArchive()
Description copied from interface:DataType
Get the source archive where this type originated- Specified by:
getSourceArchive
in interfaceDataType
- Overrides:
getSourceArchive
in classAbstractDataType
- Returns:
- source archive object
-
setSourceArchive
public void setSourceArchive(SourceArchive archive)
Description copied from interface:DataType
Set the source archive where this type originated- Specified by:
setSourceArchive
in interfaceDataType
- Overrides:
setSourceArchive
in classAbstractDataType
- Parameters:
archive
- source archive object
-
getUniversalID
public UniversalID getUniversalID()
Description copied from interface:DataType
Get the universal ID for this data type. This value is intended to be a unique identifier across all programs and archives. The same ID indicates that two data types were originally the same one. Keep in mind names, categories, and component makeup may differ and have changed since there origin.- Specified by:
getUniversalID
in interfaceDataType
- Overrides:
getUniversalID
in classAbstractDataType
- Returns:
- data type UniversalID
-
replaceWith
public void replaceWith(DataType dataType)
Description copied from interface:DataType
For dataTypes that support change, this method replaces the internals of this dataType with the internals of the given dataType. The dataTypes must be of the same "type" (i.e. structure can only be replacedWith another structure.- Specified by:
replaceWith
in interfaceDataType
- Overrides:
replaceWith
in classAbstractDataType
- Parameters:
dataType
- the dataType that contains the internals to upgrade to.
-
setLastChangeTime
public void setLastChangeTime(long lastChangeTime)
Description copied from interface:DataType
Sets the lastChangeTime for this dataType. Normally, this is updated automatically when a dataType is changed, but when committing or updating while synchronizing an archive, the lastChangeTime may need to be updated externally.- Specified by:
setLastChangeTime
in interfaceDataType
- Overrides:
setLastChangeTime
in classAbstractDataType
- Parameters:
lastChangeTime
- the time to use as the lastChangeTime for this dataType
-
setLastChangeTimeInSourceArchive
public void setLastChangeTimeInSourceArchive(long lastChangeTimeInSourceArchive)
Description copied from interface:DataType
Sets the lastChangeTimeInSourceArchive for this dataType. This is used by when a dataType change is committed back to its source archive.- Specified by:
setLastChangeTimeInSourceArchive
in interfaceDataType
- Overrides:
setLastChangeTimeInSourceArchive
in classAbstractDataType
- Parameters:
lastChangeTimeInSourceArchive
- the time to use as the lastChangeTimeInSourceArchive for this dataType
-
setDescription
public void setDescription(java.lang.String description) throws java.lang.UnsupportedOperationException
Sets a String briefly describing this DataType.
If a data type that extends this class wants to allow the description to be changed, then it must override this method.- Specified by:
setDescription
in interfaceDataType
- Overrides:
setDescription
in classAbstractDataType
- Parameters:
description
- a one-liner describing this DataType.- Throws:
java.lang.UnsupportedOperationException
- if the description is not allowed to be set for this data type.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public final boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
-