Class DecoratingFeature
- Object
-
- DecoratingFeature
-
- All Implemented Interfaces:
Attribute
,ComplexAttribute
,Feature
,Property
,SimpleFeature
public class DecoratingFeature extends Object implements SimpleFeature
Base class for feature decorators.Subclasses should override those methods which are relevant to the decorator.
- Since:
- 2.5
- Author:
- Justin Deoliveira, The Open Planning Project
-
-
Field Summary
Fields Modifier and Type Field Description protected SimpleFeature
delegate
-
Constructor Summary
Constructors Constructor Description DecoratingFeature(SimpleFeature delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
Object
getAttribute(int index)
Gets an attribute value by index.Object
getAttribute(String path)
Gets an attribute value by name.Object
getAttribute(Name arg0)
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 ofProperty.getDescriptor()
which type narrows toAttributeDescriptor
.SimpleFeatureType
getFeatureType()
The type of the feature.String
getID()
Unique Identifier for the SimpleFeatureFeatureId
getIdentifier()
A unique identifier for the feature.Name
getName()
The name of the property with respect to its descriptor.Collection<Property>
getProperties()
Complete collection of properties.Collection<Property>
getProperties(String arg0)
Returns a subset of the properties of the complex attribute which match the specified name.Collection<Property>
getProperties(Name arg0)
Returns a subset of the properties of the complex attribute which match the specified name.Property
getProperty(String arg0)
Returns single property of the complex attribute which matches the specified name.Property
getProperty(Name arg0)
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 ofProperty.getValue()
which returns the collection ofProperty
which make up the value of the complex attribute.int
hashCode()
boolean
isNillable()
Flag indicating ifnull
is an acceptable value for the property.void
setAttribute(int position, Object val)
Sets an attribute value by index.void
setAttribute(String path, Object attribute)
Sets an attribute value by name.void
setAttribute(Name arg0, Object arg1)
Sets an attribute value by name.void
setAttributes(Object[] arg0)
Sets the values of the attributes contained by the feature.void
setAttributes(List<Object> arg0)
Sets the values of the attributes contained by the feature.void
setDefaultGeometry(Object arg0)
Sets the value of the default geometry for the feature.void
setDefaultGeometry(Geometry geometry)
void
setDefaultGeometryProperty(GeometryAttribute arg0)
Sets the default geometric attribute of the feature.void
setValue(Object arg0)
Sets the value or content of the property.void
setValue(Collection<Property> arg0)
Sets the contained properties of the complex attribute.String
toString()
void
validate()
Check the properties against the constraints provided by their AttributeDescriptors.-
Methods inherited from interface Property
hasUserData
-
-
-
-
Field Detail
-
delegate
protected SimpleFeature delegate
-
-
Constructor Detail
-
DecoratingFeature
public DecoratingFeature(SimpleFeature delegate)
-
-
Method Detail
-
getAttribute
public Object getAttribute(int index)
Description copied from interface:SimpleFeature
Gets an attribute value by index.This method is a convenience for:
Property p = ((List)getProperties()).get( i ) ; return p.getValue();
- Specified by:
getAttribute
in interfaceSimpleFeature
- Parameters:
index
- The index of the attribute whose value to get.- Returns:
- The attribute value at the specified index.
-
getAttribute
public Object getAttribute(Name arg0)
Description copied from interface:SimpleFeature
Gets an attribute value by name.This 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())
.- Specified by:
getAttribute
in interfaceSimpleFeature
- Parameters:
arg0
- The name of the attribute whose value to retrieve.- Returns:
- The attribute value, or
null
if no such attribute exists with the specified name.
-
getAttribute
public Object getAttribute(String path)
Description copied from interface:SimpleFeature
Gets an attribute value by name.This method is a convenience for:
Property p = getProperty( name ); return p.getValue();
- Specified by:
getAttribute
in interfaceSimpleFeature
- Parameters:
path
- The name of the attribute whose value to retrieve.- Returns:
- The attribute value, or
null
if no such attribute exists with the specified name.
-
getAttributeCount
public int getAttributeCount()
Description copied from interface:SimpleFeature
The number of attributes the feature is composed of.This is a convenience for:
return getAttributes().size();
- Specified by:
getAttributeCount
in interfaceSimpleFeature
- Returns:
- Number of attributes of the feature.
-
getAttributes
public List<Object> getAttributes()
Description copied from interface:SimpleFeature
Returns a list of the values of the attributes contained by the feature.
This method is a convenience for:
List values = new ArrayList(); for ( Property p : getProperties(); ) { values.add( p.getValue() ); } return values;
- Specified by:
getAttributes
in interfaceSimpleFeature
- Returns:
- List of attribute values for the feature.
-
getBounds
public BoundingBox getBounds()
Description copied from interface:Feature
The bounds of this Feature, if available.This 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 returnnull
.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.
-
getDefaultGeometry
public Object getDefaultGeometry()
Description copied from interface:SimpleFeature
Returns the value of the default geometry of the feature.This method is convenience for:
return getDefaultGeometryProperty().getValue();
- Specified by:
getDefaultGeometry
in interfaceSimpleFeature
- Returns:
- The default geometry, or
null
if no default geometry attribute exists.
-
getDefaultGeometryProperty
public GeometryAttribute getDefaultGeometryProperty()
Description copied from interface:Feature
The default geometric attribute of the feature.This method returns
null
in the case where no such attribute exists.- Specified by:
getDefaultGeometryProperty
in interfaceFeature
- Returns:
- The default geometry attribute, or
null
.
-
getDescriptor
public AttributeDescriptor getDescriptor()
Description copied from interface:Attribute
Override ofProperty.getDescriptor()
which type narrows toAttributeDescriptor
.- Specified by:
getDescriptor
in interfaceAttribute
- Specified by:
getDescriptor
in interfaceProperty
- Returns:
- The attribute descriptor, may be null if this is a top level type
- See Also:
Property.getDescriptor()
-
getFeatureType
public SimpleFeatureType getFeatureType()
Description copied from interface:SimpleFeature
The type of the feature.This method is a synonym for
SimpleFeature.getType()
.- Specified by:
getFeatureType
in interfaceSimpleFeature
- See Also:
SimpleFeature.getType()
-
getIdentifier
public FeatureId getIdentifier()
Description copied from interface:Feature
A unique identifier for the feature.getType().isIdentifiable()
must returntrue
so this value must not returnnull
.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.
- Specified by:
getIdentifier
in interfaceAttribute
- Specified by:
getIdentifier
in interfaceFeature
- Returns:
- The feature identifier, never
null
.
-
getID
public String getID()
Description copied from interface:SimpleFeature
Unique Identifier for the SimpleFeatureThis value is non-null and should be the same as getIdentifier().toString(). Please note that an ID may be provided
- Specified by:
getID
in interfaceSimpleFeature
- Returns:
- A unique identifier for the attribute, or
null
if the attribute is non-identifiable.
-
getName
public Name getName()
Description copied from interface:Property
The name of the property with respect to its descriptor.This method is convenience for
getDescriptor().getName()
.
-
getProperties
public Collection<Property> getProperties()
Description copied from interface:ComplexAttribute
Complete collection of properties.This method is a convenience method for calling (Collection
) getValue(). - Specified by:
getProperties
in interfaceComplexAttribute
- Returns:
- The complete collection of properties.
-
getProperties
public Collection<Property> getProperties(Name arg0)
Description copied from interface:ComplexAttribute
Returns a subset of the properties of the complex attribute which match the specified name.The name parameter is matched against each contained
Property.getName()
, those that are equal are returned.- Specified by:
getProperties
in interfaceComplexAttribute
- Parameters:
arg0
- The name of the properties to return.- Returns:
- The collection of properties which match the specified name, or an empty collection if no such properties match.
-
getProperties
public Collection<Property> getProperties(String arg0)
Description copied from interface:ComplexAttribute
Returns a subset of the properties of the complex attribute which match the specified name.This method is a convenience for
ComplexAttribute.getProperties(Name)
in whichName.getNamespaceURI()
isnull
.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.- Specified by:
getProperties
in interfaceComplexAttribute
- Parameters:
arg0
- The local name of the properties to return.- Returns:
- The collection of properties which match the specified name, or an empty collection if no such properties match.
- See Also:
ComplexAttribute.getProperties(Name)
-
getProperty
public Property getProperty(Name arg0)
Description copied from interface:ComplexAttribute
Returns single property of the complex attribute which matches the specified name.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 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.- Specified by:
getProperty
in interfaceComplexAttribute
- Parameters:
arg0
- The name of the property to return.- Returns:
- The property matching the specified name, or
null
.
-
getProperty
public Property getProperty(String arg0)
Description copied from interface:ComplexAttribute
Returns single property of the complex attribute which matches the specified name.This method is a convenience for
ComplexAttribute.getProperty(Name)
in whichName.getNamespaceURI()
isnull
.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.- Specified by:
getProperty
in interfaceComplexAttribute
- Parameters:
arg0
- The local name of the property to return.- Returns:
- The property matching the specified name, or
null
.
-
getType
public SimpleFeatureType getType()
Description copied from interface:SimpleFeature
Override and type narrow to SimpleFeatureType.- Specified by:
getType
in interfaceAttribute
- Specified by:
getType
in interfaceComplexAttribute
- Specified by:
getType
in interfaceFeature
- Specified by:
getType
in interfaceProperty
- Specified by:
getType
in interfaceSimpleFeature
- Returns:
- The feature type
- See Also:
Attribute.getType()
-
getUserData
public Map<Object,Object> getUserData()
Description copied from interface:Property
A map of "user data" which enables applications to store "application-specific" information against a property.An 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" );
- Specified by:
getUserData
in interfaceProperty
- Returns:
- A map of user data.
-
getValue
public Collection<? extends Property> getValue()
Description copied from interface:ComplexAttribute
Override ofProperty.getValue()
which returns the collection ofProperty
which make up the value of the complex attribute.- Specified by:
getValue
in interfaceComplexAttribute
- Specified by:
getValue
in interfaceProperty
- Returns:
- The value of the property.
-
isNillable
public boolean isNillable()
Description copied from interface:Property
Flag indicating ifnull
is an acceptable value for the property.This method is convenience for
getDescriptor().isNillable()
.- Specified by:
isNillable
in interfaceProperty
- Returns:
true
if the value of the property is allowed to benull
, otherwisefalse
.
-
setAttribute
public void setAttribute(int position, Object val)
Description copied from interface:SimpleFeature
Sets an attribute value by index.This method is a convenience for:
Property p = ((List)getProperties()).get( i ) ; p.setValue(value);
- Specified by:
setAttribute
in interfaceSimpleFeature
- Parameters:
position
- The index of the attribute whose value to set.val
- The new value of the attribute.
-
setAttribute
public void setAttribute(Name arg0, Object arg1)
Description copied from interface:SimpleFeature
Sets an attribute value by name.This 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)
.- Specified by:
setAttribute
in interfaceSimpleFeature
- Parameters:
arg0
- The name of the attribute whose value to set.arg1
- The new value of the attribute.
-
setAttribute
public void setAttribute(String path, Object attribute)
Description copied from interface:SimpleFeature
Sets an attribute value by name.This method is a convenience for:
Property p = getProperty( name ); p.setValue(value);
- Specified by:
setAttribute
in interfaceSimpleFeature
- Parameters:
path
- The name of the attribute whose value to set.attribute
- The new value of the attribute.
-
setAttributes
public void setAttributes(List<Object> arg0)
Description copied from interface:SimpleFeature
Sets the values of the attributes contained by the feature.The 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++ ) ); }
- Specified by:
setAttributes
in interfaceSimpleFeature
- Parameters:
arg0
- The attribute values to set.
-
setAttributes
public void setAttributes(Object[] arg0)
Description copied from interface:SimpleFeature
Sets the values of the attributes contained by the feature.The 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] ); }
- Specified by:
setAttributes
in interfaceSimpleFeature
- Parameters:
arg0
- The attribute values to set.
-
setDefaultGeometry
public void setDefaultGeometry(Object arg0)
Description copied from interface:SimpleFeature
Sets the value of the default geometry for the feature.This method is convenience for:
getDefaultGeometryProperty().setValue(geometry);
- Specified by:
setDefaultGeometry
in interfaceSimpleFeature
- Parameters:
arg0
- The new default geometry value.
-
setDefaultGeometryProperty
public void setDefaultGeometryProperty(GeometryAttribute arg0)
Description copied from interface:Feature
Sets the default geometric attribute of the feature.This 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.
- Specified by:
setDefaultGeometryProperty
in interfaceFeature
- Parameters:
arg0
- The new geomtric attribute.
-
setDefaultGeometry
public void setDefaultGeometry(Geometry geometry) throws IllegalAttributeException
- Throws:
IllegalAttributeException
-
setValue
public void setValue(Collection<Property> arg0)
Description copied from interface:ComplexAttribute
Sets the contained properties of the complex attribute.The values should match the structure defined by
getDescriptor()
.- Specified by:
setValue
in interfaceComplexAttribute
-
setValue
public void setValue(Object arg0)
Description copied from interface:Property
Sets the value or content of the property.The class of newValue should be the same as or a subclass of
getType().getBinding()
.newValue may be
null
ifgetDescriptor().isNillable()
istrue
.
-
validate
public void validate()
Description copied from interface:ComplexAttribute
Check the properties against the constraints provided by their AttributeDescriptors.Please 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).
- Specified by:
validate
in interfaceAttribute
- Specified by:
validate
in interfaceComplexAttribute
-
-