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
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,
AttributeType
is equivalent to Field
while FeatureType
is equivalent to Class
.
Attribute characterization (discussed below) is similar to Annotation
.
Warning:
This class is expected to implement a GeoAPI
AttributeType
interface in a future version.
When such interface will be available, most references to DefaultAttributeType
in current
API will be replaced by references to the AttributeType
interface.Value type
Attributes can be used for both spatial and non-spatial properties. Some examples are:Attribute name | Value type |
---|---|
Building shape | Geometry |
Building owner | ResponsibleParty |
Horizontal accuracy | PositionalAccuracy |
Attribute characterization
AnAttribute
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.
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 (GenericName
and InternationalString
instances) and all arguments (e.g. defaultValue
) 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 getDefaultValue()
method does not clone the returned value.
This means that the same defaultValue
instance may be shared by many AbstractAttribute
instances.
Consequently, the default value should be immutable for avoiding unexpected behavior.
- Since:
- 0.5
- See Also:
-
Field Summary
Fields inherited from class AbstractIdentifiedType
DEFINITION_KEY, DEPRECATED_KEY, DESCRIPTION_KEY, DESIGNATION_KEY, NAME_KEY
-
Constructor Summary
ConstructorDescriptionDefaultAttributeType
(Map<String, ?> identification, Class<V> valueClass, int minimumOccurs, int maximumOccurs, V defaultValue, DefaultAttributeType<?>... characterizedBy) Constructs an attribute type from the given properties. -
Method Summary
Modifier and TypeMethodDescriptionOther attribute types that describes this attribute type.boolean
Compares this attribute type with the given object for equality.Returns the default value for the attribute.final int
Returns the maximum number of attribute values.final int
Returns the minimum number of attribute values.Returns the type of attribute values.int
Returns a hash code value for this attribute type.Creates a new attribute instance of this type initialized to the default value.Returns a string representation of this attribute type.Methods inherited from class AbstractIdentifiedType
getDefinition, getDescription, getDesignation, getName, getRemarks, isDeprecated
-
Constructor Details
-
DefaultAttributeType
public DefaultAttributeType(Map<String, ?> identification, Class<V> valueClass, int minimumOccurs, int maximumOccurs, V defaultValue, DefaultAttributeType<?>... characterizedBy) Constructs an attribute type from the given properties. The identification map is given unchanged to the super-class constructor. The following table is a reminder of main (not all) recognized map entries:Recognized map entries (non exhaustive list) Map key Value type Returned by "name" GenericName
orString
AbstractIdentifiedType.getName()
"definition" InternationalString
orString
AbstractIdentifiedType.getDefinition()
"designation" InternationalString
orString
AbstractIdentifiedType.getDesignation()
"description" InternationalString
orString
AbstractIdentifiedType.getDescription()
"deprecated" Boolean
AbstractIdentifiedType.isDeprecated()
- Parameters:
identification
- the name and other information to be given to this attribute type.valueClass
- the type of attribute values.minimumOccurs
- the minimum number of occurrences of the attribute within its containing entity.maximumOccurs
- the maximum number of occurrences of the attribute within its containing entity, orInteger.MAX_VALUE
if there is no restriction.defaultValue
- the default value for the attribute, ornull
if none.characterizedBy
- other attribute types that describes this attribute type (can benull
for none). For example if this newDefaultAttributeType
describes a measurement, thencharacterizedBy
could holds the measurement accuracy. See "Attribute characterization" in class Javadoc for more information.- See Also:
-
-
Method Details
-
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 thisAttributeType
shall have at least this minimum number of elements in itscollection 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 thegetMinimumOccurs()
value. If there is no maximum, then this method returnsInteger.MAX_VALUE
.To be valid, an
Attribute
instance of thisAttributeType
shall have no more than this maximum number of elements in itscollection of values
.- Returns:
- the maximum number of attribute values, or
Integer.MAX_VALUE
if none.
-
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
Other attribute types that describes this attribute type. The characteristics are enumerated in the map values. The map keys are theString
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
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
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
Returns a string representation of this attribute type. The returned string is for debugging purpose and may change in any future SIS version.
-