net.amrhassan.sqlbuilder.restrictions
Class SqlRestrictions

java.lang.Object
  extended by net.amrhassan.sqlbuilder.restrictions.SqlRestrictions

public final class SqlRestrictions
extends Object

A one-stop place for all the possible SQL restrictions. Most restrictions are provided in two flavours, one that automatically sets the restriction operands to the '?' character, the other needs the operands to be specified explicitly as Strings.


Method Summary
static SqlRestriction and(Collection<SqlRestriction> restrictions)
          AND combination of restrictions
static SqlRestriction and(SqlRestriction... restrictions)
          AND combination of restrictions
static SqlRestriction between(String field)
          The specified field falls inside a range; (field BETWEEN ? AND ?).
static SqlRestriction between(String field, String lowerBound, String upperBound)
          The specified field falls inside a range; (field BETWEEN lowerBound AND upperBound).
static SqlRestriction eq(String field)
          Equality between the provided field name and '?'
static SqlRestriction eq(String lhs, String rhs)
          Equality between two operands (lhs = rhs).
static SqlRestriction gt(String field)
          The specified field is greater-than another operand specified by a '?' character
static SqlRestriction gte(String field)
          The specified field is greater-than-or-equal to another operand specified by a '?' character
static SqlRestriction in(String field, int operandCount)
          The specified field is in a list of provided parameters; (field IN (?,?,?,...))
static SqlRestriction in(String field, SelectSqlStatement selectStatement)
          The specified field lies in the result of the provided sub-query
static SqlRestriction lt(String field)
          The specified field is less-than another operand specified by a '?' character
static SqlRestriction lte(String field)
          The specified field is less-than-or-equal to another operand specified by a '?' character
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

eq

public static SqlRestriction eq(String field)
Equality between the provided field name and '?'


eq

public static SqlRestriction eq(String lhs,
                                String rhs)
Equality between two operands (lhs = rhs). Be aware that the provided operands will not be escaped. Use the no-argument version of this method which places an automatic '?' character where each operand should go so that it's suitable for using with a PreparedStatement.


and

public static SqlRestriction and(SqlRestriction... restrictions)
AND combination of restrictions


and

public static SqlRestriction and(Collection<SqlRestriction> restrictions)
AND combination of restrictions


between

public static SqlRestriction between(String field)
The specified field falls inside a range; (field BETWEEN ? AND ?).


between

public static SqlRestriction between(String field,
                                     String lowerBound,
                                     String upperBound)
The specified field falls inside a range; (field BETWEEN lowerBound AND upperBound). Be aware that the provided operands will not be escaped; Use the no-argument version of this method which places an automatic '?' character where each operand should go so that it's suitable for using with a PreparedStatement


in

public static SqlRestriction in(String field,
                                int operandCount)
The specified field is in a list of provided parameters; (field IN (?,?,?,...))

Parameters:
field - The field name or its alias
operandCount - The number of operands in the list of possible values

in

public static SqlRestriction in(String field,
                                SelectSqlStatement selectStatement)
The specified field lies in the result of the provided sub-query

Parameters:
field - The field name or its alias
selectStatement - The sub-query

lte

public static SqlRestriction lte(String field)
The specified field is less-than-or-equal to another operand specified by a '?' character

Parameters:
field - The field name or its alias

lt

public static SqlRestriction lt(String field)
The specified field is less-than another operand specified by a '?' character

Parameters:
field - The field name or its alias

gte

public static SqlRestriction gte(String field)
The specified field is greater-than-or-equal to another operand specified by a '?' character

Parameters:
field - The field name or its alias

gt

public static SqlRestriction gt(String field)
The specified field is greater-than another operand specified by a '?' character

Parameters:
field -
Returns:


Copyright © 2013. All Rights Reserved.