Quantcast

Filtered list with OR'ed CompositeMatcherEditor

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Filtered list with OR'ed CompositeMatcherEditor

philk
Hello again,

finishing the project I wanted to add some final touches to it using a CompositeMatcherEditor to apply multiple filters to an EventList. This seems to work only when using the 'AND' matching method in CompositeMatcherEditor. When I switch the mode to "OR" the list remains unchanged regardless of which MatcherEditor I add to the CompositeMatcherEditor.

final CompositeMatcherEditor<E> compositeMatcherEditor = new CompositeMatcherEditor<E>();
compositeMatcherEditor.setMode(CompositeMatcherEditor.OR);
this.filteredItems = new FilterList<E>(this.items, compositeMatcherEditor);
this.filters = compositeMatcherEditor.getMatcherEditors();

I suspect it is because since "OR" means one of the MatcherEditors or none. So how can I filter the items with one or more MatcherEditors? If no MatcherEditors are set then the list should be not filtered. Upon activating a MatcherEditor it should be filtered by this one. And if I add another one it should be filtered by both, showing the result of *both* MatcherEditors combined (not exclusive). Or do I misunderstand the "OR" mode of CompositeMatcherEditor?

Regards,
Phil
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Filtered list with OR'ed CompositeMatcherEditor

Holger
Hi Phil,

as far as I know the CompositeMatcherEditor works as follows:
- if the CompositeMatcherEditor contains no MatcherEditors it matches all list elements.
- if the CompositeMatcherEditor contains one or more MatcherEditors it matches a list element
as soon as at least one contained MatcherEditor matches the element.

Please see this unit test class for the intended behaviour:
https://glazedlists.dev.java.net/source/browse/glazedlists/test/ca/odell/glazedlists/matchers/CompositeMatcherEditorTest.java

If you think there is an issue, please let us know, ideally with a small example that
demonstrates the problem.

Hope this helps,
Holger

>
>
> Hello again,
>
> finishing the project I wanted to add some final touches to it using a
> CompositeMatcherEditor to apply multiple filters to an EventList. This seems
> to work only when using the 'AND' matching method in CompositeMatcherEditor.
> When I switch the mode to "OR" the list remains unchanged regardless of
> which MatcherEditor I add to the CompositeMatcherEditor.
>
> final CompositeMatcherEditor<E> compositeMatcherEditor = new
> CompositeMatcherEditor<E>();
> compositeMatcherEditor.setMode(CompositeMatcherEditor.OR);
> this.filteredItems = new FilterList<E>(this.items, compositeMatcherEditor);
> this.filters = compositeMatcherEditor.getMatcherEditors();
>
> I suspect it is because since "OR" means one of the MatcherEditors or none.
> So how can I filter the items with one or more MatcherEditors? If no
> MatcherEditors are set then the list should be not filtered. Upon activating
> a MatcherEditor it should be filtered by this one. And if I add another one
> it should be filtered by both, showing the result of *both* MatcherEditors
> combined (not exclusive). Or do I misunderstand the "OR" mode of
> CompositeMatcherEditor?
>
> Regards,
> Phil
> --
> View this message in context: http://www.nabble.com/Filtered-list-with-OR%27ed-CompositeMatcherEditor-tf4475731.html#a12761671
> Sent from the GlazedLists - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000066

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Filtered list with OR'ed CompositeMatcherEditor

philk
Thanks Holger for your answer. I have already checked the unit tests for CompositeMatcherEditor without much success it seems :)
What puzzles me is that when I add a MatcherEditor that matches exactly ONE item in the list it still shows the complete list. I would have expected the list to contain only this ONE element. When I add another MatcherEdtitor that matches ANOTHER element I suspect the list to contain ONE element and ANOTHER element when the mode is set to "OR". But the list remains unchanged. I try to extract a small example to demonstrate the behaviour.


Thanks for your assistance,
Phil

Holger Brands wrote
Hi Phil,

as far as I know the CompositeMatcherEditor works as follows:
- if the CompositeMatcherEditor contains no MatcherEditors it matches all list elements.
- if the CompositeMatcherEditor contains one or more MatcherEditors it matches a list element
as soon as at least one contained MatcherEditor matches the element.

Please see this unit test class for the intended behaviour:
https://glazedlists.dev.java.net/source/browse/glazedlists/test/ca/odell/glazedlists/matchers/CompositeMatcherEditorTest.java

If you think there is an issue, please let us know, ideally with a small example that
demonstrates the problem.

