public class SimpleFeatureImpl extends Object implements SimpleFeature
SimpleFeature geared towards speed and backed by an Object[].| Modifier and Type | Field and Description |
|---|---|
protected Map<Object,Object>[] |
attributeUserData
The set of user data attached to each attribute (lazily created)
|
protected SimpleFeatureType |
featureType |
protected FeatureId |
id |
protected Map<String,Integer> |
index
The attribute name -> position index
|
protected Map<Object,Object> |
userData
The set of user data attached to the feature (lazily created)
|
protected boolean |
validating
Whether this feature is self validating or not
|
protected Object[] |
values
The actual values held by this feature
|
| Constructor and Description |
|---|
SimpleFeatureImpl(List<Object> values,
SimpleFeatureType featureType,
FeatureId id)
Builds a new feature based on the provided values and feature type
|
SimpleFeatureImpl(Object[] values,
SimpleFeatureType featureType,
FeatureId id,
boolean validating)
Fast construction of a new feature.
|
SimpleFeatureImpl(Object[] values,
SimpleFeatureType featureType,
FeatureId id,
boolean validating,
Map<String,Integer> index)
Fast construction of a new feature.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj)
override of equals.
|
Object |
getAttribute(int index)
Gets an attribute value by index.
|
Object |
getAttribute(Name name)
Gets an attribute value by name.
|
Object |
getAttribute(String name)
Gets an attribute value by name.
|
int |
getAttributeCount()
The number of attributes the feature is composed of.
|
List<Object> |
getAttributes()
Returns a list of the values of the attributes contained by the feature.
|
BoundingBox |
getBounds()
The bounds of this Feature, if available.
|
Object |
getDefaultGeometry()
Returns the value of the default geometry of the feature.
|
GeometryAttribute |
getDefaultGeometryProperty()
The default geometric attribute of the feature.
|
AttributeDescriptor |
getDescriptor()
Override of
Property.getDescriptor() which type narrows to AttributeDescriptor. |
SimpleFeatureType |
getFeatureType()
The type of the feature.
|
String |
getID()
Unique Identifier for the SimpleFeature
This value is non-null and should be the same as getIdentifier().toString().
|
FeatureId |
getIdentifier()
A unique identifier for the feature.
|
Name |
getName()
The name of the property with respect to its descriptor.
|
int |
getNumberOfAttributes() |
Collection<Property> |
getProperties()
Complete collection of properties.
|
Collection<Property> |
getProperties(Name name)
Returns a subset of the properties of the complex attribute which match the specified name.
|
Collection<Property> |
getProperties(String name)
Returns a subset of the properties of the complex attribute which match the specified name.
|
Property |
getProperty(Name name)
Returns single property of the complex attribute which matches the specified name.
|
Property |
getProperty(String name)
Returns single property of the complex attribute which matches the specified name.
|
SimpleFeatureType |
getType()
Override and type narrow to SimpleFeatureType.
|
Map<Object,Object> |
getUserData()
A map of "user data" which enables applications to store "application-specific" information
against a property.
|
Collection<? extends Property> |
getValue()
Override of
Property.getValue() which returns the collection of Property
which make up the value of the complex attribute. |
int |
hashCode()
returns a unique code for this feature
|
boolean |
isNillable()
Flag indicating if
null is an acceptable value for the property. |
void |
setAttribute(int index,
Object value)
Sets an attribute value by index.
|
void |
setAttribute(Name name,
Object value)
Sets an attribute value by name.
|
void |
setAttribute(String name,
Object value)
Sets an attribute value by name.
|
void |
setAttributes(List<Object> values)
Sets the values of the attributes contained by the feature.
|
void |
setAttributes(Object[] values)
Sets the values of the attributes contained by the feature.
|
void |
setDefaultGeometry(Object geometry)
Sets the value of the default geometry for the feature.
|
void |
setDefaultGeometryProperty(GeometryAttribute geometryAttribute)
Sets the default geometric attribute of the feature.
|
void |
setValue(Collection<Property> values)
Sets the contained properties of the complex attribute.
|
void |
setValue(Object newValue)
Sets the value or content of the property.
|
String |
toString() |
void |
validate()
Check the properties against the constraints provided by their AttributeDescriptors.
|
protected FeatureId id
protected SimpleFeatureType featureType
protected Object[] values
protected Map<Object,Object> userData
protected Map<Object,Object>[] attributeUserData
protected boolean validating
public SimpleFeatureImpl(List<Object> values, SimpleFeatureType featureType, FeatureId id)
values - featureType - id - public SimpleFeatureImpl(Object[] values, SimpleFeatureType featureType, FeatureId id, boolean validating)
The object takes ownership of the provided value array, do not modify after calling the constructor
values - featureType - id - validating - public SimpleFeatureImpl(Object[] values, SimpleFeatureType featureType, FeatureId id, boolean validating, Map<String,Integer> index)
The object takes ownership of the provided value array, do not modify after calling the constructor
values - featureType - id - validating - index - - attribute name to value index mappingpublic FeatureId getIdentifier()
FeaturegetType().isIdentifiable() must return true so this value must
not return null.
Generation of the identifier is dependent on the underlying data storage medium. Often this identifier is not persistent. Mediums such shapefiles and database tables have "keys" built in which map naturally to persistent feature identifiers. But other mediums do not have such keys and may have to generate feature identifiers "on-the-fly". This means that client code being able to depend on this value as a persistent entity is dependent on which storage medium or data source is being used.
getIdentifier in interface AttributegetIdentifier in interface Featurenull.public String getID()
SimpleFeatureThis value is non-null and should be the same as getIdentifier().toString(). Please note that an ID may be provided
getID in interface SimpleFeaturenull if the attribute is
non-identifiable.public int getNumberOfAttributes()
public Object getAttribute(int index) throws IndexOutOfBoundsException
SimpleFeatureThis method is a convenience for:
Property p = ((List)getProperties()).get( i ) ; return p.getValue();
getAttribute in interface SimpleFeatureindex - The index of the attribute whose value to get.IndexOutOfBoundsException - If the specified index is out of bounds.public Object getAttribute(String name)
SimpleFeatureThis method is a convenience for:
Property p = getProperty( name ); return p.getValue();
getAttribute in interface SimpleFeaturename - The name of the attribute whose value to retrieve.null if no such attribute exists with the
specified name.public Object getAttribute(Name name)
SimpleFeatureThis method is a convenience for:
Property p = getProperty( name ); return p.getValue();
Since attribute names in simple features do not have a namespace uri this method is
equivalent to calling getAttribute(name.getLocalPart()).
getAttribute in interface SimpleFeaturename - The name of the attribute whose value to retrieve.null if no such attribute exists with the
specified name.public int getAttributeCount()
SimpleFeatureThis is a convenience for:
return getAttributes().size();
getAttributeCount in interface SimpleFeaturepublic List<Object> getAttributes()
SimpleFeatureThis method is a convenience for:
List values = new ArrayList();
for ( Property p : getProperties(); ) {
values.add( p.getValue() );
}
return values;
getAttributes in interface SimpleFeaturepublic Object getDefaultGeometry()
SimpleFeatureThis method is convenience for:
return getDefaultGeometryProperty().getValue();
getDefaultGeometry in interface SimpleFeaturenull if no default geometry attribute exists.public SimpleFeatureType getFeatureType()
SimpleFeatureThis method is a synonym for SimpleFeature.getType().
getFeatureType in interface SimpleFeatureSimpleFeature.getType()public SimpleFeatureType getType()
SimpleFeaturegetType in interface AttributegetType in interface ComplexAttributegetType in interface FeaturegetType in interface PropertygetType in interface SimpleFeatureAttribute.getType()public void setAttribute(int index,
Object value)
throws IndexOutOfBoundsException
SimpleFeatureThis method is a convenience for:
Property p = ((List)getProperties()).get( i ) ; p.setValue(value);
setAttribute in interface SimpleFeatureindex - The index of the attribute whose value to set.value - The new value of the attribute.IndexOutOfBoundsException - If the specified index is out of bounds.public void setAttribute(String name, Object value)
SimpleFeatureThis method is a convenience for:
Property p = getProperty( name ); p.setValue(value);
setAttribute in interface SimpleFeaturename - The name of the attribute whose value to set.value - The new value of the attribute.public void setAttribute(Name name, Object value)
SimpleFeatureThis method is a convenience for:
Property p = getProperty( name ); p.setValue(value);
Since attribute names in simple features do not have a namespace uri this method is
equivalent to calling setAttribute(name.getLocalPart(), value).
setAttribute in interface SimpleFeaturename - The name of the attribute whose value to set.value - The new value of the attribute.public void setAttributes(List<Object> values)
SimpleFeatureThe values must be in the order of the attributes defined by the feature type.
This method is a convenience for:
int i = 0;
for ( Property p : getProperties() ) {
p.setValue( values.get( i++ ) );
}
setAttributes in interface SimpleFeaturevalues - The attribute values to set.public void setAttributes(Object[] values)
SimpleFeatureThe values must be in the order of the attributes defined by the feature type.
This method is a convenience for:
for ( Property p : getProperties() ) {
p.setValue( values[i] );
}
setAttributes in interface SimpleFeaturevalues - The attribute values to set.public void setDefaultGeometry(Object geometry)
SimpleFeatureThis method is convenience for:
getDefaultGeometryProperty().setValue(geometry);
setDefaultGeometry in interface SimpleFeaturegeometry - The new default geometry value.public BoundingBox getBounds()
FeatureThis value is derived from any geometric attributes that the feature is composed of.
In the case that the feature has no geometric attributes this method should return an
empty bounds, ie, bounds.isEmpty() == true. This method should never return
null.
The coordinate reference system of the returned bounds is derived from the geometric
attributes which were used to compute the bounds. In the event that the feature contains
multiple geometric attributes which have different crs's, the one defined by #getGeometryDescriptor() should take precedence and the others should be reprojected
accordingly.
public GeometryAttribute getDefaultGeometryProperty()
FeatureThis method returns null in the case where no such attribute exists.
getDefaultGeometryProperty in interface Featurenull.public void setDefaultGeometryProperty(GeometryAttribute geometryAttribute)
FeatureThis value must be an attribute which is already defined for the feature. In other words, this method can not be used to add a new attribute to the feature.
setDefaultGeometryProperty in interface FeaturegeometryAttribute - The new geomtric attribute.public Collection<Property> getProperties()
ComplexAttributeThis method is a convenience method for calling (Collection
getProperties in interface ComplexAttributepublic Collection<Property> getProperties(Name name)
ComplexAttributeThe name parameter is matched against each contained Property.getName(),
those that are equal are returned.
getProperties in interface ComplexAttributename - The name of the properties to return.public Collection<Property> getProperties(String name)
ComplexAttributeThis method is a convenience for ComplexAttribute.getProperties(Name) in which Name.getNamespaceURI() is null.
Note: Special care should be taken when using this method in the case that two properties
with the same local name but different namespace uri exist. For this reason using ComplexAttribute.getProperties(Name) is safer.
getProperties in interface ComplexAttributename - The local name of the properties to return.ComplexAttribute.getProperties(Name)public Property getProperty(Name name)
ComplexAttributeNote: This method is a convenience and care should be taken when calling it if more then a
single property matches name. In such a case the first encountered property in which
Property.getName() is equal to name is returned, and no order is guaranteed.
This method is a safe convenience for: getProperties(name).iterator().next().
In the event that no property matches the specified name null is returned.
getProperty in interface ComplexAttributename - The name of the property to return.null.public Property getProperty(String name)
ComplexAttributeThis method is a convenience for ComplexAttribute.getProperty(Name) in which Name.getNamespaceURI() is null.
Note: This method is a convenience and care should be taken when calling it if more then a
single property matches name. In such a case the first encountered property in which
Property.getName() is matches name is returned, and no order is guaranteed.
Note: Special care should be taken when using this method in the case that two properties
with the same local name but different namespace uri exist. For this reason using ComplexAttribute.getProperties(Name) is safer.
getProperty in interface ComplexAttributename - The local name of the property to return.null.public Collection<? extends Property> getValue()
ComplexAttributeProperty.getValue() which returns the collection of Property
which make up the value of the complex attribute.getValue in interface ComplexAttributegetValue in interface Propertypublic void setValue(Collection<Property> values)
ComplexAttributeThe values should match the structure defined by getDescriptor().
setValue in interface ComplexAttributepublic void setValue(Object newValue)
PropertyThe class of newValue should be the same as or a subclass of
getType().getBinding().
newValue may be null if getDescriptor().isNillable() is
true.
public AttributeDescriptor getDescriptor()
AttributeProperty.getDescriptor() which type narrows to AttributeDescriptor.getDescriptor in interface AttributegetDescriptor in interface PropertyAttribute.getDescriptor()public Name getName()
PropertyThis method is convenience for getDescriptor().getName().
getName in interface PropertySimpleFeatureTypeProperty.getName()public boolean isNillable()
Propertynull is an acceptable value for the property.
This method is convenience for getDescriptor().isNillable().
isNillable in interface Propertytrue if the value of the property is allowed to be null,
otherwise false.public Map<Object,Object> getUserData()
PropertyAn example of information that may wish to be stored along with an attribute could be its srs information (in the case of a geometric attribute ).
GeometryAttribute attribute = ...;
//set the crs
CoordinateReferenceSystem crs = CRS.decode("EPSG:4326");
attribute.setCRS( crs );
//set the srs
attribute.getUserData().put( "srs", "EPSG:4326" );
getUserData in interface Propertypublic int hashCode()
public boolean equals(Object obj)
public void validate()
ComplexAttributePlease note this method checks minOccurs and maxOccurs information; and calls each Attribute.validate on each entry in turn (in order to check isNillable, binding and restrictions).
validate in interface Attributevalidate in interface ComplexAttributeCopyright © 1996–2019 Geotools. All rights reserved.