|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.datanucleus.query.QueryUtils
public class QueryUtils
Utilities for use in queries.
| Field Summary | |
|---|---|
protected static java.lang.Class[] |
classArrayObjectObject
Convenience Class[] for parameter types in getMethod call. |
protected static Localiser |
LOCALISER
Localiser for messages. |
| Constructor Summary | |
|---|---|
QueryUtils()
|
|
| Method Summary | |
|---|---|
static boolean |
compareExpressionValues(java.lang.Object left,
java.lang.Object right,
Expression.Operator op)
Convenience method to compare two expression values against the specified operator. |
static java.lang.Object |
createResultObjectUsingArgumentedConstructor(java.lang.Class resultClass,
java.lang.Object[] fieldValues,
java.lang.Class[] fieldTypes)
Convenience method to create an instance of the result class with the provided field values, using a constructor taking the arguments. |
static java.lang.Object |
createResultObjectUsingDefaultConstructorAndSetters(java.lang.Class resultClass,
java.lang.String[] resultFieldNames,
java.lang.reflect.Field[] resultFields,
java.lang.Object[] fieldValues)
Convenience method to create an instance of the result class with the provided field values, using the default constructor and setting the fields using either public fields, or setters, or a put method. |
static java.lang.Object |
createResultObjectUsingDefaultConstructorAndSetters(java.lang.Class resultClass,
java.lang.String[] resultFieldNames,
java.util.Map resultClassFieldNames,
java.lang.Object[] fieldValues)
Convenience method to create an instance of the result class with the provided field values, using the default constructor and setting the fields using either public fields, or setters, or a put method. |
static boolean |
expressionHasNotOperator(Expression expr)
Convenience method to return if there is a NOT operator in the expression. |
static boolean |
expressionHasOrOperator(Expression expr)
Convenience method to return if there is an OR operator in the expression. |
static java.lang.String[] |
getExpressionsFromString(java.lang.String str)
Convenience method to split an expression string into its constituent parts where separated by commas. |
static java.lang.String |
getKeyForQueryResultsCache(Query query,
java.util.Map params)
Convenience method to generate the "key" for storing the query results of a query with parameters. |
static ParameterExpression |
getParameterExpressionForPosition(Expression rootExpr,
int pos)
Convenience method to return the ParameterExpression for the specified position if found in the expression tree starting at |
static java.lang.reflect.Method |
getPublicPutMethodForResultClass(java.lang.Class resultClass)
Convenience method to return the put(Object, Object method for the result class. |
static java.lang.reflect.Method |
getPublicSetMethodForFieldOfResultClass(java.lang.Class resultClass,
java.lang.String fieldName,
java.lang.Class fieldType)
Convenience method to return the setXXX method for a field of the result class. |
static java.lang.String |
getStringValue(java.lang.Object obj)
Convenience method to get the String value for an Object. |
static java.lang.String |
getStringValueForExpression(Expression expr,
java.util.Map parameters)
Convenience method to get the String value for an Expression. |
static java.lang.Object |
getValueForParameterExpression(java.util.Map parameterValues,
ParameterExpression paramExpr)
Convenience method to get the value for a ParameterExpression. |
static boolean |
queryParameterTypesAreCompatible(java.lang.Class cls1,
java.lang.Class cls2)
|
static boolean |
queryReturnsSingleRow(Query query)
Convenience method to return whether the query should return a single row. |
static boolean |
resultClassIsSimple(java.lang.String className)
Utility to return if the passed result class is a simple type with a single value. |
static boolean |
resultClassIsUserType(java.lang.String className)
Utility to return if the passed result class is a user-type, and so requires fields matching up. |
static boolean |
resultHasOnlyAggregates(java.lang.String result)
Convenience method to return if the "result" clause from a java string-based query language includes only aggregates. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final Localiser LOCALISER
protected static java.lang.Class[] classArrayObjectObject
| Constructor Detail |
|---|
public QueryUtils()
| Method Detail |
|---|
public static boolean resultClassIsUserType(java.lang.String className)
className - the class name looked for
public static boolean resultClassIsSimple(java.lang.String className)
className - the class name looked for
public static boolean resultHasOnlyAggregates(java.lang.String result)
result - The result required
public static boolean queryReturnsSingleRow(Query query)
public static java.lang.Object createResultObjectUsingArgumentedConstructor(java.lang.Class resultClass,
java.lang.Object[] fieldValues,
java.lang.Class[] fieldTypes)
resultClass - The class of results that need creatingfieldValues - The field valuesfieldTypes - The field types (optional). If specified needs same number as fieldValues
public static java.lang.Object createResultObjectUsingDefaultConstructorAndSetters(java.lang.Class resultClass,
java.lang.String[] resultFieldNames,
java.util.Map resultClassFieldNames,
java.lang.Object[] fieldValues)
resultClass - Result class that we need to create an object ofresultFieldNames - Names of the fields in the resultsresultClassFieldNames - Map of the result class fields, keyed by the field namefieldValues - The field values
public static java.lang.Object createResultObjectUsingDefaultConstructorAndSetters(java.lang.Class resultClass,
java.lang.String[] resultFieldNames,
java.lang.reflect.Field[] resultFields,
java.lang.Object[] fieldValues)
resultClass - Result class that we need to create an object ofresultFieldNames - Names of the fields in the resultsresultFields - (java.lang.reflect.)Field objects for the fields in the resultsfieldValues - The field values
public static java.lang.reflect.Method getPublicSetMethodForFieldOfResultClass(java.lang.Class resultClass,
java.lang.String fieldName,
java.lang.Class fieldType)
resultClass - The result classfieldName - Name of the fieldfieldType - The type of the field being set
public static java.lang.reflect.Method getPublicPutMethodForResultClass(java.lang.Class resultClass)
resultClass - The result class
public static java.lang.String[] getExpressionsFromString(java.lang.String str)
str - The expression string
public static java.lang.Object getValueForParameterExpression(java.util.Map parameterValues,
ParameterExpression paramExpr)
parameterValues - Input parameter values keyed by the parameter name/positionparamExpr - Expression
public static java.lang.String getStringValue(java.lang.Object obj)
obj - Object
public static java.lang.String getStringValueForExpression(Expression expr,
java.util.Map parameters)
expr - Expressionparameters - Input parameters
public static boolean compareExpressionValues(java.lang.Object left,
java.lang.Object right,
Expression.Operator op)
left - Left objectright - Right objectop - Operator
NucleusException - if the comparison is impossiblepublic static boolean expressionHasOrOperator(Expression expr)
expr - The expression
public static boolean expressionHasNotOperator(Expression expr)
expr - The expression
public static ParameterExpression getParameterExpressionForPosition(Expression rootExpr,
int pos)
rootExpr
rootExpr - The expressionpos - The position
public static boolean queryParameterTypesAreCompatible(java.lang.Class cls1,
java.lang.Class cls2)
public static java.lang.String getKeyForQueryResultsCache(Query query,
java.util.Map params)
JDOQL:SELECT FROM myClass WHERE myFilter:123456where "123456" is the hashCode of the parameters for the query
query - The queryparams - The params
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||