Class MultiAttributeProvider

  • All Implemented Interfaces:
    Serializable, Cloneable, Iterable<Attribute>, AttributeProvider, JsonableObject
    Direct Known Subclasses:
    MultiAttributeCollection

    public class MultiAttributeProvider
    extends AbstractAttributeProvider
    This class contains a collection of attribute containers and tries to gather the data. This class contains a collection of AttributeContainers and exhibites the values of the attributes of all these containers. This class follows the following rules (in that order) to retreive the value of an attribute:
    1. If the attribute is defined in none of the containers, throws the standard exception;
    2. If the attribute is defined in only one of the containers, replies the attribute value itself;
    3. If the attribute is defined in more than one container:
      1. if all the values are equal, then replies one of the attribute values;
      2. if the values are not equal and all the values have equivalent types (as replied by AttributeType.isAssignableFrom(AttributeType)), then replies an attribute value with a "undefined" value and of the type of one of the values;
      3. if the values are not equal and one of the value has not an equivalent type to the others (as replied by AttributeType.isAssignableFrom(AttributeType)), then replies an attribute value with a "undefined" value and of the type OBJECT.
    Since:
    4.0
    Version:
    17.0 2020-01-04 14:41:51
    Author:
    Stéphane GALLAND
    See Also:
    Serialized Form
    Maven Group Id:
    org.arakhne.afc.advanced
    Maven Artifact Id:
    attributes
    • Constructor Detail

      • MultiAttributeProvider

        public MultiAttributeProvider()
    • Method Detail

      • toMap

        public void toMap​(Map<String,​Object> mapToFill)
        Description copied from interface: AttributeProvider
        Fill the given map with the values stored in this attribute provider.
        Parameters:
        mapToFill - is the map to fill, never null.
      • containers

        @Pure
        protected Collection<AttributeProvider> containers()
        Replies a collection on the containers.
        Returns:
        a collection on the containers.
      • addAttributeContainer

        public boolean addAttributeContainer​(AttributeProvider container)
        Add a container in this set.
        Parameters:
        container - the container.
        Returns:
        true if the container has been added, otherwise false
      • removeAttributeContainer

        public boolean removeAttributeContainer​(AttributeProvider container)
        Remove a container in this set.
        Parameters:
        container - the container.
        Returns:
        true if the container has been removed, otherwise false
      • getAttributeContainerCount

        @Pure
        public int getAttributeContainerCount()
        Replies the number of attribute containers in this MultiAttributeContainer.
        Returns:
        the number of attribute containers in this MultiAttributeContainer.
      • freeMemory

        public void freeMemory()
        Description copied from interface: AttributeProvider
        Clean the internal memory-storage structures if they exist.

        This function permits to limit the memory usage without removing the attribute value from a hard storage area (database, files...). The attribute which are freed by this method could be reloaded in memory with a call to a getting method.

      • getAllAttributes

        @Pure
        public Collection<Attribute> getAllAttributes()
        Description copied from interface: AttributeProvider
        Replies all the attributes.
        Returns:
        the list of all attributes
      • getAllAttributesByType

        @Pure
        public Map<AttributeType,​Collection<Attribute>> getAllAttributesByType()
        Description copied from interface: AttributeProvider
        Replies all the attributes sorted by type.

        The keys of the returned hashtable are the types and the values are array of attributes (Vector).

        Returns:
        the attributes grouped by type.
      • getAttribute

        @Pure
        public AttributeValue getAttribute​(String name)
        Description copied from interface: AttributeProvider
        Replies the value for the given attribute.
        Parameters:
        name - the name.
        Returns:
        the value or null
      • getAttribute

        @Pure
        public AttributeValue getAttribute​(String name,
                                           AttributeValue defaultValue)
        Description copied from interface: AttributeProvider
        Replies the value for the given attribute.
        Parameters:
        name - the name.
        defaultValue - is the default value replied if the attribute has no value.
        Returns:
        the value or null
      • getAttributeCount

        @Pure
        public int getAttributeCount()
        Description copied from interface: AttributeProvider
        Replies the count of attributes.
        Returns:
        the count of attributes.
      • getAllAttributeNames

        @Pure
        public Collection<String> getAllAttributeNames()
        Description copied from interface: AttributeProvider
        Replies all the attribute names. This function never load the attribute values even if they are not inside the storage layer.
        Returns:
        the list of all attribute names.
      • getAttributeObject

        @Pure
        public Attribute getAttributeObject​(String name)
        Description copied from interface: AttributeProvider
        Replies the attribute with the given name.
        Parameters:
        name - the name.
        Returns:
        the attribute or null
      • hasAttribute

        @Pure
        public boolean hasAttribute​(String name)
        Description copied from interface: AttributeProvider
        Replies if the given attribute exists.
        Parameters:
        name - the name.
        Returns:
        true is an attribute with the given name exists, otherwise false