public abstract class AbstractFeature extends Object implements Serializable
AbstractFeature
can be instantiated by calls to DefaultFeatureType.newInstance()
.
AbstractFeature
instances are not thread-safe.
Synchronization, if needed, shall be done externally by the caller.DefaultFeatureType.newInstance()
,
Serialized FormDefined in the sis-feature
module
Modifier | Constructor and Description |
---|---|
protected |
AbstractFeature(DefaultFeatureType type)
Creates a new feature of the given type.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Compares this feature with the given object for equality.
|
protected Object |
getOperationValue(String name)
Executes the parameterless operation of the given name and returns the value of its result.
|
Object |
getProperty(String name)
Returns the property (attribute, feature association or operation result) of the given name.
|
abstract Object |
getPropertyValue(String name)
Returns the value for the property of the given name.
|
DefaultFeatureType |
getType()
Returns information about the feature (name, characteristics, etc.
|
int |
hashCode()
Returns a hash code value for this feature.
|
DataQuality |
quality()
Evaluates the quality of this feature at this method invocation time.
|
protected void |
setOperationValue(String name,
Object value)
Executes the parameterless operation of the given name and sets the value of its result.
|
void |
setProperty(Object property)
Sets the property (attribute or feature association).
|
abstract void |
setPropertyValue(String name,
Object value)
Sets the value for the property of the given name.
|
String |
toString()
Formats this feature in a tabular format.
|
protected AbstractFeature(DefaultFeatureType type)
type
- information about the feature (name, characteristics, etc.).DefaultFeatureType.newInstance()
public DefaultFeatureType getType()
org.opengis.feature.FeatureType
. This change is pending GeoAPI revision.public Object getProperty(String name) throws IllegalArgumentException
This method returns the property instance. If only the property value is
desired, then getPropertyValue(String)
is preferred since it gives to SIS a chance to
avoid the creation of AbstractAttribute
or AbstractAssociation
instances.
getPropertyValue(String)
and setPropertyValue(String, Object)
respectively.
That default implementation is intended to make easier for developers to create their own
customized AbstractFacture
implementations, but has drawbacks:
a new Property
instance is created every time that this getProperty(String)
method is invoked,
and the returned Property
implementation is not very efficient
since it has to perform multiple lookups and type checks.
Implementors are encouraged to override this method if they can provide a more efficient implementation.
Note that this is already the case when using implementations created by DefaultFeatureType.newInstance()
.org.opengis.feature.Property
. This change is pending GeoAPI revision.name
- the property name.null
).IllegalArgumentException
- if the given argument is not a property name of this feature.getPropertyValue(String)
,
DefaultFeatureType.getProperty(String)
public void setProperty(Object property) throws IllegalArgumentException
assert property.getType() == getType().getProperty(property.getName());This method is useful for storing non-default
Attribute
or FeatureAssociation
implementations
in this feature. When default implementations are sufficient, the setPropertyValue(String, Object)
method is preferred.
setPropertyValue(String, Object)
.
That default implementation is intended to make easier for developers to create their own
customized AbstractFacture
implementations, but has drawbacks:
the given Property
instance is not stored (only its value
is stored), and it can not have custom characteristics.
Implementors are encouraged to override this method if they can provide a better implementation.
Note that this is already the case when using implementations created by DefaultFeatureType.newInstance()
.org.opengis.feature.Property
. This change is pending GeoAPI revision.property
- the property to set.IllegalArgumentException
- if the name of the given property is not a property name of this feature.IllegalArgumentException
- if the value of the given property is not valid.IllegalArgumentException
- if the property can not be set for another reason.setPropertyValue(String, Object)
public abstract Object getPropertyValue(String name) throws IllegalArgumentException
getProperty(String)
for the given name,
then to perform one of the following actions depending on the property type and the cardinality:
Property type | max. occurs | Method invoked | Return type |
---|---|---|---|
AttributeType | 0 or 1 | Attribute.getValue() | Object |
AttributeType | 2 or more | Attribute.getValues() | Collection<?> |
FeatureAssociationRole | 0 or 1 | FeatureAssociation.getValue() | Feature |
FeatureAssociationRole | 2 or more | FeatureAssociation.getValues() | Collection<Feature> |
Collection<?>
does not allow such operations, and more specific
casts (e.g. Collection<String>
can not be checked at runtime (at least as of Java 8).
If a type-safe modifiable collection is desired, the following approach can be used instead:
Attribute<String> attribute = Features.cast((Attribute<?>) feature.getProperty(name), String.class); Collection<String> values = attribute.getValues(); // This collection is guaranteed to be "live".
name
- the property name.null
if none.IllegalArgumentException
- if the given argument is not an attribute or association name of this feature.AbstractAttribute.getValue()
public abstract void setPropertyValue(String name, Object value) throws IllegalArgumentException
quality()
method.name
- the attribute name.value
- the new value for the given attribute (may be null
).IllegalArgumentException
- if the given name is not an attribute or association name of this feature.ClassCastException
- if the value is not assignable to the expected value class.IllegalArgumentException
- if the given value is not valid for a reason other than its type.AbstractAttribute.setValue(Object)
protected Object getOperationValue(String name)
Feature
instance
(for example a link to another property value).
Invoking this method is equivalent to performing the following steps:
Operation operation = (Operation) type.getProperty(name); Property result = operation.apply(this, null); if (result instanceof Attribute<?>) { return ...; // the attribute value. } else if (result instanceof FeatureAssociation) { return ...; // the associated feature. } else { return null; }
name
- the name of the operation to execute. The caller is responsible to ensure that the
property type for that name is an instance of AbstractOperation
.null
if none.protected void setOperationValue(String name, Object value)
getOperationValue(String)
for subclasses where
some properties may be operations. Not all operations accept assignments,
but the link operation for instance does.name
- the name of the operation to execute. The caller is responsible to ensure that the
property type for that name is an instance of AbstractOperation
.value
- the value to assign to the result of the named operation.IllegalStateException
- if the operation of the given name does not accept assignment.public DataQuality quality()
The default implementation reports data quality with at least the following information:
ScopeCode.FEATURE
.
AbstractAttribute.quality()
javadoc.
false
.
quality()
method will return the following data quality report:
Data quality ├─Scope │ └─Level………………………………………………… Feature └─Report ├─Measure identification │ └─Code………………………………………… population ├─Evaluation method type…… Direct internal └─Result ├─Explanation……………………… Missing value for “population” property. └─Pass………………………………………… false
AbstractAttribute.quality()
,
AbstractAssociation.quality()
public String toString()
toString
in class Object
FeatureFormat
public int hashCode()
type.getProperty(true)
–
thus including properties inherited from parent types (if any):
getPropertyValue(String)
.public boolean equals(Object obj)
type.getProperty(true)
–
thus including properties inherited from parent types (if any):
FeatureType
by a call to getPropertyValue(String)
.Object.equals(Object)
.Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.