com.arsdigita.persistence
Interface FilterFactory


public interface FilterFactory

FilterFactory is the interface that dictates the methods needed by factories to hand out filters

Version:
$Revision: #6 $ $Date: 2004/04/07 $
Author:
randyg@alum.mit.edu

Field Summary
static int CONTAINS
           
static int ENDS_WITH
           
static int EQUALS
           
static int GREATER_THAN
           
static int GREATER_THAN_EQUALS
           
static int LESS_THAN
           
static int LESS_THAN_EQUALS
           
static int NOT_EQUALS
           
static int STARTS_WITH
           
static String versionId
           
 
Method Summary
 CompoundFilter and()
          This creates and returns a filter that can be used to AND existing filters together.
 Filter compare(String expressionOne, int comparator, String expressionTwo)
          This method is used to compare two expressions to each other.
 Filter contains(String attribute, String value, boolean trueForAllIfValueIsNull)
          This creates the appropriate SQL for the given attribute and passed in value.
 Filter endsWith(String attribute, String value, boolean trueForAllIfValueIsNull)
          This creates the appropriate SQL for the given attribute and passed in value.
 Filter equals(String attribute, Object value)
          This creates the appropriate SQL for the given attribute and passed in value.
 Filter greaterThan(String attribute, Object value, boolean trueForAllIfValueIsNull)
          This creates the appropriate SQL for the given attribute and passed in value.
 Filter greaterThanEquals(String attribute, Object value, boolean trueForAllIfValueIsNull)
          This creates the appropriate SQL for the given attribute and passed in value.
 Filter in(String propertyName, String queryName)
          This creates a filter that constructs an "in" style subquery with the given property and subquery.
 Filter in(String property, String subQueryProperty, String queryName)
          This creates a filter that constructs an "in" style subquery with the given property to be filtered on and subquery.
 Filter lessThan(String attribute, Object value, boolean trueForAllIfValueIsNull)
          This creates the appropriate SQL for the given attribute and passed in value.
 Filter lessThanEquals(String attribute, Object value, boolean trueForAllIfValueIsNull)
          This creates the appropriate SQL for the given attribute and passed in value.
 Filter notEquals(String attribute, Object value)
          This creates the appropriate SQL for the given attribute and passed in value.
 Filter notIn(String propertyName, String queryName)
          This creates a filter that constructs a "not in" style subquery with the given property and subquery.
 CompoundFilter or()
          This creates and returns a filter that can be used to OR existing filters together.
 Filter simple(String sql)
           
 Filter startsWith(String attribute, String value, boolean trueForAllIfValueIsNull)
          This creates the appropriate SQL for the given attribute and passed in value.
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values

EQUALS

public static final int EQUALS
See Also:
Constant Field Values

NOT_EQUALS

public static final int NOT_EQUALS
See Also:
Constant Field Values

GREATER_THAN

public static final int GREATER_THAN
See Also:
Constant Field Values

LESS_THAN

public static final int LESS_THAN
See Also:
Constant Field Values

GREATER_THAN_EQUALS

public static final int GREATER_THAN_EQUALS
See Also:
Constant Field Values

LESS_THAN_EQUALS

public static final int LESS_THAN_EQUALS
See Also:
Constant Field Values

STARTS_WITH

public static final int STARTS_WITH
See Also:
Constant Field Values

ENDS_WITH

public static final int ENDS_WITH
See Also:
Constant Field Values

CONTAINS

public static final int CONTAINS
See Also:
Constant Field Values
Method Detail

simple

public Filter simple(String sql)
Parameters:
sql - The conditions for the filter. This is a string that should represent part of a SQL "where" clause. Specifically, it should normally take the form of

        <column_name> <condition> <attribute bind variable>
        
where the "condition" is something like "=", "<", ">", or "!=". The "bind variable" should be a colon followed by some attribute name that will later be set with a call to Filter.set(java.lang.String, java.lang.Object)

It is possible to set multiple conditions with a single addFilter statement by combining the conditions with an "and" or an "or". Conditions may be grouped by using parentheses. Consecutive calls to addFilter append the filters using "and".


equals

public Filter equals(String attribute,
                     Object value)
This creates the appropriate SQL for the given attribute and passed in value. It creates a filter for "attributeName = 'value.toString()'" unless the value is an integer (in which case it creates "attributeName = value.toString()") or the developer is using oracle and the value is null. In this case, it would create "attributeName is null".

Parameters:
attribute - The name of the attribute to bind with the value
value - The value for the specified attribute

notEquals

public Filter notEquals(String attribute,
                        Object value)
This creates the appropriate SQL for the given attribute and passed in value. It creates a filter for "attributeName != 'value.toString()'" unless the value is an integer (in which case it creates "attributeName != value.toString()") or the developer is using oracle and the value is null. In this case, it would create "attributeName is not null".

Parameters:
attribute - The name of the attribute to bind with the value
value - The value for the specified attribute

lessThan

public Filter lessThan(String attribute,
                       Object value,
                       boolean trueForAllIfValueIsNull)
This creates the appropriate SQL for the given attribute and passed in value. It creates a filter for "attributeName < value" unless the developer is using oracle and the value is null. In this case, it uses the parameter trueForAllIfValueIsNull to determine how to change the query to work.

Parameters:
attribute - The name of the attribute to bind with the value
value - The value for the specified attribute
trueForAllIfValueIsNull - This specifies whether a value of null should be the equivalent of 1==1 (true) or 1==2 (false)

