org.geotools.filter.visitor
Class CapabilitiesFilterSplitter

Object
  extended by CapabilitiesFilterSplitter
All Implemented Interfaces:
ExpressionVisitor, FilterVisitor

public class CapabilitiesFilterSplitter
extends Object
implements FilterVisitor, ExpressionVisitor

Determines what queries can be processed server side and which can be processed client side.

IMPLEMENTATION NOTE: This class is implemented as a stack processor. If you're curious how it works, compare it with the old SQLUnpacker class, which did the same thing using recursion in a more straightforward way.

Here's a non-implementors best-guess at the algorithm: Starting at the top of the filter, split each filter into its constituent parts. If the given FilterCapabilities support the given operator, then keep checking downwards.

The key is in knowing whether or not something "down the tree" from you wound up being supported or not. This is where the stacks come in. Right before handing off to accept() the sub- filters, we count how many things are currently on the "can be proccessed by the underlying datastore" stack (the preStack) and we count how many things are currently on the "need to be post- processed" stack.

After the accept() call returns, we look again at the preStack.size() and postStack.size(). If the postStack has grown, that means that there was stuff down in the accept()-ed filter that wasn't supportable. Usually this means that our filter isn't supportable, but not always. In some cases a sub-filter being unsupported isn't necessarily bad, as we can 'unpack' OR statements into AND statements (DeMorgans rule/modus poens) and still see if we can handle the other side of the OR. Same with NOT and certain kinds of AND statements.

In addition this class supports the case where we're doing an split in the middle of a client-side transaction. I.e. imagine doing a against a WFS-T where you have to filter against actions that happened previously in the transaction. That's what the ClientTransactionAccessor interface does, and this class splits filters while respecting the information about deletes and updates that have happened previously in the Transaction. I can't say with certainty exactly how the logic for that part of this works, but the test suite does seem to test it and the tests do pass.

Since:
2.5.3
Author:
dzwiers, commented and ported from gt to ogc filters by saul.farber, ported to work upon org.geotools.filter.Capabilities by Gabriel Roldan
Module:

Constructor Summary
CapabilitiesFilterSplitter(Capabilities fcs, FeatureType parent, ClientTransactionAccessor transactionAccessor)
          Create a new instance.
 
Method Summary
 Filter getFilterPost()
          Gets the filter that cannot be sent to the server and must be post-processed on the client by geotools.
 Filter getFilterPre()
          Gets the filter that can be sent to the server for pre-processing.
 Object visit(Add filter, Object notUsed)
           
 Object visit(And filter, Object notUsed)
           
 Object visit(BBOX filter, Object notUsed)
           
 Object visit(Beyond filter, Object notUsed)
           
 Object visit(Contains filter, Object notUsed)
           
 Object visit(Crosses filter, Object notUsed)
           
 Object visit(Disjoint filter, Object notUsed)
           
 Object visit(Divide filter, Object notUsed)
           
 Object visit(DWithin filter, Object notUsed)
           
 Object visit(Equals filter, Object notUsed)
           
 void visit(ExcludeFilter filter)
           
 Object visit(ExcludeFilter filter, Object notUsed)
           
 Object visit(Function expression, Object notUsed)
           
 Object visit(Id filter, Object notUsed)
           
 void visit(IncludeFilter filter)
           
 Object visit(IncludeFilter filter, Object notUsed)
           
 Object visit(Intersects filter, Object notUsed)
           
 Object visit(Literal expression, Object notUsed)
           
 Object visit(Multiply filter, Object notUsed)
           
 Object visit(NilExpression nilExpression, Object notUsed)
           
 Object visit(Not filter, Object notUsed)
           
 Object visit(Or filter, Object notUsed)
           
 Object visit(Overlaps filter, Object notUsed)
           
 Object visit(PropertyIsBetween filter, Object extradata)
           
 Object visit(PropertyIsEqualTo filter, Object notUsed)
           
 Object visit(PropertyIsGreaterThan filter, Object notUsed)
           
 Object visit(PropertyIsGreaterThanOrEqualTo filter, Object notUsed)
           
 Object visit(PropertyIsLessThan filter, Object notUsed)
           
 Object visit(PropertyIsLessThanOrEqualTo filter, Object notUsed)
           
 Object visit(PropertyIsLike filter, Object notUsed)
           
 Object visit(PropertyIsNotEqualTo filter, Object notUsed)
           
 Object visit(PropertyIsNull filter, Object notUsed)
           
 Object visit(PropertyName expression, Object notUsed)
           
 Object visit(Subtract filter, Object notUsed)
           
 Object visit(Touches filter, Object notUsed)
           
 Object visit(Within filter, Object notUsed)
           
 Object visitNullFilter(Object notUsed)
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CapabilitiesFilterSplitter

