Package ghidra.program.model.data
Class DefaultDataType
- java.lang.Object
-
- ghidra.program.model.data.AbstractDataType
-
- ghidra.program.model.data.DataTypeImpl
-
- ghidra.program.model.data.DefaultDataType
-
- All Implemented Interfaces:
DataType,java.util.EventListener,javax.swing.event.ChangeListener
public class DefaultDataType extends DataTypeImpl
Provides an implementation of a byte that has not been defined yet as a particular type of data in the program.
-
-
Field Summary
Fields Modifier and Type Field Description static DefaultDataTypedataTypeA statically defined DefaultDataType used when an Undefined byte is needed.-
Fields inherited from class ghidra.program.model.data.DataTypeImpl
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
-
-
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.DataTypeclone(DataTypeManager dtm)Returns an instance of this DataType with its universalID and SourceArchive identity retained.DataTypecopy(DataTypeManager dtm)Returns a new instance (shallow copy) of this DataType with a new identity.voiddataTypeDeleted(DataType dt)Informs this dataType that the given dataType has been deleted.voiddataTypeNameChanged(DataType dt, java.lang.String oldName)Informs this data type that its name has changed from the indicated old name.voiddataTypeReplaced(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.voiddataTypeSizeChanged(DataType dt)Notification that the given dataType's size has changed.booleandependsOn(DataType dt)Returns true if this dataType depends on the existence of the given dataType.java.lang.StringgetDescription()Get a String briefly describing this DataType.longgetLastChangeTime()Get the timestamp corresponding to the last time this type was changed within its data type managerintgetLength()Get the length (number of 8-bit bytes) of this DataType.java.lang.StringgetMnemonic(Settings settings)Get the mnemonic for this DataType.java.lang.StringgetRepresentation(MemBuffer buf, Settings settings, int length)Get bytes from memory in a printable format for this type.java.lang.ObjectgetValue(MemBuffer buf, Settings settings, int length)Get the Undefined byte as a Scalar.booleanisEquivalent(DataType dt)Returns true if the given dataType is equivalent to this dataType.voidremoveParent(DataType dt)Remove a parent data type
TODO: This method is reserved for internal DB use.voidsetCategoryPath(CategoryPath path)voidsetName(java.lang.String name)Sets the name of the dataTypevoidsetNameAndCategory(CategoryPath path, java.lang.String name)Sets the name and category of a dataType at the same time.-
Methods inherited from class ghidra.program.model.data.DataTypeImpl
equals, getAlignment, getDefaultSettings, getLastChangeTimeInSourceArchive, getParents, getPathName, getSettingsDefinitions, getSourceArchive, getUniversalID, getValueClass, hashCode, notifyAlignmentChanged, notifyDeleted, notifyNameChanged, notifyParents, notifyReplaced, notifySizeChanged, replaceWith, setDefaultSettings, setDescription, setLastChangeTime, setLastChangeTimeInSourceArchive, setSourceArchive, stateChanged
-
Methods inherited from class ghidra.program.model.data.AbstractDataType
dataTypeAlignmentChanged, getCategoryPath, getDataOrganization, getDataTypeManager, getDataTypePath, getDefaultAbbreviatedLabelPrefix, getDefaultLabelPrefix, getDefaultLabelPrefix, getDefaultOffcutLabelPrefix, getDisplayName, getDocs, getName, hasLanguageDependantLength, isDeleted, isNotYetDefined, isZeroLength, toString
-
-
-
-
Field Detail
-
dataType
public static DefaultDataType dataType
A statically defined DefaultDataType used when an Undefined byte is needed.
-
-
Method Detail
-
getMnemonic
public java.lang.String getMnemonic(Settings settings)
Description copied from interface:DataTypeGet the mnemonic for this DataType.- Specified by:
getMnemonicin interfaceDataType- Overrides:
getMnemonicin classAbstractDataType- Parameters:
settings- settings which may influence the result or null- Returns:
- the mnemonic for this DataType.
- See Also:
DataType.getMnemonic(Settings)
-
getLength
public int getLength()
Description copied from interface:DataTypeGet the length (number of 8-bit bytes) of this DataType.- Returns:
- the length of this DataType
- See Also:
DataType.getLength()
-
getDescription
public java.lang.String getDescription()
Description copied from interface:DataTypeGet a String briefly describing this DataType.- Returns:
- a one-liner describing this DataType.
- See Also:
DataType.getDescription()
-
getRepresentation
public java.lang.String getRepresentation(MemBuffer buf, Settings settings, int length)
Description copied from interface:DataTypeGet bytes from memory in a printable format for this type.- Parameters:
buf- the data.settings- the settings to use for the representation.length- the number of bytes to represent.- Returns:
- the representation of the data in this format, never null.
- See Also:
DataType.getRepresentation(MemBuffer, Settings, int)
-
getValue
public java.lang.Object getValue(MemBuffer buf, Settings settings, int length)
Get the Undefined byte as a Scalar.- Parameters:
buf- the data buffer.settings- the display settings to use.length- the number of bytes to get the value from.- Returns:
- the data Object.
-
clone
public DataType clone(DataTypeManager dtm)
Description copied from interface:DataTypeReturns an instance of this DataType with its universalID and SourceArchive identity retained. The current instanceof will be returned if this datatype's DataTypeManager matches the specified dtm. The recursion depth of a clone will stop on any datatype whose DataTypeManager matches the specified dtm and simply use the existing datatype instance.- Parameters:
dtm- the data-type manager instance whose data-organization should apply.- Returns:
- cloned instance which may be the same as this instance
-
copy
public DataType copy(DataTypeManager dtm)
Description copied from interface:DataTypeReturns a new instance (shallow copy) of this DataType with a new identity. Any reference to other datatypes will useDataType.clone(DataTypeManager).- Parameters:
dtm- the data-type manager instance whose data-organization should apply.- Returns:
- new instanceof of this datatype
-
dataTypeSizeChanged
public void dataTypeSizeChanged(DataType dt)
Description copied from interface:DataTypeNotification 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.- Specified by:
dataTypeSizeChangedin interfaceDataType- Overrides:
dataTypeSizeChangedin classAbstractDataType- Parameters:
dt- the dataType that has changed.- See Also:
DataType.dataTypeSizeChanged(ghidra.program.model.data.DataType)
-
isEquivalent
public boolean isEquivalent(DataType dt)
Description copied from interface:DataTypeReturns true if the given dataType is equivalent to this dataType. The precise meaning of "equivalent" is dataType dependent.
NOTE: if invoked by a DB object or manager it should be invoked on the DataTypeDB object passing the other datatype as the argument.- Parameters:
dt- the dataType being tested for equivalence.- Returns:
- true if the if the given dataType is equivalent to this dataType.
- See Also:
DataType.isEquivalent(ghidra.program.model.data.DataType)
-
setCategoryPath
public void setCategoryPath(CategoryPath path) throws DuplicateNameException
- Specified by:
setCategoryPathin interfaceDataType- Overrides:
setCategoryPathin classAbstractDataType- Parameters:
path- set the categoryPath associated with this data type- Throws:
DuplicateNameException- if an attempt to place this datatype into the specified category resulted in a name collision. This should not occur for non-DB DataType instances.- See Also:
DataType.setCategoryPath(ghidra.program.model.data.CategoryPath)
-
setName
public void setName(java.lang.String name)
Description copied from interface:DataTypeSets the name of the dataType- Specified by:
setNamein interfaceDataType- Overrides:
setNamein classAbstractDataType- Parameters:
name- the new name for this dataType.- See Also:
DataType.setName(java.lang.String)
-
setNameAndCategory
public void setNameAndCategory(CategoryPath path, java.lang.String name) throws InvalidNameException, DuplicateNameException
Description copied from interface:DataTypeSets the name and category of a dataType at the same time.- Specified by:
setNameAndCategoryin interfaceDataType- Overrides:
setNameAndCategoryin classAbstractDataType- Parameters:
path- the new category path.name- the new name- Throws:
InvalidNameException- if the name is invalidDuplicateNameException- if name change on storedDataTypeis a duplicate of another datatype within the same category (only applies to DB storedDataType).- See Also:
DataType.setNameAndCategory(ghidra.program.model.data.CategoryPath, java.lang.String)
-
dataTypeDeleted
public void dataTypeDeleted(DataType dt)
Description copied from interface:DataTypeInforms this dataType that the given dataType has been deleted.
TODO: This method is reserved for internal DB use.- Specified by:
dataTypeDeletedin interfaceDataType- Overrides:
dataTypeDeletedin classAbstractDataType- Parameters:
dt- the dataType that has been deleted.- See Also:
DataType.dataTypeDeleted(ghidra.program.model.data.DataType)
-
dataTypeNameChanged
public void dataTypeNameChanged(DataType dt, java.lang.String oldName)
Description copied from interface:DataTypeInforms this data type that its name has changed from the indicated old name.
TODO: This method is reserved for internal DB use.- Specified by:
dataTypeNameChangedin interfaceDataType- Overrides:
dataTypeNameChangedin classAbstractDataType- Parameters:
dt- the data type whose name changedoldName- the data type's old name- See Also:
DataType.dataTypeNameChanged(ghidra.program.model.data.DataType, java.lang.String)
-
dataTypeReplaced
public void dataTypeReplaced(DataType oldDt, DataType newDt)
Description copied from interface:DataTypeInforms this data type that the given oldDT has been replaced with newDT
TODO: This method is reserved for internal DB use.- Specified by:
dataTypeReplacedin interfaceDataType- Overrides:
dataTypeReplacedin classAbstractDataType- Parameters:
oldDt- old data typenewDt- new data type- See Also:
DataType.dataTypeReplaced(ghidra.program.model.data.DataType, ghidra.program.model.data.DataType)
-
dependsOn
public boolean dependsOn(DataType dt)
Description copied from interface:DataTypeReturns 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.- Specified by:
dependsOnin interfaceDataType- Overrides:
dependsOnin classAbstractDataType- Parameters:
dt- the dataType to test that this dataType depends on.- Returns:
- true if the existence of this datatype relies on the existence of the specified datatype dt.
- See Also:
DataType.dependsOn(ghidra.program.model.data.DataType)
-
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.- Specified by:
addParentin interfaceDataType- Overrides:
addParentin classDataTypeImpl- 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.- Specified by:
removeParentin interfaceDataType- Overrides:
removeParentin classDataTypeImpl- Parameters:
dt- parent data type- See Also:
DataType.removeParent(ghidra.program.model.data.DataType)
-
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- Overrides:
getLastChangeTimein classDataTypeImpl- Returns:
- timestamp of last change within data type manager
-
-