org.geotools.filter.visitor
Class CapabilitiesFilterSplitter

java.lang.Object
  extended by org.geotools.filter.visitor.CapabilitiesFilterSplitter
All Implemented Interfaces:
org.opengis.filter.expression.ExpressionVisitor, org.opengis.filter.FilterVisitor

public class CapabilitiesFilterSplitter
extends java.lang.Object
implements org.opengis.filter.FilterVisitor, org.opengis.filter.expression.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

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

Constructor Detail

CapabilitiesFilterSplitter

public CapabilitiesFilterSplitter(Capabilities fcs,
                                  org.opengis.feature.type.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 org.opengis.filter.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 org.opengis.filter.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(org.opengis.filter.IncludeFilter filter)
Parameters:
filter - the Filter to visit
See Also:
FilterVisitor.visit(IncludeFilter, Object)

visit

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

visit

public java.lang.Object visit(org.opengis.filter.PropertyIsBetween filter,
                              java.lang.Object extradata)
Specified by:
visit in interface org.opengis.filter.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 java.lang.Object visit(org.opengis.filter.PropertyIsEqualTo filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.PropertyIsGreaterThan filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.PropertyIsGreaterThanOrEqualTo filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.PropertyIsLessThan filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.PropertyIsLessThanOrEqualTo filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.PropertyIsNotEqualTo filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.spatial.BBOX filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.spatial.Beyond filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.spatial.Contains filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.spatial.Crosses filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.spatial.Disjoint filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.spatial.DWithin filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.spatial.Equals filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.spatial.Intersects filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.spatial.Overlaps filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.spatial.Touches filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.spatial.Within filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.PropertyIsLike filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.And filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.Not filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.Or filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visitNullFilter

public java.lang.Object visitNullFilter(java.lang.Object notUsed)
Specified by:
visitNullFilter in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.IncludeFilter filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.ExcludeFilter filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.PropertyIsNull filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.Id filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.FilterVisitor

visit

public java.lang.Object visit(org.opengis.filter.expression.PropertyName expression,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.expression.ExpressionVisitor

visit

public java.lang.Object visit(org.opengis.filter.expression.Literal expression,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.expression.ExpressionVisitor

visit

public java.lang.Object visit(org.opengis.filter.expression.Add filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.expression.ExpressionVisitor

visit

public java.lang.Object visit(org.opengis.filter.expression.Divide filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.expression.ExpressionVisitor

visit

public java.lang.Object visit(org.opengis.filter.expression.Multiply filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.expression.ExpressionVisitor

visit

public java.lang.Object visit(org.opengis.filter.expression.Subtract filter,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.expression.ExpressionVisitor

visit

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

visit

public java.lang.Object visit(org.opengis.filter.expression.NilExpression nilExpression,
                              java.lang.Object notUsed)
Specified by:
visit in interface org.opengis.filter.expression.ExpressionVisitor


Copyright © 1996-2010 Geotools. All Rights Reserved.