public CapabilitiesFilterSplitter(Capabilities fcs,
                                  FeatureType parent,
                                  ClientTransactionAccessor transactionAccessor)
Create a new instance.

Parameters:
fcs - The FilterCapabilties that describes what Filters/Expressions the server can process.
parent - The FeatureType that this filter involves. Why is this needed?
transactionAccessor - If the transaction is handled on the client and not the server then different filters must be sent to the server. This class provides a generic way of obtaining the information from the transaction.
Method Detail

getFilterPost

public Filter getFilterPost()
Gets the filter that cannot be sent to the server and must be post-processed on the client by geotools.

Returns:
the filter that cannot be sent to the server and must be post-processed on the client by geotools.

getFilterPre

public Filter getFilterPre()
Gets the filter that can be sent to the server for pre-processing.

Returns:
the filter that can be sent to the server for pre-processing.

visit

public void visit(IncludeFilter filter)
Parameters:
filter - the Filter to visit
See Also:
FilterVisitor.visit(IncludeFilter, Object)

visit

public void visit(ExcludeFilter filter)
Parameters:
filter - the Filter to visit
See Also:
FilterVisitor.visit(ExcludeFilter, Object)

visit

public Object visit(PropertyIsBetween filter,
                    Object extradata)
Specified by:
visit in interface FilterVisitor
Parameters:
filter - the Filter to visit
See Also:
NOTE: This method is extra documented as an example of how all the other methods are implemented. If you want to know how this class works read this method first!

visit

public Object visit(PropertyIsEqualTo filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(PropertyIsGreaterThan filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(PropertyIsGreaterThanOrEqualTo filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(PropertyIsLessThan filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(PropertyIsLessThanOrEqualTo filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(PropertyIsNotEqualTo filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(BBOX filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(Beyond filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(Contains filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(Crosses filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(Disjoint filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(DWithin filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(Equals filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(Intersects filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(Overlaps filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(Touches filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(Within filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(PropertyIsLike filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(And filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(Not filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(Or filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visitNullFilter

public Object visitNullFilter(Object notUsed)
Specified by:
visitNullFilter in interface FilterVisitor

visit

public Object visit(IncludeFilter filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(ExcludeFilter filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(PropertyIsNull filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(Id filter,
                    Object notUsed)
Specified by:
visit in interface FilterVisitor

visit

public Object visit(PropertyName expression,
                    Object notUsed)
Specified by:
visit in interface ExpressionVisitor

visit

public Object visit(Literal expression,
                    Object notUsed)
Specified by:
visit in interface ExpressionVisitor

visit

public Object visit(Add filter,
                    Object notUsed)
Specified by:
visit in interface ExpressionVisitor

visit

public Object visit(Divide filter,
                    Object notUsed)
Specified by:
visit in interface ExpressionVisitor

visit

public Object visit(Multiply filter,
                    Object notUsed)
Specified by:
visit in interface ExpressionVisitor

visit

public Object visit(Subtract filter,
                    Object notUsed)
Specified by:
visit in interface ExpressionVisitor

visit

public Object visit(Function expression,
                    Object notUsed)
Specified by:
visit in interface ExpressionVisitor
See Also:
FilterVisitor.visit(org.geotools.filter.FunctionExpression)

visit

public Object visit(NilExpression nilExpression,
                    Object notUsed)
Specified by:
visit in interface ExpressionVisitor


Copyright © 1996-2009 Geotools. All Rights Reserved.