Class AttributeView<V>

Type Parameters:
V - the type of attribute values. If the attribute supports multi-occurrences, then this is the type of elements (not the collection type).
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AttributeView.Singleton

class AttributeView<V> extends AbstractAttribute<V>
An attribute implementation which delegate its work to the parent feature. This class is used for default implementation of AbstractFeature.getProperty(String).

This implementation is inefficient! This class is for making easier to begin with a custom AbstractFeature implementation, but developers are encouraged to provide their own AbstractFeature.getProperty(String) implementation.

Since:
0.8
Version:
0.8
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
    • feature

      final AbstractFeature feature
      The feature from which to read and where to write the attribute or association value.
    • name

      final String name
      The string representation of the property name. This is the value to be given in calls to Feature.getPropertyValue(String) and Feature.setPropertyValue(String, Object).
  • Constructor Details

  • Method Details

    • create

      static <V> AbstractAttribute<V> create(AbstractFeature feature, DefaultAttributeType<V> type)
      Creates a new attribute which will delegate its work to the given feature.
      Parameters:
      feature - the feature from which to read and where to write the attribute value.
      type - the type of this attribute. Must be one of the properties listed in the feature (this is not verified by this constructor).
    • getName

      public final org.opengis.util.GenericName getName()
      Returns the name of the type specified at construction time.
      Overrides:
      getName in class AbstractAttribute<V>
      Returns:
      the attribute name specified by its type.
    • getValue

      public V getValue()
      Description copied from class: AbstractAttribute
      Returns the attribute value, or null if none. This convenience method can be invoked in the common case where the maximum number of attribute values is restricted to 1 or 0.
      Specified by:
      getValue in class AbstractAttribute<V>
      Returns:
      the attribute value (may be null).
      See Also:
    • setValue

      public void setValue(V value)
      Description copied from class: AbstractAttribute
      Sets the attribute value. All previous values are replaced by the given singleton.

      Validation

      The amount of validation performed by this method is implementation dependent. Usually, only the most basic constraints are verified. This is so for performance reasons and also because some rules may be temporarily broken while constructing a feature. A more exhaustive verification can be performed by invoking the AbstractAttribute.quality() method.
      Specified by:
      setValue in class AbstractAttribute<V>
      Parameters:
      value - the new value, or null for removing all values from this attribute.
      See Also:
    • getValues

      public Collection<V> getValues()
      Description copied from class: AbstractAttribute
      Returns all attribute values, or an empty collection if none. The returned collection is live: changes in the returned collection will be reflected immediately in this Attribute instance, and conversely.

      The default implementation returns a collection which will delegate its work to AbstractAttribute.getValue() and AbstractAttribute.setValue(Object).

      Overrides:
      getValues in class AbstractAttribute<V>
      Returns:
      the attribute values in a live collection.
    • setValues

      public final void setValues(Collection<? extends V> values)
      Description copied from class: AbstractAttribute
      Sets the attribute values. All previous values are replaced by the given collection.

      The default implementation ensures that the given collection contains at most one element, then delegates to AbstractAttribute.setValue(Object).

      Overrides:
      setValues in class AbstractAttribute<V>
      Parameters:
      values - the new values.
    • characteristics

      public final Map<String,AbstractAttribute<?>> characteristics()
      Returns an empty map since this simple view does not support characteristics.
      Overrides:
      characteristics in class AbstractAttribute<V>
      Returns:
      other attribute types that describes this attribute type, or an empty map if none.
      See Also:
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public final String toString()
      Description copied from class: AbstractAttribute
      Returns a string representation of this attribute. The returned string is for debugging purpose and may change in any future SIS version. The current implementation is like below:
      Overrides:
      toString in class AbstractAttribute<V>
      Returns:
      a string representation of this attribute for debugging purpose.