Package org.apache.openjpa.kernel.exps
Class AbstractExpressionBuilder
java.lang.Object
org.apache.openjpa.kernel.exps.AbstractExpressionBuilder
- Direct Known Subclasses:
JPQLExpressionBuilder
Abstract base class to help build expressions. Provides
generic language-independent support for variable resolution,
path traversal, and error messages.
- Author:
- Marc Prud'hommeaux
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intprotected static final intprotected static final intprotected static final intprotected ExpressionFactoryprotected final Resolverstatic final Class<Collection> -
Constructor Summary
ConstructorsConstructorDescriptionAbstractExpressionBuilder(ExpressionFactory factory, Resolver resolver) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected ClassMetaDataaddAccessPath(ClassMetaData meta) Register the specified metadata as being in the query's access path.protected abstract voidaddSchemaToContext(String alias, ClassMetaData meta) Register the schema alias to the current JPQL query context.protected abstract voidaddVariableToContext(String id, Value var) Register the variable associated with the schema alias (id) to the current JPQL query context.protected voidValidate that all unbound variables are of a PC type.protected voidRecord that the given variable is bound.static voidconvertTypes(Value val1, Value val2) Perform conversions to make values compatible.static voidconvertTypesQuotedNumbers(Value val1, Value val2) Perform conversions to make values compatible.protected ValuecreateVariable(String id, boolean bind) protected abstract StringReturns the current string being parsed; used for error messages.protected ClassMetaData[]Return the recorded query access path.protected abstract ClassLoaderReturns the class loader that should be used for resolving class names (in addition to the resolver in the query).protected abstract Class<?>Returns the type of the named variable if it has been declared.protected abstract LocalizerUsed for obtaining theLocalizerto use for translating error messages.protected ClassMetaDatagetMetaData(Class<?> c, boolean required) Convenience method to get metadata for the given type.protected ClassMetaDatagetMetaData(Class<?> c, boolean required, ClassLoader loader) Convenience method to get metadata for the given type.protected abstract ValuegetVariable(String id) Returns the variable associated with the schema alias (id).protected ValuegetVariable(String id, boolean bind) Returns a value for the given id.protected booleanReturn true if the given variable has been bound.protected abstract booleanReturns whether the specified variable name has been explicitly declared.static booleanReturn true if given class can be used as a number.protected booleanisSeenVariable(String id) Return whether the given id has been used as a variable.protected OpenJPAExceptionparseException(int e, String token, Object[] args, Exception nest) Create a proper parse exception for the given reason.protected voidsetImplicitContainsTypes(Value val1, Value val2, int op) Set the implicit types of the given values based on the fact that the first is supposed to contain the second.protected static voidsetImplicitType(Value val, Class<?> expected) Set the implicit type of the given value to the given class.protected voidsetImplicitTypes(Value val1, Value val2, Class<?> expected) Set the implicit types of the given values based on the fact that they're used together, and based on the operator type.protected static voidsetImplicitTypes(Value val1, Value val2, Class<?> expected, Resolver resolver) protected ValuetraversePath(Path path, String field) Traverse the given field in the given path.protected ValuetraversePath(Path path, String field, boolean pcOnly, boolean allowNull) Traverse the given field in the given path.protected ObjecttraverseStaticField(Class<?> cls, String field) Return a constant containing the value of the given static field.protected ValuetraverseXPath(Path path, String field)
-
Field Details
-
EX_USER
protected static final int EX_USER- See Also:
-
EX_FATAL
protected static final int EX_FATAL- See Also:
-
EX_UNSUPPORTED
protected static final int EX_UNSUPPORTED- See Also:
-
TYPE_OBJECT
-
TYPE_STRING
-
TYPE_CHAR_OBJ
-
TYPE_NUMBER
-
TYPE_COLLECTION
-
TYPE_MAP
-
CONTAINS_TYPE_ELEMENT
public static final int CONTAINS_TYPE_ELEMENT- See Also:
-
CONTAINS_TYPE_KEY
public static final int CONTAINS_TYPE_KEY- See Also:
-
CONTAINS_TYPE_VALUE
public static final int CONTAINS_TYPE_VALUE- See Also:
-
resolver
-
factory
-
-
Constructor Details
-
AbstractExpressionBuilder
Constructor.- Parameters:
factory- the expression factory to useresolver- used to resolve variables, parameters, and class names used in the query
-
-
Method Details
-
getClassLoader
Returns the class loader that should be used for resolving class names (in addition to the resolver in the query). -
parseException
Create a proper parse exception for the given reason. -
addAccessPath
Register the specified metadata as being in the query's access path. -
getAccessPath
Return the recorded query access path. -
isBound
Return true if the given variable has been bound. -
bind
Record that the given variable is bound. -
getVariable
Returns a value for the given id. -
createVariable
-
assertUnboundVariablesValid
protected void assertUnboundVariablesValid()Validate that all unbound variables are of a PC type. If not, assume that the user actually made a typo that we took for an implicit unbound variable. -
isDeclaredVariable
Returns whether the specified variable name has been explicitly declared. Note all query languages necessarily support declaring variables.- Parameters:
id- the variable to check- Returns:
- true if the variabe has been explicitely declared
-
isSeenVariable
Return whether the given id has been used as a variable. -
getMetaData
Convenience method to get metadata for the given type. -
getMetaData
Convenience method to get metadata for the given type. -
traversePath
Traverse the given field in the given path. -
traverseXPath
-
traversePath
Traverse the given field in the given path. -
traverseStaticField
Return a constant containing the value of the given static field. -
getDeclaredVariableType
Returns the type of the named variable if it has been declared. -
setImplicitTypes
Set the implicit types of the given values based on the fact that they're used together, and based on the operator type. -
setImplicitTypes
-
convertTypes
Perform conversions to make values compatible. -
convertTypesQuotedNumbers
Perform conversions to make values compatible. -
isNumeric
Return true if given class can be used as a number. -
setImplicitContainsTypes
Set the implicit types of the given values based on the fact that the first is supposed to contain the second. -
setImplicitType
Set the implicit type of the given value to the given class. -
getLocalizer
Used for obtaining theLocalizerto use for translating error messages. -
currentQuery
Returns the current string being parsed; used for error messages. -
addSchemaToContext
Register the schema alias to the current JPQL query context. -
addVariableToContext
Register the variable associated with the schema alias (id) to the current JPQL query context. -
getVariable
Returns the variable associated with the schema alias (id).
-