org.jcreme.filters
Class OrderFilter

java.lang.Object
  extended byorg.jcreme.filters.OrderFilter
All Implemented Interfaces:
java.lang.Cloneable, Filter, java.io.Serializable
Direct Known Subclasses:
DateOrderFilter, DoubleOrderFilter

public class OrderFilter
extends java.lang.Object
implements Filter, java.io.Serializable

A filter that accepts objects that fulfill a given comparison relation with a given referent object, according to a given Comparator object.

Version:
$Revision: 1.3 $
Author:
$Author: dbregeon $
See Also:
Serialized Form

Field Summary
(package private) static long serialVersionUID
           
 
Constructor Summary
OrderFilter(OrderComparisonOperator op, java.util.Comparator comp, java.lang.Object referent)
          Creates new OrderComparator
 
Method Summary
 boolean accept(java.lang.Object o)
          Tells whether the given object 'passes' the filter or not.
 java.lang.Object clone()
          This forces override of the Object class clone method. it makes a deep copy so a change in a subfilter does not affect the cloned version.
 boolean equals(java.lang.Object o)
          Overloads the 'dummy' implementation in Object, so that it returns true only if the passed in parameter is a filter of the same kind as this one, and accepts exactly the same objects.
 java.util.Comparator getComparator()
          Gives access to the COmparator object used by this filter.
 ComparisonOperator getOperator()
          Gives access to the operator used by this filter.
 java.lang.Object getReferent()
          Gives access to the referent object used by this filter.
 int hashCode()
          Overloads the 'dummy' implementation in Object so that it fulfills the implicit hashCode contract, i.e. same filters have the same hashCode and different ones have different hashCodes.
 java.lang.String toString()
          Gives an SQL-like string representation for this filter.
 java.lang.String toString(java.lang.String field)
          This method is useful when generating SQL queries.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

OrderFilter

public OrderFilter(OrderComparisonOperator op,
                   java.util.Comparator comp,
                   java.lang.Object referent)
            throws java.lang.IllegalArgumentException
Creates new OrderComparator

Parameters:
op - The OrderComparisonOperator to be used.
comp - The Comparator object to be used to compare objects to the referent object.
referent - The referent object 'tested' objects have to be compare to.
Throws:
java.lang.IllegalArgumentException - In case any of the passed in parameters is null, which is not wanted here.
Method Detail

accept

public boolean accept(java.lang.Object o)
Tells whether the given object 'passes' the filter or not.

Specified by:
accept in interface Filter
Parameters:
o - The object you want to 'test'.
Returns:
True if the passed in parameter is accepted by the filter, false otherwise.

getOperator

public ComparisonOperator getOperator()
Gives access to the operator used by this filter.

Returns:
The comparison operator used by this filter.

getReferent

public java.lang.Object getReferent()
Gives access to the referent object used by this filter.

Returns:
The referent object used by this filter.

getComparator

public java.util.Comparator getComparator()
Gives access to the COmparator object used by this filter.

Returns:
The Comparator object used by this filter.

toString

public java.lang.String toString()
Gives an SQL-like string representation for this filter.

Returns:
the string representation of the filter.

toString

public java.lang.String toString(java.lang.String field)
This method is useful when generating SQL queries. This method will return the actual SQL condition.

Parameters:
field - the field name that applies to this filter.
Returns:
the string representation of the filter including the field name.

equals

public boolean equals(java.lang.Object o)
Overloads the 'dummy' implementation in Object, so that it returns true only if the passed in parameter is a filter of the same kind as this one, and accepts exactly the same objects.

Parameters:
o - The object to be compared to this one.
Returns:
True if the passed in object is an OrderFilter that accepts exactly the same objects as this one.

hashCode

public int hashCode()
Overloads the 'dummy' implementation in Object so that it fulfills the implicit hashCode contract, i.e. same filters have the same hashCode and different ones have different hashCodes.

Returns:
The hash code for this filter.

clone

public java.lang.Object clone()
This forces override of the Object class clone method. it makes a deep copy so a change in a subfilter does not affect the cloned version.

Specified by:
clone in interface Filter
Returns:
the cloned object.


Copyright 2006 null. All Rights Reserved.