Hope this helps,
Holger

>
>
> Hello again,
>
> finishing the project I wanted to add some final touches to it using a
> CompositeMatcherEditor to apply multiple filters to an EventList. This seems
> to work only when using the 'AND' matching method in CompositeMatcherEditor.
> When I switch the mode to "OR" the list remains unchanged regardless of
> which MatcherEditor I add to the CompositeMatcherEditor.
>
> final CompositeMatcherEditor<E> compositeMatcherEditor = new
> CompositeMatcherEditor<E>();
> compositeMatcherEditor.setMode(CompositeMatcherEditor.OR);
> this.filteredItems = new FilterList<E>(this.items, compositeMatcherEditor);
> this.filters = compositeMatcherEditor.getMatcherEditors();
>
> I suspect it is because since "OR" means one of the MatcherEditors or none.
> So how can I filter the items with one or more MatcherEditors? If no
> MatcherEditors are set then the list should be not filtered. Upon activating
> a MatcherEditor it should be filtered by this one. And if I add another one
> it should be filtered by both, showing the result of *both* MatcherEditors
> combined (not exclusive). Or do I misunderstand the "OR" mode of
> CompositeMatcherEditor?
>
> Regards,
> Phil
> --
> View this message in context: http://www.nabble.com/Filtered-list-with-OR%27ed-CompositeMatcherEditor-tf4475731.html#a12761671
> Sent from the GlazedLists - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glazedlists.dev.java.net
> For additional commands, e-mail: users-help@glazedlists.dev.java.net
>
>


_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000066

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glazedlists.dev.java.net
For additional commands, e-mail: users-help@glazedlists.dev.java.net
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Filtered list with OR'ed CompositeMatcherEditor

epelene
Hi
Did you ever find a solutin for this problem?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Filtered list with OR'ed CompositeMatcherEditor

James Lemieux
Coincidentally, I just pushed a fix up to github for this problem.


The problem here resided in an attempted optimization in CompositeMatcherEditor.setMode(). It incorrectly assumed that OrMatcher and AndMatcher produce identical filter states when there are no delegate Matchers. This is patently wrong.

I'll ask my cohort Holger to update a snapshot of the jar somewhere... I'm not exactly sure where that is hosted these days. The stuff on java.net is 2 years old.... that seems too old.

FYI, you could work around this problem in the short term (just to see correct behavior) by temporarily adding a MatcherEditor to your CompositeMatcherEditor (doesn't matter what), then changing the MODE, then removing the MatcherEditor. This would avoid executing the broken optimization in the code.

James

On Fri, Apr 10, 2015 at 1:23 AM, epelene <[hidden email]> wrote:
Hi
Did you ever find a solutin for this problem?




--
View this message in context: http://glazedlists.1045722.n5.nabble.com/Filtered-list-with-OR-ed-CompositeMatcherEditor-tp3418452p5710209.html
Sent from the GlazedLists - User mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Filtered list with OR'ed CompositeMatcherEditor

hbrands
Administrator
The fix is contained in the latest snapshot build.
You can get it directly with Maven from the java.net snapshot repository (http://www.glazedlists.com/Home/maven)
or download it manually from here:
https://java.net/projects/glazedlists/downloads/directory/latest_build

Holger


2015-04-10 10:54 GMT+02:00 James Lemieux <[hidden email]>:
Coincidentally, I just pushed a fix up to github for this problem.


The problem here resided in an attempted optimization in CompositeMatcherEditor.setMode(). It incorrectly assumed that OrMatcher and AndMatcher produce identical filter states when there are no delegate Matchers. This is patently wrong.

I'll ask my cohort Holger to update a snapshot of the jar somewhere... I'm not exactly sure where that is hosted these days. The stuff on java.net is 2 years old.... that seems too old.

FYI, you could work around this problem in the short term (just to see correct behavior) by temporarily adding a MatcherEditor to your CompositeMatcherEditor (doesn't matter what), then changing the MODE, then removing the MatcherEditor. This would avoid executing the broken optimization in the code.

James

On Fri, Apr 10, 2015 at 1:23 AM, epelene <[hidden email]> wrote:
Hi
Did you ever find a solutin for this problem?




--
View this message in context: http://glazedlists.1045722.n5.nabble.com/Filtered-list-with-OR-ed-CompositeMatcherEditor-tp3418452p5710209.html
Sent from the GlazedLists - User mailing list archive at Nabble.com.


Loading...