org.objectweb.telosys.dal.sql
Class Criteria

java.lang.Object
  extended byorg.objectweb.telosys.common.TelosysObject
      extended byorg.objectweb.telosys.dal.sql.Criteria
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
SQLCriterias

public class Criteria
extends TelosysObject
implements java.io.Serializable

A Criteria object is a collection of Criterion objects to be used together to build dynamic SQL Queries

See Also:
Serialized Form

Constructor Summary
Criteria(Criterion[] critArray)
          Build a new criteria ( collection of criterion objects ) with the defaut "and" operator
Criteria(Criterion[] critArray, java.lang.String sOperator)
          Build a new criteria ( collection of criterion objects )
 
Method Summary
 int applyParameters(java.util.Map params)
          Apply the given parameters to the criteria, each Criterion parameter name
is used to try to find a parameter value in the given Map.
 void doNotUse(int i)
          Fix the given criterion as "not used"
 int getCount()
          Returns the number of criteria
 java.lang.String[] getDynamicParameters()
          Build a String array containing the useful parameters values
 int[] getDynamicTypes()
          Build a int array containing the useful parameters types
 java.lang.String getDynamicWhere()
          Build the SQL where clause dynamicaly with the useful criterion objects
 java.lang.String getOperator()
          Returns the current operator for criteria combination ( "and" or "or" )
 int getParamType(int i)
          Return the parameter type expected for the given criterion index
 java.lang.String getSqlExpression(int i)
          Return the SQL criterion expression ( ie "thecolumn = ?"
 Criterion[] getUsefulCriteria()
          Build an array containing the useful Criterion objects
 int getUsefulParametersCount()
          Return the number of useful parameters
 void reset()
          Reset each criterion as "not used"
 void useWithValue(int i, java.lang.String sParamVal)
          Fix the given criterion as "useful" and set its parameter value
 
Methods inherited from class org.objectweb.telosys.common.TelosysObject
error, error, error, getFlagTrace, info, setFlagTrace, trace, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Criteria

public Criteria(Criterion[] critArray)
Build a new criteria ( collection of criterion objects ) with the defaut "and" operator

Parameters:
critArray - array of criterion objects to be used in conjunction for dynamic request
Since:
1.1.0

Criteria

public Criteria(Criterion[] critArray,
                java.lang.String sOperator)
Build a new criteria ( collection of criterion objects )

Parameters:
critArray - array of criterion objects to be used in conjunction for dynamic request
sOperator - where operator to use between each criterion ( "and" / "or" )
Method Detail

getOperator

public java.lang.String getOperator()
Returns the current operator for criteria combination ( "and" or "or" )

Returns:

getCount

public int getCount()
Returns the number of criteria

Returns:

getSqlExpression

public java.lang.String getSqlExpression(int i)
Return the SQL criterion expression ( ie "thecolumn = ?" )

Parameters:
i - criterion index ( from 1 to N )
Returns:

getParamType

public int getParamType(int i)
Return the parameter type expected for the given criterion index

Parameters:
i - criterion index ( from 1 to N )
Returns:

applyParameters

public int applyParameters(java.util.Map params)
Apply the given parameters to the criteria, each Criterion parameter name
is used to try to find a parameter value in the given Map.
If a parameter value is found, it is used
If there's no parameter in the Map, the Criterion is declared as "not to be used"
If the given map is null, each Criterion is declared as "not to be used"
The Map is supposed to provide for each key a single String ( "key" --> "value" ),
or an array of Strings (in this case, the first item is used : "key" --> values[0] )

Parameters:
params - the parameters to apply
Returns:
the number of parameters applyed on the criteria

useWithValue

public void useWithValue(int i,
                         java.lang.String sParamVal)
Fix the given criterion as "useful" and set its parameter value

Parameters:
i - criterion index ( from 1 to N )
sParamVal - criterion parameter value

doNotUse

public void doNotUse(int i)
Fix the given criterion as "not used"

Parameters:
i - criterion index ( from 1 to N )

reset

public void reset()
Reset each criterion as "not used"


getDynamicWhere

public java.lang.String getDynamicWhere()
Build the SQL where clause dynamicaly with the useful criterion objects

Returns:
the SQL where clause built

getUsefulParametersCount

public int getUsefulParametersCount()
Return the number of useful parameters

Returns:

getDynamicTypes

public int[] getDynamicTypes()
Build a int array containing the useful parameters types

Returns:

getDynamicParameters

public java.lang.String[] getDynamicParameters()
Build a String array containing the useful parameters values

Returns:

getUsefulCriteria

public Criterion[] getUsefulCriteria()
Build an array containing the useful Criterion objects

Returns: