com.trg.search
Class Filter

java.lang.Object
  extended by com.trg.search.Filter
All Implemented Interfaces:
java.io.Serializable

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

A Filter is used by the Search class to specify a restriction on what results should be returned in the search. For example, if a filter Filter.equal("name","Paul") were added to the search, only objects with the property "name" equal to the string "Paul" would be returned.

Nested properties can also be specified, for example Filter.greaterThan("employee.age",65).

Author:
dwolverton
See Also:
Serialized Form

Field Summary
static int OP_ALL
           
static int OP_AND
           
static int OP_EMPTY
           
static int OP_EQUAL
           
static int OP_GREATER_OR_EQUAL
           
static int OP_GREATER_THAN
           
static int OP_IEQUAL
           
static int OP_ILIKE
           
static int OP_IN
           
static int OP_LESS_OR_EQUAL
           
static int OP_LESS_THAN
           
static int OP_LIKE
           
static int OP_NONE
           
static int OP_NOT
           
static int OP_NOT_EMPTY
           
static int OP_NOT_EQUAL
           
static int OP_NOT_IN
           
static int OP_NOT_NULL
           
static int OP_NULL
           
static int OP_OR
           
static int OP_SOME
           
protected  int operator
          The type of comparison to do between the property and the value.
protected  java.lang.String property
          The name of the property to filter on.
static java.lang.String ROOT_ENTITY
          Property string representing the root entity of the search.
protected  java.lang.Object value
          The value to compare the property with.
 
Constructor Summary
Filter()
           
Filter(java.lang.String property, java.lang.Object value)
           
Filter(java.lang.String property, java.lang.Object value, int operator)
           
 
Method Summary
 void add(Filter filter)
          Used with OP_OR and OP_AND filters.
static Filter all(java.lang.String property, Filter filter)
          Create a new Filter using the ALL operator.
static Filter and(Filter... filters)
          Create a new Filter using the AND operator.
static Filter equal(java.lang.String property, java.lang.Object value)
          Create a new Filter using the == operator.
 boolean equals(java.lang.Object obj)
           
 int getOperator()
           
 java.lang.String getProperty()
           
 java.lang.Object getValue()
           
static Filter greaterOrEqual(java.lang.String property, java.lang.Object value)
          Create a new Filter using the >= operator.
static Filter greaterThan(java.lang.String property, java.lang.Object value)
          Create a new Filter using the > operator.
 int hashCode()
           
static Filter iequal(java.lang.String property, java.lang.Object value)
          Create a new Filter using the == operator.
static Filter ilike(java.lang.String property, java.lang.String value)
          Create a new Filter using the ILIKE operator.
static Filter in(java.lang.String property, java.util.Collection<?> value)
          Create a new Filter using the IN operator.
static Filter in(java.lang.String property, java.lang.Object... value)
          Create a new Filter using the IN operator.
static Filter isEmpty(java.lang.String property)
          Create a new Filter using the IS EMPTY operator.
static Filter isNotEmpty(java.lang.String property)
          Create a new Filter using the IS NOT EMPTY operator.
static Filter isNotNull(java.lang.String property)
          Create a new Filter using the IS NOT NULL operator.
static Filter isNull(java.lang.String property)
          Create a new Filter using the IS NULL operator.
 boolean isTakesListOfSubFilters()
           
 boolean isTakesListOfValues()
           
 boolean isTakesNoProperty()
           
 boolean isTakesNoValue()
           
 boolean isTakesSingleSubFilter()
           
 boolean isTakesSingleValue()
           
static Filter lessOrEqual(java.lang.String property, java.lang.Object value)
          Create a new Filter using the <= operator.
static Filter lessThan(java.lang.String property, java.lang.Object value)
          Create a new Filter using the < operator.
static Filter like(java.lang.String property, java.lang.String value)
          Create a new Filter using the LIKE operator.
static Filter none(java.lang.String property, Filter filter)
          Create a new Filter using the NONE operator.
static Filter not(Filter filter)
          Create a new Filter using the NOT operator.
static Filter notEqual(java.lang.String property, java.lang.Object value)
          Create a new Filter using the !
static Filter notIn(java.lang.String property, java.util.Collection<?> value)
          Create a new Filter using the NOT IN operator.
