Class AbstractExpressionBuilder

java.lang.Object
org.apache.openjpa.kernel.exps.AbstractExpressionBuilder
Direct Known Subclasses:
JPQLExpressionBuilder

public abstract class AbstractExpressionBuilder extends Object
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 Details

  • Constructor Details

    • AbstractExpressionBuilder

      public AbstractExpressionBuilder(ExpressionFactory factory, Resolver resolver)
      Constructor.
      Parameters:
      factory - the expression factory to use
      resolver - used to resolve variables, parameters, and class names used in the query
  • Method Details

    • getClassLoader

      protected abstract ClassLoader getClassLoader()
      Returns the class loader that should be used for resolving class names (in addition to the resolver in the query).
    • parseException

      protected OpenJPAException parseException(int e, String token, Object[] args, Exception nest)
      Create a proper parse exception for the given reason.
    • addAccessPath

      protected ClassMetaData addAccessPath(ClassMetaData meta)
      Register the specified metadata as being in the query's access path.
    • getAccessPath

      protected ClassMetaData[] getAccessPath()
      Return the recorded query access path.
    • isBound

      protected boolean isBound(Value var)
      Return true if the given variable has been bound.
    • bind

      protected void bind(Value var)
      Record that the given variable is bound.
    • getVariable

      protected Value getVariable(String id, boolean bind)
      Returns a value for the given id.
    • createVariable

      protected Value createVariable(String id, boolean bind)
    • 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

      protected abstract boolean isDeclaredVariable(String id)
      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

      protected boolean isSeenVariable(String id)
      Return whether the given id has been used as a variable.
    • getMetaData

      protected ClassMetaData getMetaData(Class<?> c, boolean required)
      Convenience method to get metadata for the given type.
    • getMetaData

      protected ClassMetaData getMetaData(Class<?> c, boolean required, ClassLoader loader)
      Convenience method to get metadata for the given type.
    • traversePath

      protected Value traversePath(Path path, String field)
      Traverse the given field in the given path.
    • traverseXPath

      protected Value traverseXPath(Path path, String field)
    • traversePath

      protected Value traversePath(Path path, String field, boolean pcOnly, boolean allowNull)
      Traverse the given field in the given path.
    • traverseStaticField

      protected Object traverseStaticField(Class<?> cls, String field)
      Return a constant containing the value of the given static field.
    • getDeclaredVariableType

      protected abstract Class<?> getDeclaredVariableType(String name)
      Returns the type of the named variable if it has been declared.
    • setImplicitTypes

      protected void setImplicitTypes(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.
    • setImplicitTypes

      protected static void setImplicitTypes(Value val1, Value val2, Class<?> expected, Resolver resolver)
    • convertTypes

      public static void convertTypes(Value val1, Value val2)
      Perform conversions to make values compatible.
    • convertTypesQuotedNumbers

      public static void convertTypesQuotedNumbers(Value val1, Value val2)
      Perform conversions to make values compatible.
    • isNumeric

      public static boolean isNumeric(Class<?> type)
      Return true if given class can be used as a number.
    • setImplicitContainsTypes

      protected void setImplicitContainsTypes(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.
    • setImplicitType

      protected static void setImplicitType(Value val, Class<?> expected)
      Set the implicit type of the given value to the given class.
    • getLocalizer

      protected abstract Localizer getLocalizer()
      Used for obtaining the Localizer to use for translating error messages.
    • currentQuery

      protected abstract String currentQuery()
      Returns the current string being parsed; used for error messages.
    • addSchemaToContext

      protected abstract void addSchemaToContext(String alias, ClassMetaData meta)
      Register the schema alias to the current JPQL query context.
    • addVariableToContext

      protected abstract void addVariableToContext(String id, Value var)
      Register the variable associated with the schema alias (id) to the current JPQL query context.
    • getVariable

      protected abstract Value getVariable(String id)
      Returns the variable associated with the schema alias (id).