Disk space is now plentiful, and users have started to archive everything: emails, MP3s, pictures, documents, Webpages, and more. As the volume of information grows, it becomes increasingly difficult to manage. Filtering can help users get a handle on their archived information. This article demonstrates how Glazed Lists, an open source toolkit for list transformations, can be used to add filtering to your application.
Text filtering is a general filtering technique that is easy to use yet powerful. It is the filtering technique of choice for Apple iTunes and other programs. With text filtering, there is a data table and a search field—type a word in the search field and the data table is filtered to show only those elements containing that word.
Users can perform text filtering with different goals in mind. Suppose a data table contains customer names and locations. Text filtering can be used to search for a particular entry. You can find a customer's entry in the data table by filtering for his name. Text filtering can also select a subset of interest. Another example: when preparing a conference in Portland, an appropriate list of customers is obtained by filtering for "Portland," as shown in Figure 1.

Figure 1. Text filtering for Portland
In this example, text filtering is used to transform the original list into a list containing only customers from Portland. Other useful transformations exist as well. Sorting the list transforms it by reordering the elements. A list of unique cities is another transformation.
List transformations are powerful tools for data manipulation. They are nondestructive, allowing transformations to be created without affecting the original list. Therefore, a list can be transformed in multiple ways simultaneously. Given a list of customers, you could create a transformation filtered by name and a second transformation sorted by location.
List transformations are live. As a list changes, its transformations change automatically. For example, take a list of customers and a filtered transformation of that list. When a customer in the original list is removed, that customer is automatically removed from the filtered list.
List transformations can be chained. Multiple transformations can be combined to manipulate data, offering an elegant approach to separating concerns so sorting logic does not need to consider filtering logic or vice versa. Using the same customers example, you can first filter the customers list by location and then sort that list by name.
Glazed Lists is an open source toolkit for list transformations. For links to download the source or a jar file, see Resources. It has a Lesser General Public License, so it is safe to use in commercial applications.
If a developer is already familiar with ArrayList or Vector, she will feel at home with Glazed Lists. It uses the same well-understood java.util.List API throughout. This helps to soften the learning curve, especially when Glazed Lists is used in a multiple-developer project.