Interface ComplexAttribute
-
- All Known Subinterfaces:
Feature
,SimpleFeature
- All Known Implementing Classes:
ComplexAttributeImpl
,DecoratingFeature
,FeatureImpl
,JDBCFeatureReader.ResultSetFeature
,MongoDBObjectFeature
,MongoFeature
,PreGeneralizedSimpleFeature
,SimpleFeatureImpl
public interface ComplexAttribute extends Attribute
An instance ofComplexType
which is composed of other properties.A complex attribute is a container for other properties (attributes + associations). The value of a complex attribute is a collection of those contained properties.
Property Access
ThegetValue()
method returns a collection of the properties contained by the complex attribute.ComplexAttribute attribute = ...; //loop through all the properties for (Property p : attribute.getValue(); ) { // do something with the property }
Contained properties can also be fetched by name byName
with thegetProperties(Name)
andgetProperties(String)
methods.ComplexAttribute attribute = ...; //loop through all the "foo" attributes for ( Property p : attribute.getProperties( "foo" ) ) { p.getName().getLocalPart() == "foo"; }
Often it is known in advance that a single instance of a particular property exists. When this is the case thegetProperty(Name)
andgetProperty(String)
methods can be used to get direct access to the property.ComplexAttribute attribute = ...; //get the single foo attribute Property foo = attribute.getProperty( "foo" );
Xpath and Query Language Access
The above property access methods perform an exact match on property name against the name passed in. However, often it is necesary to access properties via a query language such as xpath.
For instance.the expression
"//foo"
should return all the properties named "foo". Or the expression"foo/bar"
should return the "bar" property nested inside of the "foo" property. In these cases, anExpression
must be used:ComplexAttribute attribute = ...; //get the 'foo/bar' property FilterFactory factory = ...; PropertyName xpath = factory.property( "foo/bar" ); Property bar = xpath.evaluate( attribute );
- Author:
- Jody Garnett, Refractions Research, Gabriel Roldan, Axios Engineering, Justin Deoliveira, The Open Planning Project
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Collection<Property>
getProperties()
Complete collection of properties.Collection<Property>
getProperties(String name)
Returns a subset of the properties of the complex attribute which match the specified name.Collection<Property>
getProperties(Name name)
Returns a subset of the properties of the complex attribute which match the specified name.Property
getProperty(String name)
Returns single property of the complex attribute which matches the specified name.Property
getProperty(Name name)
Returns single property of the complex attribute which matches the specified name.ComplexType
getType()
Override ofAttribute.getType()
which type narrows toComplexType
.Collection<? extends Property>
getValue()
Override ofProperty.getValue()
which returns the collection ofProperty
which make up the value of the complex attribute.void
setValue(Collection<Property> values)
Sets the contained properties of the complex attribute.void
validate()
Check the properties against the constraints provided by their AttributeDescriptors.-
Methods inherited from interface Attribute
getDescriptor, getIdentifier
-
Methods inherited from interface Property
getName, getUserData, hasUserData, isNillable, setValue
-
-
-
-
Method Detail
-
getType
ComplexType getType()
Override ofAttribute.getType()
which type narrows toComplexType
.- Specified by:
getType
in interfaceAttribute
- Specified by:
getType
in interfaceProperty
- Returns:
- The attribute type.
- See Also:
Attribute.getType()
-
setValue
void setValue(Collection<Property> values)
Sets the contained properties of the complex attribute.The values should match the structure defined by
getDescriptor()
.
-
getValue
Collection<? extends Property> getValue()
Override ofProperty.getValue()
which returns the collection ofProperty
which make up the value of the complex attribute.
-
getProperties
Collection<Property> getProperties(Name name)
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.- Parameters:
name
- 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.
-
getProperty
Property getProperty(Name name)
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.- Parameters:
name
- The name of the property to return.- Returns:
- The property matching the specified name, or
null
.
-
getProperties
Collection<Property> getProperties(String name)
Returns a subset of the properties of the complex attribute which match the specified name.This method is a convenience for
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
getProperties(Name)
is safer.- Parameters:
name
- 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:
getProperties(Name)
-
getProperties
Collection<Property> getProperties()
Complete collection of properties.This method is a convenience method for calling (Collection
) getValue(). - Returns:
- The complete collection of properties.
-
getProperty
Property getProperty(String name)
Returns single property of the complex attribute which matches the specified name.This method is a convenience for
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
getProperties(Name)
is safer.- Parameters:
name
- The local name of the property to return.- Returns:
- The property matching the specified name, or
null
.
-
validate
void validate() throws IllegalAttributeException
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
- Throws:
IllegalAttributeException
- If any attribute fails validation
-
-