Package ghidra.program.model.data
Class DataTypeImpl
- java.lang.Object
-
- ghidra.program.model.data.DataTypeImpl
-
- All Implemented Interfaces:
DataType,java.io.Serializable,java.util.EventListener,javax.swing.event.ChangeListener
- Direct Known Subclasses:
ArrayDataType,BuiltIn,DefaultDataType,GenericDataType,MissingBuiltInDataType
public abstract class DataTypeImpl extends java.lang.Object implements DataType, javax.swing.event.ChangeListener, java.io.Serializable
Base implementation for dataTypes.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected CategoryPathcategoryPathprotected SettingsdefaultSettingsprotected java.lang.Stringname-
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 protectedDataTypeImpl(CategoryPath path, java.lang.String name, DataTypeManager dataMgr)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddParent(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!!booleanequals(java.lang.Object obj)intgetAlignment()Gets the alignment to be used when aligning this data type within another data type.CategoryPathgetCategoryPath()Gets the categoryPath associated with this data typeprotected DataOrganizationgetDataOrganization()Returns the DataOrganization associated with this data-types DataTypeManagerDataTypeManagergetDataTypeManager()Returns the DataTypeManager that is associated with this dataType.DataTypePathgetDataTypePath()Returns the dataTypePath for this dataType;java.lang.StringgetDefaultAbbreviatedLabelPrefix()Returns the prefix to use for this datatype when an abbreviated prefix is desired.java.lang.StringgetDefaultLabelPrefix()Returns the appropriate string to use as the default label prefix in the absence of any data.java.lang.StringgetDefaultLabelPrefix(MemBuffer buf, Settings settings, int len, DataTypeDisplayOptions options)Returns the appropriate string to use as the default label prefix.java.lang.StringgetDefaultOffcutLabelPrefix(MemBuffer buf, Settings settings, int len, DataTypeDisplayOptions options, int offcutLength)Returns the appropriate string to use as the default label prefix, taking into account the fact that there exists a reference to the data that references offcutLength bytes into this typeSettingsgetDefaultSettings()Gets the default settings for this data type.java.lang.StringgetDisplayName()Gets the name for referring to this data type.java.net.URLgetDocs()The getDocs method should provide a URL pointing to extended documentation for this DataType if it exists.longgetLastChangeTime()Get the timestamp corresponding to the last time this type was changed within its data type managerlonggetLastChangeTimeInSourceArchive()Get the timestamp corresponding to the last time this type was sync'd within its source archivejava.lang.StringgetName()Return that name of the data typeDataType[]getParents()java.lang.StringgetPathName()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.SourceArchivegetSourceArchive()Get the source archive where this type originatedUniversalIDgetUniversalID()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.inthashCode()booleanisDeleted()Returns true if this data type has been deleted and is no longer validbooleanisNotYetDefined()Indicates if type has not yet been defined.protected voidnotifyDeleted()Notify any parents that I am deleted.protected voidnotifyNameChanged(java.lang.String oldName)Notify any parents that my name has changed.protected voidnotifyReplaced(DataType replacement)Notify any parents that I have been replaced.protected voidnotifySizeChanged()Notify any parent data types that my size has changed.voidremoveParent(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!!voidreplaceWith(DataType dataType)For dataTypes that support change, this method replaces the internals of this dataType with the internals of the given dataType.voidsetDefaultSettings(Settings settings)Set the default settings for this data type.voidsetDescription(java.lang.String description)Sets a String briefly describing this DataType.voidsetLastChangeTime(long lastChangeTime)Sets the lastChangeTime for this dataType.voidsetLastChangeTimeInSourceArchive(long lastChangeTimeInSourceArchive)Sets the lastChangeTimeInSourceArchive for this dataType.voidsetSourceArchive(SourceArchive archive)Set the source archive where this type originatedvoidstateChanged(javax.swing.event.ChangeEvent e)java.lang.StringtoString()-
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, dataTypeDeleted, dataTypeNameChanged, dataTypeReplaced, dataTypeSizeChanged, dependsOn, getDescription, getLength, getMnemonic, getRepresentation, getValue, isDynamicallySized, isEquivalent, setCategoryPath, setName, setNameAndCategory
-
-
-
-
Field Detail
-
defaultSettings
protected Settings defaultSettings
-
name
protected java.lang.String name
-
categoryPath
protected CategoryPath categoryPath
-
-
Constructor Detail
-
DataTypeImpl
protected DataTypeImpl(CategoryPath path, java.lang.String name, DataTypeManager dataMgr)
-
-
Method Detail
-
getDataOrganization
protected final DataOrganization getDataOrganization()
Returns the DataOrganization associated with this data-types DataTypeManager
-
isNotYetDefined
public boolean isNotYetDefined()
Description copied from interface:DataTypeIndicates if type has not yet been defined. Such types will always return a size of 1. (example: empty structure)- Specified by:
isNotYetDefinedin interfaceDataType- Returns:
- true if this type is not yet defined.
-
getValueClass
public java.lang.Class<?> getValueClass(Settings settings)
Description copied from interface:DataTypeGet the Class of the value to be returned by this data type.- Specified by:
getValueClassin 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:DataTypeGets the default settings for this data type.- Specified by:
getDefaultSettingsin interfaceDataType- Returns:
- the default settings for this dataType.
- See Also:
DataType.getDefaultSettings()
-
getCategoryPath
public CategoryPath getCategoryPath()
Description copied from interface:DataTypeGets the categoryPath associated with this data type- Specified by:
getCategoryPathin interfaceDataType- Returns:
- the datatype's category path
-
getDataTypePath
public DataTypePath getDataTypePath()
Description copied from interface:DataTypeReturns the dataTypePath for this dataType;- Specified by:
getDataTypePathin interfaceDataType- Returns:
- the dataTypePath for this dataType;
-
getDocs
public java.net.URL getDocs()
Description copied from interface:DataTypeThe getDocs method should provide a URL pointing to extended documentation for this DataType if it exists. A typical use would be to return a URL pointing to the programmers reference for this instruction or a page describing this data structure.- Specified by:
getDocsin interfaceDataType- Returns:
- null - there is no URL documentation for this prototype.
- See Also:
DataType.getDocs()
-
getSettingsDefinitions
public SettingsDefinition[] getSettingsDefinitions()
Description copied from interface:DataTypeGets a list of all the settingsDefinitions used by this data type.- Specified by:
getSettingsDefinitionsin interfaceDataType- Returns:
- a list of the settingsDefinitions used by this data type.
- See Also:
DataType.getSettingsDefinitions()
-
getName
public java.lang.String getName()
Description copied from interface:DataTypeReturn that name of the data type- Specified by:
getNamein interfaceDataType- See Also:
DataType.getName()
-
getDisplayName
public java.lang.String getDisplayName()
Description copied from interface:DataTypeGets the name for referring to this data type.- Specified by:
getDisplayNamein interfaceDataType- Returns:
- generic name for this Data Type (i.e.: Word)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isDeleted
public boolean isDeleted()
Description copied from interface:DataTypeReturns true if this data type has been deleted and is no longer valid- Specified by:
isDeletedin interfaceDataType- Returns:
- true if this data type has been deleted and is no longer valid.
- See Also:
DataType.isDeleted()
-
stateChanged
public void stateChanged(javax.swing.event.ChangeEvent e)
- Specified by:
stateChangedin interfacejavax.swing.event.ChangeListener- See Also:
ChangeListener.stateChanged(javax.swing.event.ChangeEvent)
-
getDataTypeManager
public DataTypeManager getDataTypeManager()
Description copied from interface:DataTypeReturns the DataTypeManager that is associated with this dataType. This association should not be used to indicate whether this DataType has been resolved, but is intended to indicate whether the appropriate DataOrganization is being used.- Specified by:
getDataTypeManagerin interfaceDataType- See Also:
DataType.getDataTypeManager()
-
setDefaultSettings
public void setDefaultSettings(Settings settings)
Description copied from interface:DataTypeSet 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:
setDefaultSettingsin interfaceDataType- Parameters:
settings- the settings to be used as this dataTypes default settings.- See Also:
DataType.setDefaultSettings(ghidra.docking.settings.Settings)
-
getPathName
public java.lang.String getPathName()
Description copied from interface:DataTypeReturns 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:
getPathNamein interfaceDataType- See Also:
DataType.getPathName()
-
getAlignment
public int getAlignment()
Description copied from interface:DataTypeGets the alignment to be used when aligning this data type within another data type.- Specified by:
getAlignmentin interfaceDataType- Returns:
- this data type's alignment.
-
addParent
public void addParent(DataType dt)
Description copied from interface:DataTypeInform 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:
addParentin interfaceDataType- Parameters:
dt- parent data type- See Also:
DataType.addParent(ghidra.program.model.data.DataType)
-
removeParent
public void removeParent(DataType dt)
Description copied from interface:DataTypeRemove a parent data type
TODO: This method is reserved for internal DB use and should be removed from the public DataType interface!!- Specified by:
removeParentin interfaceDataType- Parameters:
dt- parent data type- See Also:
DataType.removeParent(ghidra.program.model.data.DataType)
-
getParents
public DataType[] getParents()
- Specified by:
getParentsin interfaceDataType- 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
-
getDefaultLabelPrefix
public java.lang.String getDefaultLabelPrefix()
Description copied from interface:DataTypeReturns the appropriate string to use as the default label prefix in the absence of any data.- Specified by:
getDefaultLabelPrefixin interfaceDataType- Returns:
- the default label prefix or null if none specified.
-
getDefaultAbbreviatedLabelPrefix
public java.lang.String getDefaultAbbreviatedLabelPrefix()
Description copied from interface:DataTypeReturns the prefix to use for this datatype when an abbreviated prefix is desired. For example, some data types will built a large default label, at which is is more desirable to have a shortened prefix.- Specified by:
getDefaultAbbreviatedLabelPrefixin interfaceDataType- Returns:
- the prefix to use for this datatype when an abbreviated prefix is desired. May return null.
-
getDefaultLabelPrefix
public java.lang.String getDefaultLabelPrefix(MemBuffer buf, Settings settings, int len, DataTypeDisplayOptions options)
Description copied from interface:DataTypeReturns the appropriate string to use as the default label prefix.- Specified by:
getDefaultLabelPrefixin interfaceDataType- Parameters:
buf- memory buffer containing the bytes.settings- the Settings objectoptions- options for how to format the default label prefix.- Returns:
- the default label prefix or null if none specified.
-
getDefaultOffcutLabelPrefix
public java.lang.String getDefaultOffcutLabelPrefix(MemBuffer buf, Settings settings, int len, DataTypeDisplayOptions options, int offcutLength)
Description copied from interface:DataTypeReturns the appropriate string to use as the default label prefix, taking into account the fact that there exists a reference to the data that references offcutLength bytes into this type- Specified by:
getDefaultOffcutLabelPrefixin interfaceDataType- Parameters:
buf- memory buffer containing the bytes.settings- the Settings objectoptions- options for how to format the default label prefix.- Returns:
- the default label prefix.
-
getLastChangeTime
public long getLastChangeTime()
Description copied from interface:DataTypeGet the timestamp corresponding to the last time this type was changed within its data type manager- Specified by:
getLastChangeTimein interfaceDataType- Returns:
- timestamp of last change within data type manager
-
getLastChangeTimeInSourceArchive
public long getLastChangeTimeInSourceArchive()
Description copied from interface:DataTypeGet the timestamp corresponding to the last time this type was sync'd within its source archive- Specified by:
getLastChangeTimeInSourceArchivein interfaceDataType- Returns:
- timestamp of last sync with source archive
-
getSourceArchive
public SourceArchive getSourceArchive()
Description copied from interface:DataTypeGet the source archive where this type originated- Specified by:
getSourceArchivein interfaceDataType- Returns:
- source archive object
-
setSourceArchive
public void setSourceArchive(SourceArchive archive)
Description copied from interface:DataTypeSet the source archive where this type originated- Specified by:
setSourceArchivein interfaceDataType- Parameters:
archive- source archive object
-
getUniversalID
public UniversalID getUniversalID()
Description copied from interface:DataTypeGet 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:
getUniversalIDin interfaceDataType- Returns:
- data type UniversalID
-
replaceWith
public void replaceWith(DataType dataType)
Description copied from interface:DataTypeFor 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:
replaceWithin interfaceDataType- Parameters:
dataType- the dataType that contains the internals to upgrade to.
-
setLastChangeTime
public void setLastChangeTime(long lastChangeTime)
Description copied from interface:DataTypeSets 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:
setLastChangeTimein interfaceDataType- Parameters:
lastChangeTime- the time to use as the lastChangeTime for this dataType
-
setLastChangeTimeInSourceArchive
public void setLastChangeTimeInSourceArchive(long lastChangeTimeInSourceArchive)
Description copied from interface:DataTypeSets the lastChangeTimeInSourceArchive for this dataType. This is used by when a dataType change is committed back to its source archive.- Specified by:
setLastChangeTimeInSourceArchivein interfaceDataType- Parameters:
lastChangeTimeInSourceArchive- the time to use as the lastChangeTimeInSourceArchive for this dataType
-
setDescription
public void setDescription(java.lang.String description) throws java.lang.UnsupportedOperationExceptionSets 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:
setDescriptionin interfaceDataType- 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:
hashCodein classjava.lang.Object
-
equals
public final boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-