ojb.broker.query
Class SearchFilter

java.lang.Object
  |
  +--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.


Nested Class Summary
protected  class SearchFilter.SearchBase
          SearchBase is the base node class for the parse tree This class holds the binary operator
protected  class SearchFilter.SearchBaseLeaf
          SearchBaseLeaf holds a leaf of the search tree This class holds an element name, and a vector of possible matches.
protected  class SearchFilter.SearchBaseLeafComparison
          SearchBaseLeafComparison holds a leaf of the search tree This class holds an element name, a binary operator, and a value to be compared
protected  class SearchFilter.SearchBaseLeafInt
          SearchBaseLeafInt holds a leaf of the search tree with integers This class holds an element name, and a vector of possible matches.
protected  class SearchFilter.SearchBaseNode
          Define the class to represent a node of the search tree This class holds an operator and a vector other nodes.
 
Field Summary
static int AND
           
protected static int BINARY_OPER_MASK
           
static int EQUAL
           
protected  SearchFilter.SearchBase filter
           
static int GREATER_EQUAL
           
static int GREATER_THAN
           
static int IN
           
static int LESS_EQUAL
           
static int LESS_THAN
           
static int LIKE
           
protected static int LOGICAL_OPER_MASK
           
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.
protected static java.lang.String ConvertBinaryOperator(int oper)
          Static method to convert a binary operator into a string.
protected  SearchFilter.SearchBase getFilter()
          Get the actual filter out of the class.
 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
clone, equals, finalize, 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

BINARY_OPER_MASK

protected static final int BINARY_OPER_MASK
See Also:
Constant Field Values

LOGICAL_OPER_MASK

protected static final int LOGICAL_OPER_MASK
See Also:
Constant Field Values

filter

protected SearchFilter.SearchBase filter
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:
gov.lanl.Database.DBException
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:
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:
gov.lanl.Utilty.DBException
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
Throws:
gov.lanl.Database.DBException
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:
gov.lanl.Database.DBException
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:
gov.lanl.Database.DBException
DBException

ConvertBinaryOperator

protected static java.lang.String ConvertBinaryOperator(int oper)
Static method to convert a binary operator into a string.

Parameters:
oper - is the binary comparison operator to be converted
Returns:

getFilter

protected SearchFilter.SearchBase getFilter()
Get the actual filter out of the class. This is only needed when combining filters together and one instantiation has to get the filter from another. However, I do not know how to protect it from outside use.

Returns:

toString

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

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


Authors: Thomas Mahler and others. (C) 2000, 2001.
All rights reserved. Published under the Gnu Public License.
http://objectbridge.sourceforge.net
Version: 0.8.375, 2002-04-04