com.xavax.xstore
Class Criteria

Object
  extended byOperator
      extended byCriteria
All Implemented Interfaces:
Node

public class Criteria
extends Operator

Criteria encapsulates the search criteria for finding objects and provides methods for constructing a query.


Method Summary
 Criteria and()
          Create a new Criteria bound to the same database and class as this Criteria and logically AND the two search criteria.
 Criteria and(Criteria crit)
          Logically AND a Criteria with this Criteria.
 Criteria between(String lhs, double lower, double upper)
          Append a Between comparison to the search criteria.
 Criteria between(String lhs, int lower, int upper)
          Append a Between comparison to the search criteria.
 Criteria between(String lhs, long lower, long upper)
          Append a Between comparison to the search criteria.
 Criteria between(String lhs, String lower, String upper)
          Append a Between comparison to the search criteria.
 Criteria database(String name)
          Bind this Criteria to another database.
 Criteria equal(String lhs, double rhs)
          Append an Equal comparison to the search criteria.
 Criteria equal(String lhs, int rhs)
          Append an Equal comparison to the search criteria.
 Criteria equal(String lhs, long rhs)
          Append an Equal comparison to the search criteria.
 Criteria equal(String lhs, String rhs)
          Append an Equal comparison to the search criteria.
 Criteria greater(String lhs, double rhs)
          Append a Greater Than comparison to the search criteria.
 Criteria greater(String lhs, int rhs)
          Append a Greater Than comparison to the search criteria.
 Criteria greater(String lhs, long rhs)
          Append a Greater Than comparison to the search criteria.
 Criteria greater(String lhs, String rhs)
          Append a Greater Than comparison to the search criteria.
 Criteria greaterEqual(String lhs, double rhs)
          Append a Greater Than or Equal comparison to the search criteria.
 Criteria greaterEqual(String lhs, int rhs)
          Append a Greater Than or Equal comparison to the search criteria.
 Criteria greaterEqual(String lhs, long rhs)
          Append a Greater Than or Equal comparison to the search criteria.
 Criteria greaterEqual(String lhs, String rhs)
          Append a Greater Than or Equal comparison to the search criteria.
 Criteria in(String lhs, Collection c)
          Append an In comparison to the search criteria.
 boolean isCompound()
          Returns true if this Criteria is a compound sesarch criteria consisting of multiple comparisons.
 boolean isConstant()
          Returns true if the boolean value of this Criteria is constant.
 Criteria isNotNull(String lhs)
          Append an Is Not Null comparison to the search criteria.
 Criteria isNull(String lhs)
          Append an Is Null comparison to the search criteria.
 Criteria less(String lhs, double rhs)
          Append a Less Than comparison to the search criteria.
 Criteria less(String lhs, int rhs)
          Append a Less Than comparison to the search criteria.
 Criteria less(String lhs, long rhs)
          Append a Less Than comparison to the search criteria.
 Criteria less(String lhs, String rhs)
          Append a Less Than comparison to the search criteria.
 Criteria lessEqual(String lhs, double rhs)
          Append a Less Than or Equal comparison to the search criteria.
 Criteria lessEqual(String lhs, int rhs)
          Append a Less Than or Equal comparison to the search criteria.
 Criteria lessEqual(String lhs, long rhs)
          Append a Less Than or Equal comparison to the search criteria.
 Criteria lessEqual(String lhs, String rhs)
          Append a Less Than or Equal comparison to the search criteria.
 Criteria like(String lhs, String rhs)
          Append a Like comparison to the search criteria.
 Criteria like(String lhs, String rhs, char escape)
          Append a Like comparison to the search criteria.
 int nodeType()
          Returns the node type of this query tree node.
 Criteria not()
          Create a new Criteria bound to the same class and database asn this Criteria and logically AND the inverse of the new Criteria with this Criteria.
 Criteria not(Criteria crit)
          Logically AND this Criteria with the inverse of a second Criteria.
 Criteria notBetween(String lhs, double lower, double upper)
          Append a Not Between comparison to the search criteria.
 Criteria notBetween(String lhs, int lower, int upper)
          Append a Not Between comparison to the search criteria.
 Criteria notBetween(String lhs, long lower, long upper)
          Append a Not Between comparison to the search criteria.
 Criteria notBetween(String lhs, String lower, String upper)
          Append a Not Between comparison to the search criteria.
 Criteria notEqual(String lhs, double rhs)
          Append a Not Equal comparison to the search criteria.
 Criteria notEqual(String lhs, int rhs)
          Append a Not Equal comparison to the search criteria.
 Criteria notEqual(String lhs, long rhs)
          Append a Not Equal comparison to the search criteria.
 Criteria notEqual(String lhs, String rhs)
          Append a Not Equal comparison to the search criteria.
 Criteria notIn(String lhs, Collection c)
          Append a Not In comparison to the search criteria.
 Criteria notLike(String lhs, String rhs)
          Append a Not Like comparison to the search criteria.
 Criteria notLike(String lhs, String rhs, char escape)
          Append a Not Like comparison to the search criteria.
 Criteria or()
          Create a new Criteria bound to the same database and class as this Criteria and logically OR the two search criteria.
 Criteria or(Criteria crit)
          Logically OR a Criteria with this Criteria.
 String query()
          Create a string representation of the query defined by this Criteria.
 void query(StringBuffer sb)
          Create a string representation of the query defined by this Criteria in the specified string buffer.
 void reset()
          Reset this Criteria to an empty search criteria.
 Criteria setClass(String name)
          Reset this Criteria and bind it to another persistent class.
 boolean validate()
          Returns true if the node is valid.
 int valueType()
          Returns the value type of this query tree node.
 String verboseQuery()
          Create a string representation of the query defined by this Criteria.
 
Methods inherited from class Operator
booleanValue, doubleValue, integerValue, longValue, stringValue
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isNull

public Criteria isNull(String lhs)
                throws PersistenceException
Append an Is Null comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
Returns:
this Criteria.
Throws:
PersistenceException

isNotNull

public Criteria isNotNull(String lhs)
                   throws PersistenceException
Append an Is Not Null comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
Returns:
this Criteria.
Throws:
PersistenceException

equal

public Criteria equal(String lhs,
                      int rhs)
               throws PersistenceException
Append an Equal comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

equal

public Criteria equal(String lhs,
                      long rhs)
               throws PersistenceException
Append an Equal comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

equal

public Criteria equal(String lhs,
                      double rhs)
               throws PersistenceException
Append an Equal comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

equal

public Criteria equal(String lhs,
                      String rhs)
               throws PersistenceException
Append an Equal comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

notEqual

public Criteria notEqual(String lhs,
                         int rhs)
                  throws PersistenceException
Append a Not Equal comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

notEqual

public Criteria notEqual(String lhs,
                         long rhs)
                  throws PersistenceException
Append a Not Equal comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

notEqual

public Criteria notEqual(String lhs,
                         double rhs)
                  throws PersistenceException
Append a Not Equal comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

notEqual

public Criteria notEqual(String lhs,
                         String rhs)
                  throws PersistenceException
Append a Not Equal comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

greater

public Criteria greater(String lhs,
                        int rhs)
                 throws PersistenceException
Append a Greater Than comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

greater

public Criteria greater(String lhs,
                        long rhs)
                 throws PersistenceException
Append a Greater Than comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

greater

public Criteria greater(String lhs,
                        double rhs)
                 throws PersistenceException
Append a Greater Than comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

greater

public Criteria greater(String lhs,
                        String rhs)
                 throws PersistenceException
Append a Greater Than comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

greaterEqual

public Criteria greaterEqual(String lhs,
                             int rhs)
                      throws PersistenceException
Append a Greater Than or Equal comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

greaterEqual

public Criteria greaterEqual(String lhs,
                             long rhs)
                      throws PersistenceException
Append a Greater Than or Equal comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

greaterEqual

public Criteria greaterEqual(String lhs,
                             double rhs)
                      throws PersistenceException
Append a Greater Than or Equal comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

greaterEqual

public Criteria greaterEqual(String lhs,
                             String rhs)
                      throws PersistenceException
Append a Greater Than or Equal comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

less

public Criteria less(String lhs,
                     int rhs)
              throws PersistenceException
Append a Less Than comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

less

public Criteria less(String lhs,
                     long rhs)
              throws PersistenceException
Append a Less Than comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

less

public Criteria less(String lhs,
                     double rhs)
              throws PersistenceException
Append a Less Than comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

less

public Criteria less(String lhs,
                     String rhs)
              throws PersistenceException
Append a Less Than comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

lessEqual

public Criteria lessEqual(String lhs,
                          int rhs)
                   throws PersistenceException
Append a Less Than or Equal comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

lessEqual

public Criteria lessEqual(String lhs,
                          long rhs)
                   throws PersistenceException
Append a Less Than or Equal comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

lessEqual

public Criteria lessEqual(String lhs,
                          double rhs)
                   throws PersistenceException
Append a Less Than or Equal comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

lessEqual

public Criteria lessEqual(String lhs,
                          String rhs)
                   throws PersistenceException
Append a Less Than or Equal comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - an attribute value.
Returns:
this Criteria.
Throws:
PersistenceException

between

public Criteria between(String lhs,
                        int lower,
                        int upper)
                 throws PersistenceException
Append a Between comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
lower - the lower bound of the comparison.
upper - the upper bound of the comparison.
Returns:
this Criteria.
Throws:
PersistenceException

between

public Criteria between(String lhs,
                        long lower,
                        long upper)
                 throws PersistenceException
Append a Between comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
lower - the lower bound of the comparison.
upper - the upper bound of the comparison.
Returns:
this Criteria.
Throws:
PersistenceException

between

public Criteria between(String lhs,
                        double lower,
                        double upper)
                 throws PersistenceException
Append a Between comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
lower - the lower bound of the comparison.
upper - the upper bound of the comparison.
Returns:
this Criteria.
Throws:
PersistenceException

between

public Criteria between(String lhs,
                        String lower,
                        String upper)
                 throws PersistenceException
Append a Between comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
lower - the lower bound of the comparison.
upper - the upper bound of the comparison.
Returns:
this Criteria.
Throws:
PersistenceException

notBetween

public Criteria notBetween(String lhs,
                           int lower,
                           int upper)
                    throws PersistenceException
Append a Not Between comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
lower - the lower bound of the comparison.
upper - the upper bound of the comparison.
Returns:
this Criteria.
Throws:
PersistenceException

notBetween

public Criteria notBetween(String lhs,
                           long lower,
                           long upper)
                    throws PersistenceException
Append a Not Between comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
lower - the lower bound of the comparison.
upper - the upper bound of the comparison.
Returns:
this Criteria.
Throws:
PersistenceException

notBetween

public Criteria notBetween(String lhs,
                           double lower,
                           double upper)
                    throws PersistenceException
Append a Not Between comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
lower - the lower bound of the comparison.
upper - the upper bound of the comparison.
Returns:
this Criteria.
Throws:
PersistenceException

notBetween

public Criteria notBetween(String lhs,
                           String lower,
                           String upper)
                    throws PersistenceException
Append a Not Between comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
lower - the lower bound of the comparison.
upper - the upper bound of the comparison.
Returns:
this Criteria.
Throws:
PersistenceException

in

public Criteria in(String lhs,
                   Collection c)
            throws PersistenceException
Append an In comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
c - the collection of values compared with the attribute.
Returns:
this Criteria.
Throws:
PersistenceException

notIn

public Criteria notIn(String lhs,
                      Collection c)
               throws PersistenceException
Append a Not In comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
c - the collection of values compared with the attribute.
Returns:
this Criteria.
Throws:
PersistenceException

like

public Criteria like(String lhs,
                     String rhs)
              throws PersistenceException
Append a Like comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - a pattern possibly including wild card characters.
Returns:
this Criteria.
Throws:
PersistenceException

like

public Criteria like(String lhs,
                     String rhs,
                     char escape)
              throws PersistenceException
Append a Like comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - a pattern possibly including wild card characters.
Returns:
this Criteria.
Throws:
PersistenceException

notLike

public Criteria notLike(String lhs,
                        String rhs)
                 throws PersistenceException
Append a Not Like comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - a pattern possibly including wild card characters.
Returns:
this Criteria.
Throws:
PersistenceException

notLike

public Criteria notLike(String lhs,
                        String rhs,
                        char escape)
                 throws PersistenceException
Append a Not Like comparison to the search criteria. The comparison is logically ANDed with any existing search criteria.

Parameters:
lhs - an attribute name.
rhs - a pattern possibly including wild card characters.
Returns:
this Criteria.
Throws:
PersistenceException

and

public Criteria and(Criteria crit)
Logically AND a Criteria with this Criteria.

Parameters:
crit - the second set of search criteria.
Returns:
this Criteria.

and

public Criteria and()
Create a new Criteria bound to the same database and class as this Criteria and logically AND the two search criteria.

Returns:
the new Criteria.

or

public Criteria or(Criteria crit)
Logically OR a Criteria with this Criteria.

Parameters:
crit - the second set of search criteria.
Returns:
this Criteria.

or

public Criteria or()
Create a new Criteria bound to the same database and class as this Criteria and logically OR the two search criteria.

Returns:
the new Criteria.

not

public Criteria not(Criteria crit)
Logically AND this Criteria with the inverse of a second Criteria.

Parameters:
crit - the second set of search criteria.
Returns:
this Criteria.

not

public Criteria not()
Create a new Criteria bound to the same class and database asn this Criteria and logically AND the inverse of the new Criteria with this Criteria.

Returns:
the new Criteria.

setClass

public Criteria setClass(String name)
                  throws ClassNotSupportedException
Reset this Criteria and bind it to another persistent class.

Parameters:
name - the class name.
Returns:
this Criteria.
Throws:
ClassNotSupportedException

database

public Criteria database(String name)
                  throws ClassNotSupportedException
Bind this Criteria to another database.

Parameters:
name - the database name.
Returns:
this Criteria.
Throws:
ClassNotSupportedException

reset

public void reset()
Reset this Criteria to an empty search criteria.


query

public String query()
Create a string representation of the query defined by this Criteria. The string resembles an SQL where clause.

Returns:
a query string.

verboseQuery

public String verboseQuery()
Create a string representation of the query defined by this Criteria. The string resembles an SQL where clause.

Returns:
a query string.

query

public void query(StringBuffer sb)
Create a string representation of the query defined by this Criteria in the specified string buffer.

Parameters:
sb - a string buffer.

isCompound

public boolean isCompound()
Returns true if this Criteria is a compound sesarch criteria consisting of multiple comparisons.

Returns:
true if this is a compound criteria.

isConstant

public boolean isConstant()
Returns true if the boolean value of this Criteria is constant.

Returns:
true if this Criteria has a constant value.

validate

public boolean validate()
Returns true if the node is valid.

Returns:
true if the node is valid.

nodeType

public int nodeType()
Returns the node type of this query tree node.

Returns:
the node type of this query tree node.

valueType

public int valueType()
Returns the value type of this query tree node. The possible value types are: BOOLEAN, INTEGER, DOUBLE, and STRING.

Returns:
the value type of this query tree node.