lessThanEquals

public Filter lessThanEquals(String attribute,
                             Object value,
                             boolean trueForAllIfValueIsNull)
This creates the appropriate SQL for the given attribute and passed in value. It creates a filter for "attributeName <= value" unless the developer is using oracle and the value is null. In this case, it uses the parameter trueForAllIfValueIsNull to determine how to change the query to work.

Parameters:
attribute - The name of the attribute to bind with the value
value - The value for the specified attribute
trueForAllIfValueIsNull - This specifies whether a value of null should be the equivalent of 1==1 (true) or 1==2 (false)

greaterThan

public Filter greaterThan(String attribute,
                          Object value,
                          boolean trueForAllIfValueIsNull)
This creates the appropriate SQL for the given attribute and passed in value. It creates a filter for "attributeName > value" unless the developer is using oracle and the value is null. In this case, it uses the parameter trueForAllIfValueIsNull to determine how to change the query to work.

Parameters:
attribute - The name of the attribute to bind with the value
value - The value for the specified attribute
trueForAllIfValueIsNull - This specifies whether a value of null should be the equivalent of 1==1 (true) or 1==2 (false)

greaterThanEquals

public Filter greaterThanEquals(String attribute,
                                Object value,
                                boolean trueForAllIfValueIsNull)
This creates the appropriate SQL for the given attribute and passed in value. It creates a filter for "attributeName >= value" unless the developer is using oracle and the value is null. In this case, it uses the parameter trueForAllIfValueIsNull to determine how to change the query to work.

Parameters:
attribute - The name of the attribute to bind with the value
value - The value for the specified attribute
trueForAllIfValueIsNull - This specifies whether a value of null should be the equivalent of 1==1 (true) or 1==2 (false)

startsWith

public Filter startsWith(String attribute,
                         String value,
                         boolean trueForAllIfValueIsNull)
This creates the appropriate SQL for the given attribute and passed in value. It creates a filter for "attributeName like 'value%'" unless the developer is using oracle and the value is null. In this case, it uses the parameter trueForAllIfValueIsNull to determine how to change the query to work.

Parameters:
attribute - The name of the attribute to bind with the value
value - The value for the specified attribute
trueForAllIfValueIsNull - This specifies whether a value of null should be the equivalent of 1==1 (true) or 1==2 (false)

endsWith

public Filter endsWith(String attribute,
                       String value,
                       boolean trueForAllIfValueIsNull)
This creates the appropriate SQL for the given attribute and passed in value. It creates a filter for "attributeName like '%value'" unless the developer is using oracle and the value is null. In this case, it uses the parameter trueForAllIfValueIsNull to determine how to change the query to work.

Parameters:
attribute - The name of the attribute to bind with the value
value - The value for the specified attribute
trueForAllIfValueIsNull - This specifies whether a value of null should be the equivalent of 1==1 (true) or 1==2 (false)

contains

public Filter contains(String attribute,
                       String value,
                       boolean trueForAllIfValueIsNull)
This creates the appropriate SQL for the given attribute and passed in value. It creates a filter for "attributeName like '%value%'" unless the developer is using oracle and the value is null. In this case, it uses the parameter trueForAllIfValueIsNull to determine how to change the query to work.

Parameters:
attribute - The name of the attribute to bind with the value
value - The value for the specified attribute
trueForAllIfValueIsNull - This specifies whether a value of null should be the equivalent of 1==1 (true) or 1==2 (false)

compare

public Filter compare(String expressionOne,
                      int comparator,
                      String expressionTwo)
This method is used to compare two expressions to each other. This is necessary instead of just passing in straight SQL so that Oracle's null problem may be handled correctly. Specifically, this creates the expression
  ((<expressionOne> <comparator> <expressionTwo>)
    or
   (<expressionOne> is [not] null
     and <expressionTwo> is [not] null))
  

This method is useful when code needs to use PL/SQL functions within the filter (e.g. nvl or upper or lower

Parameters:
expressionOne - This is the first expression for the comparrison. One typical use for it is to pass in something like "upper(<attribute name>)"
comparator - This is the "int" that is used to represent how to compare the two expressions. The int should be one of the "int"s specified by the constants within FilterFactory
expressionTwo - This is the second expression. This could be something as simple as a bind variable or as complex as a call to a PL/SQL function.

in

public Filter in(String propertyName,
                 String queryName)
This creates a filter that constructs an "in" style subquery with the given property and subquery. The subquery must be a fully qualified query name of a query defined in a PDL file somewhere.


in

public Filter in(String property,
                 String subQueryProperty,
                 String queryName)
This creates a filter that constructs an "in" style subquery with the given property to be filtered on and subquery. subQueryProperty is the property in the subquery which relates to the property being filtered on. The subquery must be a fully qualified query name of a query defined in a PDL file somewhere.


notIn

public Filter notIn(String propertyName,
                    String queryName)
This creates a filter that constructs a "not in" style subquery with the given property and subquery. The subquery must be a fully qualified query name of a query defined in a PDL file somewhere.


and

public CompoundFilter and()
This creates and returns a filter that can be used to AND existing filters together. Whenever addFilter is called on the filters that is returned, it ANDs the passed in Filters with the existing filter


or

public CompoundFilter or()
This creates and returns a filter that can be used to OR existing filters together. Whenever addFilter is called on the filters that is returned, it ORs the passed in Filters with the existing filter



Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC