com.townleyenterprises.filter
Class QueryFilter

java.lang.Object
  extended bycom.townleyenterprises.common.PropertyProxy
      extended bycom.townleyenterprises.filter.QueryFilter
All Implemented Interfaces:
Filter, java.io.Serializable
Direct Known Subclasses:
StringFilter

public class QueryFilter
extends PropertyProxy
implements Filter, java.io.Serializable

This class provides an implementation of the Query Object design pattern for the filtering mechanism which may be used for lazy evaluation of the filter criteria. This class is the basis for using Filters with database systems as they can be easily translated into SQL.

Since:
2.0
Version:
$Id: QueryFilter.java,v 1.7 2004/11/28 20:12:52 atownley Exp $
Author:
Andrew S. Townley
See Also:
Serialized Form

Constructor Summary
QueryFilter(java.lang.Class klass, java.lang.String property, QueryOperator op, java.lang.Comparable val)
          The constructor initializes the query filter.
 
Method Summary
 boolean doFilter(java.lang.Object o)
          This method actually performs the operation that will determine if the parameter object should be included in the "result" or not.
 QueryOperator getOperator()
           
protected  java.lang.String getOperatorString()
          This method may be overridden by custom query filter instances to return a string which describes the test they are performing if it is not one of the standard operators.
 java.lang.String getProperty()
           
 java.lang.Comparable getValue()
           
 java.lang.String toString()
           
 
Methods inherited from class com.townleyenterprises.common.PropertyProxy
getPropertyValue, getSubjectClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QueryFilter

public QueryFilter(java.lang.Class klass,
                   java.lang.String property,
                   QueryOperator op,
                   java.lang.Comparable val)
The constructor initializes the query filter. Each QueryFilter is fixed once it is constructed.

Parameters:
klass - the class of the object to be filtered
property - the property name based on the object being queried
op - the QueryOperator to be used
val - the Comparable to be used for comparison (must
Method Detail

doFilter

public boolean doFilter(java.lang.Object o)
Description copied from interface: Filter
This method actually performs the operation that will determine if the parameter object should be included in the "result" or not.

Specified by:
doFilter in interface Filter
Parameters:
o - the object to be tested
Returns:
true if the object should be included in the result; false if the object should not

getProperty

public java.lang.String getProperty()

getOperator

public QueryOperator getOperator()

getValue

public java.lang.Comparable getValue()

toString

public java.lang.String toString()

getOperatorString

protected java.lang.String getOperatorString()
This method may be overridden by custom query filter instances to return a string which describes the test they are performing if it is not one of the standard operators.

Returns:
the operator string


Copyright © 2002-2004, Andrew S. Townley and Townley Enterprises. All Rights Reserved.
This project is hosted on http://te-code.sourceforge.net.