to.etc.webapp.query
Class QRestrictor<T>

java.lang.Object
  extended by to.etc.webapp.query.QRestrictor<T>
Direct Known Subclasses:
QCriteriaQueryBase

public abstract class QRestrictor<T>
extends java.lang.Object

Builds the "where" part of a query, or a part of that "where" part, under construction. The nodes added, when > 1, are combined using either OR or AND.

Author:
Frits Jalvingh Created on Dec 22, 2009

Constructor Summary
protected QRestrictor(java.lang.Class<T> baseClass, QOperation combinator)
           
protected QRestrictor(ICriteriaTableDef<T> meta, QOperation combinator)
           
 
Method Summary
 QRestrictor<T> add(QOperatorNode n)
           
 QRestrictor<T> and()
           
 QRestrictor<T> between(java.lang.String property, java.lang.Object a, java.lang.Object b)
          Compare the value of a property with two literal bounds.
 QRestrictor<T> eq(java.lang.String property, double value)
          Compare a property with some literal object value.
 QRestrictor<T> eq(java.lang.String property, long value)
          Compare a property with some literal object value.
 QRestrictor<T> eq(java.lang.String property, java.lang.Object value)
          Compare a property with some literal object value.
<U> QRestrictor<U>
exists(java.lang.Class<U> childclass, java.lang.String childproperty)
          Create a joined "exists" subquery on some child list property.
 QRestrictor<T> ge(java.lang.String property, double value)
          Compare a property with some literal object value.
 QRestrictor<T> ge(java.lang.String property, long value)
          Compare a property with some literal object value.
 QRestrictor<T> ge(java.lang.String property, java.lang.Object value)
          Compare a property with some literal object value.
 java.lang.Class<T> getBaseClass()
          Returns the persistent class being queried and returned, if this is a class-based query.
 ICriteriaTableDef<T> getMetaTable()
          Returns the metatable being queried, or null.
abstract  QOperatorNode getRestrictions()
           
 java.lang.Class<T> getReturnClass()
          Return the datatype returned by a principal query using this criteria.
 QRestrictor<T> gt(java.lang.String property, double value)
          Compare a property with some literal object value.
 QRestrictor<T> gt(java.lang.String property, long value)
          Compare a property with some literal object value.
 QRestrictor<T> gt(java.lang.String property, java.lang.Object value)
          Compare a property with some literal object value.
 boolean hasRestrictions()
          Returns T if this has restrictions.
 QRestrictor<T> ilike(java.lang.String property, java.lang.Object value)
          Do a case-independent 'like' comparison.
protected  void internalAdd(QOperatorNode r)
          Add a new restriction to the list of restrictions on the data.
 QRestrictor<T> isnotnull(java.lang.String property)
          Add the restriction that the property specified must be not-null.
 QRestrictor<T> isnull(java.lang.String property)
          Add the restriction that the property specified must be null.
 QRestrictor<T> le(java.lang.String property, double value)
          Compare a property with some literal object value.
 QRestrictor<T> le(java.lang.String property, long value)
          Compare a property with some literal object value.
 QRestrictor<T> le(java.lang.String property, java.lang.Object value)
          Compare a property with some literal object value.
 QRestrictor<T> like(java.lang.String property, java.lang.Object value)
          Do a 'like' comparison.
 QRestrictor<T> lt(java.lang.String property, double value)
          Compare a property with some literal object value.
 QRestrictor<T> lt(java.lang.String property, long value)
          Compare a property with some literal object value.
 QRestrictor<T> lt(java.lang.String property, java.lang.Object value)
          Compare a property with some literal object value.
 QRestrictor<T> ne(java.lang.String property, double value)
          Compare a property with some literal object value.
 QRestrictor<T> ne(java.lang.String property, long value)
          Compare a property with some literal object value.
 QRestrictor<T> ne(java.lang.String property, java.lang.Object value)
          Compare a property with some literal object value.
 QRestrictor<T> or()
          Return a thingy that constructs nodes combined with "or".
 QRestrictor<T> or(QOperatorNode a1, QOperatorNode a2, QOperatorNode... rest)
          Deprecated. 
abstract  void setRestrictions(QOperatorNode n)
           
 QRestrictor<T> sqlCondition(java.lang.String sql)
          Add a restriction specified in bare SQL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QRestrictor

protected QRestrictor(java.lang.Class<T> baseClass,
                      QOperation combinator)

QRestrictor

protected QRestrictor(ICriteriaTableDef<T> meta,
                      QOperation combinator)
Method Detail

getRestrictions

public abstract QOperatorNode getRestrictions()

setRestrictions

public abstract void setRestrictions(QOperatorNode n)

getBaseClass

@Nullable
public java.lang.Class<T> getBaseClass()
Returns the persistent class being queried and returned, if this is a class-based query.

Returns:

getMetaTable

@Nullable
public ICriteriaTableDef<T> getMetaTable()
Returns the metatable being queried, or null.

Returns:

getReturnClass

public java.lang.Class<T> getReturnClass()
Return the datatype returned by a principal query using this criteria.

Returns:

hasRestrictions

public final boolean hasRestrictions()
Returns T if this has restrictions.


internalAdd

