Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applying a range filter to RowFilter

 
Matthew Tilic
Ranch Hand
Posts: 41
Chrome Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
Chrome Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I have to override the include method! Is their a way so that I do not have to do this
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
Chrome Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic