org.geotools.filter
Class SQLUnpacker

java.lang.Object
  extended byorg.geotools.filter.SQLUnpacker

public class SQLUnpacker
extends java.lang.Object

Determines which parts of a Filter can be turned into valid SQL statements. Given a filter it constructs two filters, one of the supported parts of the filter passed in, one of the unsupported. If one of the constructed filters is null (ie the whole filter is supported or unsupported), it is the clients responsibility to deal with that. The SQLUnpacker should be tightly coordinated with the SQLEncoder. The SQLEncoder passes its Capabilities (ie which filters it can encode and which it can't) to the Unpacker, and the Unpacker returns a supported filter, which should be passed to the Encoder as the Encoder Capabilities claimed to fully support everything in the supported filter. The unsupported filter should be used after the SQL statement is executed, testing each feature in the result set with the contains method.

This Unpacker can likely be easily used with any Encoder that has a FilterCapabilities of the actions it can perform. May want to rename it FilterUnpacker, as it is likely generic enough, but for now this name should be fine, to emphasize that the SQLEncoder needs to be closely linked to it to work properly.

Author:
Chris Holmes, TOPP
Task:
REVISIT: The getSupported getUnsupported is clunky and dangerous, as clients could be using this and do an unpack, get the unsupported filter, and then do another unpack, and want to get the first supported filter, and would get the second instead. This is likely in a getFeatures when the unpacker is held by the class. So for now clients should construct an unpacker whenever they want to use it. This is obviously less than ideal. So this should be revisited. One way is fir the unpack methods to return FilterPairs, for the clients to deal with themselves. I'm not sure that this is the best semantic, and it exposes an inner class that really has no other use, so it could be nice to do it a better way. Another option is to have static methods SQLUnpacker.getSupported(Filter, splitType, capabilities), or something to that effect. Or non static, but pass the filter in each time. If anyone is looking at this class and has suggestions email the list, as we should think this through more, but I've other pressing tasks.

Constructor Summary
SQLUnpacker(FilterCapabilities capabilities)
          Constructor with FilterCapabilities from the Encoder used in conjunction with this Unpacker.
 
Method Summary
 Filter getSupported()
          After an unPack has been called, returns the resulting Filter of the supported parts of the unPacked filter.
 Filter getUnSupported()
          After an unPack has been called, returns the resulting Filter of the unsupported parts of the unPacked filter.
 void unPackAND(Filter filter)
          Performs the unpacking of a filter, for the cases when ANDs can be split and ORs can not.
 void unPackOR(Filter filter)
          Performs the unpacking of a filter, for the cases when ORs can be split and ANDs can not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLUnpacker

public SQLUnpacker(FilterCapabilities capabilities)
Constructor with FilterCapabilities from the Encoder used in conjunction with this Unpacker.

Parameters:
capabilities - what FilterTypes should be supported.
Method Detail

unPackAND

public void unPackAND(Filter filter)
Performs the unpacking of a filter, for the cases when ANDs can be split and ORs can not. To get the results of the unpacking getUnsupported and getSupported must be called before another unpacking is done.

Parameters:
filter - to be unpacked, split on ANDs

unPackOR

public void unPackOR(Filter filter)
Performs the unpacking of a filter, for the cases when ORs can be split and ANDs can not. To get the results of the unpacking getUnsupported and getSupported must be called before another unpacking is done.

Parameters:
filter - to be unpacked, split on ANDs

getUnSupported

public Filter getUnSupported()
After an unPack has been called, returns the resulting Filter of the unsupported parts of the unPacked filter. If the unPacked filter is fully supported this returns a null, it is the client's responsibility to deal with it. If there are multiple unsupported subfilters they are ANDed together.

Returns:
A filter of the unsupported parts of the unPacked filter.

getSupported

public Filter getSupported()
After an unPack has been called, returns the resulting Filter of the supported parts of the unPacked filter. If the unPacked filter is not supported at all this returns a null, it is the client's responsibility to deal with it. If there are multiple supported subfilters they are ANDed together.

Returns:
A filter of the supported parts of the unPacked filter.


Copyright © GeoTools. All Rights Reserved.