Interface DataType

    • Method Detail

      • hasLanguageDependantLength

        boolean hasLanguageDependantLength()
        Indicates if the length of this data-type is determined based upon the DataOrganization obtained from the associated DataTypeManager.
        Returns:
        true length is language/compiler-specification dependent, else false
      • getSettingsDefinitions

        SettingsDefinition[] getSettingsDefinitions()
        Gets a list of all the settingsDefinitions used by this datatype.
        Returns:
        a list of the settingsDefinitions used by this datatype.
      • getDefaultSettings

        Settings getDefaultSettings()
        Gets the default settings for this datatype.
        Returns:
        the default settings for this datatype.
      • clone

        DataType clone​(DataTypeManager dtm)
        Returns an instance of this DataType with its universalID and SourceArchive identity retained.

        The current instanceof will be returned if this datatype's DataTypeManager matches the specified dtm. The recursion depth of a clone will stop on any datatype whose DataTypeManager matches the specified dtm and simply use the existing datatype instance.

        Parameters:
        dtm - the data-type manager instance whose data-organization should apply.
        Returns:
        cloned instance which may be the same as this instance
      • copy

        DataType copy​(DataTypeManager dtm)
        Returns a new instance (shallow copy) of this DataType with a new identity.

        Any reference to other datatypes will use clone(DataTypeManager).

        Parameters:
        dtm - the data-type manager instance whose data-organization should apply.
        Returns:
        new instanceof of this datatype
      • getCategoryPath

        CategoryPath getCategoryPath()
        Gets the categoryPath associated with this datatype
        Returns:
        the datatype's category path
      • getDataTypePath

        DataTypePath getDataTypePath()
        Returns the dataTypePath for this datatype;
        Returns:
        the dataTypePath for this datatype;
      • setCategoryPath

        void setCategoryPath​(CategoryPath path)
                      throws DuplicateNameException
        Set the categoryPath associated with this 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.
      • getDataTypeManager

        DataTypeManager getDataTypeManager()
        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.

        Returns:
        the DataTypeManager that is associated with this datatype.
      • getDisplayName

        java.lang.String getDisplayName()
        Gets the name for referring to this datatype.
        Returns:
        generic name for this Data Type (i.e.: Word)
      • getName

        java.lang.String getName()
        Get the name of this datatype.
        Returns:
        the name
      • getPathName

        java.lang.String getPathName()
        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.

        Returns:
        the path, or just this type's name
      • getMnemonic

        java.lang.String getMnemonic​(Settings settings)
        Get the mnemonic for this DataType.
        Parameters:
        settings - settings which may influence the result or null
        Returns:
        the mnemonic for this DataType.
      • getLength

        int getLength()
        Get the length (number of 8-bit bytes) of this DataType.

        NOTE: No datatype should ever return 0, even if isZeroLength(), and only Dynamic datatypes should return -1. If isZeroLength() is true a length of 1 should be returned. Where a zero-length datatype can be handled (e.g., Composite) the isZeroLength() method should be used.

        Returns:
        the length of this DataType
      • isZeroLength

        boolean isZeroLength()
        Indicates this datatype is defined with a zero length.

        This method should not be confused with 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 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.

        Returns:
        true if type definition has a length of 0, else false
      • isNotYetDefined

        boolean isNotYetDefined()
        Indicates if this datatype has not yet been fully defined.

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

        Returns:
        true if this type is not yet defined.
      • getDescription

        java.lang.String getDescription()
        Get a String briefly describing this DataType.
        Returns:
        a one-liner describing this DataType.
      • setDescription

        void setDescription​(java.lang.String description)
                     throws java.lang.UnsupportedOperationException
        Sets a String briefly describing this 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.
      • getDocs

        java.net.URL getDocs()
        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.

        Returns:
        null - there is no URL documentation for this prototype.
      • getValue

        java.lang.Object getValue​(MemBuffer buf,
                                  Settings settings,
                                  int length)
        Get the data in the form of the appropriate Object for this DataType.

        For instance if the datatype is an AddressDT, return an Address object. a Byte, return a Scalar* (maybe this should be a Byte) a Float, return a Float

        Parameters:
        buf - the data buffer.
        settings - the settings to use.
        length - the number of bytes to get the value from.
        Returns:
        the data Object.
      • encodeValue

        byte[] encodeValue​(java.lang.Object value,
                           MemBuffer buf,
                           Settings settings,
                           int length)
                    throws DataTypeEncodeException
        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.

        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 isEncodable()).
      • getValueClass

        java.lang.Class<?> getValueClass​(Settings settings)
        Get the Class of the value to be returned by this datatype.
        Parameters:
        settings - the relevant settings to use or null for default.
        Returns:
        Class of the value to be returned by this datatype or null if it can vary or is unspecified. Types which correspond to a string or char array will return the String class.
      • getDefaultLabelPrefix

        java.lang.String getDefaultLabelPrefix()
        Returns the appropriate string to use as the default label prefix in the absence of any data.
        Returns:
        the default label prefix or null if none specified.
      • getDefaultAbbreviatedLabelPrefix

        java.lang.String getDefaultAbbreviatedLabelPrefix()
        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.

        Returns:
        the prefix to use for this datatype when an abbreviated prefix is desired. May return null.
      • getDefaultLabelPrefix

        java.lang.String getDefaultLabelPrefix​(MemBuffer buf,
                                               Settings settings,
                                               int len,
                                               DataTypeDisplayOptions options)
        Returns the appropriate string to use as the default label prefix.
        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

        java.lang.String getDefaultOffcutLabelPrefix​(MemBuffer buf,
                                                     Settings settings,
                                                     int len,
                                                     DataTypeDisplayOptions options,
                                                     int offcutOffset)
        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

        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.
        offcutOffset - offset into datatype
        Returns:
        the default label prefix.
      • getRepresentation

        java.lang.String getRepresentation​(MemBuffer buf,
                                           Settings settings,
                                           int length)
        Get bytes from memory in a printable format for this type.
        Parameters:
        buf - the data.
        settings - the settings to use for the representation.
        length - the number of bytes to represent.
        Returns:
        the representation of the data in this format, never null.
      • encodeRepresentation

        byte[] encodeRepresentation​(java.lang.String repr,
                                    MemBuffer buf,
                                    Settings settings,
                                    int length)
                             throws DataTypeEncodeException
        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.

        Parameters:
        repr - the representation of the desired value, as in 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 isEncodable()).
      • isDeleted

        boolean isDeleted()
        Returns true if this datatype has been deleted and is no longer valid
        Returns:
        true if this datatype has been deleted and is no longer valid.
      • isEquivalent

        boolean isEquivalent​(DataType dt)
        Check if the given datatype is equivalent to this datatype.

        The precise meaning of "equivalent" is datatype dependent.
        NOTE: if invoked by a DB object or manager it should be invoked on the DataTypeDB object passing the other datatype as the argument.

        Parameters:
        dt - the datatype being tested for equivalence.
        Returns:
        true if the if the given datatype is equivalent to this datatype.
      • dataTypeSizeChanged

        void dataTypeSizeChanged​(DataType dt)
        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.

        Parameters:
        dt - the datatype that has changed.
      • dataTypeAlignmentChanged

        void dataTypeAlignmentChanged​(DataType dt)
        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.

        Parameters:
        dt - the datatype that has changed.
      • dataTypeDeleted

        void dataTypeDeleted​(DataType dt)
        Informs this datatype that the given datatype has been deleted.

        TODO: This method is reserved for internal DB use.

        Parameters:
        dt - the datatype that has been deleted.
      • dataTypeReplaced

        void dataTypeReplaced​(DataType oldDt,
                              DataType newDt)
        Informs this datatype that the given oldDT has been replaced with newDT

        TODO: This method is reserved for internal DB use.

        Parameters:
        oldDt - old datatype
        newDt - new datatype
      • setDefaultSettings

        void setDefaultSettings​(Settings settings)
        Set the default settings for this datatype.

        TODO: This method is reserved for internal DB use.

        Parameters:
        settings - the settings to be used as this dataTypes default settings.
      • addParent

        void addParent​(DataType dt)
        Inform this datatype that it has the given parent

        TODO: This method is reserved for internal DB use.

        Parameters:
        dt - parent datatype
      • removeParent

        void removeParent​(DataType dt)
        Remove a parent datatype

        TODO: This method is reserved for internal DB use.

        Parameters:
        dt - parent datatype
      • dataTypeNameChanged

        void dataTypeNameChanged​(DataType dt,
                                 java.lang.String oldName)
        Informs this datatype that its name has changed from the indicated old name.

        TODO: This method is reserved for internal DB use.

        Parameters:
        dt - the datatype whose name changed
        oldName - the datatype's old name
      • getParents

        DataType[] getParents()
        Get the parents of this datatype
        Returns:
        an array of parents of this datatype
      • getAlignment

        int getAlignment()
        Gets the alignment to be used when aligning this datatype within another datatype.
        Returns:
        this datatype's alignment.
      • dependsOn

        boolean dependsOn​(DataType dt)
        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.

        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

        SourceArchive getSourceArchive()
        Get the source archive where this type originated
        Returns:
        source archive object
      • setSourceArchive

        void setSourceArchive​(SourceArchive archive)
        Set the source archive where this type originated
        Parameters:
        archive - source archive object
      • getLastChangeTime

        long getLastChangeTime()
        Get the timestamp corresponding to the last time this type was changed within its datatype manager
        Returns:
        timestamp of last change within datatype manager
      • getLastChangeTimeInSourceArchive

        long getLastChangeTimeInSourceArchive()
        Get the timestamp corresponding to the last time this type was sync'd within its source archive
        Returns:
        timestamp of last sync with source archive
      • getUniversalID

        UniversalID getUniversalID()
        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.

        Returns:
        datatype UniversalID
      • replaceWith

        void replaceWith​(DataType 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.

        Parameters:
        datatype - the datatype that contains the internals to upgrade to.
        Throws:
        java.lang.UnsupportedOperationException - if the datatype does not support change.
        java.lang.IllegalArgumentException - if the given datatype is not the same type as this datatype.
      • setLastChangeTime

        void setLastChangeTime​(long lastChangeTime)
        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.

        Parameters:
        lastChangeTime - the time to use as the lastChangeTime for this datatype
      • setLastChangeTimeInSourceArchive

        void setLastChangeTimeInSourceArchive​(long lastChangeTimeInSourceArchive)
        Sets the lastChangeTimeInSourceArchive for this datatype.

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

        Parameters:
        lastChangeTimeInSourceArchive - the time to use as the lastChangeTimeInSourceArchive for this datatype
      • getDataOrganization

        DataOrganization getDataOrganization()
        Returns the DataOrganization associated with this data-type
        Returns:
        associated data organization