Class Capabilities


  • public class Capabilities
    extends Object
    Allows for easier interaction with FilterCapabilities.

    This class provides some out of the box FilterCapabilities constants that you can quickly use to describe the encoding abilities of your service.

    This class behaves similar to Citations in that the constants are to be considered immutable, methods have been provided to assist in composing your own set of FilterCapabilities.

    Example:

    
     Capabilities capabilities = new Capabilities();
     capabilities.addAll( Capabilities.LOGICAL );
     capabilities.addAll( Capabilities.SIMPLE_COMPARISONS );
     
    You can use the Capabilities class at runtime to check existing filters to see if they are fully supported:
    
     if( fullySupports( filter )) {
         // do something
     }
     
    Right now the class gives no indication as to what part of the provided filter was in error.
    Author:
    Jody Garnett
    • Field Detail

      • LOGICAL

        public static Capabilities LOGICAL
        Support for logical types AND, OR and NOT
      • LOGICAL_OPENGIS

        public static Capabilities LOGICAL_OPENGIS
      • SIMPLE_COMPARISONS

        public static Capabilities SIMPLE_COMPARISONS
        Capabilities representing the simple comparisions.
      • SIMPLE_COMPARISONS_OPENGIS

        public static Capabilities SIMPLE_COMPARISONS_OPENGIS
    • Constructor Detail

      • Capabilities

        public Capabilities()
    • Method Detail

      • getContents

        public FilterCapabilitiesImpl getContents()
        Returns the internal FilterCapabilities data structure used for checking.
        Returns:
        FilterCapabilities
      • addType

        public void addType​(Class type)
        Adds a new support type to capabilities.

        This is the same as:addName( toOperationName( type ) )

        Parameters:
        type - the Class that indicates the new support.
      • addName

        public void addName​(String name)
        Adds support for the provided name.

        If this is a known name (avaialble as part of opengis interface) it will be grouped into:

        • Spatial Operators: Will added a SpatialOperator into the mix with Point, LineString, Polygon as the supported geometry operands (based on the assumption of JTS)
        • Comparison Operators:
        • Arithmetic Operators: will cause hassimpleArithmetic to be true
        • Other: will be treated as a no argument function call
        This method will have no effect if the operator is already known.

        Examples:

        
         capabilities.addName("Beyond"); // will enabled Beyond Filter
         capabilities.addName("NullCheck"); // will enable PropertyIsNull Filter
         capabilities.addName("SUB"); // will enabled hasSimpleArithmetic
         capabilities.addName("PI"); // add a no argument function called PI()
         
        Parameters:
        name - FilterCapabilities Operand name such as "BBOX", "Like" or "MUL"
      • addName

        public void addName​(String name,
                            int argumentCount)
        Will add support for a function with the provided number of arguments

        This method will have no effect if the function is already listed.

        Example:capabilities.addName( "Length", 1 )

      • addName

        public void addName​(String name,
                            String... argumentNames)
        Document support for the provided function.

        This method will have no effect if the function is already listed.

        Example:capabilities.addName( "Min", "value1", "value2" )

      • supports

        public boolean supports​(Filter filter)
        Determines if specific filter passed in is supported.
        Parameters:
        filter - The Filter to be tested.
        Returns:
        true if supported, false otherwise.
        See Also:
        IsSupportedFilterVisitor
      • fullySupports

        public boolean fullySupports​(Filter filter)
        Determines if the filter and all its sub filters and expressions are supported.

        Is most important for logic filters, as they are the only ones with subFilters. The geoapi FilterVisitor and ExpressionVisitors allow for the handling of null, even so care should be taken to use Filter.INCLUDE and Expression.NIL where you can.

        Parameters:
        filter - the filter to be tested.
        Returns:
        true if all sub filters are supported, false otherwise.
        See Also:
        IsFullySupportedFilterVisitor
      • fullySupports

        public boolean fullySupports​(Expression expression)
        Determines if the expression and all its sub expressions is supported.

        The Expression visitor used for this work can handle null, even so care should be taken to useExpression.NIL where you can.

        Parameters:
        expression - the expression to be tested.
        Returns:
        true if all sub filters are supported, false otherwise.
        See Also:
        IsFullySupportedFilterVisitor
      • toOperationName

        public String toOperationName​(Filter filter)
        Quickly look at the filter and determine the OperationName we need to check for in the FilterCapabilities data structure.
        Returns:
        Operation name
      • toOperationName

        public String toOperationName​(Class filterType)
        Figure out the OperationName for the provided filterType.

        The returned name can be used to check the FilterCapabilities to see if it type is supported in this execution context.

        This approach is not applicable for Functions.

        Parameters:
        filterType - Filter type
        Returns:
        Operation name for the provided FilterType