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`

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 DefaultDataType`
  `dataType`
  A 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, TYPEDEF_ATTRIBUTE_PREFIX, TYPEDEF_ATTRIBUTE_SUFFIX, VOID`

- ## Method Summary

  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.
  `DataType`
  `clone(DataTypeManager dtm)`
  Returns an instance of this DataType using the specified `DataTypeManager` to allow its use of the corresponding `DataOrganization` while retaining its unique identity (see `DataType.getUniversalID()` and archive association (see `DataType.getSourceArchive()`) if applicable.
  `DataType`
  `copy(DataTypeManager dtm)`
  Returns a new instance (shallow copy) of this DataType with a new identity and no source archive association.
  `void`
  `dataTypeDeleted(DataType dt)`
  Informs this datatype that the given datatype has been deleted.
  `void`
  `dataTypeNameChanged(DataType dt, String oldName)`
  Informs this datatype that its name has changed from the indicated old name.
  `void`
  `dataTypeReplaced(DataType oldDt, DataType newDt)`
  Informs this datatype that the given oldDT has been replaced with newDT
  `void`
  `dataTypeSizeChanged(DataType dt)`
  Notification that the given datatype's size has changed.
  `boolean`
  `dependsOn(DataType dt)`
  Check if this datatype depends on the existence of the given datatype.
  `String`
  `getDescription()`
  Get a String briefly describing this DataType.
  `long`
  `getLastChangeTime()`
  Get the timestamp corresponding to the last time this type was changed within its datatype manager
  `int`
  `getLength()`
  Get the length of this DataType as a number of 8-bit bytes.
  `String`
  `getMnemonic(Settings settings)`
  Get the mnemonic for this DataType.
  `String`
  `getRepresentation(MemBuffer buf, Settings settings, int length)`
  Get bytes from memory in a printable format for this type.
  `Object`
  `getValue(MemBuffer buf, Settings settings, int length)`
  Get the Undefined byte as a Scalar.
  `boolean`
  `isEquivalent(DataType dt)`
  Check if the given datatype is equivalent to this datatype.
  `void`
  `removeParent(DataType dt)`
  Remove a parent datatype
  `void`
  `setCategoryPath(CategoryPath path)`
  Set the categoryPath associated with this datatype
  `void`
  `setName(String name)`
  Sets the name of the datatype
  `void`
  `setNameAndCategory(CategoryPath path, String name)`
  Sets the name and category of a datatype at the same time.

  ### Methods inherited from class ghidra.program.model.data.DataTypeImpl

  `equals, getAlignedLength, getAlignment, getDefaultSettings, getLastChangeTimeInSourceArchive, getParents, getPathName, getSettingsDefinitions, getSourceArchive, getUniversalID, getValueClass, hashCode, notifyAlignmentChanged, notifyDeleted, notifyNameChanged, notifyParents, notifyReplaced, notifySizeChanged, replaceWith, setDescription, setLastChangeTime, setLastChangeTimeInSourceArchive, setSourceArchive`

  ### Methods inherited from class ghidra.program.model.data.AbstractDataType

  `dataTypeAlignmentChanged, encodeRepresentation, encodeValue, getCategoryPath, getDataOrganization, getDataOrganization, getDataTypeManager, getDataTypePath, getDefaultAbbreviatedLabelPrefix, getDefaultLabelPrefix, getDefaultLabelPrefix, getDefaultOffcutLabelPrefix, getDisplayName, getDocs, getName, getTypeDefSettingsDefinitions, hasLanguageDependantLength, isDeleted, isEncodable, isNotYetDefined, isZeroLength, toString`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### dataType

    public static DefaultDataType dataType
    A statically defined DefaultDataType used when an Undefined byte is needed.

- ## Method Details

  - ### getMnemonic

    public String getMnemonic(Settings settings)
    Description copied from interface: `DataType`
    Get the mnemonic for this DataType.
    Specified by:
      `getMnemonic` in interface `DataType`
    Overrides:
      `getMnemonic` in class `AbstractDataType`
    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: `DataType`
    Get the length of this DataType as a number of 8-bit bytes.

    For primitive datatypes this reflects the smallest varnode which can be used to contain its value (i.e., raw data length).

    Example: For x86 32-bit gcc an 80-bit `long double` `raw data length` of 10-bytes will fit within a floating point register while its `aligned-length` of 12-bytes is used by the gcc compiler for data/array/component allocations to maintain alignment (i.e., `sizeof(long double)` ).

    NOTE: Other than the `VoidDataType`, no datatype should ever return 0, even if `DataType.isZeroLength()`, and only `Dynamic`/`FactoryDataType` datatypes should return -1. If `DataType.isZeroLength()` is true a length of 1 should be returned. Where a zero-length datatype can be handled (e.g., `Composite`) the `DataType.isZeroLength()` method should be used.

    Returns:
      the length of this DataType
    See Also:
      - `DataType.getLength()`

  - ### getDescription

    public String getDescription()
    Description copied from interface: `DataType`
    Get a String briefly describing this DataType.
    Returns:
      a one-liner describing this DataType.
    See Also:
      - `DataType.getDescription()`

  - ### getRepresentation

    public String getRepresentation(MemBuffer buf, Settings settings, int length)
    Description copied from interface: `DataType`
    Get 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 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: `DataType`
    Returns an instance of this DataType using the specified `DataTypeManager` to allow its use of the corresponding `DataOrganization` while retaining its unique identity (see `DataType.getUniversalID()` and archive association (see `DataType.getSourceArchive()`) if applicable.

    This instance 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.

    NOTE: In general, this method should not be used to obtain an instance to be modified. In most cases changes may be made directly to this instance if supported or to a `DataType.copy(DataTypeManager)` of this type.

    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: `DataType`
    Returns a new instance (shallow copy) of this DataType with a new identity and no source archive association.

    Any reference to other datatypes will use `DataType.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: `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.

    Specified by:
      `dataTypeSizeChanged` in interface `DataType`
    Overrides:
      `dataTypeSizeChanged` in class `AbstractDataType`
    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: `DataType`
    Check 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
    Description copied from interface: `DataType`
    Set the categoryPath associated with this datatype
    Specified by:
      `setCategoryPath` in interface `DataType`
    Overrides:
      `setCategoryPath` in class `AbstractDataType`
    Parameters:
      `path` - the new path
    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(String name)
    Description copied from interface: `DataType`
    Sets the name of the datatype
    Specified by:
      `setName` in interface `DataType`
    Overrides:
      `setName` in class `AbstractDataType`
    Parameters:
      `name` - the new name for this datatype.
    See Also:
      - `DataType.setName(java.lang.String)`

  - ### setNameAndCategory

    public void setNameAndCategory(CategoryPath path, 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 interface `DataType`
    Overrides:
      `setNameAndCategory` in class `AbstractDataType`
    Parameters:
      `path` - the new category path.
      `name` - the new name
    Throws:
      `InvalidNameException` - if the name is invalid
      `DuplicateNameException` - if name change on stored `DataType` is a duplicate of another datatype within the same category (only applies to DB stored `DataType`).
    See Also:
      - `DataType.setNameAndCategory(ghidra.program.model.data.CategoryPath, java.lang.String)`

  - ### 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.

    Specified by:
      `dataTypeDeleted` in interface `DataType`
    Overrides:
      `dataTypeDeleted` in class `AbstractDataType`
    Parameters:
      `dt` - the datatype that has been deleted.
    See Also:
      - `DataType.dataTypeDeleted(ghidra.program.model.data.DataType)`

  - ### dataTypeNameChanged

    public void dataTypeNameChanged(DataType dt, String oldName)
    Description copied from interface: `DataType`
    Informs this datatype that its name has changed from the indicated old name.

    TODO: This method is reserved for internal DB use.

    Specified by:
      `dataTypeNameChanged` in interface `DataType`
    Overrides:
      `dataTypeNameChanged` in class `AbstractDataType`
    Parameters:
      `dt` - the datatype whose name changed
      `oldName` - the datatype'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: `DataType`
    Informs this datatype that the given oldDT has been replaced with newDT

    TODO: This method is reserved for internal DB use.

    Specified by:
      `dataTypeReplaced` in interface `DataType`
    Overrides:
      `dataTypeReplaced` in class `AbstractDataType`
    Parameters:
      `oldDt` - old datatype
      `newDt` - new datatype
    See Also:
      - `DataType.dataTypeReplaced(ghidra.program.model.data.DataType, ghidra.program.model.data.DataType)`

  - ### dependsOn

    public boolean dependsOn(DataType dt)
    Description copied from interface: `DataType`
    Check 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:
      `dependsOn` in interface `DataType`
    Overrides:
      `dependsOn` in class `AbstractDataType`
    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: `DataType`
    Inform this data type that it has the given parent
    TODO: This method is reserved for internal DB use.
    Specified by:
      `addParent` in interface `DataType`
    Overrides:
      `addParent` in class `DataTypeImpl`
    Parameters:
      `dt` - parent data type
    See Also:
      - `DataType.addParent(ghidra.program.model.data.DataType)`

  - ### removeParent

    public void removeParent(DataType dt)
    Description copied from interface: `DataType`
    Remove a parent datatype

    TODO: This method is reserved for internal DB use.

    Specified by:
      `removeParent` in interface `DataType`
    Overrides:
      `removeParent` in class `DataTypeImpl`
    Parameters:
      `dt` - parent datatype
    See Also:
      - `DataType.removeParent(ghidra.program.model.data.DataType)`

  - ### getLastChangeTime

    public long getLastChangeTime()
    Description copied from interface: `DataType`
    Get the timestamp corresponding to the last time this type was changed within its datatype manager
    Specified by:
      `getLastChangeTime` in interface `DataType`
    Overrides:
      `getLastChangeTime` in class `DataTypeImpl`
    Returns:
      timestamp of last change within datatype manager