Class DefaultAttributeType<V>

Object
AbstractIdentifiedType
DefaultAttributeType<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, Deprecable

public class DefaultAttributeType<V> extends AbstractIdentifiedType
Definition of an attribute in a feature type. The name of attribute type is mandatory. The name scope is typically the name of the feature type containing this attribute, but this is not mandatory. The scope could also be defined by the ontology for example.
Analogy: Compared to the Java language, Attribute­Type is equivalent to Field while Feature­Type is equivalent to Class. Attribute characterization (discussed below) is similar to Annotation.
Warning: This class is expected to implement a GeoAPI Attribute­Type interface in a future version. When such interface will be available, most references to Default­Attribute­Type in current API will be replaced by references to the Attribute­Type interface.

Value type

Attributes can be used for both spatial and non-spatial properties. Some examples are:
Attribute value type examples
Attribute name Value type
Building shape Geometry
Building owner ResponsibleParty
Horizontal accuracy PositionalAccuracy

Attribute characterization

An Attribute can be characterized by other attributes. For example, an attribute that carries a measurement (e.g. air temperature) may have another attribute that holds the measurement accuracy (e.g. ±0.1°C). The accuracy value is often constant for all instances of that attribute (e.g. for all temperature measurements in the same dataset), but this is not mandatory.

Design notes

Such accuracy could be stored as an ordinary, independent, attribute (like another column in a table), but storing accuracy as a characteristic of the measurement attribute instead provides the following advantages:
  • The same characteristic name (e.g. “accuracy”) can be used for different attributes (e.g. “temperature”, “humidity”, etc.) since all characteristics are local to their attribute.
  • A reference to an attribute gives also access to its characteristics. For example, any method expecting an Attribute argument, when given a measurement, can also get its accuracy at the same time.
  • In the common case of a simple feature with characteristics that are constants, declaring them as attribute characteristics allows to specify the constants only once.
Constant values of characteristics are given by their default value. It is still possible for any specific Attribute instance to specify their own value, but simple feature usually don't do that.

Immutability and thread safety

Instances of this class are immutable if all properties (Generic­Name and International­String instances) and all arguments (e.g. default­Value) given to the constructor are also immutable. Such immutable instances can be shared by many objects and passed between threads without synchronization.

In particular, the get­Default­Value() method does not clone the returned value. This means that the same default­Value instance may be shared by many Abstract­Attribute instances. Consequently, the default value should be immutable for avoiding unexpected behavior.

Since:
0.5
See Also:
  • Constructor Details

  • Method Details

    • getValueClass

      public final Class<V> getValueClass()
      Returns the type of attribute values.
      Returns:
      the type of attribute values.
    • getMinimumOccurs

      public final int getMinimumOccurs()
      Returns the minimum number of attribute values. The returned value is greater than or equal to zero.

      To be valid, an Attribute instance of this Attribute­Type shall have at least this minimum number of elements in its collection of values.

      Returns:
      the minimum number of attribute values.
    • getMaximumOccurs

      public final int getMaximumOccurs()
      Returns the maximum number of attribute values. The returned value is greater than or equal to the get­Minimum­Occurs() value. If there is no maximum, then this method returns Integer​.MAX_VALUE.

      To be valid, an Attribute instance of this Attribute­Type shall have no more than this maximum number of elements in its collection of values.

      Returns:
      the maximum number of attribute values, or Integer​.MAX_VALUE if none.
    • getDefaultValue

      public V getDefaultValue()
      Returns the default value for the attribute. This value is used when an attribute is created and no value for it is specified.
      Returns:
      the default value for the attribute, or null if none.
    • characteristics

      public Map<String,DefaultAttributeType<?>> characteristics()
      Other attribute types that describes this attribute type. The characteristics are enumerated in the map values. The map keys are the String representations of characteristics name, for more convenient lookups. See "Attribute characterization" in class Javadoc for more information.

      Example

      An attribute that carries a measurement (e.g. air temperature) may have another attribute that holds the measurement accuracy. The accuracy is often constant for all measurements in a dataset, but not necessarily. If the accuracy is a constant, then the characteristics default value shall hold that constant.
      Returns:
      other attribute types that describes this attribute type, or an empty map if none.
      See Also:
    • newInstance

      public AbstractAttribute<V> newInstance()
      Creates a new attribute instance of this type initialized to the default value.
      Returns:
      a new attribute instance.
      See Also:
    • hashCode

      public int hashCode()
      Returns a hash code value for this attribute type.
      Returns:
      the hash code for this type.
    • equals

      public boolean equals(Object obj)
      Compares this attribute type with the given object for equality.
      Parameters:
      obj - the object to compare with this type.
      Returns:
      true if the given object is equal to this type.
    • toString

      public String toString()
      Returns a string representation of this attribute type. The returned string is for debugging purpose and may change in any future SIS version.
      Overrides:
      to­String in class Object
      Returns:
      a string representation of this attribute type for debugging purpose.