static Filter notIn(java.lang.String property, java.lang.Object... value)
          Create a new Filter using the NOT IN operator.
static Filter or(Filter... filters)
          Create a new Filter using the OR operator.
 void remove(Filter filter)
          Used with OP_OR and OP_AND filters.
 void setOperator(int operator)
           
 void setProperty(java.lang.String property)
           
 void setValue(java.lang.Object value)
           
static Filter some(java.lang.String property, Filter filter)
          Create a new Filter using the SOME operator.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ROOT_ENTITY

public static final java.lang.String ROOT_ENTITY
Property string representing the root entity of the search. This is just the empty string ("").

See Also:
Constant Field Values

property

protected java.lang.String property
The name of the property to filter on. It may be nested. Examples: "name", "dateOfBirth", "employee.age", "employee.spouse.job.title"


value

protected java.lang.Object value
The value to compare the property with. Should be of a compatible type with the property. Examples: "Fred", new Date(), 45


operator

protected int operator
The type of comparison to do between the property and the value. The options are limited to the integer constants on this class: OP_EQAUL, OP_NOT_EQUAL, OP_LESS_THAN, OP_GREATER_THAN, LESS_OR_EQUAL, OP_GREATER_OR_EQUAL, OP_IN, OP_NOT_IN, OP_LIKE, OP_ILIKE, OP_NULL, OP_NOT_NULL, OP_EMPTY, OP_NOT_EMPTY, OP_SOME, OP_ALL, OP_NONE, OP_AND, OP_OR, OP_NOT .


OP_EQUAL

public static final int OP_EQUAL
See Also:
Constant Field Values

OP_NOT_EQUAL

public static final int OP_NOT_EQUAL
See Also:
Constant Field Values

OP_LESS_THAN

public static final int OP_LESS_THAN
See Also:
Constant Field Values

OP_GREATER_THAN

public static final int OP_GREATER_THAN
See Also:
Constant Field Values

OP_LESS_OR_EQUAL

public static final int OP_LESS_OR_EQUAL
See Also:
Constant Field Values

OP_GREATER_OR_EQUAL

public static final int OP_GREATER_OR_EQUAL
See Also:
Constant Field Values

OP_LIKE

public static final int OP_LIKE
See Also:
Constant Field Values

OP_ILIKE

public static final int OP_ILIKE
See Also:
Constant Field Values

OP_IN

public static final int OP_IN
See Also:
Constant Field Values

OP_NOT_IN

public static final int OP_NOT_IN
See Also:
Constant Field Values

OP_NULL

public static final int OP_NULL
See Also:
Constant Field Values

OP_NOT_NULL

public static final int OP_NOT_NULL
See Also:
Constant Field Values

OP_EMPTY

public static final int OP_EMPTY
See Also:
Constant Field Values

OP_NOT_EMPTY

public static final int OP_NOT_EMPTY
See Also:
Constant Field Values

OP_AND

public static final int OP_AND
See Also:
Constant Field Values

OP_OR

public static final int OP_OR
See Also:
Constant Field Values

OP_NOT

public static final int OP_NOT
See Also:
Constant Field Values

OP_SOME

public static final int OP_SOME
See Also:
Constant Field Values

OP_ALL

public static final int OP_ALL
See Also:
Constant Field Values

OP_NONE

public static final int OP_NONE
See Also:
Constant Field Values

OP_IEQUAL

public static final int OP_IEQUAL
See Also:
Constant Field Values
Constructor Detail

Filter

public Filter()

Filter

public Filter(java.lang.String property,
              java.lang.Object value,
              int operator)

Filter

public Filter(java.lang.String property,
              java.lang.Object value)
Method Detail

iequal

public static Filter iequal(java.lang.String property,
                            java.lang.Object value)
Create a new Filter using the == operator.


equal

public static Filter equal(java.lang.String property,
                           java.lang.Object value)
Create a new Filter using the == operator.


lessThan

public static Filter lessThan(java.lang.String property,
                              java.lang.Object value)
Create a new Filter using the < operator.


greaterThan

public static Filter greaterThan(java.lang.String property,
                                 java.lang.Object value)
Create a new Filter using the > operator.


lessOrEqual

