Package org.apache.sis.feature
Class DenseFeature
java.lang.Object
org.apache.sis.feature.AbstractFeature
org.apache.sis.feature.DenseFeature
- All Implemented Interfaces:
Serializable,Cloneable
A feature in which most properties are expected to be provided. This implementation uses a plain array for
its internal storage of properties. This consumes less memory than
Map when we know that
all (or almost all) elements in the array will be assigned a value.- Since:
- 0.5
- Version:
- 1.1
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe map of property names to indices in thepropertiesarray.private Object[]The properties (attributes or feature associations) in this feature.private static final longFor cross-version compatibility.Fields inherited from class org.apache.sis.feature.AbstractFeature
MISSING, type -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new feature of the given type. -
Method Summary
Modifier and TypeMethodDescriptionclone()Returns a copy of this feature.booleanCompares this feature with the given object for equality.private intReturns the index for the property of the given name, orDefaultFeatureType.OPERATION_INDEXif the property is a parameterless operation.getProperty(String name) Returns the property (attribute, operation or association) of the given name.getPropertyValue(String name) Returns the value for the property of the given name.final ObjectgetValueOrFallback(String name, Object missingPropertyFallback) Returns the value for the property of the given name if that property exists, or a fallback value otherwise.inthashCode()Returns a hash code value for this feature.org.opengis.metadata.quality.DataQualityquality()Verifies if all current properties met the constraints defined by the feature type.voidsetProperty(Object property) Sets the property (attribute, operation or association).voidsetPropertyValue(String name, Object value) Sets the value for the property of the given name.private voidWraps values inPropertyobjects for all elements in thepropertiesarray.Methods inherited from class org.apache.sis.feature.AbstractFeature
canSkipVerification, comparisonEnd, comparisonStart, createProperty, createProperty, getAssociationValue, getAttributeValue, getDefaultValue, getName, getOperationResult, getOperationValue, getType, propertyNotFound, setOperationValue, setPropertyValue, toString, unsupportedPropertyType, verifyPropertyType, verifyPropertyValue
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
indices
The map of property names to indices in thepropertiesarray. This map is a reference to theDefaultFeatureType.indicesmap (potentially shared by many feature instances) and shall not be modified. -
properties
The properties (attributes or feature associations) in this feature. Conceptually, values in this array arePropertyinstances. However, at first we will store only the property values, and convert to an array of typeProperty[]only when at least one property is requested. The intent is to reduce the amount of allocated objects as much as possible, because typical SIS applications may create a very large amount of features.
-
-
Constructor Details
-
DenseFeature
Creates a new feature of the given type.- Parameters:
type- information about the feature (name, characteristics, etc.).
-
-
Method Details
-
getIndex
Returns the index for the property of the given name, orDefaultFeatureType.OPERATION_INDEXif the property is a parameterless operation.- Parameters:
name- the property name.- Returns:
- the index for the property of the given name, or a negative value if the property is a parameterless operation.
- Throws:
IllegalArgumentException- if the given argument is not a property name of this feature.
-
getProperty
Returns the property (attribute, operation or association) of the given name.- Overrides:
getPropertyin classAbstractFeature- Parameters:
name- the property name.- Returns:
- the property of the given name.
- Throws:
IllegalArgumentException- if the given argument is not a property name of this feature.- See Also:
-
setProperty
Sets the property (attribute, operation or association).- Overrides:
setPropertyin classAbstractFeature- Parameters:
property- the property to set.- Throws:
IllegalArgumentException- if the type of the given property is not one of the types known to this feature, or if the property cannot be set or another reason.- See Also:
-
wrapValuesInProperties
private void wrapValuesInProperties()Wraps values inPropertyobjects for all elements in thepropertiesarray. This operation is executed at most once per feature. -
getPropertyValue
Returns the value for the property of the given name.- Specified by:
getPropertyValuein classAbstractFeature- Parameters:
name- the property name.- Returns:
- the value for the given property, or
nullif none. - Throws:
IllegalArgumentException- if the given argument is not an attribute or association name of this feature.- See Also:
-
getValueOrFallback
Returns the value for the property of the given name if that property exists, or a fallback value otherwise.- Specified by:
getValueOrFallbackin classAbstractFeature- Parameters:
name- the property name.missingPropertyFallback- the value to return if no attribute or association of the given name exists.- Returns:
- the value for the given property, or
nullif none. - Since:
- 1.1
-
setPropertyValue
Sets the value for the property of the given name.- Specified by:
setPropertyValuein classAbstractFeature- Parameters:
name- the attribute name.value- the new value for the given attribute (may benull).- Throws:
ClassCastException- if the value is not assignable to the expected value class.IllegalArgumentException- if the given value cannot be assigned for another reason.- See Also:
-
quality
public org.opengis.metadata.quality.DataQuality quality()Verifies if all current properties met the constraints defined by the feature type. This method returns reports for all invalid properties, if any.- Overrides:
qualityin classAbstractFeature- Returns:
- reports on all constraint violations found.
- See Also:
-
clone
Returns a copy of this feature. This method also clones all cloneable property instances in this feature, but not necessarily property values. Whether the property values are cloned or not (i.e. whether the clone operation is deep or shallow) depends on the behavior of theclone()method of properties.- Overrides:
clonein classObject- Returns:
- a clone of this attribute.
- Throws:
CloneNotSupportedException- if this feature cannot be cloned, typically becauseclone()on a property instance failed.
-
hashCode
public int hashCode()Returns a hash code value for this feature. This implementation computes the hash code using only the property values, not thePropertyinstances, in order to keep the hash code value stable before and after thepropertiesarray is promoted from theObject[]type to theProperty[]type.- Overrides:
hashCodein classAbstractFeature- Returns:
- a hash code value.
-
equals
Compares this feature with the given object for equality.- Overrides:
equalsin classAbstractFeature- Returns:
trueif both objects are equal.
-