|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.mdm.index.query.Condition
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));
Field Summary | |
(package private) Condition |
mCondition
|
(package private) static int |
PREPARE_ATLEAST_ONE
|
(package private) static int |
PREPARE_IN
|
(package private) static int |
PREPARE_NONE
|
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. |
(package private) void |
calcBlock()
The Condition Tree is traversed to calculate if this node will be considered a Block or not. |
(package private) void |
chains(Condition otherCondition,
java.util.Hashtable conditionsLookup)
|
(package private) boolean |
compareWith(Condition otherCondTree,
java.util.Map bindingAssociation)
If the two conditions are EQUAL then a entry key = this & value = newCondition is added to the binding parameters. |
boolean |
equals(Condition theOtherCondition)
|
(package private) static java.lang.String |
formatDate(java.lang.Object value,
java.lang.String returnType)
Reformats a date to a String. |
(package private) java.lang.String |
getAlternateSubQuery()
Retrieves a subquery for the condition expression. |
(package private) ConditionDescriptor |
getConditionDescriptor()
Retrieves the condition descriptor for the prepared statement. |
(package private) java.lang.String |
getField()
Retrieves the field name to be used for this condition in the WHERE clause. |
(package private) java.util.List |
getJoinConditionList()
Retrieves a list of join operators for the conditions. |
(package private) Condition |
getLeftOperand()
|
(package private) java.lang.String |
getObjectName()
Retrieves the name of the object to which the field in this condition belongs. |
(package private) java.lang.String |
getOperator()
Retrieves the SQL operator to be used for this condition in the WHERE clause. |
(package private) int |
getParamSize()
|
(package private) int |
getPrepareStatus()
Three types of status possible 1. |
(package private) java.lang.String |
getType()
Retrieves the column type from an instance of the Condition class, based on the path of the condition field. |
(package private) java.lang.Object |
getValue()
Retrieves the value to be used for this condition in the WHERE clause. |
(package private) java.lang.Object |
getValues()
Retrieves an array of values to be used for this condition in the WHERE clause. |
int |
hashCode()
|
java.lang.String |
hashString()
|
(package private) boolean |
isBlock()
Returns an indicator of whether a condition node is a block. |
(package private) boolean |
isInOperator()
Indicates whether the operator for the condition is IN. |
(package private) boolean |
isLeaf()
Returns an indicator of whether a condition node is a leaf in the object tree. |
(package private) boolean |
isOldFormatConditionExpressionTree()
This method will return true if and only if all the Conditions in the Condition Expression are connected by AND Operator. |
(package private) boolean |
isPrepare()
Indicates whether the statement will be prepared. |
(package private) void |
parseTree()
|
(package private) void |
propagatePrepareStatus(boolean prepareStatus)
|
(package private) void |
setAlternateSubQuery(java.lang.String alternateSubQuery)
Sets a subquery for the condition expression. |
(package private) void |
setConditionDescriptor(ConditionDescriptor condDesc)
|
(package private) void |
setConditionsBlockList(java.util.List list)
Sets a list of all conditions in a condition expression if the following is true: |
(package private) void |
setConditionsLeafList(java.util.List list)
Sets a list of all conditions in a condition expression that are leafs in the object tree. |
(package private) void |
setPrepare(boolean prepare)
Sets the prepared statement indicator for an instance of the Condition class. |
java.lang.String |
toString()
Returns a String representation of this class |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
Condition mCondition
static int PREPARE_ATLEAST_ONE
static int PREPARE_IN
static int PREPARE_NONE
Constructor Detail |
public Condition(Condition condition)
condition
- The Condition object to copy.
public Condition(java.lang.String field, java.lang.Object value)
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).
public Condition(java.lang.String field, java.lang.String operator, java.lang.Object value)
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).
public Condition(java.lang.String field, java.lang.String operator, java.lang.Object[] values)
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.
public Condition(java.lang.String field, java.lang.String operator, java.lang.Object[] values, boolean prepare)
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.
public Condition(java.lang.String field, java.lang.String operator, java.lang.Object value, boolean prepare)
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.
Method Detail |
public void addCondition(java.lang.String joinType, java.lang.String field, java.lang.Object value)
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).
void
- None.
public void addCondition(java.lang.String joinType, java.lang.String field, java.lang.String operator, java.lang.Object value)
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).
void
- None.
public void addCondition(java.lang.String joinType, java.lang.String field, java.lang.String operator, java.lang.Object[] values)
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.
void
- None.
public void addCondition(java.lang.String joinType, java.lang.String field, java.lang.String operator, java.lang.Object value, boolean prepare)
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.
void
- None.
public void addConditions(java.lang.String joinType, Condition condition)
joinType
- The type of join operator to use between this condition
and the previous one.condition
- The condition to add to the statement.
void
- None.
void calcBlock()
void chains(Condition otherCondition, java.util.Hashtable conditionsLookup)
boolean compareWith(Condition otherCondTree, java.util.Map bindingAssociation)
public boolean equals(Condition theOtherCondition)
static java.lang.String formatDate(java.lang.Object value, java.lang.String returnType)
value
- The value to reformat.returnType
- The type of value to reformat. You can specify
"DATE" or "TIMESTAMP".
java.lang.String getAlternateSubQuery()
String
- The subquery for the condition expression.
ConditionDescriptor getConditionDescriptor()
ConditionDescriptor
- The condition descriptor.
java.lang.String getField()
String
- The name of the field to use.
java.util.List getJoinConditionList()
List
- A list of join operators.
Condition getLeftOperand()
java.lang.String getObjectName()
String
- The name of the field's object.
java.lang.String getOperator()
String
- The operator for the WHERE clause.
int getParamSize()
int getPrepareStatus()
java.lang.String getType()
String
- The type of database column used
in the WHERE clause.
java.lang.Object getValue()
Object
- The value for the WHERE clause.
java.lang.Object getValues()
Object
- An array of values for the WHERE clause.
public int hashCode()
public java.lang.String hashString()
boolean isBlock()
Boolean
- A Boolean indicator of whether the node is
a block. True indicates the node is a block; false indicates
the node is not a block.
boolean isInOperator()
Boolean
- An indicator of whether the operator in
this condition is IN. Boolean true indicates the operator is
IN; Boolean false indicates it is not.
boolean isLeaf()
Boolean
- A Boolean indicator of whether the node is
a leaf. True indicates the node is a leaf; false indicates
the node is not a leaf.
boolean isOldFormatConditionExpressionTree()
boolean isPrepare()
Boolean
- An indicator of whether the condition
will be prepared. Boolean true indicates the condition will be
prepared; Boolean false indicates it will not be prepared.
void parseTree()
void propagatePrepareStatus(boolean prepareStatus)
void setAlternateSubQuery(java.lang.String alternateSubQuery)
alternateSubQuery
- A subquery for the condition expression.
void
- None.
void setConditionDescriptor(ConditionDescriptor condDesc)
condDesc
- A Condition Object may represent a Condition Expression
And to Calculate a Condition Descriptor requires to
traverse to all the child Objects. A Condition Descriptor
for a Condition represents a Condition Expression.void setConditionsBlockList(java.util.List list)
This keeps conditions together if they belong to the same object, and helps generate optimized queries.
list
- A list of conditions.
void
- None.
void setConditionsLeafList(java.util.List list)
list
- A list of conditions.
void
- None.
void setPrepare(boolean prepare)
prepare
- A Boolean indicator of whether to prepare the statement
for the condition. Specify true to prepare the statement;
otherwise specify false.
void
- None.
public java.lang.String toString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Sun Microsystems, Inc.