Interface DataTypeComponent

  • All Known Subinterfaces:
    InternalDataTypeComponent
    All Known Implementing Classes:
    DataTypeComponentImpl, ReadOnlyDataTypeComponent

    public interface DataTypeComponent
    DataTypeComponents are holders for the dataTypes that make up composite (Structures and Unions) dataTypes.

    While most all components must have a fixed length greater than 0, structures support an optional trailing flexible array component whose length is zero and whose offset equals the length of the structure.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DEFAULT_FIELD_NAME_PREFIX
      The default prefix for the name of a component.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String getComment()
      Get the comment for this dataTypeComponent.
      DataType getDataType()
      Returns the dataType in this component.
      java.lang.String getDefaultFieldName()
      Returns a default Field name.
      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.
      java.lang.String getFieldName()
      Get the name of the field name as a component of a Data Type.
      int getLength()
      Get the length of this component.
      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 isFlexibleArrayComponent()
      Determine if this component corresponds to a unsized flexible array which is permitted as the trailing component within a structure.
      boolean isZeroBitFieldComponent()
      Determine if the specified component corresponds to a zero-length bit-field.
      void setComment​(java.lang.String comment)
      Sets the comment for the component.
      void setDefaultSettings​(Settings settings)
      Set default settings for this dataType.
      void setFieldName​(java.lang.String fieldName)
      Sets the field name.
    • Field Detail

      • DEFAULT_FIELD_NAME_PREFIX

        static final java.lang.String DEFAULT_FIELD_NAME_PREFIX
        The default prefix for the name of a component.
        See Also:
        Constant Field Values
    • Method Detail

      • getDataType

        DataType getDataType()
        Returns the dataType in this component.

        NOTE: If this component corresponds to a structure flexible array the returned data type reflects the base type of the array (e.g., char is returned for a flexible char array).

        Returns:
        the dataType in this component
      • getParent

        DataType getParent()
        returns the dataType that contains this component.
        Returns:
        the dataType that contains this component.
      • isFlexibleArrayComponent

        boolean isFlexibleArrayComponent()
        Determine if this component corresponds to a unsized flexible array which is permitted as the trailing component within a structure.
        Returns:
        true if component is a trailing flexible array component.
      • isBitFieldComponent

        boolean isBitFieldComponent()
        Determine if the specified component corresponds to a bit-field.
        Returns:
        true if bit-field else false
      • isZeroBitFieldComponent

        boolean isZeroBitFieldComponent()
        Determine if the specified component corresponds to a zero-length bit-field.
        Returns:
        true if zer-length bit-field else false
      • getOrdinal

        int getOrdinal()
        Get the ordinal position within the parent dataType.

        NOTE: The special case of a structure flexible array component returns an ordinal equal to the parent structure's Structure.getNumComponents() since it is not included in the list of normal components (see Structure.getFlexibleArrayComponent().

        Returns:
        ordinal of this component within the parent data type.
      • getOffset

        int getOffset()
        Get the byte offset of where this component begins relative to the start of the parent data type.

        NOTE: The special case of a structure flexible array component returns an offset equal to the length of the parent structure since the flexible array component is not included in a structure's length.

        Returns:
        offset of start of component relative to the start of the parent data type.
      • getEndOffset

        int getEndOffset()
        Get the byte offset of where this component ends relative to the start of the parent data type.

        NOTE: The special case of a structure flexible array component returns -1 since its length is undefined.

        Returns:
        offset of end of component relative to the start of the parent data type.
      • getLength

        int getLength()
        Get the length of this component.

        NOTE: The special case of a structure flexible array component returns 0 since its length is undefined.

        Returns:
        the length of this component or 0 for a structure flexible array.
      • getComment

        java.lang.String getComment()
        Get the comment for this dataTypeComponent.
      • getDefaultSettings

        Settings getDefaultSettings()
        Gets the default settings for this data type component.
        Returns:
        a Settings object that is the set of default values for this dataType component
      • setDefaultSettings

        void setDefaultSettings​(Settings settings)
        Set default settings for this dataType.
        Parameters:
        settings - the new default settings.
      • setComment

        void setComment​(java.lang.String comment)
        Sets the comment for the component.
        Parameters:
        comment - this components comment.
      • getFieldName

        java.lang.String getFieldName()
        Get the name of the field name as a component of a Data Type.
        Returns:
        the name as a component of another Data Type.
      • setFieldName

        void setFieldName​(java.lang.String fieldName)
                   throws DuplicateNameException
        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.
        Parameters:
        fieldName - the new field name for this component.
        Throws:
        DuplicateNameException - if another component of the parent has the specified field name.
      • getDefaultFieldName

        java.lang.String getDefaultFieldName()
        Returns a default Field name. Used only if a field name is not set.
      • isEquivalent

        boolean isEquivalent​(DataTypeComponent dtc)
        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, length, ordinal, field name, and comment.
        Parameters:
        dtc - the dataTypeComponent being tested for equivalence.
        Returns:
        true if the given dataTypeComponent is equivalent to this dataTypeComponent.