File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Applying a range filter to RowFilter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Applying a range filter to RowFilter" Watch "Applying a range filter to RowFilter" New topic
Author

Applying a range filter to RowFilter

Matthew Tilic
Ranch Hand

Joined: Apr 07, 2011
Posts: 41

Hi,

I have a JTable with some delightful information that needs to be filtered. I have applied a row filter successfully to a single column and filtered it to search for a value e.g. 205, however, I would like to search a range of data 205-250 and find all the values in this column that are anywhere in-between.

secondly I will then want to apply extra filters on top later. e.g. search a range of data in column 1 with that data being successfully found re-filter that with another set of parameters based on column2.

Thanks
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4664
    
    5

Matthew Tilic wrote:I would like to search a range of data 205-250 and find all the values in this column that are anywhere in-between.

secondly I will then want to apply extra filters on top later.

You can find the answers to both parts of your question in the documentation for RowFilter.
Matthew Tilic
Ranch Hand

Joined: Apr 07, 2011
Posts: 41

So I have to override the include method! Is their a way so that I do not have to do this
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4664
    
    5

Matthew Tilic wrote:Is their a way so that I do not have to do this

Don't know, and to be honest I don't care. The RowFilter API provides a clean, adequately documented way to achieve the goal; why look for anything else?
Matthew Tilic
Ranch Hand

Joined: Apr 07, 2011
Posts: 41

Because I still think it looks ugly when applying multiple filters as its to much code for someone when they come to edit it at a later date
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4664
    
    5

Matthew Tilic wrote:Because I still think it looks ugly when applying multiple filters as its to much code for someone when they come to edit it at a later date


Not if you break it up into separate classes, each well documented, and use RowFilter#andFilter(...).

Any other approach, if you can find one, is IMHO going to be even less readable.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applying a range filter to RowFilter