com.stc.eindex.ejb.query
Class Condition

java.lang.Object
  extended bycom.stc.eindex.ejb.query.Condition

public class Condition
extends java.lang.Object

The Condition class represents a condition in the WHERE clause of a SQL statement that is used to build a query object. Each condition in the clause requires a different instance of the Condition class. A condition contains a field name, an operator, and one or more values for the field. By default, conditions are joined to each other by AND operators, but you can specify OR by using the addConditions method and specifying "OR" as the join type. A Condition objet can be a condition container that includes both a left condition and a list of right conditions. By using the appropriate methods, you can build a next OR/AND condition tree.

For example, to create the condition statement "Enterprise.SystemSBR.Person.FirstName = John OR Enterprise.SystemSBR.Person.FirstName = James", use the following methods.

Condition condition = new Condition ("Enterprise.SystemSBR.Person.FirstName", "=", "John", true);

condition.addConditions("OR", new Condition("Enterprise.SystemSBR.Person.FirstName", "=", "James", true));


Constructor Summary
Condition(Condition condition)
          This a copy constructor for the Condition class and creates a copy of the specified condition object enclosed in parenthesis.
Condition(java.lang.String field, java.lang.Object value)
          Creates a new instance of the Condition class where the operator is = (equals) by default.
Condition(java.lang.String field, java.lang.String operator, java.lang.Object value)
          Creates a new instance of the Condition class.
Condition(java.lang.String field, java.lang.String operator, java.lang.Object[] values)
          Creates a new instance of the Condition class that uses an array of values, and only supports the IN operator.
Condition(java.lang.String field, java.lang.String operator, java.lang.Object[] values, boolean prepare)
          Creates a new instance of the Condition class that uses an array of values, and only supports the IN operator.
Condition(java.lang.String field, java.lang.String operator, java.lang.Object value, boolean prepare)
          Creates a new instance of the Condition class.
 
Method Summary
 void addCondition(java.lang.String joinType, java.lang.String field, java.lang.Object value)
          Adds a new condition to a generated SQL statement where the operator within the condition is = (equals) by default.
 void addCondition(java.lang.String joinType, java.lang.String field, java.lang.String operator, java.lang.Object value)
          Adds a new condition to a generated SQL statement.
 void addCondition(java.lang.String joinType, java.lang.String field, java.lang.String operator, java.lang.Object[] values)
          Adds a new condition to a generated SQL statement using an array of values.
 void addCondition(java.lang.String joinType, java.lang.String field, java.lang.String operator, java.lang.Object value, boolean prepare)
          Adds a new condition to a generated SQL statement and specifies whether to bind the value to a prepared statement.
 void addConditions(java.lang.String joinType, Condition condition)
          Adds an existing condition to a generated SQL statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Condition

public Condition(Condition condition)
This a copy constructor for the Condition class and creates a copy of the specified condition object enclosed in parenthesis. This condition arguement becomes the left condition in a condition container, allowing for nested AND/OR operators in the WHERE clauses of your queries.

Parameters:
condition - The Condition object to copy.
Throws:
None.

Condition

public Condition(java.lang.String field,
                 java.lang.Object value)
Creates a new instance of the Condition class where the operator is = (equals) by default.

Parameters:
field - The qualified field name for the condition (qualified field names are in the format object_name.field_name).
value - The value for the condition (do not use quotes).
Throws:
None.

Condition

public Condition(java.lang.String field,
                 java.lang.String operator,
                 java.lang.Object value)
Creates a new instance of the Condition class.

Parameters:
field - The qualified field name for the condition (qualified field names are in the format object_name.field_name).
operator - The operator for the condition. Supported operators include LIKE, =, >, <, >=, and <=.
value - The value for the condition (do not use quotes).
Throws:
None.

Condition

public Condition(java.lang.String field,
                 java.lang.String operator,
                 java.lang.Object[] values)
Creates a new instance of the Condition class that uses an array of values, and only supports the IN operator.

