Usage with Java 5

This library was initially developed targeting Java 5, and then modified to handle the new filtering capabilities in Java 6. Both versions were very different, but considering that the features in Java 6 will likely stay, I decided to retrofit the new implementation into the Java 5 ' library, adding some classes that only exist on the Java 6 standard library. These added classes are placed in the com.byteslooser.filters.artifacts package (only for the Java 5 implementation).

At the end, both versions share most of the code, although the internal imports are different in some cases. And users see the same interface using Java 5 or Java 6, which is an important feature, in case some later migration happens.

There is, however, a difference between JTable users in Java 5 and Java 6: the former does not provide sorting capabilities. The solution is usually to setup a table model with sorting capabilities, like the TableSorter. The source version of TableFilter includes such class for the test programs, although the TableFilter itself does obviously not require it.

Starting with version 1.2.6, the TableSorter included in the tests package has been modified: the original implementation re-sorts the whole table when there are changes on any cell. However, that is not the default behaviour under Java 6; updating the value of one or more cells -in sequence- in the table does not imply invoking again the sorting or filtering mechanisms. This behaviour is quite consistent: otherwise, updating a row could imply moving that row -to other position or outside the view, if is filtered out-.

Although this library exports the same interface to Java 5 and 6 users, the internal implementation is quite different; in Java 6, there is one table model, while in Java 5 users must handle at least two table models (plus a third one if sorting is also added):

This library is distributed with an implementation of the second model, described below, and it can be setup automatically; note, however, that the usage of multiple table models makes some operations more complicated. For example, once that filtering is on place, the row number in the view does not correspond any more to the row number in the model; the JTable provides methods to enquiry for translations between both views, but in version 5, users must extract the model and perform these queries against the model.

ITableModelFilter

Java 5 users of this library must attach, to the table, a model implementing the interface ITableModelFilter

If the attached model does not implement this interface, the library automatically creates one and replaces the current model with it. The default implementation is called TableModelFilter.

This implementation tries to mimic the behaviour found in the Java 6 tables; however, users can definitely provide their own implementation, for performance or extended interface reasons. The implementation provides two specific methods to convert positions between the index and the model:

Javadoc

Most of the generated documentation has the same contents for Java 5 and Java 6, but the links can be quite different. The Java 5 version is reachable here.