Dismiss
InnovationQ will be updated on Sunday, Oct. 22, from 10am ET - noon. You may experience brief service interruptions during that time.
Browse Prior Art Database

"Filter" - a framework to generate subsets of collections in programs written in Java* Programming Language . It is a piece of software useful for other software projects.

IP.com Disclosure Number: IPCOM000010697D
Original Publication Date: 2003-Jan-09
Included in the Prior Art Database: 2003-Jan-09
Document File: 4 page(s) / 9K

Publishing Venue

IBM

Abstract

"Filter" - a framework to generate subsets of collections in programs written in Java* Programming Language.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 41% of the total text.

Page 1 of 4

  "Filter" - a framework to generate subsets of collections in programs written in Java* Programming Language . It is a piece of software useful for other software projects.

  Common task in an object-oriented program is the selection of objects, matching a certain criterion, from a given set (list) of objects. Databases have standardized methods for this. For sets of objects no such queries are commonly accepted. This class offers a simple solution for this problem. Objects of the class "Filter" define, whether or not a certain object (of some other class) matches the filter-criterion of the filter-object. Main method is

Boolean match(Object object).

  This is an abstract method and needs to be implemented by the concrete filter-class.

The second main method is

Collection filter(Collection collection)

  This method provides a subset of the given collection, containing only those objects, where the match method replies true.

  The other methods of the class Filter allow to concatenate two or more filter objects in a boolean way (and, or, not).

    The concrete filter-classes should be defined (and implemented) "close" the object, they are applied on, or close to the according list-class (if applicable), i.e.
e.g. with class Person, or with Persons.

Filter-objects usually are immutable. In GUIs they might be mutable, i.e. their criterion might be changed. E.g. the selection in one JList might define the content of a second JList. Then a new selection in the first JList sets a new match-condition in the filter-object; the second JList needs to be refilled then. For these cases the Filters are Observable; the according Observer initiates the refilling of the second JList.

    Main idea of the invention is the elegant and lean but powerful and flexible interface (with the power of the boolean algebra). The implementation is quite straight forward, although it contains some interesting details for performance approvements. The result is really surprising: Even large object lists with 6000 or more elements can be filtered with complex filters in less than a second.

  Here comes The complete interface of the Filter-framework (in Java* programming language)


1.


2.

A demonstration program, using and demonstrating the Filter-framework


3.

The output of the demonstration program.

1. The complete interface of the Filter-framework (in Java* programming language)

import Java.io.Serializable;
import Java.util.Collection;
import Java.util.List;
import Java.util.Observer;

public interface FilterIF extends Serializable
{
static final long serialVersionUID = 2094541310687213570L;
public static final String cLessRestricted = "lessRestricted";
public static final String cMoreRestricted = "moreRestricted";
public static final FilterIF cNullFilter = new NullFilter();

Page 2 of 4

public class NullFilter extends Filter
{
final long serialVersionUID = -7125220864033232850L;
public boolean match(Object object)

{

  return true;
}

public String toString()
{

StringBuffer retVal = new StringBuffer...