Parameters:
field - The qualified field name for the condition (qualified field names are in the format object_name.field_name).
operator - The condition operator (currently, IN is the only supported operator).
values - An array of values for the condition.
Throws:
None.

Condition

public Condition(java.lang.String field,
                 java.lang.String operator,
                 java.lang.Object[] values,
                 boolean prepare)
Creates a new instance of the Condition class that uses an array of values, and only supports the IN operator. You can also specify whether to bind the values to a prepared statement.

Parameters:
field - The qualified field name for the condition (qualified field names are in the format object_name.field_name).
operator - The condition operator (currently, IN is the only supported operator).
values - An array of values for the condition.
prepare - A Boolean indicator of whether to bind the values to a prepared statement. Specify true to bind the values; otherwise specify false.
Throws:
None.

Condition

public Condition(java.lang.String field,
                 java.lang.String operator,
                 java.lang.Object value,
                 boolean prepare)
Creates a new instance of the Condition class. This methods allows you to specify whether to bind the values to a prepared statement.

Parameters:
field - The qualified field name for the condition (qualified field names are in the format object_name.field_name).
operator - The condition operator. Supported operators include LIKE, =, >, and <.
value - The value for the condition (do not use quotes).
prepare - A Boolean indicator of whether to bind the values to a prepared statement. Specify true to bind the values; otherwise specify false.
Throws:
None.
Method Detail

addCondition

public void addCondition(java.lang.String joinType,
                         java.lang.String field,
                         java.lang.Object value)
Adds a new condition to a generated SQL statement where the operator within the condition is = (equals) by default.

Parameters:
joinType - The type of join operator to use between this condition and the previous one.
field - The qualified field name for the condition (qualified field names are in the format object_name.field_name.
value - The value for the condition (do not use quotes).
Returns:
void - None.
Throws:
None.

addCondition

public void addCondition(java.lang.String joinType,
                         java.lang.String field,
                         java.lang.String operator,
                         java.lang.Object value)
Adds a new condition to a generated SQL statement.

Parameters:
joinType - The type of join operator to use between this condition and the previous one.
field - The qualified field name for the condition (qualified field names are in the format object_name.field_name).
operator - The condition operator. Supported operators include LIKE, =, >, and <.
value - The value for the condition (do not use quotes).
Returns:
void - None.
Throws:
None.

addCondition

public void addCondition(java.lang.String joinType,
                         java.lang.String field,
                         java.lang.String operator,
                         java.lang.Object[] values)
Adds a new condition to a generated SQL statement using an array of values. This method only supports the IN operator within the new condition.

Parameters:
joinType - The type of join operator to use between this condition and the previous one.
field - The qualified field name for the condition (qualified field names are in the format object_name.field_name).
operator - The condition operator (currently, IN is the only supported operator).
values - An array of values for the condition.
Returns:
void - None.
Throws:
None.

addCondition

public void addCondition(java.lang.String joinType,
                         java.lang.String field,
                         java.lang.String operator,
                         java.lang.Object value,
                         boolean prepare)
Adds a new condition to a generated SQL statement and specifies whether to bind the value to a prepared statement.

Parameters:
joinType - The type of join operator to use between this condition and the previous one.
field - The qualified field name for the condition (qualified field names are in the format object_name.field_name).
operator - The condition operator. Supported operators include LIKE, =, >, and <.
value - The value for the condition.
prepare - A Boolean indicator of whether bind the value to a prepared statement. Specify true to bind the value; otherwise specify false.
Returns:
void - None.
Throws:
None.

addConditions

public void addConditions(java.lang.String joinType,
                          Condition condition)
Adds an existing condition to a generated SQL statement.

Parameters:
joinType - The type of join operator to use between this condition and the previous one.
condition - The condition to add to the statement.
Returns:
void - None.
Throws:
None.


Copyright 2007 by Sun Microsystems, Inc. All Rights Reserved.