Functor-based filtering in the incubator
I've put an implementation of table filtering based on jga functors into the incubator project. These are based on a pre-release of jga-0.7. It is compatable with Java 1.4, and takes advantage of a parser that I've been writing that compiles a java-esque expression language into compound functors.
There are two demos, both based on the TableFormDemo. The first, TableFormDemo1 replaces the existing JXSearchPanel with a FunctorSearchPanel, which consists of a text field for expression entry and a label where errors are reported. The language is very java-like: you can do basic arithmetic on all built-in Numbers, you can compare values and do logical expressions, you can call methods and constructors (with the short-term restriction that they may only
take 0 or 1 argument).
(Another place where I'm using this technology is at a site that I've not linked to from anywhere until now: a demonstration of a table where the cells take a single line of the sorta-java expression language to describe their values. You can try this out at http://jga.sf.net/docs/HacksheetDemo.shtml. That page has more details on the restrictions and extensions of the current expression language: it is very much a work in progress, and I plan to remove many of the restrictions before formally releasing jga-0.7.)
A language extension that is used by the FunctorFilter is the ability to reference arbitrary columns in the data model: a 'col' keyword is supported by this panel: it takes an integer argument, and it is used to get access to the data in a particular column. Here are a few examples:
- Find all of the JTable bugs
col(4).indexOf("JTable") >= 0
- Find all of the severe JTable bugs
col(4).indexOf("JTable") >= 0 & col(3) == 1
- Find all of the unassigned bugs
col(5) == "null"
- Find all L&F bugs not assigned to leif
!col(5).equals("leif") && col(4).indexOf("L&F") >= 0
- Find all of the bugs where severity exceeds priority
col(2) > col(3)
- Find all of the severe or highest priority bugs
col(2) <= 2 || col(3) == 1
The second demo replaces the implementation of JXSearchPanel. Rather than use an instance of PatternFilter (which is tightly constrained to regular expression matches on a single column), it uses a FunctorFilter. From the user's standpoint, it should be functionally identical to the standard TableFormDemo