public static Filter lessOrEqual(java.lang.String property,
                                 java.lang.Object value)
Create a new Filter using the <= operator.


greaterOrEqual

public static Filter greaterOrEqual(java.lang.String property,
                                    java.lang.Object value)
Create a new Filter using the >= operator.


in

public static Filter in(java.lang.String property,
                        java.util.Collection<?> value)
Create a new Filter using the IN operator.

This takes a variable number of parameters. Any number of values can be specified.


in

public static Filter in(java.lang.String property,
                        java.lang.Object... value)
Create a new Filter using the IN operator.

This takes a variable number of parameters. Any number of values can be specified.


notIn

public static Filter notIn(java.lang.String property,
                           java.util.Collection<?> value)
Create a new Filter using the NOT IN operator.

This takes a variable number of parameters. Any number of values can be specified.


notIn

public static Filter notIn(java.lang.String property,
                           java.lang.Object... value)
Create a new Filter using the NOT IN operator.

This takes a variable number of parameters. Any number of values can be specified.


like

public static Filter like(java.lang.String property,
                          java.lang.String value)
Create a new Filter using the LIKE operator.


ilike

public static Filter ilike(java.lang.String property,
                           java.lang.String value)
Create a new Filter using the ILIKE operator.


notEqual

public static Filter notEqual(java.lang.String property,
                              java.lang.Object value)
Create a new Filter using the != operator.


isNull

public static Filter isNull(java.lang.String property)
Create a new Filter using the IS NULL operator.


isNotNull

public static Filter isNotNull(java.lang.String property)
Create a new Filter using the IS NOT NULL operator.


isEmpty

public static Filter isEmpty(java.lang.String property)
Create a new Filter using the IS EMPTY operator.


isNotEmpty

public static Filter isNotEmpty(java.lang.String property)
Create a new Filter using the IS NOT EMPTY operator.


and

public static Filter and(Filter... filters)
Create a new Filter using the AND operator.

This takes a variable number of parameters. Any number of Filters can be specified.


or

public static Filter or(Filter... filters)
Create a new Filter using the OR operator.

This takes a variable number of parameters. Any number of Filters can be specified.


not

public static Filter not(Filter filter)
Create a new Filter using the NOT operator.


some

public static Filter some(java.lang.String property,
                          Filter filter)
Create a new Filter using the SOME operator.


all

public static Filter all(java.lang.String property,
                         Filter filter)
Create a new Filter using the ALL operator.


none

public static Filter none(java.lang.String property,
                          Filter filter)
Create a new Filter using the NONE operator.


add

public void add(Filter filter)
Used with OP_OR and OP_AND filters. These filters take a collection of filters as their value. This method adds a filter to that list.


remove

public void remove(Filter filter)
Used with OP_OR and OP_AND filters. These filters take a collection of filters as their value. This method removes a filter from that list.


getProperty

public java.lang.String getProperty()

setProperty

public void setProperty(java.lang.String property)

getValue

public java.lang.Object getValue()

setValue

public void setValue(java.lang.Object value)

getOperator

public int getOperator()

setOperator

public void setOperator(int operator)

isTakesSingleValue

public boolean isTakesSingleValue()
Returns:
true if the operator should have a single value specified.

EQUAL, NOT_EQUAL, LESS_THAN, LESS_OR_EQUAL, GREATER_THAN, GREATER_OR_EQUAL, LIKE, ILIKE


isTakesListOfValues

public boolean isTakesListOfValues()
Returns:
true if the operator should have a list of values specified.

IN, NOT_IN


isTakesNoValue

public boolean isTakesNoValue()
Returns:
true if the operator does not require a value to be specified.

NULL, NOT_NULL, EMPTY, NOT_EMPTY


isTakesSingleSubFilter

public boolean isTakesSingleSubFilter()
Returns:
true if the operator should have a single Filter specified for the value.

NOT, ALL, SOME, NONE


isTakesListOfSubFilters

public boolean isTakesListOfSubFilters()
Returns:
true if the operator should have a list of Filters specified for the value.

AND, OR


isTakesNoProperty

public boolean isTakesNoProperty()
Returns:
true if the operator does not require a property to be specified.

AND, OR, NOT


hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2008-2010 eBM WebSourcing. All Rights Reserved.