Class AbstractDataType

  • All Implemented Interfaces:
    DataType
    Direct Known Subclasses:
    BitFieldDataType, DataTypeImpl

    public abstract class AbstractDataType
    extends java.lang.Object
    implements DataType
    Base class for DataType classes. Many of the DataType methods are stubbed out so simple datatype classes can be created without implementing too many methods.
    • Constructor Detail

    • Method Detail

      • getCategoryPath

        public CategoryPath getCategoryPath()
        Description copied from interface: DataType
        Gets the categoryPath associated with this datatype
        Specified by:
        getCategoryPath in interface DataType
        Returns:
        the datatype's category path
      • getDataTypeManager

        public final DataTypeManager getDataTypeManager()
        Description copied from interface: DataType
        Get the DataTypeManager containing this datatype.

        This association should not be used to indicate whether this DataType has been resolved, but is intended to indicate whether the appropriate DataOrganization is being used.

        Specified by:
        getDataTypeManager in interface DataType
        Returns:
        the DataTypeManager that is associated with this datatype.
        See Also:
        DataType.getDataTypeManager()
      • getDataOrganization

        public final DataOrganization getDataOrganization()
        Description copied from interface: DataType
        Returns the DataOrganization associated with this data-type
        Specified by:
        getDataOrganization in interface DataType
        Returns:
        associated data organization
      • getDataTypePath

        public DataTypePath getDataTypePath()
        Description copied from interface: DataType
        Returns the dataTypePath for this datatype;
        Specified by:
        getDataTypePath in interface DataType
        Returns:
        the dataTypePath for this datatype;
      • getDocs

        public java.net.URL getDocs()
        Description copied from interface: DataType
        The getDocs method should provide a URL pointing to extended documentation for this DataType if it exists.

        A typical use would be to return a URL pointing to the programmers reference for this instruction or a page describing this data structure.

        Specified by:
        getDocs in interface DataType
        Returns:
        null - there is no URL documentation for this prototype.
      • getName

        public java.lang.String getName()
        Description copied from interface: DataType
        Get the name of this datatype.
        Specified by:
        getName in interface DataType
        Returns:
        the name
      • getPathName

        public java.lang.String getPathName()
        Description copied from interface: DataType
        Get the full category path name that includes this datatype's name.

        If the category is null, then this just the datatype's name is returned.

        Specified by:
        getPathName in interface DataType
        Returns:
        the path, or just this type's name
      • getDisplayName

        public java.lang.String getDisplayName()
        Description copied from interface: DataType
        Gets the name for referring to this datatype.
        Specified by:
        getDisplayName in interface DataType
        Returns:
        generic name for this Data Type (i.e.: Word)
      • getMnemonic

        public java.lang.String getMnemonic​(Settings settings)
        Description copied from interface: DataType
        Get the mnemonic for this DataType.
        Specified by:
        getMnemonic in interface DataType
        Parameters:
        settings - settings which may influence the result or null
        Returns:
        the mnemonic for this DataType.
      • isNotYetDefined

        public boolean isNotYetDefined()
        Description copied from interface: DataType
        Indicates if this datatype has not yet been fully defined.

        Such datatypes should always return a DataType.getLength() of 1 and true for DataType.isZeroLength(). (example: empty structure)

        Specified by:
        isNotYetDefined in interface DataType
        Returns:
        true if this type is not yet defined.
      • isZeroLength

        public boolean isZeroLength()
        Description copied from interface: DataType
        Indicates this datatype is defined with a zero length.

        This method should not be confused with DataType.isNotYetDefined() which indicates that nothing but the name and basic type is known.

        NOTE: a zero-length datatype must return a length of 1 via DataType.getLength(). Zero-length datatypes used as a component within a Composite may, or may not, be assigned a component length of 0. The method DataTypeComponent.usesZeroLengthComponent(DataType) is used to make this determination.

        Specified by:
        isZeroLength in interface DataType
        Returns:
        true if type definition has a length of 0, else false
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isDeleted

        public boolean isDeleted()
        Description copied from interface: DataType
        Returns true if this datatype has been deleted and is no longer valid
        Specified by:
        isDeleted in interface DataType
        Returns:
        true if this datatype has been deleted and is no longer valid.
      • setName

        public void setName​(java.lang.String name)
                     throws InvalidNameException
        Description copied from interface: DataType
        Sets the name of the datatype
        Specified by:
        setName in interface DataType
        Parameters:
        name - the new name for this datatype.
        Throws:
        InvalidNameException - if the given name does not form a valid name.
      • 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
        Parameters:
        dt - the datatype that has changed.
      • dataTypeAlignmentChanged

        public void dataTypeAlignmentChanged​(DataType dt)
        Description copied from interface: DataType
        Notification that the given datatype's alignment has changed.

        DataTypes may need to make internal changes in response.
        TODO: This method is reserved for internal DB use.

        Specified by:
        dataTypeAlignmentChanged in interface DataType
        Parameters:
        dt - the datatype that has changed.
      • 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
        Parameters:
        dt - the datatype that has been deleted.
      • 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
        Parameters:
        oldDt - old datatype
        newDt - new datatype
      • addParent

        public void addParent​(DataType dt)
        Description copied from interface: DataType
        Inform this datatype that it has the given parent

        TODO: This method is reserved for internal DB use.

        Specified by:
        addParent in interface DataType
        Parameters:
        dt - parent 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
        Parameters:
        dt - parent datatype
      • getParents

        public DataType[] getParents()
        Description copied from interface: DataType
        Get the parents of this datatype
        Specified by:
        getParents in interface DataType
        Returns:
        an array of parents of this 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
        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.
      • getSourceArchive

        public SourceArchive getSourceArchive()
        Description copied from interface: DataType
        Get the source archive where this type originated
        Specified by:
        getSourceArchive in interface DataType
        Returns:
        source archive object
      • setSourceArchive

        public void setSourceArchive​(SourceArchive archive)
        Description copied from interface: DataType
        Set the source archive where this type originated
        Specified by:
        setSourceArchive in interface DataType
        Parameters:
        archive - source archive object
      • 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
        Returns:
        timestamp of last change within datatype manager
      • getLastChangeTimeInSourceArchive

        public long getLastChangeTimeInSourceArchive()
        Description copied from interface: DataType
        Get the timestamp corresponding to the last time this type was sync'd within its source archive
        Specified by:
        getLastChangeTimeInSourceArchive in interface DataType
        Returns:
        timestamp of last sync with source archive
      • getUniversalID

        public UniversalID getUniversalID()
        Description copied from interface: DataType
        Get the universal ID for this datatype.

        This value is intended to be a unique identifier across all programs and archives. The same ID indicates that two datatypes were originally the same one. Keep in mind names, categories, and component makeup may differ and have changed since there origin.

        Specified by:
        getUniversalID in interface DataType
        Returns:
        datatype UniversalID
      • dataTypeNameChanged

        public void dataTypeNameChanged​(DataType dt,
                                        java.lang.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
        Parameters:
        dt - the datatype whose name changed
        oldName - the datatype's old name
      • replaceWith

        public void replaceWith​(DataType dataType)
        Description copied from interface: DataType
        For datatypes that support change, this method replaces the internals of this datatype with the internals of the given datatype.

        The datatypes must be of the same "type" (i.e. structure can only be replacedWith another structure.

        Specified by:
        replaceWith in interface DataType
      • setLastChangeTime

        public void setLastChangeTime​(long lastChangeTime)
        Description copied from interface: DataType
        Sets the lastChangeTime for this datatype.

        Normally, this is updated automatically when a datatype is changed, but when committing or updating while synchronizing an archive, the lastChangeTime may need to be updated externally.

        Specified by:
        setLastChangeTime in interface DataType
        Parameters:
        lastChangeTime - the time to use as the lastChangeTime for this datatype
      • setLastChangeTimeInSourceArchive

        public void setLastChangeTimeInSourceArchive​(long lastChangeTimeInSourceArchive)
        Description copied from interface: DataType
        Sets the lastChangeTimeInSourceArchive for this datatype.

        This is used by when a datatype change is committed back to its source archive.

        Specified by:
        setLastChangeTimeInSourceArchive in interface DataType
        Parameters:
        lastChangeTimeInSourceArchive - the time to use as the lastChangeTimeInSourceArchive for this datatype
      • setDescription

        public void setDescription​(java.lang.String description)
                            throws java.lang.UnsupportedOperationException
        Description copied from interface: DataType
        Sets a String briefly describing this DataType.
        Specified by:
        setDescription in interface DataType
        Parameters:
        description - a one-liner describing this DataType.
        Throws:
        java.lang.UnsupportedOperationException - if the description is not allowed to be set for this datatype.
      • hasLanguageDependantLength

        public boolean hasLanguageDependantLength()
        Description copied from interface: DataType
        Indicates if the length of this data-type is determined based upon the DataOrganization obtained from the associated DataTypeManager.
        Specified by:
        hasLanguageDependantLength in interface DataType
        Returns:
        true length is language/compiler-specification dependent, else false
      • getDefaultLabelPrefix

        public java.lang.String getDefaultLabelPrefix()
        Description copied from interface: DataType
        Returns the appropriate string to use as the default label prefix in the absence of any data.
        Specified by:
        getDefaultLabelPrefix in interface DataType
        Returns:
        the default label prefix or null if none specified.
      • getDefaultAbbreviatedLabelPrefix

        public java.lang.String getDefaultAbbreviatedLabelPrefix()
        Description copied from interface: DataType
        Returns the prefix to use for this datatype when an abbreviated prefix is desired.

        For example, some datatypes will built a large default label, at which is is more desirable to have a shortened prefix.

        Specified by:
        getDefaultAbbreviatedLabelPrefix in interface DataType
        Returns:
        the prefix to use for this datatype when an abbreviated prefix is desired. May return null.
      • 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
        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.
      • getDefaultLabelPrefix

        public java.lang.String getDefaultLabelPrefix​(MemBuffer buf,
                                                      Settings settings,
                                                      int len,
                                                      DataTypeDisplayOptions options)
        Description copied from interface: DataType
        Returns the appropriate string to use as the default label prefix.
        Specified by:
        getDefaultLabelPrefix in interface DataType
        Parameters:
        buf - memory buffer containing the bytes.
        settings - the Settings object
        len - the length of the data.
        options - options for how to format the default label prefix.
        Returns:
        the default label prefix or null if none specified.
      • getDefaultOffcutLabelPrefix

        public java.lang.String getDefaultOffcutLabelPrefix​(MemBuffer buf,
                                                            Settings settings,
                                                            int len,
                                                            DataTypeDisplayOptions options,
                                                            int offcutLength)
        Description copied from interface: DataType
        Returns the appropriate string to use as the default label prefix.

        This takes into account the fact that there exists a reference to the data that references offcutLength bytes into this type

        Specified by:
        getDefaultOffcutLabelPrefix in interface DataType
        Parameters:
        buf - memory buffer containing the bytes.
        settings - the Settings object
        len - the length of the data.
        options - options for how to format the default label prefix.
        offcutLength - offset into datatype
        Returns:
        the default label prefix.
      • encodeValue

        public byte[] encodeValue​(java.lang.Object value,
                                  MemBuffer buf,
                                  Settings settings,
                                  int length)
                           throws DataTypeEncodeException
        Description copied from interface: DataType
        Encode bytes from an Object appropriate for this DataType.

        Converts the given object to the byte encoding and returns it. When appropriate, this should seek the nearest encoding to the specified value, since the object may come from a user script. For example, a floating-point value may be rounded. Invalid values should be rejected with a DataTypeEncodeException.

        Specified by:
        encodeValue in interface DataType
        Parameters:
        value - the desired value.
        buf - a buffer representing the eventual destination of the bytes.
        settings - the settings to use.
        length - the expected length of the result, usually the length of the data unit, or -1 to let the type choose the length. It may be ignored, e.g., for fixed-length types.
        Returns:
        the encoded value.
        Throws:
        DataTypeEncodeException - if the value cannot be encoded for any reason, e.g., incorrect type, not enough space, buffer overflow, unsupported (see DataType.isEncodable()).
      • encodeRepresentation

        public byte[] encodeRepresentation​(java.lang.String repr,
                                           MemBuffer buf,
                                           Settings settings,
                                           int length)
                                    throws DataTypeEncodeException
        Description copied from interface: DataType
        Encode bytes according to the display format for this type.

        Converts the given representation to the byte encoding and returns it. When appropriate, this should seek the nearest encoding to the specified value, since the representation is likely coming from user input. For example, a floating-point value may be rounded. Invalid representations should be rejected with a DataTypeEncodeException.

        Specified by:
        encodeRepresentation in interface DataType
        Parameters:
        repr - the representation of the desired value, as in DataType.getRepresentation(MemBuffer, Settings, int). The supported formats depend on the specific datatype and its settings.
        buf - a buffer representing the eventual destination of the bytes.
        settings - the settings to use for the representation.
        length - the expected length of the result, usually the length of the data unit, or -1 to let the type choose the length. It may be ignored, e.g., for fixed-length types.
        Returns:
        the encoded value.
        Throws:
        DataTypeEncodeException - if the value cannot be encoded for any reason, e.g., incorrect format, not enough space, buffer overflow, unsupported (see DataType.isEncodable()).