uk.co.kimble.cobra.criteria
Class PersistentCriteria

java.lang.Object
  |
  +--uk.co.kimble.cobra.criteria.PersistentCriteria

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

Persistent Criteria can be used to retrieve sets of objects based on their attributes Normally each attribute is ANDed together, an OR can be performed by creating a new PersistentCriteria and adding it.

Criteria are used, rather than a simple string, because they can be precompiled for efficiency.

See Also:
Serialized Form

Constructor Summary
PersistentCriteria()
           
 
Method Summary
 void addEqualTo(java.lang.String attribute, java.lang.Object value)
          Adds and equals (=) criteria, customer_id = 10034 Where Value is a string simple pattern matching can be used, the character * is a wildcard, e.g.
 void addGreaterThan(java.lang.String attribute, java.lang.Object value)
          Adds Greater Than (>) criteria, customer_id > 10034
 void addLessThan(java.lang.String attribute, java.lang.Object value)
          Adds Less Than (<) criteria, customer_id < 10034
 void addOrCriteria(PersistentCriteria pc)
          ORs two sets of criteria together: active = true AND balance < 0 OR active = true AND overdraft = 0
 java.util.Enumeration getElements()
           
 java.lang.String getOrderby()
           
 void orderBy(java.lang.String column)
          ORs two sets of criteria together: active = true AND balance < 0 OR active = true AND overdraft = 0
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PersistentCriteria

public PersistentCriteria()
Method Detail

getElements

public java.util.Enumeration getElements()

addEqualTo

public void addEqualTo(java.lang.String attribute,
                       java.lang.Object value)
Adds and equals (=) criteria, customer_id = 10034

Where Value is a string simple pattern matching can be used, the character * is a wildcard, e.g. customer_name = Ander*

Would match the customers: Anderson and Anderton. The character ? matches a single occurence of a character.

Parameters:
attribute - The field name to be used
value - An object representing the value of the field

addGreaterThan

public void addGreaterThan(java.lang.String attribute,
                           java.lang.Object value)
Adds Greater Than (>) criteria, customer_id > 10034
Parameters:
attribute - The field name to be used
value - An object representing the value of the field

addLessThan

public void addLessThan(java.lang.String attribute,
                        java.lang.Object value)
Adds Less Than (<) criteria, customer_id < 10034
Parameters:
attribute - The field name to be used
value - An object representing the value of the field

addOrCriteria

public void addOrCriteria(PersistentCriteria pc)
                   throws PersistentException
ORs two sets of criteria together: active = true AND balance < 0 OR active = true AND overdraft = 0
Parameters:
persistent - criteria
Throws:
PersisentException - when there are no previous criteria to OR with

orderBy

public void orderBy(java.lang.String column)
ORs two sets of criteria together: active = true AND balance < 0 OR active = true AND overdraft = 0
Parameters:
persistent - criteria
Throws:
PersisentException - when there are no previous criteria to OR with

getOrderby

public java.lang.String getOrderby()

toString

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