Package ghidra.program.model.data
Class AbstractDataType
- java.lang.Object
-
- ghidra.program.model.data.AbstractDataType
-
- All Implemented Interfaces:
DataType
- Direct Known Subclasses:
BitFieldDataType
,DataTypeImpl
public abstract class AbstractDataType extends java.lang.Object implements DataType
Base class for DataType classes. Many of the DataType methods are stubbed out so simple datatype classes can be created without implementing too many methods.
-
-
Field Summary
Fields Modifier and Type Field Description protected CategoryPath
categoryPath
protected DataTypeManager
dataMgr
protected java.lang.String
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
AbstractDataType(CategoryPath path, java.lang.String name, DataTypeManager dataTypeManager)
-
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!!void
dataTypeDeleted(DataType dt)
Informs this dataType that the given dataType has been deleted.void
dataTypeNameChanged(DataType dt, java.lang.String oldName)
Informs this data type that its name has changed from the indicated old name.void
dataTypeReplaced(DataType oldDt, DataType newDt)
Informs this data type that the given oldDT has been replaced with newDT
TODO: This method is reserved for internal DB use and should be removed from the public DataType interface!!void
dataTypeSizeChanged(DataType dt)
Notification that the given dataType's size has changed.boolean
dependsOn(DataType dt)
Returns true if this dataType depends on the existence of the given dataType.CategoryPath
getCategoryPath()
Gets the categoryPath associated with this data typeDataOrganization
getDataOrganization()
Returns the DataOrganization associated with this data-typeDataTypeManager
getDataTypeManager()
Returns the DataTypeManager that is associated with this dataType.DataTypePath
getDataTypePath()
Returns the dataTypePath for this dataType;java.lang.String
getDefaultAbbreviatedLabelPrefix()
Returns the prefix to use for this datatype when an abbreviated prefix is desired.java.lang.String
getDefaultLabelPrefix()
Returns the appropriate string to use as the default label prefix in the absence of any data.java.lang.String
getDefaultLabelPrefix(MemBuffer buf, Settings settings, int len, DataTypeDisplayOptions options)
Returns the appropriate string to use as the default label prefix.java.lang.String
getDefaultOffcutLabelPrefix(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 typejava.lang.String
getDisplayName()
Gets the name for referring to this data type.java.net.URL
getDocs()
The getDocs method should provide a URL pointing to extended documentation for this DataType if it exists.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 archivejava.lang.String
getMnemonic(Settings settings)
Get the mnemonic for this DataType.java.lang.String
getName()
Return that name of the data typeDataType[]
getParents()
java.lang.String
getPathName()
Returns the full category path name that includes this dataType's name.SourceArchive
getSourceArchive()
Get the source archive where this type originatedUniversalID
getUniversalID()
Get the universal ID for this data type.boolean
isDeleted()
Returns true if this data type has been deleted and is no longer validboolean
isDynamicallySized()
Indicates if this data-type is dynamically sized based upon DataOrganization.boolean
isNotYetDefined()
Indicates if type has not yet been defined.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
setCategoryPath(CategoryPath path)
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
setName(java.lang.String name)
Sets the name of the dataTypevoid
setNameAndCategory(CategoryPath path, java.lang.String name)
Sets the name and category of a dataType at the same time.void
setSourceArchive(SourceArchive archive)
Set the source archive where this type originatedjava.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ghidra.program.model.data.DataType
clone, copy, getAlignment, getDefaultSettings, getDescription, getLength, getRepresentation, getSettingsDefinitions, getValue, getValueClass, isEquivalent, setDefaultSettings
-
-
-
-
Field Detail
-
name
protected java.lang.String name
-
categoryPath
protected CategoryPath categoryPath
-
dataMgr
protected final DataTypeManager dataMgr
-
-
Constructor Detail
-
AbstractDataType
protected AbstractDataType(CategoryPath path, java.lang.String name, DataTypeManager dataTypeManager)
-
-
Method Detail
-
getCategoryPath
public CategoryPath getCategoryPath()
Description copied from interface:DataType
Gets the categoryPath associated with this data type- Specified by:
getCategoryPath
in interfaceDataType
- Returns:
- the datatype's category path
-
getDataTypeManager
public final DataTypeManager getDataTypeManager()
Description copied from interface:DataType
Returns 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:
getDataTypeManager
in interfaceDataType
- See Also:
DataType.getDataTypeManager()
-
getDataOrganization
public final DataOrganization getDataOrganization()
Description copied from interface:DataType
Returns the DataOrganization associated with this data-type- Specified by:
getDataOrganization
in interfaceDataType
-
getDataTypePath
public DataTypePath getDataTypePath()
Description copied from interface:DataType
Returns the dataTypePath for this dataType;- Specified by:
getDataTypePath
in interfaceDataType
- Returns:
- the dataTypePath for this dataType;
-
getDocs
public java.net.URL getDocs()
Description copied from interface:DataType
The 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.
-
getName
public java.lang.String getName()
Description copied from interface:DataType
Return that name of the data type
-
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
-
getDisplayName
public java.lang.String getDisplayName()
Description copied from interface:DataType
Gets the name for referring to this data type.- Specified by:
getDisplayName
in interfaceDataType
- Returns:
- generic name for this Data Type (i.e.: Word)
-
getMnemonic
public java.lang.String getMnemonic(Settings settings)
Description copied from interface:DataType
Get the mnemonic for this DataType.- Specified by:
getMnemonic
in interfaceDataType
- Returns:
- the mnemonic for this DataType.
-
isNotYetDefined
public boolean isNotYetDefined()
Description copied from interface:DataType
Indicates if type has not yet been defined. Such types will always return a size of 1. (example: empty structure)- Specified by:
isNotYetDefined
in interfaceDataType
- Returns:
- true if this type is not yet defined.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isDeleted
public boolean isDeleted()
Description copied from interface:DataType
Returns true if this data type has been deleted and is no longer valid
-
setName
public void setName(java.lang.String name) throws InvalidNameException
Description copied from interface:DataType
Sets the name of the dataType- Specified by:
setName
in interfaceDataType
- Parameters:
name
- the new name for this dataType.- Throws:
InvalidNameException
- if the given name does not form a valid name.
-
setNameAndCategory
public void setNameAndCategory(CategoryPath path, java.lang.String name) throws InvalidNameException, DuplicateNameException
Description copied from interface:DataType
Sets the name and category of a dataType at the same time.- Specified by:
setNameAndCategory
in interfaceDataType
- Parameters:
path
- the new category path.name
- the new name- Throws:
InvalidNameException
- if the name is invalidDuplicateNameException
- if a dataType already exists with that name and
-
dataTypeSizeChanged
public void dataTypeSizeChanged(DataType dt)
Description copied from interface:DataType
Notification that the given dataType's size has changed. DataTypes may need to make internal changes in response.
TODO: This method is reserved for internal DB use and should be removed from the public DataType interface!!- Specified by:
dataTypeSizeChanged
in interfaceDataType
- Parameters:
dt
- the dataType that has changed.
-
dataTypeDeleted
public void dataTypeDeleted(DataType dt)
Description copied from interface:DataType
Informs this dataType that the given dataType has been deleted.
TODO: This method is reserved for internal DB use and should be removed from the public DataType interface!!- Specified by:
dataTypeDeleted
in interfaceDataType
- Parameters:
dt
- the dataType that has been deleted.
-
dataTypeReplaced
public void dataTypeReplaced(DataType oldDt, DataType newDt)
Description copied from interface:DataType
Informs this data type that the given oldDT has been replaced with newDT
TODO: This method is reserved for internal DB use and should be removed from the public DataType interface!!- Specified by:
dataTypeReplaced
in interfaceDataType
- Parameters:
oldDt
- old data typenewDt
- new data type
-
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!!
-
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
- Parameters:
dt
- parent data type
-
getParents
public DataType[] getParents()
- Specified by:
getParents
in interfaceDataType
- Returns:
- an array of parents of this data type
-
dependsOn
public boolean dependsOn(DataType dt)
Description copied from interface:DataType
Returns true if this dataType depends on the existence of the given dataType. For example byte[] depends on byte. If byte were deleted, then byte[] would also be deleted.
-
getSourceArchive
public SourceArchive getSourceArchive()
Description copied from interface:DataType
Get the source archive where this type originated- Specified by:
getSourceArchive
in interfaceDataType
- 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
- Parameters:
archive
- source archive object
-
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
- 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
- Returns:
- timestamp of last sync with source archive
-
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
- Returns:
- data type UniversalID
-
dataTypeNameChanged
public void dataTypeNameChanged(DataType dt, java.lang.String oldName)
Description copied from interface:DataType
Informs this data type that its name has changed from the indicated old name.
TODO: This method is reserved for internal DB use and should be removed from the public DataType interface!!- Specified by:
dataTypeNameChanged
in interfaceDataType
- Parameters:
dt
- the data type whose name changedoldName
- the data type's old name
-
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
- 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
- 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
- Parameters:
lastChangeTimeInSourceArchive
- the time to use as the lastChangeTimeInSourceArchive for this dataType
-
setDescription
public void setDescription(java.lang.String description) throws java.lang.UnsupportedOperationException
Description copied from interface:DataType
Sets a String briefly describing this DataType.- Specified by:
setDescription
in 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.
-
isDynamicallySized
public boolean isDynamicallySized()
Description copied from interface:DataType
Indicates if this data-type is dynamically sized based upon DataOrganization.- Specified by:
isDynamicallySized
in interfaceDataType
-
getDefaultLabelPrefix
public java.lang.String getDefaultLabelPrefix()
Description copied from interface:DataType
Returns the appropriate string to use as the default label prefix in the absence of any data.- Specified by:
getDefaultLabelPrefix
in interfaceDataType
- Returns:
- the default label prefix or null if none specified.
-
getDefaultAbbreviatedLabelPrefix
public java.lang.String getDefaultAbbreviatedLabelPrefix()
Description copied from interface:DataType
Returns 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:
getDefaultAbbreviatedLabelPrefix
in interfaceDataType
- Returns:
- the prefix to use for this datatype when an abbreviated prefix is desired. May return null.
-
setCategoryPath
public void setCategoryPath(CategoryPath path) throws DuplicateNameException
- Specified by:
setCategoryPath
in interfaceDataType
- Parameters:
path
- set the categoryPath associated with this data type- Throws:
DuplicateNameException
-
getDefaultLabelPrefix
public java.lang.String getDefaultLabelPrefix(MemBuffer buf, Settings settings, int len, DataTypeDisplayOptions options)
Description copied from interface:DataType
Returns the appropriate string to use as the default label prefix.- Specified by:
getDefaultLabelPrefix
in 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:DataType
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 type- Specified by:
getDefaultOffcutLabelPrefix
in 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.
-
-