Class Filter

java.lang.Object
wt.clients.beans.explorer.Filter

public class Filter extends Object
This class can perform simple filtering operations for an array of objects. Filter objects contain the name of an attribute, a comparison value, and a flag to indicate if matching values should be allowed or disallowed. The static method applyFilters() applys an array of filter objects to an array of arbitrary objects, and then returns the qualified objects which are valid for the specified filter.

The following is some sample code for using the class:

        // create some filter objects, then apply a new filter on them
       
        Filter filterone = new Filter("name3", "value", Filter.ALLOW_ONLY);
        Filter filtertwo = new Filter("name2", "value", Filter.ALLOW_ONLY);
        
        Object[] objects = new Object[] { filterone, filtertwo };
        
        
        // note capitalized attribute name
        Filter filterthree = new Filter("Test", new Boolean(true), Filter.DISALLOW);
        Filter filters[] = new Filter[] { filterthree };     
     
        Object[] validObjects = Filter.applyFilters(filters, objects);
        
        System.out.println("Number of Valid objects: " + validObjects.length);
        
        for ( int i =0; i < validObjects.length; i++ )
        {
            Filter filter = (Filter) validObjects[i];
            System.out.println("Filter attributeName: " + filter.getAttributeName());
        }
        
 >/pre>     
 



Supported API: true

Extendable: false