pt.jcodeutil.core.sql
Class DynamicQuery

java.lang.Object
  |
  +--pt.jcodeutil.core.sql.DynamicQuery

public class DynamicQuery
extends java.lang.Object

Title: DynamicQuery

Description: Provides a simple way of constructing SQL Queries to the database.

Version:
1.0
Author:
Marco Samuel (samuelbb@sapo.pt)

Field Summary
static java.lang.String AND
           
static java.lang.String COMMA
           
static int DATE
           
static java.lang.String EQUAL
           
static java.lang.String GREATER
           
static java.lang.String GREATER_OR_EQUAL
           
static java.lang.String IS
           
static java.lang.String ISNOT
           
static java.lang.String LEFT_BRACE
           
static java.lang.String LESS
           
static java.lang.String LESS_OR_EQUAL
           
static java.lang.String LIKE
           
static int LONG
           
static java.lang.String NONE
           
static java.lang.String NOTEQUAL
           
static java.lang.String NULL
           
static int NUMBER
           
static java.lang.String OR
           
static java.lang.String RIGHT_BRACE
           
static java.lang.String STAR
           
static java.lang.String UNION
           
static java.lang.String UNIONALL
           
static int VARCHAR2
           
 
Constructor Summary
DynamicQuery()
          Empty constructor
 
Method Summary
 java.lang.String getClause()
          Returns the clause that was built.
 java.lang.String getClause(boolean removeWhereWord, java.lang.String andOr)
          Returns the clause, depending on the parameters, that was built.
 void insertDirectValueIntoClause(java.lang.String value)
          Inserts a direct value into the clause
 void insertValue(java.lang.String op, boolean left, java.lang.String field, java.lang.String operation, java.lang.String value, boolean right)
          Inserts a new clause to the already existing.
 void reset()
          Clears the existing clause
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EQUAL

public static final java.lang.String EQUAL

NOTEQUAL

public static final java.lang.String NOTEQUAL

GREATER

public static final java.lang.String GREATER

LESS

public static final java.lang.String LESS

GREATER_OR_EQUAL

public static final java.lang.String GREATER_OR_EQUAL

LESS_OR_EQUAL

public static final java.lang.String LESS_OR_EQUAL

LEFT_BRACE

public static final java.lang.String LEFT_BRACE

RIGHT_BRACE

public static final java.lang.String RIGHT_BRACE

STAR

public static final java.lang.String STAR

NONE

public static final java.lang.String NONE

AND

public static final java.lang.String AND

OR

public static final java.lang.String OR

LIKE

public static final java.lang.String LIKE

ISNOT

public static final java.lang.String ISNOT

IS

public static final java.lang.String IS

UNION

public static final java.lang.String UNION

NULL

public static final java.lang.String NULL

COMMA

public static final java.lang.String COMMA

UNIONALL

public static final java.lang.String UNIONALL

VARCHAR2

public static final int VARCHAR2

NUMBER

public static final int NUMBER

DATE

public static final int DATE

LONG

public static final int LONG
Constructor Detail

DynamicQuery

public DynamicQuery()
Empty constructor
Method Detail

getClause

public java.lang.String getClause()
Returns the clause that was built.
Returns:
The clause filled until now.

getClause

public java.lang.String getClause(boolean removeWhereWord,
                                  java.lang.String andOr)
Returns the clause, depending on the parameters, that was built.
Parameters:
removeWhereWord - if true, remove the where word from the clause.
andOr - if true, add this clause in the beginning of the clause.
Returns:
The clause that was built.

insertDirectValueIntoClause

public void insertDirectValueIntoClause(java.lang.String value)
Inserts a direct value into the clause
Parameters:
value - to be inserted in the clause

insertValue

public void insertValue(java.lang.String op,
                        boolean left,
                        java.lang.String field,
                        java.lang.String operation,
                        java.lang.String value,
                        boolean right)
Inserts a new clause to the already existing.
Parameters:
op - AND | OR | ANY conjunction for this clause
left - Left parenthesis existence
field - Name of the column to be filtered in the database table
operation - Operation name to use in this clause
value - Value to test for
right - Right parenthesis existence

reset

public void reset()
Clears the existing clause