protected void internalAdd(QOperatorNode r)
Add a new restriction to the list of restrictions on the data. This will do "and" collapsion: when the node added is an "and" it's nodes will be added directly to the list (because that already represents an and combinatory).

Parameters:
r -

or

public QRestrictor<T> or()
Return a thingy that constructs nodes combined with "or".

Returns:

and

public QRestrictor<T> and()

add

public QRestrictor<T> add(QOperatorNode n)

eq

public QRestrictor<T> eq(java.lang.String property,
                         java.lang.Object value)
Compare a property with some literal object value.

Parameters:
property -
value -
Returns:

eq

public QRestrictor<T> eq(java.lang.String property,
                         long value)
Compare a property with some literal object value.

Parameters:
property -
value -
Returns:

eq

public QRestrictor<T> eq(java.lang.String property,
                         double value)
Compare a property with some literal object value.

Parameters:
property -
value -
Returns:

ne

public QRestrictor<T> ne(java.lang.String property,
                         java.lang.Object value)
Compare a property with some literal object value.

Parameters:
property -
value -
Returns:

ne

public QRestrictor<T> ne(java.lang.String property,
                         long value)
Compare a property with some literal object value.

Parameters:
property -
value -
Returns:

ne

public QRestrictor<T> ne(java.lang.String property,
                         double value)
Compare a property with some literal object value.

Parameters:
property -
value -
Returns:

gt

public QRestrictor<T> gt(java.lang.String property,
                         java.lang.Object value)
Compare a property with some literal object value.

Parameters:
property -
value -
Returns:

gt

public QRestrictor<T> gt(java.lang.String property,
                         long value)
Compare a property with some literal object value.

Parameters:
property -
value -
Returns:

gt

public QRestrictor<T> gt(java.lang.String property,
                         double value)
Compare a property with some literal object value.

Parameters:
property -
value -
Returns:

lt

public QRestrictor<T> lt(java.lang.String property,
                         java.lang.Object value)
Compare a property with some literal object value.

Parameters:
property -
value -
Returns:

lt

public QRestrictor<T> lt(java.lang.String property,
                         long value)
Compare a property with some literal object value.

Parameters:
property -
value -
Returns:

lt

public QRestrictor<T> lt(java.lang.String property,
                         double value)
Compare a property with some literal object value.

Parameters:
property -
value -
Returns:

ge

public QRestrictor<T> ge(java.lang.String property,
                         java.lang.Object value)
Compare a property with some literal object value.

Parameters:
property -
value -
Returns:

ge

public QRestrictor<T> ge(java.lang.String property,
                         long value)
Compare a property with some literal object value.

Parameters:
property -
value -
Returns:

ge

public QRestrictor<T> ge(java.lang.String property,
                         double value)
Compare a property with some literal object value.

Parameters:
property -
value -
Returns:

le

public QRestrictor<T> le(java.lang.String property,
                         java.lang.Object value)
Compare a property with some literal object value.

Parameters:
property -
value -
Returns:

le

public QRestrictor<T> le(java.lang.String property,
                         long value)
Compare a property with some literal object value.

Parameters:
property -
value -
Returns:

le

public QRestrictor<T> le(java.lang.String property,
                         double value)
Compare a property with some literal object value.

Parameters:
property -
value -
Returns:

like

public QRestrictor<T> like(java.lang.String property,
                           java.lang.Object value)
Do a 'like' comparison. The wildcard marks here are always %; a literal % is to be presented as \%. The comparison is case-dependent.

Parameters:
property -
value -
Returns:

between

public QRestrictor<T> between(java.lang.String property,
                              java.lang.Object a,
                              java.lang.Object b)
Compare the value of a property with two literal bounds.

Parameters:
property -
a -
b -
Returns:

ilike

public QRestrictor<T> ilike(java.lang.String property,
                            java.lang.Object value)
Do a case-independent 'like' comparison. The wildcard marks here are always %; a literal % is to be presented as \%. The comparison is case-independent.

Parameters:
property -
value -
Returns:

or

@Deprecated
public QRestrictor<T> or(QOperatorNode a1,
                                    QOperatorNode a2,
                                    QOperatorNode... rest)
Deprecated. 

Add a set of OR nodes to the set.

Parameters:
a -
Returns:

isnull

public QRestrictor<T> isnull(java.lang.String property)
Add the restriction that the property specified must be null.

Parameters:
property -
Returns:

isnotnull

public QRestrictor<T> isnotnull(java.lang.String property)
Add the restriction that the property specified must be not-null.

Parameters:
property -
Returns:

sqlCondition

public QRestrictor<T> sqlCondition(java.lang.String sql)
Add a restriction specified in bare SQL. This is implementation-dependent.

Parameters:
sql -
Returns:

exists

public <U> QRestrictor<U> exists(java.lang.Class<U> childclass,
                                 java.lang.String childproperty)
Create a joined "exists" subquery on some child list property. The parameters passed have a relation with eachother; this relation cannot be checked at compile time because Java still lacks property references (Sun is still too utterly stupid to define them). They will be checked at runtime when the query is executed.

Type Parameters:
U - The type of the children.
Parameters:
childclass - The class type of the children, because Java Generics is too bloody stupid to find out itself.
childproperty - The name of the property in the parent class that represents the List of child records.
Returns: