Package org.apache.sis.feature
Class AttributeView<V>
java.lang.Object
org.apache.sis.feature.Property
org.apache.sis.feature.Field<V>
org.apache.sis.feature.AbstractAttribute<V>
org.apache.sis.feature.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
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
Specialization ofAttributeView
when the amount of values can be only zero or one. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final AbstractFeature
The feature from which to read and where to write the attribute or association value.(package private) final String
The string representation of the property name.private static final long
For cross-version compatibility.Fields inherited from class org.apache.sis.feature.AbstractAttribute
type
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
AttributeView
(AbstractFeature feature, DefaultAttributeType<V> type) Creates a new attribute which will delegate its work to the given feature. -
Method Summary
Modifier and TypeMethodDescriptionfinal Map
<String, AbstractAttribute<?>> Returns an empty map since this simple view does not support characteristics.(package private) static <V> AbstractAttribute
<V> create
(AbstractFeature feature, DefaultAttributeType<V> type) Creates a new attribute which will delegate its work to the given feature.final boolean
final org.opengis.util.GenericName
getName()
Returns the name of the type specified at construction time.getValue()
Returns the attribute value, ornull
if none.Returns all attribute values, or an empty collection if none.final int
hashCode()
void
Sets the attribute value.final void
setValues
(Collection<? extends V> values) Sets the attribute values.final String
toString()
Returns a string representation of this attribute.Methods inherited from class org.apache.sis.feature.AbstractAttribute
characteristicsReadOnly, clone, create, create, getType, quality
Methods inherited from class org.apache.sis.feature.Field
isDeprecated, isSingleton
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
feature
The feature from which to read and where to write the attribute or association value. -
name
The string representation of the property name. This is the value to be given in calls toFeature.getPropertyValue(String)
andFeature.setPropertyValue(String, Object)
.
-
-
Constructor Details
-
AttributeView
Creates a new attribute which will delegate its work to the given feature.
-
-
Method Details
-
create
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 thefeature
(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 classAbstractAttribute<V>
- Returns:
- the attribute name specified by its type.
-
getValue
Description copied from class:AbstractAttribute
Returns the attribute value, ornull
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 classAbstractAttribute<V>
- Returns:
- the attribute value (may be
null
). - See Also:
-
setValue
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 theAbstractAttribute.quality()
method.- Specified by:
setValue
in classAbstractAttribute<V>
- Parameters:
value
- the new value, ornull
for removing all values from this attribute.- See Also:
-
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 thisAttribute
instance, and conversely.The default implementation returns a collection which will delegate its work to
AbstractAttribute.getValue()
andAbstractAttribute.setValue(Object)
.- Overrides:
getValues
in classAbstractAttribute<V>
- Returns:
- the attribute values in a live collection.
-
setValues
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 classAbstractAttribute<V>
- Parameters:
values
- the new values.
-
characteristics
Returns an empty map since this simple view does not support characteristics.- Overrides:
characteristics
in classAbstractAttribute<V>
- Returns:
- other attribute types that describes this attribute type, or an empty map if none.
- See Also:
-
hashCode
public final int hashCode() -
equals
-
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 classAbstractAttribute<V>
- Returns:
- a string representation of this attribute for debugging purpose.
-