org.apache.ojb.broker.query
Class SearchFilter

java.lang.Object
  extended by org.apache.ojb.broker.query.SearchFilter
Direct Known Subclasses:
OJBSearchFilter

public abstract class SearchFilter
extends java.lang.Object

Class to build selection criteria for searches Search Filter Class (Abstract) This class builds a search filter tree, specifing how names and values are to be compared when searching a database. It just builds internal structures, and needs to be extended to return a search filter string or other object that can be used by the database to perform the actual search.


Field Summary
static int AND
           
static int EQUAL
           
static int GREATER_EQUAL
           
static int GREATER_THAN
           
static int IN
           
static int LESS_EQUAL
           
static int LESS_THAN
           
static int LIKE
           
static int NOT
           
static int NOT_EQUAL
           
static int NOT_IN
           
static int OR
           
 
Constructor Summary
SearchFilter()
          Create an empty search filter.
 
Method Summary
 void combine(SearchFilter new_filter, int op)
          Combine one other search filters with this one, using the specific operator.
 void combine(java.util.Vector new_filters, int op)
          Combine other search filters with this one, using the specific operator.
 void compareFilter(java.lang.String ElementName, java.lang.String value, int oper)
          Change the search filter to one that compares an element name to a value.
 void matchList(java.lang.String ElementName, int[] values, int oper)
          Change the search filter to one that specifies an element to not match one of a list of integer values.
 void matchList(java.lang.String ElementName, java.lang.String[] values, int oper)
          Change the search filter to one that specifies an element to not match one of a list of values.
 void matchList(java.lang.String ElementName, java.util.Vector values, int oper)
          Change the search filter to one that specifies an element to match or not match one of a list of values.
 void matchSet(java.util.Hashtable elements, int combine_op, int compare_op)
          Change the search filter to one that specifies a set of elements and their values that must match, and the operator to use to combine the elements.
 void matchSet(java.lang.String[] ElementNames, java.lang.String[] ElementValues, int op)
          Change the search filter to one that specifies a set of elements and their values that must match, and the operator to use to combine the elements.
 void matchValue(java.lang.String ElementName, int value, int oper)
          -----------------------------------------------------------
 void matchValue(java.lang.String ElementName, java.lang.String value, int oper)
          Change the search filter to one that specifies an element to not match one single value.
abstract  java.lang.String toString()
          -----------------------------------------------------------
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

AND

public static final int AND
See Also:
Constant Field Values

OR

public static final int OR
See Also:
Constant Field Values

NOT

public static final int NOT
See Also:
Constant Field Values

IN

public static final int IN
See Also:
Constant Field Values

NOT_IN

public static final int NOT_IN
See Also:
Constant Field Values

LIKE

public static final int LIKE
See Also:
Constant Field Values

EQUAL

public static final int EQUAL
See Also:
Constant Field Values

NOT_EQUAL

public static final int NOT_EQUAL
See Also:
Constant Field Values

LESS_THAN

public static final int LESS_THAN
See Also:
Constant Field Values

GREATER_THAN

public static final int GREATER_THAN
See Also:
Constant Field Values

GREATER_EQUAL

public static final int GREATER_EQUAL
See Also:
Constant Field Values

LESS_EQUAL

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

SearchFilter

public SearchFilter()
Create an empty search filter.

Method Detail

matchList

public void matchList(java.lang.String ElementName,
                      java.util.Vector values,
                      int oper)
Change the search filter to one that specifies an element to match or not match one of a list of values. The old search filter is deleted.

Parameters:
ElementName - is the name of the element to be matched
values - is a vector of possible matches
oper - is the IN or NOT_IN operator to indicate how to matche

matchList

public void matchList(java.lang.String ElementName,
                      java.lang.String[] values,
                      int oper)
Change the search filter to one that specifies an element to not match one of a list of values. The old search filter is deleted.

Parameters:
ElementName - is the name of the element to be matched
values - is an array of possible matches
oper - is the IN or NOT_IN operator to indicate how to matche

matchList

public void matchList(java.lang.String ElementName,
                      int[] values,
                      int oper)
Change the search filter to one that specifies an element to not match one of a list of integer values. The old search filter is deleted.

Parameters:
ElementName - is the name of the element to be matched
values - is an array of possible integer matches
oper - is the IN or NOT_IN operator to indicate how to matche

matchValue

public void matchValue(java.lang.String ElementName,
                       java.lang.String value,
                       int oper)
Change the search filter to one that specifies an element to not match one single value. The old search filter is deleted.

Parameters:
ElementName - is the name of the element to be matched
value - is the value to not be matched
oper - is the IN or NOT_IN operator to indicate how to matche

matchValue

public void matchValue(java.lang.String ElementName,
                       int value,
                       int oper)
-----------------------------------------------------------

Parameters:
ElementName -
value -
oper -

compareFilter

public void compareFilter(java.lang.String ElementName,
                          java.lang.String value,
                          int oper)
                   throws DBException
Change the search filter to one that compares an element name to a value. The old search filter is deleted.

Parameters:
ElementName - is the name of the element to be tested
value - is the value to be compared against
oper - is the binary comparison operator to be used
Throws:
DBException

matchSet

public void matchSet(java.util.Hashtable elements,
                     int combine_op,
                     int compare_op)
              throws DBException
Change the search filter to one that specifies a set of elements and their values that must match, and the operator to use to combine the elements. Each key is compared for an equal match to the value, and all comparisons are combined by the specified logical operator (OR or AND). The old search filter is deleted.

Parameters:
elements - is a hashtable holding key-value pairs
combine_op - is the logical operator to be used to combine the comparisons
compare_op - is the binary operator to be used for the comparisons
Throws:
DBException

matchSet

public void matchSet(java.lang.String[] ElementNames,
                     java.lang.String[] ElementValues,
                     int op)
              throws DBException
Change the search filter to one that specifies a set of elements and their values that must match, and the operator to use to combine the elements. Each element name is compared for an equal match to the value, and all comparisons are combined by the specified logical operator (OR or AND). The old search filter is deleted.

Parameters:
ElementNames - is an array of names of elements to be tested
ElementValues - is an array of values for the corresponding element
op - is the logical operator to be used to combine the comparisons
Throws:
DBException

combine

public void combine(java.util.Vector new_filters,
                    int op)
             throws DBException
Combine other search filters with this one, using the specific operator.

Parameters:
new_filters - is a vector of SearchFilter classes to be combined
op - is the logical operator to be used to combine the filters
Throws:
DBException

combine

public void combine(SearchFilter new_filter,
                    int op)
             throws DBException
Combine one other search filters with this one, using the specific operator.

Parameters:
new_filter - is the SearchFilter class to be combined
op - is the logical operator to be used to combine the filters
Throws:
DBException

toString

public abstract java.lang.String toString()
-----------------------------------------------------------

Overrides:
toString in class java.lang.Object
Returns:


(C) 2002 - 2006 Apache Software Foundation
All rights reserved. Published under the Apache License 2.0.
http://db.apache.org/ojb
Version: 1.0.4, 2005-12-30