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:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
    • name

      protected final String name
      Name of the property from which to retrieve the value. This is the argument to give in calls to Feature#getProperty(String)
    • isVirtual

      protected final boolean isVirtual
      Whether the property to fetch is considered virtual (a property that may be defined only in sub-types). If true, then expectedType(FeatureType, FeatureTypeBuilder) will not throw an exception if the property is not found.
    • VIRTUAL_PREFIX

      static final String VIRTUAL_PREFIX
      The prefix in a x-path for considering a property as virual.
      See Also:
  • Constructor Details

    • PropertyValue

      protected PropertyValue(String name, boolean isVirtual)
      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 interface Expression<AbstractFeature,V>
      Returns:
      name of the function to be called.
    • create

      static <V> ValueReference<AbstractFeature,V> create(String xpath, Class<V> type)
      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 of type.
      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

      protected final Collection<?> getChildren()
      Specified by:
      getChildren in class Node
      Returns:
      the children of this node, or an empty collection if none.
    • getXPath

      public final String getXPath()
      Returns the name of the property whose value will be returned by the Expression.apply(Object) method.
      Specified by:
      getXPath in interface ValueReference<AbstractFeature,V>
    • getSourceClass

      protected Class<?> getSourceClass()
      Returns the type of values fetched from AbstractFeature instance. This is the type before conversion to the target type. The type is always Object on newly created expression because the type of feature property values is unknown, but may become a specialized type after Optimization has been applied.
    • expectedType

      final PropertyTypeBuilder expectedType(FeatureTypeBuilder addTo)
      Returns the default value of expectedType(FeatureType, FeatureTypeBuilder) when it cannot be inferred by the analysis of the given FeatureType.
    • toValueType

      public final <N> PropertyValue<N> toValueType(Class<N> target)
      Returns an expression that provides values as instances of the specified class.
      Specified by:
      toValueType in interface Expression<AbstractFeature,V>
      Type Parameters:
      N - compile-time value of type.
      Parameters:
      target - desired type of expression results.
      Returns:
      expression doing the same operation this this expression but with results of the specified type.
    • optimize

      public 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. This optimization is important for allowing SQLStore to put the column name in the SQL WHERE clause. It makes the difference between using or not the database index.
      Specified by:
      optimize in interface Optimization.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

      public PropertyTypeBuilder expectedType(DefaultFeatureType valueType, FeatureTypeBuilder addTo)
      Provides the expected type of values produced by this expression when a feature of the given type is evaluated.
      Specified by:
      expectedType in interface FeatureExpression<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.