Class Join


  • public class Join
    extends Object
    Represents the joining of two feature types within a Query.

    The Join class is similar to Query in that it allows one to specify a FeatureType name, a set of properties, and a filter. A Join must specify:

    1. A type name that references the feature type to join to, see getTypeName()
    2. A join filter that describes how to join, see getJoinFilter()
    Optionally a Join may also specify:
    • A set of property names constraining the attributes of joined features, see getProperties()
    • A secondary filter used to constrained features from the joined feature type, see getFilter()
    • An alias for the joined feature type, which can be used in the join filter to disambiguate attributes of the feature types being joined, see getAlias()
    • A join type specifying what type of join (inner, outer, etc...) should be performed, see getType()
    Since:
    8.0
    Author:
    Justin Deoliveira, OpenGeo
    • Constructor Detail

      • Join

        public Join​(String typeName,
                    Filter join)
        Constructs a join.
        Parameters:
        typeName - The name of the feature type to join to.
        join - The filter specifying the join condition between the two feature types being joined.
      • Join

        public Join​(Join other)
        Constructs a join from another.
    • Method Detail

      • getTypeName

        public String getTypeName()
        The name of the feature type being joined to.

        This name may be the same as the name of the primary feature type, this is how a self join is specified.

      • getJoinFilter

        public Filter getJoinFilter()
        The filter defining the join condition between the primary feature type and the feature type being joined to.

        This filter should be a comparison operator whose contents are two PropertyName instances. For example:

         new Join("theOtherType", propertyIsEqualTo(propertyName("foo"), propertyName("bar")));
         
        In instances where the two property names involved in the join are the same a prefix or alias must be used to differentiate:
         Join j = new Join("theOtherType", propertyIsEqualTo(propertyName("foo"), propertyName("other.bar")));
         j.alias("other");
         
      • setType

        public void setType​(Join.Type type)
        Sets the join type.
        See Also:
        getType()
      • getProperties

        public List<PropertyName> getProperties()
        List of properties specifying which attributes of joined features to obtain.

        This method has the same purpose as Query.getProperties().

      • setProperties

        public void setProperties​(List<PropertyName> properties)
        Sets list of properties specifying which attributes of joined features to obtain.

        This method has the same purpose as Query.setProperties(List).

      • getPropertyNames

        public String[] getPropertyNames()
        List of property names specifying which attributes of joined features to obtain.

        This method has the same purpose as Query.getPropertyNames().

      • setFilter

        public void setFilter​(Filter filter)
        Sets the filter used to constrain which features from the joined feature type to return.
        See Also:
        getFilter()
      • getFilter

        public Filter getFilter()
        Filter used to constrain which features from the joined feature type to return.

        This filter must only reference attributes from the joined feature type, and not of any other feature types involved in the join.

      • setAlias

        public void setAlias​(String alias)
        Sets an alias for the feature type being joined to.
        See Also:
        getAlias()
      • getAlias

        public String getAlias()
        An alias for the feature type being joined to.

        This method is useful in cases where the two feature types being joined contain attributes identically named, or in cases where a self join is being performed:

         Join j = new Join("theOtherType", PropertyIsEqualTo(PropertyName("foo"), PropertyName("other.foo")));
         j.setAlias("other");
         
        See Also:
        getJoinFilter()
      • attributeName

        public String attributeName()
        Convenience method that returns the attribute name to be used for this join.

        Convenience for:

          return getAlias() != null ? getAlias() : getTypeName();