through all the properties for (Property p : attribute.getValue(); ) { // do something with the property }
Contained properties can also be fetched by name by {@link Name} with the{@link #getProperties(Name)} and {@link #getProperties(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 the {@link #getProperty(Name)} and{@link #getProperty(String)} methods can be used to get direct access to theproperty.
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, an {@link Expression} 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
@author Gabriel Roldan, Axios Engineering
@author Justin Deoliveira, The Open Planning Project
@source $URL$