[udig-devel] Code that did not make sense ... implementation of MapImpl.select( bbox, and )

Jody Garnett jgarnett at refractions.net
Sat Dec 2 17:38:14 PST 2006


The following code goes to a lot of trouble to set up:
( newFilter OR oldFIlter AND (newFIlterCopy AND NOT(null)))

The second half of this filter is sure to fail - as NOT( null ) will be 
a null pointer exception every time ...

BEFORE (the problem is with the first line - notFilter never has an 
filter provided to it to inverse)
> LogicFilter 
> notFilter=createFilterFactory.createLogicFilter(FilterType.LOGIC_NOT);
> LogicFilter intersectionFilter = 
> createFilterFactory.createLogicFilter(newFilterCopy, notFilter, 
> FilterType.LOGIC_AND);
>                             
> LogicFilter andFilter = 
> createFilterFactory.createLogicFilter(oldFilter, intersectionFilter, 
> FilterType.LOGIC_AND);
> LogicFilter orFilter = 
> createFilterFactory.createLogicFilter(newFilter, andFilter, 
> FilterType.LOGIC_OR);
>                             
> layer.setFilter(orFilter);
I think this results to the same thing as newFilter - especially now 
that NPE is not fatal for an OR expression...

I have simply updated the factory use - preserving what I suspect is a 
bug on trunk:
> Filter notFilter=createFilterFactory.not( null ); // WARNING this is a 
> null operation
> Filter intersectionFilter = createFilterFactory.and(newFilterCopy, 
> notFilter);
>                             
> Filter andFilter = createFilterFactory.and(oldFilter, intersectionFilter);
> Filter orFilter = createFilterFactory.or(newFilter, andFilter );
>                             
> layer.setFilter(orFilter);

Jody


More information about the udig-devel mailing list