Class IckleQueryOperators
- java.lang.Object
-
- org.keycloak.models.map.storage.hotRod.IckleQueryOperators
-
public class IckleQueryOperators extends Object
This class provides knowledge on how to build Ickle query where clauses for specifiedModelCriteriaBuilder.Operator
. For example, for operatorModelCriteriaBuilder.Operator.EQ
we concatenate left operand and right operand with equal sign:fieldName = :parameterName
however, for operatorModelCriteriaBuilder.Operator.EXISTS
we add following:fieldName IS NOT NULL AND fieldName IS NOT EMPTY"
. For right side operands we use named parameters to avoid injection attacks. Mapping between named parameter and corresponding value is then saved intoMap<String, Object>
that is passed to eachIckleQueryOperators.ExpressionCombinator
.
-
-
Constructor Summary
Constructors Constructor Description IckleQueryOperators()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
combineExpressions(ModelCriteriaBuilder.Operator op, String modelFieldName, Object[] values, Map<String,Object> parameters)
Provides a string containing where clause for given operator, field name and valuesstatic String
findAvailableNamedParam(Set<String> existingNames, String namePrefix)
MapsnamePrefix
to next available parameter name.
-
-
-
Field Detail
-
C
public static final String C
- See Also:
- Constant Field Values
-
-
Method Detail
-
findAvailableNamedParam
public static String findAvailableNamedParam(Set<String> existingNames, String namePrefix)
MapsnamePrefix
to next available parameter name. For example, ifnamePrefix == "id"
andexistingNames
set already containsid0
andid1
it returnsid2
. Any character that is not an alphanumeric will be stripped, so that it works for prefixes like"attributes.name"
as well. This method is used for computing available names for name query parameters. Instead of creating generic named parameters that would be hard to debug and read by humans, it creates readable named parameters from the prefix.- Parameters:
existingNames
- set of parameter names that are already used in this Ickle querynamePrefix
- name of the parameter- Returns:
- next available parameter name
-
combineExpressions
public static String combineExpressions(ModelCriteriaBuilder.Operator op, String modelFieldName, Object[] values, Map<String,Object> parameters)
Provides a string containing where clause for given operator, field name and values- Parameters:
op
- operatormodelFieldName
- field namevalues
- valuesparameters
- mapping between named parameters and their values- Returns:
- where clause
-
-