org.geotools.filter
Class LogicSAXParser

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

public class LogicSAXParser
extends java.lang.Object

Processes messages from clients to create Logic Filters. Handles nested logic filters. Filters should call start and end when they reach logic filters, and create when the filter is complete. This documenation provided by Dave Blasby April 1/2005 after fixing GEOS-328: DJB: okay, there's no where near enough comments in here to understand whats going on. Hopefully I'm correct. I've looked at this for a bit, and this is what I can figure out. This is called by the FilterFilter class (nice name...NOT) which is also a sax parser-like class. Basically, the FilterFilter does most of the Filter parsing - but it hands most of the work off to the appropriate classes. For NOT, AND, OR clauses, this class is used. As a simple example, [STATE_NAME = 'NY'] [STATE_NAME = 'WA'] Or, in long form: STATE_NAME NY STATE_NAME WA The "PropertyIsEqualTo" is handled by another parser, so we dont have to worry about it here for the moment. So, the order of events are like this: start( "OR" ) add([STATE_NAME = 'NY']) // these are handled by another class add([STATE_NAME = 'WA']) // these are handled by another class end ("OR") create() // this creates an actual Filter [[ STATE_NAME = NY ] OR [ STATE_NAME = WA ]] This is pretty simple, but it gets more complex when you have nested structures. STATE_NAME NY STATE_NAME WA STATE_NAME BC Again, we're going to ignore the "PropertyIsEqualTo" stuff since its handled elsewhere. The main idea is that there will be a LogicSAXParser for the top-level "AND" and another one for the nested "OR". It gets a bit harder to describe because the classes start passing events to each other. start("AND") -- the parent LogicSAXParser starts to construct an "AND" filter start("OR") -- the "AND" parser sees that its sub-element is another logic operator. It makes another LogicSAXParser that will handle the "OR" SAX events. add([STATE_NAME = 'NY']) -- this is sent to the "AND" parser. It then sends it to the "OR" parser. + "OR" parser remembers this component add([STATE_NAME = 'WA']) -- this is sent to the "AND" parser. It then sends it to the "OR" parser. + "OR" parser remembers this component end("OR") -- this is sent to the "AND" parser. It then sends it to the "OR" parser. + The "OR" parser marks itself as complete + The "AND" parser notices that its child is completed parsing + The "AND" parser calls create() on the "OR" parser to make a filter (see next step) + Since "OR" is finished, "AND" stop passing events to it. "OR".create() -- makes a "[[ STATE_NAME = NY ] OR [ STATE_NAME = WA ]]" and "AND" remembers it as a component add ([ STATE_NAME = BC ]) --This is added as a component to the "AND" filter. end ("AND") -- the "AND" parser marks itself as complete create() -- the "AND" parser creates a FILTER [[[ STATE_NAME = NY ] OR [ STATE_NAME = WA ]] AND [ STATE_NAME = BC ]] Higher levels of nesting work the same way - each level will send the event down to the next level. If logicFilter == null then this object is the one doing the processing. If its non-null, then the sub-object is doing the processing - event are sent to it.

Version:
$Id: LogicSAXParser.java 17701 2006-01-23 00:00:51Z desruisseaux $
Author:
Rob Hranac, Vision for New York, Chris Holmes, TOPP

Constructor Summary
LogicSAXParser()
          Constructor which flags the operator as between.
LogicSAXParser(FilterFactory factory)
          Constructor injection
 
Method Summary
 void add(Filter filter)
          Adds a filter to the current logic list.
 Filter create()
          Creates the the logic filter if in a complete state.
 void end(short logicType)
          To be called when the sax parser reaches the end of a logic filter.
 boolean isComplete()
          indicates if the logic filter is complete.
 void setFilterFactory(FilterFactory factory)
          Setter injection
 void start(short logicType)
          To be called by a parser to start the creation of a logic filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogicSAXParser

public LogicSAXParser()
Constructor which flags the operator as between.


LogicSAXParser

public LogicSAXParser(FilterFactory factory)
Constructor injection

Method Detail

setFilterFactory

public void setFilterFactory(FilterFactory factory)
Setter injection


start

public void start(short logicType)
           throws IllegalFilterException
To be called by a parser to start the creation of a logic filter. Can start a nested or a base logic filter.

Parameters:
logicType - OR, or AND abstract filter type.
Throws:
IllegalFilterException - if filter type does not match declared type.

end

public void end(short logicType)
         throws IllegalFilterException
To be called when the sax parser reaches the end of a logic filter. Tells this class to complete.

Parameters:
logicType - the Filter type.
Throws:
IllegalFilterException - If the end message can't be processed in this state.

add

public void add(Filter filter)
Adds a filter to the current logic list.

Parameters:
filter - The filter to be added.

create

public Filter create()
              throws IllegalFilterException
Creates the the logic filter if in a complete state.

Returns:
The created logic filter.
Throws:
IllegalFilterException - if the filter is not complete.

isComplete

public boolean isComplete()
indicates if the logic filter is complete.

Returns:
true if this holds a complete logic filter to be created, false otherwise.


Copyright © GeoTools. All Rights Reserved.