Interface Attribute<V>

  • Type Parameters:
    V - The type of attribute values.
    All Superinterfaces:
    Property

    public interface Attribute<V>
    extends Property
    An instance of an AttributeType containing the value of an attribute in a feature. Attribute holds two main information:
    • A reference to an AttributeType which define the base Java type and domain of valid values.
    • A value, which may be a singleton ([0 … 1] cardinality) or multi-valued ([0 … ∞] cardinality).
    Analogy with Java language
    an attribute is similar to a "field" in a Java object. A field also brings together a field name, value and type. However attributes are limited to fields of primitive types or arrays of primitive types. For a field of other Java type, use FeatureAssociation instead.
    Attribute can be instantiated by calls to AttributeType.newInstance().
    Since:
    3.1
    See Also:
    AttributeType
    • Method Detail

      • getType

        AttributeType<V> getType()
        Returns information about the attribute (base Java class, domain of values, etc.).
        Returns:
        information about the attribute.
      • setValue

        void setValue​(V value)
               throws InvalidPropertyValueException
        Sets the attribute value. All previous values are replaced by the given singleton.
        Note on validation
        the verifications performed by this method is implementation dependent. For performance reasons, an implementation may verify only the most basic constraints and offer an other method for performing more extensive validation. Implementations should document their validation process.
        Parameters:
        value - the new value, or null for removing all values from this attribute.
        Throws:
        InvalidPropertyValueException - if this method verifies argument validity and the given value does not met the attribute constraints.
        See Also:
        Feature.setPropertyValue(String, Object)
      • getValues

        Collection<V> getValues()
        Returns all attribute values, or an empty collection if none.
        Implementation note
        there is different approaches in the way that collection elements are related to this property values:
        • The collection may be a snapshot of property values at the method invocation time.
        • The collection may be an unmodifiable view of properties values.
        • The collection may be live (changes in the collection are reflected in this attribute, and vis-versa).
        This method does not mandate a particular approach. However implementations should document which policy they choose.
        Returns:
        the attribute values.
      • setValues

        void setValues​(Collection<? extends V> values)
                throws InvalidPropertyValueException
        Sets the attribute values. All previous values are replaced by the given collection.
        Note on validation
        the verifications performed by this method is implementation dependent. For performance reasons, an implementation may verify only the most basic constraints and offer an other method for performing more extensive validation. Implementations should document their validation process.
        Parameters:
        values - the new values.
        Throws:
        InvalidPropertyValueException - if this method verifies argument validity and the given values do not met the attribute constraints.
      • characteristics

        Map<String,Attribute<?>> characteristics()
        Other attributes that describes this attribute. For example if this attribute carries a measurement, then a characteristic of this attribute could be the measurement accuracy. See "Attribute characterization" in AttributeType Javadoc for more information.

        Attributes having a value equals to their default value do not need to appear in this characteristics map. For example all temperature measurements in a dataset may have the same accuracy, which can be specified only once in the AttributeType.characteristics() map instead of being repeated in every Attribute.characteristics() maps.

        The characteristic values are enumerated in the map values. The map keys are the String representations of characteristics name, for more convenient lookups.

        Returns:
        other attribute types that describes this attribute type, or an empty map if none.
        See Also:
        AttributeType.characteristics()