Last update: 2011-06-23

org.proteios.core.query
Class Restrictions

java.lang.Object
  extended by org.proteios.core.query.Restrictions

public class Restrictions
extends Object

A factory class to create restrictions.

Version:
2.0
Author:
Samuel, Nicklas
Last modified
$Date: 2010-03-16 11:09:06 +0100 (Tue, 16 Mar 2010) $

Constructor Summary
Restrictions()
           
 
Method Summary
static Restriction and(Restriction... r)
          Combine one or more restrictions with AND: new restriction = r[0] AND r[1] AND ...
static Restriction between(Expression e, Expression low, Expression high)
          Compare if one expression falls between two other expressions: new expression = low <= e AND e < high.
static Restriction eq(Expression e1, Expression e2)
          Compare if two expressions are equal: new restriction = e1 == e2.
static Restriction gt(Expression e1, Expression e2)
          Compare if one expression is greater than another: new restriction = e1 > e2.
static Restriction gteq(Expression e1, Expression e2)
          Compare if one expression is greater than or equal to another: new restriction = e1 >= e2.
static Restriction in(Expression e1, Expression... e2)
          Check if an expression is contained in a set of other expressions: e1 IN (e2[0], e2[1], ...)
static Restriction in(Expression e1, List<Expression> e2)
          Check if an expression is contained in a set of other expressions: e1 IN (e2[0], e2[1], ...)
static Restriction like(Expression e1, Expression e2)
          Check if one expression matches another: e1 LIKE e2
static Restriction lt(Expression e1, Expression e2)
          Compare if one expression is less than another: new restriction = e1 < e2.
static Restriction lteq(Expression e1, Expression e2)
          Compare if one expression is less than or equal to another: new restriction = e1 <= e2.
static Restriction neq(Expression e1, Expression e2)
          Compare if two expressions are inequal: new restriction = e1 <> e2.
static Restriction not(Restriction r)
          Negate a restriction: new restriction = NOT r
static Restriction or(Restriction... r)
          Combine one or more restrictions with OR: new restriction = r[0] OR r[1] ...
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Restrictions

public Restrictions()
Method Detail

and

public static Restriction and(Restriction... r)
                       throws InvalidDataException
Combine one or more restrictions with AND: new restriction = r[0] AND r[1] AND ...

Parameters:
r - The restrictions to combine
Returns:
The new restriction
Throws:
InvalidDataException - If any of the elements is null or the array doesn't contain at least one element

or

public static Restriction or(Restriction... r)
                      throws InvalidDataException
Combine one or more restrictions with OR: new restriction = r[0] OR r[1] ...

Parameters:
r - The restrictions to combine
Returns:
The new restriction
Throws:
InvalidDataException - If any of the elements is null or the array doesn't contain at least one element

not

public static Restriction not(Restriction r)
                       throws InvalidDataException
Negate a restriction: new restriction = NOT r

Parameters:
r - The restrictions to negate
Returns:
The new restriction
Throws:
InvalidDataException - If the restriction is null

eq

public static Restriction eq(Expression e1,
                             Expression e2)
                      throws InvalidDataException
Compare if two expressions are equal: new restriction = e1 == e2. If the right expression is null, the IS NULL operation is used: new restriction = e1 IS NULL.

Parameters:
e1 - The left expression
e2 - The right expression (optional)
Returns:
The new restriction
Throws:
InvalidDataException - If the left expression is null

neq

public static Restriction neq(Expression e1,
                              Expression e2)
                       throws InvalidDataException
Compare if two expressions are inequal: new restriction = e1 <> e2. If the right expression is null, the NOT IS NULL operation is used: new restriction = NOT e1 IS NULL.

Parameters:
e1 - The left expression
e2 - The right expression (optional)
Returns:
The new restriction
Throws:
InvalidDataException - If the left expression is null

gt

public static Restriction gt(Expression e1,
                             Expression e2)
                      throws InvalidDataException
Compare if one expression is greater than another: new restriction = e1 > e2.

Parameters:
e1 - The left expression
e2 - The right expression
Returns:
The new restriction
Throws:
InvalidDataException - If any of the expressions are null

gteq

public static Restriction gteq(Expression e1,
                               Expression e2)
                        throws InvalidDataException
Compare if one expression is greater than or equal to another: new restriction = e1 >= e2.

Parameters:
e1 - The left expression
e2 - The right expression
Returns:
The new restriction
Throws:
InvalidDataException - If any of the expressions are null

lt

public static Restriction lt(Expression e1,
                             Expression e2)
                      throws InvalidDataException
Compare if one expression is less than another: new restriction = e1 < e2.

Parameters:
e1 - The left expression
e2 - The right expression
Returns:
The new restriction
Throws:
InvalidDataException - If any of the expressions are null

lteq

public static Restriction lteq(Expression e1,
                               Expression e2)
                        throws InvalidDataException
Compare if one expression is less than or equal to another: new restriction = e1 <= e2.

Parameters:
e1 - The left expression
e2 - The right expression
Returns:
The new restriction
Throws:
InvalidDataException - If any of the expressions are null

between

public static Restriction between(Expression e,
                                  Expression low,
                                  Expression high)
                           throws InvalidDataException
Compare if one expression falls between two other expressions: new expression = low <= e AND e < high. Since the inclusion/exclusion of the low and high limits are dependent of the database Proteios hase defined the between this way to make sure that Proteios will treat BETWEEN the same way regardless of database.

Parameters:
e - The expression to check against the limits
low - The expression for the low limit
high - The expression for the high limit
Returns:
The new restriction
Throws:
InvalidDataException - If any of the expressions are null

in

public static Restriction in(Expression e1,
                             Expression... e2)
                      throws InvalidDataException
Check if an expression is contained in a set of other expressions: e1 IN (e2[0], e2[1], ...)

Parameters:
e1 - The expression to check
e2 - The set of expression to check against
Returns:
The new restriction
Throws:
InvalidDataException - If any of the expressions are null, the set contains null values or the set is empty

in

public static Restriction in(Expression e1,
                             List<Expression> e2)
                      throws InvalidDataException
Check if an expression is contained in a set of other expressions: e1 IN (e2[0], e2[1], ...)

Parameters:
e1 - The expression to check
e2 - The set of expression to check against
Returns:
The new restriction
Throws:
InvalidDataException - If any of the expressions are null, the set contains null values or the set is empty

like

public static Restriction like(Expression e1,
                               Expression e2)
                        throws InvalidDataException
Check if one expression matches another: e1 LIKE e2

Parameters:
e1 - The left expression
e2 - The right expression
Returns:
The new restriction
Throws:
InvalidDataException - If any of the expressions are null

Last update: 2011-06-23