Package ghidra.program.model.data
Class DataTypeComponentImpl
- java.lang.Object
-
- ghidra.program.model.data.DataTypeComponentImpl
-
- All Implemented Interfaces:
DataTypeComponent,InternalDataTypeComponent,java.io.Serializable
public class DataTypeComponentImpl extends java.lang.Object implements InternalDataTypeComponent, java.io.Serializable
Basic implementation of a DataTypeComponent- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface ghidra.program.model.data.DataTypeComponent
DEFAULT_FIELD_NAME_PREFIX
-
-
Constructor Summary
Constructors Constructor Description DataTypeComponentImpl(DataType dataType, CompositeDataTypeImpl parent, int length, int ordinal, int offset)Create a new DataTypeComponentDataTypeComponentImpl(DataType dataType, CompositeDataTypeImpl parent, int length, int ordinal, int offset, java.lang.String fieldName, java.lang.String comment)Create a new DataTypeComponent
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidcheckDefaultFieldName(java.lang.String fieldName)booleanequals(java.lang.Object obj)java.lang.StringgetComment()Get the comment for this dataTypeComponent.DataTypegetDataType()Returns the dataType in this component.SettingsgetDefaultSettings()Gets the default settings for this data type component.intgetEndOffset()Get the byte offset of where this component ends relative to the start of the parent data type.java.lang.StringgetFieldName()Get the name of the field name as a component of a Data Type.intgetLength()Get the length of this component.intgetOffset()Get the byte offset of where this component begins relative to the start of the parent data type.intgetOrdinal()Get the ordinal position within the parent dataType.DataTypegetParent()returns the dataType that contains this component.inthashCode()booleanisBitFieldComponent()Determine if the specified component corresponds to a bit-field.booleanisEquivalent(DataTypeComponent dtc)Returns true if the given dataTypeComponent is equivalent to this dataTypeComponent.booleanisZeroBitFieldComponent()Determine if the specified component corresponds to a zero-length bit-field.voidsetComment(java.lang.String comment)Sets the comment for the component.voidsetDataType(DataType dt)Sets the DataType for this component.voidsetDefaultSettings(Settings settings)Set default settings for this dataType.voidsetFieldName(java.lang.String name)Sets the field name.java.lang.StringtoString()voidupdate(int ordinal, int offset, int length)Update component ordinal, offset and length during alignment-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ghidra.program.model.data.DataTypeComponent
getDefaultFieldName
-
-
-
-
Constructor Detail
-
DataTypeComponentImpl
public DataTypeComponentImpl(DataType dataType, CompositeDataTypeImpl parent, int length, int ordinal, int offset, java.lang.String fieldName, java.lang.String comment)
Create a new DataTypeComponent- Parameters:
dataType- the dataType for this componentparent- the dataType that this component belongs tolength- the length of the dataType in this component.ordinal- the index within its parent.offset- the byte offset within the parentfieldName- the name associated with this componentcomment- the comment associated with this component
-
DataTypeComponentImpl
public DataTypeComponentImpl(DataType dataType, CompositeDataTypeImpl parent, int length, int ordinal, int offset)
Create a new DataTypeComponent- Parameters:
dataType- the dataType for this componentparent- the dataType that this component belongs tolength- the length of the dataType in this component.ordinal- the index of this component within its parent.offset- the byte offset within the parent
-
-
Method Detail
-
isBitFieldComponent
public boolean isBitFieldComponent()
Description copied from interface:DataTypeComponentDetermine if the specified component corresponds to a bit-field.- Specified by:
isBitFieldComponentin interfaceDataTypeComponent- Returns:
- true if bit-field else false
-
isZeroBitFieldComponent
public boolean isZeroBitFieldComponent()
Description copied from interface:DataTypeComponentDetermine if the specified component corresponds to a zero-length bit-field.- Specified by:
isZeroBitFieldComponentin interfaceDataTypeComponent- Returns:
- true if zero-length bit-field else false
-
getOffset
public int getOffset()
Description copied from interface:DataTypeComponentGet the byte offset of where this component begins relative to the start of the parent data type.- Specified by:
getOffsetin interfaceDataTypeComponent- Returns:
- offset of start of component relative to the start of the parent data type.
-
getEndOffset
public int getEndOffset()
Description copied from interface:DataTypeComponentGet the byte offset of where this component ends relative to the start of the parent data type.- Specified by:
getEndOffsetin interfaceDataTypeComponent- Returns:
- offset of end of component relative to the start of the parent data type.
-
getComment
public java.lang.String getComment()
Description copied from interface:DataTypeComponentGet the comment for this dataTypeComponent.- Specified by:
getCommentin interfaceDataTypeComponent- Returns:
- component comment string or null if one has not been set
-
setComment
public void setComment(java.lang.String comment)
Description copied from interface:DataTypeComponentSets the comment for the component.- Specified by:
setCommentin interfaceDataTypeComponent- Parameters:
comment- this components comment or null to clear comment.
-
getFieldName
public java.lang.String getFieldName()
Description copied from interface:DataTypeComponentGet the name of the field name as a component of a Data Type.- Specified by:
getFieldNamein interfaceDataTypeComponent- Returns:
- the name as a component of another Data Type.
-
setFieldName
public void setFieldName(java.lang.String name) throws DuplicateNameExceptionDescription copied from interface:DataTypeComponentSets 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:
setFieldNamein interfaceDataTypeComponent- Parameters:
name- the new field name for this component.- Throws:
DuplicateNameException- if another component of the parent has the specified field name.
-
checkDefaultFieldName
public static void checkDefaultFieldName(java.lang.String fieldName) throws DuplicateNameException- Throws:
DuplicateNameException
-
getDataType
public DataType getDataType()
Description copied from interface:DataTypeComponentReturns the dataType in this component.- Specified by:
getDataTypein interfaceDataTypeComponent- Returns:
- the dataType in this component
-
getParent
public DataType getParent()
Description copied from interface:DataTypeComponentreturns the dataType that contains this component.- Specified by:
getParentin interfaceDataTypeComponent- Returns:
- the dataType that contains this component.
-
update
public void update(int ordinal, int offset, int length)Description copied from interface:InternalDataTypeComponentUpdate component ordinal, offset and length during alignment- Specified by:
updatein interfaceInternalDataTypeComponent- Parameters:
ordinal- updated ordinaloffset- updated offsetlength- updated byte length
-
getLength
public int getLength()
Description copied from interface:DataTypeComponentGet the length of this component. 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:
getLengthin interfaceDataTypeComponent- Returns:
- the length of this component
-
getOrdinal
public int getOrdinal()
Description copied from interface:DataTypeComponentGet the ordinal position within the parent dataType.- Specified by:
getOrdinalin interfaceDataTypeComponent- Returns:
- ordinal of this component within the parent data type.
-
getDefaultSettings
public Settings getDefaultSettings()
Description copied from interface:DataTypeComponentGets the default settings for this data type component.- Specified by:
getDefaultSettingsin interfaceDataTypeComponent- Returns:
- a Settings object that is the set of default values for this dataType component
-
setDefaultSettings
public void setDefaultSettings(Settings settings)
Description copied from interface:DataTypeComponentSet default settings for this dataType.- Specified by:
setDefaultSettingsin interfaceDataTypeComponent- Parameters:
settings- the new default settings.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
isEquivalent
public boolean isEquivalent(DataTypeComponent dtc)
Description copied from interface:DataTypeComponentReturns 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 dyanmic and whose size must be specified when creating a component.- Specified by:
isEquivalentin interfaceDataTypeComponent- Parameters:
dtc- the dataTypeComponent being tested for equivalence.- Returns:
- true if the given dataTypeComponent is equivalent to this dataTypeComponent.
-
setDataType
public void setDataType(DataType dt)
Description copied from interface:InternalDataTypeComponentSets the DataType for this component. Must be used carefully since the component will not be resized.- Specified by:
setDataTypein interfaceInternalDataTypeComponent- Parameters:
dt- the new DataType for this component
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-