Class EnumDataType

    • Constructor Detail

      • EnumDataType

        public EnumDataType​(java.lang.String name,
                            int length)
      • EnumDataType

        public EnumDataType​(CategoryPath path,
                            java.lang.String name,
                            int length)
    • Method Detail

      • getValue

        public long getValue​(java.lang.String valueName)
                      throws java.util.NoSuchElementException
        Description copied from interface: Enum
        Get the value for the given name.
        Specified by:
        getValue in interface Enum
        Parameters:
        valueName - name of the entry.
        Returns:
        the value.
        Throws:
        java.util.NoSuchElementException - if the name does not exist in this Enum.
      • getName

        public java.lang.String getName​(long value)
        Description copied from interface: Enum
        Get the name for the given value.
        Specified by:
        getName in interface Enum
        Parameters:
        value - value of the enum entry.
        Returns:
        null if the name with the given value was not found.
      • getComment

        public java.lang.String getComment​(java.lang.String valueName)
        Description copied from interface: Enum
        Get the comment for the given name.
        Specified by:
        getComment in interface Enum
        Parameters:
        valueName - name of the entry.
        Returns:
        the comment or the empty string if the name does not exist in this enum or if no comment is set.
      • getValues

        public long[] getValues()
        Description copied from interface: Enum
        Get the values of the enum entries.
        Specified by:
        getValues in interface Enum
        Returns:
        values sorted in ascending order
      • getNames

        public java.lang.String[] getNames()
        Description copied from interface: Enum
        Get the names of the enum entries. The returned names are first sorted by the enum int value, then sub-sorted by name value where there are multiple name values per int value.
        Specified by:
        getNames in interface Enum
        Returns:
        the names of the enum entries.
      • getCount

        public int getCount()
        Description copied from interface: Enum
        Get the number of entries in this Enum.
        Specified by:
        getCount in interface Enum
        Returns:
        the number of entries in this Enum.
      • add

        public void add​(java.lang.String valueName,
                        long value)
        Description copied from interface: Enum
        Add a enum entry.
        Specified by:
        add in interface Enum
        Parameters:
        valueName - name of the new entry
        value - value of the new entry
      • add

        public void add​(java.lang.String valueName,
                        long value,
                        java.lang.String comment)
        Description copied from interface: Enum
        Add a enum entry.
        Specified by:
        add in interface Enum
        Parameters:
        valueName - name of the new entry
        value - value of the new entry
        comment - comment of the new entry
      • remove

        public void remove​(java.lang.String valueName)
        Description copied from interface: Enum
        Remove the enum entry with the given name.
        Specified by:
        remove in interface Enum
        Parameters:
        valueName - name of entry to remove.
      • copy

        public DataType copy​(DataTypeManager dtm)
        Description copied from interface: DataType
        Returns a new instance (shallow copy) of this DataType with a new identity.

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

        Specified by:
        copy in interface DataType
        Parameters:
        dtm - the data-type manager instance whose data-organization should apply.
        Returns:
        new instanceof of this datatype
      • clone

        public DataType clone​(DataTypeManager dtm)
        Description copied from interface: DataType
        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.

        Specified by:
        clone in interface DataType
        Parameters:
        dtm - the data-type manager instance whose data-organization should apply.
        Returns:
        cloned instance which may be the same as this instance
      • 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
        Overrides:
        getMnemonic in class AbstractDataType
        Parameters:
        settings - settings which may influence the result or null
        Returns:
        the mnemonic for this DataType.
      • setLength

        public void setLength​(int length)
      • getDescription

        public java.lang.String getDescription()
        Description copied from interface: DataType
        Get a String briefly describing this DataType.
        Specified by:
        getDescription in interface DataType
        Returns:
        a one-liner describing this DataType.
      • setDescription

        public void setDescription​(java.lang.String description)
        Description copied from class: DataTypeImpl
        Sets a String briefly describing this DataType.
        If a data type that extends this class wants to allow the description to be changed, then it must override this method.
        Specified by:
        setDescription in interface DataType
        Specified by:
        setDescription in interface Enum
        Overrides:
        setDescription in class DataTypeImpl
        Parameters:
        description - a one-liner describing this DataType.
      • getValue

        public java.lang.Object getValue​(MemBuffer buf,
                                         Settings settings,
                                         int valueLength)
        Description copied from interface: DataType
        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

        Specified by:
        getValue in interface DataType
        Parameters:
        buf - the data buffer.
        settings - the settings to use.
        valueLength - the number of bytes to get the value from.
        Returns:
        the data Object.
      • getValueClass

        public java.lang.Class<?> getValueClass​(Settings settings)
        Description copied from interface: DataType
        Get the Class of the value to be returned by this datatype.
        Specified by:
        getValueClass in interface DataType
        Overrides:
        getValueClass in class DataTypeImpl
        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.
      • getRepresentation

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

        public java.lang.String getRepresentation​(java.math.BigInteger bigInt,
                                                  Settings settings,
                                                  int bitLength)
        Description copied from interface: Enum
        Get enum representation of the big-endian value.
        Specified by:
        getRepresentation in interface Enum
        Parameters:
        bigInt - BigInteger value with the appropriate sign
        settings - integer format settings (PADDING, FORMAT, etc.)
        bitLength - the bit length
        Returns:
        formatted integer string
      • isEquivalent

        public boolean isEquivalent​(DataType dt)
        Description copied from interface: DataType
        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.

        Specified by:
        isEquivalent in interface DataType
        Parameters:
        dt - the datatype being tested for equivalence.
        Returns:
        true if the if the given datatype is equivalent to this datatype.
      • 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
        Overrides:
        replaceWith in class DataTypeImpl
      • 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
        Overrides:
        getDefaultLabelPrefix in class AbstractDataType
        Returns:
        the default label prefix or null if none specified.