Package ghidra.program.model.data
Class DataTypeComponentImpl
java.lang.Object
ghidra.program.model.data.DataTypeComponentImpl
- All Implemented Interfaces:
- DataTypeComponent,- InternalDataTypeComponent,- Serializable
public class DataTypeComponentImpl
extends Object
implements InternalDataTypeComponent, Serializable
Basic implementation of a DataTypeComponent
- See Also:
- 
Field SummaryFields inherited from interface ghidra.program.model.data.DataTypeComponentDEFAULT_FIELD_NAME_PREFIX
- 
Constructor SummaryConstructorsConstructorDescriptionDataTypeComponentImpl(DataType dataType, CompositeDataTypeImpl parent, int length, int ordinal, int offset) Create a new DataTypeComponentDataTypeComponentImpl(DataType dataType, CompositeDataTypeImpl parent, int length, int ordinal, int offset, String fieldName, String comment) Create a new DataTypeComponent
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidcheckDefaultFieldName(String fieldName) booleanGet the comment for this dataTypeComponent.Returns the dataType in this component.Gets the default settings for this data type component.intGet the byte offset of where this component ends relative to the start of the parent data type.Get this component's field name within its parent.intGet the length of this component in 8-bit bytes.intGet the byte offset of where this component begins relative to the start of the parent data type.intGet the ordinal position within the parent dataType.returns the dataType that contains this component.static intgetPreferredComponentLength(DataType dataType, int length) Get the preferred length for a new component.inthashCode()booleanDetermine if the specified component corresponds to a bit-field.booleanReturns true if the given dataTypeComponent is equivalent to this dataTypeComponent.booleanReturns true if this component is not defined.booleanDetermine if the specified component corresponds to a zero-length bit-field.voidsetComment(String comment) Sets the comment for the component.voidsetDataType(DataType dt) Sets the DataType for this component.voidsetFieldName(String name) Sets the field name.toString()voidupdate(int newOrdinal, int newOffset, int newLength) Update component ordinal, offset and length during alignmentMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface ghidra.program.model.data.DataTypeComponentgetDefaultFieldNameMethods inherited from interface ghidra.program.model.data.InternalDataTypeComponentcleanupFieldName
- 
Constructor Details- 
DataTypeComponentImplpublic DataTypeComponentImpl(DataType dataType, CompositeDataTypeImpl 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 within its parent.
- offset- the byte offset within the parent
- fieldName- the name associated with this component
- comment- the comment associated with this component
 
- 
DataTypeComponentImplpublic DataTypeComponentImpl(DataType dataType, CompositeDataTypeImpl 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 within its parent.
- offset- the byte offset within the parent
 
 
- 
- 
Method Details- 
isBitFieldComponentpublic boolean isBitFieldComponent()Description copied from interface:DataTypeComponentDetermine if the specified component corresponds to a bit-field.- Specified by:
- isBitFieldComponentin interface- DataTypeComponent
- Returns:
- true if bit-field else false
 
- 
isZeroBitFieldComponentpublic boolean isZeroBitFieldComponent()Description copied from interface:DataTypeComponentDetermine if the specified component corresponds to a zero-length bit-field.- Specified by:
- isZeroBitFieldComponentin interface- DataTypeComponent
- Returns:
- true if zero-length bit-field else false
 
- 
getOffsetpublic 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 interface- DataTypeComponent
- Returns:
- offset of start of component relative to the start of the parent data type.
 
- 
getEndOffsetpublic 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 interface- DataTypeComponent
- Returns:
- offset of end of component relative to the start of the parent data type.
 
- 
getCommentDescription copied from interface:DataTypeComponentGet the comment for this dataTypeComponent.- Specified by:
- getCommentin interface- DataTypeComponent
- Returns:
- component comment string or null if one has not been set
 
- 
setCommentDescription copied from interface:DataTypeComponentSets the comment for the component.- Specified by:
- setCommentin interface- DataTypeComponent
- Parameters:
- comment- this components comment or null to clear comment.
 
- 
getFieldNameDescription copied from interface:DataTypeComponentGet this component's field name within its parent. If this method returns nullDataTypeComponent.getDefaultFieldName()can be used to obtain a default generated field name.- Specified by:
- getFieldNamein interface- DataTypeComponent
- Returns:
- this component's field name within its parent or null if one has not been set.
 
- 
setFieldNameDescription 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 interface- DataTypeComponent
- Parameters:
- name- 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.
 
- 
checkDefaultFieldName- Throws:
- DuplicateNameException
 
- 
getDataTypeDescription copied from interface:DataTypeComponentReturns the dataType in this component.- Specified by:
- getDataTypein interface- DataTypeComponent
- Returns:
- the dataType in this component
 
- 
getParentDescription copied from interface:DataTypeComponentreturns the dataType that contains this component.- Specified by:
- getParentin interface- DataTypeComponent
- Returns:
- the dataType that contains this component.
 
- 
updatepublic void update(int newOrdinal, int newOffset, int newLength) Description copied from interface:InternalDataTypeComponentUpdate component ordinal, offset and length during alignment- Specified by:
- updatein interface- InternalDataTypeComponent
- Parameters:
- newOrdinal- updated ordinal
- newOffset- updated offset
- newLength- updated byte length
 
- 
getLengthpublic int getLength()Description copied from interface:DataTypeComponentGet 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:
- getLengthin interface- DataTypeComponent
- Returns:
- the length of this component in 8-bit bytes
 
- 
getOrdinalpublic int getOrdinal()Description copied from interface:DataTypeComponentGet the ordinal position within the parent dataType.- Specified by:
- getOrdinalin interface- DataTypeComponent
- Returns:
- ordinal of this component within the parent data type.
 
- 
getDefaultSettingsDescription copied from interface:DataTypeComponentGets the default settings for this data type component.- Specified by:
- getDefaultSettingsin interface- DataTypeComponent
- Returns:
- a Settings object that is the set of default values for this dataType component
 
- 
hashCodepublic int hashCode()
- 
equals
- 
isEquivalentDescription 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 dynamic and whose size must be specified when creating a component.- Specified by:
- isEquivalentin interface- DataTypeComponent
- Parameters:
- dtc- the dataTypeComponent being tested for equivalence.
- Returns:
- true if the given dataTypeComponent is equivalent to this dataTypeComponent.
 
- 
setDataTypeDescription copied from interface:InternalDataTypeComponentSets the DataType for this component. Must be used carefully since the component will not be resized.- Specified by:
- setDataTypein interface- InternalDataTypeComponent
- Parameters:
- dt- the new DataType for this component
 
- 
isUndefinedpublic boolean isUndefined()Description copied from interface:DataTypeComponentReturns true if this component is not defined. It is just a placeholder.- Specified by:
- isUndefinedin interface- DataTypeComponent
- Returns:
- true if this component is not defined. It is just a placeholder.
 
- 
toString
- 
getPreferredComponentLengthGet the preferred length for a new component. The length returned will be no larger than the specified length.- Parameters:
- dataType- new component datatype
- length- constrained length or -1 to force use of dataType size. Dynamic types such as string must have a positive length specified.
- Returns:
- preferred component length
- Throws:
- IllegalArgumentException- if length not specified for a- DynamicdataType.
 
 
-