Package ghidra.program.model.data

# Class ReadOnlyDataTypeComponent

java.lang.Object
ghidra.program.model.data.ReadOnlyDataTypeComponent

All Implemented Interfaces:
  `DataTypeComponent`, `Serializable`

public class ReadOnlyDataTypeComponent extends Object implements DataTypeComponent, Serializable
DataTypeComponents from dataTypes that can not be modified.

See Also:
  - Serialized Form

- ## Field Summary

  ### Fields inherited from interface ghidra.program.model.data.DataTypeComponent

  `DEFAULT_FIELD_NAME_PREFIX`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ReadOnlyDataTypeComponent(DataType dataType, DynamicDataType parent, int length, int ordinal, int offset)`
  Create a new DataTypeComponent
  `ReadOnlyDataTypeComponent(DataType dataType, DynamicDataType parent, int length, int ordinal, int offset, String fieldName, String comment)`
  Create a new DataTypeComponent

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  `String`
  `getComment()`
  Get the comment for this dataTypeComponent.
  `DataType`
  `getDataType()`
  Returns the dataType in this component.
  `Settings`
  `getDefaultSettings()`
  Gets the default settings for this data type component.
  `int`
  `getEndOffset()`
  Get the byte offset of where this component ends relative to the start of the parent data type.
  `String`
  `getFieldName()`
  Get this component's field name within its parent.
  `int`
  `getLength()`
  Get the length of this component in 8-bit bytes.
  `int`
  `getOffset()`
  Get the byte offset of where this component begins relative to the start of the parent data type.
  `int`
  `getOrdinal()`
  Get the ordinal position within the parent dataType.
  `DataType`
  `getParent()`
  returns the dataType that contains this component.
  `boolean`
  `isBitFieldComponent()`
  Determine if the specified component corresponds to a bit-field.
  `boolean`
  `isEquivalent(DataTypeComponent dtc)`
  Returns true if the given dataTypeComponent is equivalent to this dataTypeComponent.
  `boolean`
  `isUndefined()`
  Returns true if this component is not defined.
  `boolean`
  `isZeroBitFieldComponent()`
  Determine if the specified component corresponds to a zero-length bit-field.
  `void`
  `setComment(String comment)`
  Sets the comment for the component.
  `void`
  `setFieldName(String fieldName)`
  Sets the field name.

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

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

  ### Methods inherited from interface ghidra.program.model.data.DataTypeComponent

  `getDefaultFieldName, isDefaultFieldName`

- ## Constructor Details

  - ### ReadOnlyDataTypeComponent

    public ReadOnlyDataTypeComponent(DataType dataType, DynamicDataType parent, int length, int ordinal, int offset, String fieldName, String comment)
    Create a new DataTypeComponent
    Parameters:
      `dataType` - the dataType for this component
      `parent` - the dataType that this component belongs to
      `length` - the length of the dataType in this component.
      `ordinal` - the index of this component in the parent.
      `offset` - the byte offset within the parent
      `fieldName` - the name associated with this component
      `comment` - the comment associated with ths component

  - ### ReadOnlyDataTypeComponent

    public ReadOnlyDataTypeComponent(DataType dataType, DynamicDataType parent, int length, int ordinal, int offset)
    Create a new DataTypeComponent
    Parameters:
      `dataType` - the dataType for this component
      `parent` - the dataType that this component belongs to
      `length` - the length of the dataType in this component.
      `ordinal` - the index of this component in the parent.
      `offset` - the byte offset within the parent

- ## Method Details

  - ### isBitFieldComponent

    public boolean isBitFieldComponent()
    Description copied from interface: `DataTypeComponent`
    Determine if the specified component corresponds to a bit-field.
    Specified by:
      `isBitFieldComponent` in interface `DataTypeComponent`
    Returns:
      true if bit-field else false

  - ### isZeroBitFieldComponent

    public boolean isZeroBitFieldComponent()
    Description copied from interface: `DataTypeComponent`
    Determine if the specified component corresponds to a zero-length bit-field.
    Specified by:
      `isZeroBitFieldComponent` in interface `DataTypeComponent`
    Returns:
      true if zero-length bit-field else false

  - ### getOffset

    public int getOffset()
    Description copied from interface: `DataTypeComponent`
    Get the byte offset of where this component begins relative to the start of the parent data type.
    Specified by:
      `getOffset` in interface `DataTypeComponent`
    Returns:
      offset of start of component relative to the start of the parent data type.

  - ### getEndOffset

    public int getEndOffset()
    Description copied from interface: `DataTypeComponent`
    Get the byte offset of where this component ends relative to the start of the parent data type.
    Specified by:
      `getEndOffset` in interface `DataTypeComponent`
    Returns:
      offset of end of component relative to the start of the parent data type.

  - ### getComment

    public String getComment()
    Description copied from interface: `DataTypeComponent`
    Get the comment for this dataTypeComponent.
    Specified by:
      `getComment` in interface `DataTypeComponent`
    Returns:
      component comment string or null if one has not been set

  - ### setComment

    public void setComment(String comment)
    Description copied from interface: `DataTypeComponent`
    Sets the comment for the component.
    Specified by:
      `setComment` in interface `DataTypeComponent`
    Parameters:
      `comment` - this components comment or null to clear comment.

  - ### getFieldName

    public String getFieldName()
    Description copied from interface: `DataTypeComponent`
    Get this component's field name within its parent. If this method returns null `DataTypeComponent.getDefaultFieldName()` can be used to obtain a default generated field name.
    Specified by:
      `getFieldName` in interface `DataTypeComponent`
    Returns:
      this component's field name within its parent or null if one has not been set.

  - ### setFieldName

    public void setFieldName(String fieldName) throws DuplicateNameException
    Description copied from interface: `DataTypeComponent`
    Sets the field name. If the field name is empty it will be set to null, which is the default field name. An exception is thrown if one of the parent's other components already has the specified field name.
    Specified by:
      `setFieldName` in interface `DataTypeComponent`
    Parameters:
      `fieldName` - the new field name for this component.
    Throws:
      `DuplicateNameException` - This is actually never thrown anymore. All the other ways of naming fields did not perform this check and it would cause quite a bit of churn to add that exception to all the other methods that affect field names. So to be consistent, we no longer do the check in this method.

  - ### getDataType

    public DataType getDataType()
    Description copied from interface: `DataTypeComponent`
    Returns the dataType in this component.
    Specified by:
      `getDataType` in interface `DataTypeComponent`
    Returns:
      the dataType in this component

  - ### getParent

    public DataType getParent()
    Description copied from interface: `DataTypeComponent`
    returns the dataType that contains this component.
    Specified by:
      `getParent` in interface `DataTypeComponent`
    Returns:
      the dataType that contains this component.

  - ### getLength

    public int getLength()
    Description copied from interface: `DataTypeComponent`
    Get the length of this component in 8-bit bytes. Zero-length components will report a length of 0 and may overlap other components at the same offset. Similarly, multiple adjacent bit-field components may appear to overlap at the byte-level.
    Specified by:
      `getLength` in interface `DataTypeComponent`
    Returns:
      the length of this component in 8-bit bytes

  - ### getOrdinal

    public int getOrdinal()
    Description copied from interface: `DataTypeComponent`
    Get the ordinal position within the parent dataType.
    Specified by:
      `getOrdinal` in interface `DataTypeComponent`
    Returns:
      ordinal of this component within the parent data type.

  - ### getDefaultSettings

    public Settings getDefaultSettings()
    Description copied from interface: `DataTypeComponent`
    Gets the default settings for this data type component.
    Specified by:
      `getDefaultSettings` in interface `DataTypeComponent`
    Returns:
      a Settings object that is the set of default values for this dataType component

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`

  - ### isEquivalent

    public boolean isEquivalent(DataTypeComponent dtc)
    Description copied from interface: `DataTypeComponent`
    Returns true if the given dataTypeComponent is equivalent to this dataTypeComponent. A dataTypeComponent is "equivalent" if the other component has a data type that is equivalent to this component's data type. The dataTypeComponents must also have the same offset, field name, and comment. The length is only checked for components which are dynamic and whose size must be specified when creating a component.
    Specified by:
      `isEquivalent` in interface `DataTypeComponent`
    Parameters:
      `dtc` - the dataTypeComponent being tested for equivalence.
    Returns:
      true if the given dataTypeComponent is equivalent to this dataTypeComponent.

  - ### isUndefined

    public boolean isUndefined()
    Description copied from interface: `DataTypeComponent`
    Returns true if this component is not defined. It is just a placeholder.
    Specified by:
      `isUndefined` in interface `DataTypeComponent`
    Returns:
      true if this component is not defined. It is just a placeholder.