Dealing with Conditions¶
Conditions passed to a Custom wrapper as arguments for its run, delete
and update methods (see sections Extending AbstractCustomWrapper and
Overriding AbstractCustomWrapper) come encapsulated in instances of
CustomWrapperConditionHolder. The objects of this class contain two
versions of the conditions passed to the Custom wrapper:
A simplified version, available by calling the
getConditionMapmethod. This version consists on an association betweenCustomWrapperFieldExpressionsandObjects. For example, if we have a condition map like{ FIELD1 - 100; FIELD2 - 'foo' }, it means that the condition passed to the CUSTOM wrapper isFIELD1 = 100 AND FIELD2 = 'foo'. For a condition to be available as a map, it must match the patternFIELD_1 = value [AND FIELD_N = value]*, in other case thegetConditionMapmethod will return null. Conversion to map can be forced by calling thegetConditionMap(boolean force)method, passing true as the value for force. Take into account that in this case the returned map may not be equivalent to the original condition.A
CustomWrapperConditioninstance. This version is available by calling thegetComplexConditionmethod.
CustomWrapperCondition is the superclass of all the types of conditions that can be supported by a Custom wrapper:
CustomWrapperSimpleConditionrepresents a simple condition. It holds the left expression (aCustomWrapperExpressionobject), an operator and the right expression (an array ofCustomWrapperExpressionobjects). The right expression is stored in array, which usually contains only one expression.CustomWrapperAndConditionrepresents a series of conditions joined by the AND operator. It holds a list ofCustomWrapperConditionobjects.CustomWrapperOrConditionrepresents a series of conditions joined by the OR operator. It holds a list ofCustomWrapperConditionobjects.CustomWrapperNotConditionrepresents a negated condition. It holds aCustomWrapperCondition.
CustomWrapperExpression is the superclass of all the types of expressions supported by a Custom wrapper:
CustomWrapperFieldExpression. This is the most common type of expression in a condition’s left side. See section Overriding AbstractCustomWrapper for details.CustomWrapperSimpleExpression. This kind of expression has a type (one of the types defined injava.sql.Types) and a value.CustomWrapperFunctionExpression. Represents a function with parameters. This type of expression has a name, an optional modifier (ALLorDISTINCT), a list of parameters (instances ofCustomWrapperFunctionParameter) and the property of being an aggregation function or not. ACustomWrapperFunctionParametercontains a list ofCustomWrapperExpressions.CustomWrapperConditionExpression. Represents a condition parameter in aCASEfunction. Contains aCustomWrapperCondition.CustomWrapperArrayExpression. Contains a list ofCustomWrapperExpressions, all of the same kind.CustomWrapperRegisterExpression. Contains a list ofCustomWrapperExpressionsof any kind.
