Package org.apache.sis.filter
Class PropertyValue<V>
- Type Parameters:
V
- the type of value computed by the expression.
- All Implemented Interfaces:
Serializable
,Function<AbstractFeature,
,V> Expression<AbstractFeature,
,V> Optimization.OnExpression<AbstractFeature,
,V> FeatureExpression<AbstractFeature,
,V> ValueReference<AbstractFeature,
V>
- Direct Known Subclasses:
PropertyValue.AsObject
,PropertyValue.Converted
abstract class PropertyValue<V>
extends LeafExpression<AbstractFeature,V>
implements ValueReference<AbstractFeature,V>, Optimization.OnExpression<AbstractFeature,V>
Expression whose value is computed by retrieving the value indicated by the provided name.
This expression does not store any value; it acts as an indirection to a property value of
the evaluated feature.
- Since:
- 1.1
- Version:
- 1.2
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
An expression fetching property values asObject
.private static final class
An expression fetching property values as an object of specified type.private static class
An expression fetching property values as an object of specified type.Nested classes/interfaces inherited from class org.apache.sis.filter.LeafExpression
LeafExpression.Literal<R,
V>, LeafExpression.Transformed<R, V> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final boolean
Whether the property to fetch is considered virtual (a property that may be defined only in sub-types).protected final String
Name of the property from which to retrieve the value.private static final long
For cross-version compatibility.(package private) static final String
The prefix in a x-path for considering a property as virual. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
PropertyValue
(String name, boolean isVirtual) Creates a new expression retrieving values from a property of the given name. -
Method Summary
Modifier and TypeMethodDescription(package private) static <V> ValueReference<AbstractFeature,
V> Creates a new expression retrieving values from a property of the given path.(package private) final PropertyTypeBuilder
expectedType
(FeatureTypeBuilder addTo) Returns the default value ofexpectedType(FeatureType, FeatureTypeBuilder)
when it cannot be inferred by the analysis of the givenFeatureType
.expectedType
(DefaultFeatureType valueType, FeatureTypeBuilder addTo) Provides the expected type of values produced by this expression when a feature of the given type is evaluated.protected final Collection<?>
final org.opengis.util.ScopedName
Returns the name of the function to be called.protected Class<?>
Returns the type of values fetched fromAbstractFeature
instance.final String
getXPath()
Returns the name of the property whose value will be returned by theExpression.apply(Object)
method.abstract PropertyValue<V>
optimize
(Optimization optimization) If the evaluated property is a link, replaces this expression by a more direct reference to the target property.final <N> PropertyValue<N>
toValueType
(Class<N> target) Returns an expression that provides values as instances of the specified class.Methods inherited from class org.apache.sis.filter.LeafExpression
getParameters
Methods inherited from class org.apache.sis.internal.filter.Node
createName, createType, equals, getGeometryLibrary, hashCode, symbol, toGeometryWrapper, toString, unwrap, warning
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.sis.filter.Expression
apply, getParameters
Methods inherited from interface org.apache.sis.internal.feature.FeatureExpression
getValueClass
Methods inherited from interface org.apache.sis.filter.Optimization.OnExpression
recreate
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
name
Name of the property from which to retrieve the value. This is the argument to give in calls toFeature#getProperty(String)
-
isVirtual
protected final boolean isVirtualWhether the property to fetch is considered virtual (a property that may be defined only in sub-types). Iftrue
, thenexpectedType(FeatureType, FeatureTypeBuilder)
will not throw an exception if the property is not found. -
VIRTUAL_PREFIX
The prefix in a x-path for considering a property as virual.- See Also:
-
-
Constructor Details
-
PropertyValue
Creates a new expression retrieving values from a property of the given name.
-
-
Method Details
-
getFunctionName
public final org.opengis.util.ScopedName getFunctionName()Description copied from interface:Expression
Returns the name of the function to be called.- Specified by:
getFunctionName
in interfaceExpression<AbstractFeature,
V> - Returns:
- name of the function to be called.
-
create
Creates a new expression retrieving values from a property of the given path. Simple path expressions of the form "a/b/c" can be used.- Type Parameters:
V
- compile-time value oftype
.- Parameters:
xpath
- path (usually a single name) of the property to fetch.type
- the desired type for the expression result.- Returns:
- expression retrieving values from a property of the given name.
- Throws:
IllegalArgumentException
- if the given XPath is not supported.
-
getChildren
- Specified by:
getChildren
in classNode
- Returns:
- the children of this node, or an empty collection if none.
-
getXPath
Returns the name of the property whose value will be returned by theExpression.apply(Object)
method.- Specified by:
getXPath
in interfaceValueReference<AbstractFeature,
V>
-
getSourceClass
Returns the type of values fetched fromAbstractFeature
instance. This is the type before conversion to the target type. The type is alwaysObject
on newly created expression because the type of feature property values is unknown, but may become a specialized type afterOptimization
has been applied. -
expectedType
Returns the default value ofexpectedType(FeatureType, FeatureTypeBuilder)
when it cannot be inferred by the analysis of the givenFeatureType
. -
toValueType
Returns an expression that provides values as instances of the specified class.- Specified by:
toValueType
in interfaceExpression<AbstractFeature,
V> - Type Parameters:
N
- compile-time value oftype
.- Parameters:
target
- desired type of expression results.- Returns:
- expression doing the same operation this this expression but with results of the specified type.
-
optimize
If the evaluated property is a link, replaces this expression by a more direct reference to the target property. This optimization is important for allowingSQLStore
to put the column name in the SQLWHERE
clause. It makes the difference between using or not the database index.- Specified by:
optimize
in interfaceOptimization.OnExpression<AbstractFeature,
V> - Parameters:
optimization
- the simplifications or optimizations to apply on this expression.- Returns:
- the simplified or optimized expression, or
this
if no optimization has been applied.
-
expectedType
Provides the expected type of values produced by this expression when a feature of the given type is evaluated.- Specified by:
expectedType
in interfaceFeatureExpression<AbstractFeature,
V> - Parameters:
valueType
- the type of features to be evaluated by the given expression.addTo
- where to add the type of properties evaluated by the given expression.- Returns:
- builder of the added property, or
null
if this method cannot add a property. - Throws:
IllegalArgumentException
- if this method cannot determine the property type for the given feature type.
-