Class ParseTreeContext


  • public class ParseTreeContext
    extends java.lang.Object
    INTERNAL

    Purpose: The ParseTreeContext holds and manages context information for the parse tree for validation.

    Responsibilities:

    • Associate schema names with variables
    • Associate identifier with nodes
    • Answer an alias for a variable name
    • Answer a class for a variable name
    • Answer a class loader
    • Answer true if there is a class for a variable name
    • Answer a node for a given identifier
    • Print the context on a string
    Since:
    TopLink 4.0
    Author:
    Jon Driscoll and Joel Lucuik
    See Also:
    ParseTree
    • Constructor Summary

      Constructors 
      Constructor Description
      ParseTreeContext​(NodeFactory nodeFactory, java.lang.String queryInfo)
      INTERNAL Return a new initialized ParseTreeContext
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addParameter​(java.lang.String parameterName)
      INTERNAL Add a parameter.
      java.lang.Class classForSchemaName​(java.lang.String schemaName, GenerationContext context)
      INTERNAL Answer the class associated with the provided schema name
      void defineParameterType​(java.lang.String parameterName, java.lang.Object parameterType, int line, int column)
      INTERNAL Defines the type of the parameter with the specified name.
      void enterScope()
      INTERNAL Enters a new scope.
      java.lang.String getBaseVariable()  
      java.util.List getFetchJoins​(java.lang.String variableName)
      Returns a list of FETCH JOIN nodes for the specified attached to the specified variable.
      NodeFactory getNodeFactory()  
      java.util.Set getOuterScopeVariables()
      INTERNAL Returns the set of outer scope variables.
      java.util.List getParameterNames()
      INTERNAL Return the parameter names.
      java.lang.Object getParameterType​(java.lang.String parameter)
      INTERNAL Return the type of the specified parameter.
      java.lang.String getQueryInfo()  
      TypeHelper getTypeHelper()
      INTERNAL Returns the type helper stored in this context.
      java.util.Set getUnusedVariables()
      Returns s set of variables that are declared in the current scope, but not used in the query.
      java.lang.String getVariableNameForClass​(java.lang.Class theClass, GenerationContext context)
      INTERNAL getVariableNameForClass(): Answer the name mapped to the specified class.
      boolean hasMoreThanOneAliasInFrom()  
      boolean hasMoreThanOneVariablePerType()  
      boolean hasParameters()
      INTERNAL Returns true if the query has at least one parameter.
      boolean isDeclaredInOuterScope​(java.lang.String variable)
      INTERNAL Returns true if the specified string denotes a variable declared in an outer scope.
      boolean isRangeVariable​(java.lang.String variable)  
      boolean isVariable​(java.lang.String variable)
      INTERNAL Returns true if the specified string denotes a variable.
      void leaveScope()
      INTERNAL Leaves the current scope.
      Node pathForVariable​(java.lang.String variable)
      INTERNAL Returns the path if the specified string denotes a join or collection member variable.
      void registerFetchJoin​(java.lang.String variableName, Node node)
      Associate the given variableName with the given node representing a JOIN FETCH node.
      void registerJoinVariable​(java.lang.String variable, Node path, int line, int column)
      INTERNAL Associate the given path with the given variable.
      void registerOuterScopeVariable​(java.lang.String variable)
      INTERNAL Adds the specified variable to the set of outer scope variables.
      void registerSchema​(java.lang.String variable, java.lang.String schema, int line, int column)
      INTERNAL Associate the given schema with the given variable.
      void resetOuterScopeVariables()
      INTERNAL Resets the set of outer scope variables.
      void resetOuterScopeVariables​(java.util.Set variables)
      INTERNAL Resets the set of outer scope variables.
      java.lang.String schemaForVariable​(java.lang.String variable)
      INTERNAL Returns the abstract schema name if the specified string denotes a range variable.
      void setBaseVariable​(java.lang.String variable)  
      void setScopeOfVariable​(java.lang.String variable)
      INTERNAL Sets the scope of the specified variable to the current scope.
      void setTypeHelper​(TypeHelper typeHelper)
      INTERNAL Stores the specified type helper in this context.
      void unregisterVariable​(java.lang.String variable)
      INTERNAL
      void usedVariable​(java.lang.String variable)
      Mark the specified variable as used if it is declared in the current scope.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ParseTreeContext

        public ParseTreeContext​(NodeFactory nodeFactory,
                                java.lang.String queryInfo)
        INTERNAL Return a new initialized ParseTreeContext
    • Method Detail

      • registerSchema

        public void registerSchema​(java.lang.String variable,
                                   java.lang.String schema,
                                   int line,
                                   int column)
        INTERNAL Associate the given schema with the given variable.
      • registerJoinVariable

        public void registerJoinVariable​(java.lang.String variable,
                                         Node path,
                                         int line,
                                         int column)
        INTERNAL Associate the given path with the given variable.
      • unregisterVariable

        public void unregisterVariable​(java.lang.String variable)
        INTERNAL
      • isVariable

        public boolean isVariable​(java.lang.String variable)
        INTERNAL Returns true if the specified string denotes a variable.
      • isRangeVariable

        public boolean isRangeVariable​(java.lang.String variable)
      • schemaForVariable

        public java.lang.String schemaForVariable​(java.lang.String variable)
        INTERNAL Returns the abstract schema name if the specified string denotes a range variable.
      • classForSchemaName

        public java.lang.Class classForSchemaName​(java.lang.String schemaName,
                                                  GenerationContext context)
        INTERNAL Answer the class associated with the provided schema name
      • getVariableNameForClass

        public java.lang.String getVariableNameForClass​(java.lang.Class theClass,
                                                        GenerationContext context)
        INTERNAL getVariableNameForClass(): Answer the name mapped to the specified class. Answer null if none found. SELECT OBJECT (emp) FROM Employee emp getVariableNameForClass(Employee.class) => "emp"
      • pathForVariable

        public Node pathForVariable​(java.lang.String variable)
        INTERNAL Returns the path if the specified string denotes a join or collection member variable.
      • getBaseVariable

        public java.lang.String getBaseVariable()
      • setBaseVariable

        public void setBaseVariable​(java.lang.String variable)
      • getQueryInfo

        public java.lang.String getQueryInfo()
      • isDeclaredInOuterScope

        public boolean isDeclaredInOuterScope​(java.lang.String variable)
        INTERNAL Returns true if the specified string denotes a variable declared in an outer scope.
      • setScopeOfVariable

        public void setScopeOfVariable​(java.lang.String variable)
        INTERNAL Sets the scope of the specified variable to the current scope.
      • enterScope

        public void enterScope()
        INTERNAL Enters a new scope. This initializes the set of outer scope variables.
      • leaveScope

        public void leaveScope()
        INTERNAL Leaves the current scope.
      • registerOuterScopeVariable

        public void registerOuterScopeVariable​(java.lang.String variable)
        INTERNAL Adds the specified variable to the set of outer scope variables.
      • getOuterScopeVariables

        public java.util.Set getOuterScopeVariables()
        INTERNAL Returns the set of outer scope variables.
      • resetOuterScopeVariables

        public void resetOuterScopeVariables()
        INTERNAL Resets the set of outer scope variables.
      • resetOuterScopeVariables

        public void resetOuterScopeVariables​(java.util.Set variables)
        INTERNAL Resets the set of outer scope variables.
      • registerFetchJoin

        public void registerFetchJoin​(java.lang.String variableName,
                                      Node node)
        Associate the given variableName with the given node representing a JOIN FETCH node.
      • getFetchJoins

        public java.util.List getFetchJoins​(java.lang.String variableName)
        Returns a list of FETCH JOIN nodes for the specified attached to the specified variable.
      • usedVariable

        public void usedVariable​(java.lang.String variable)
        Mark the specified variable as used if it is declared in the current scope.
      • getUnusedVariables

        public java.util.Set getUnusedVariables()
        Returns s set of variables that are declared in the current scope, but not used in the query.
      • hasMoreThanOneVariablePerType

        public boolean hasMoreThanOneVariablePerType()
      • hasMoreThanOneAliasInFrom

        public boolean hasMoreThanOneAliasInFrom()
      • getTypeHelper

        public TypeHelper getTypeHelper()
        INTERNAL Returns the type helper stored in this context.
      • setTypeHelper

        public void setTypeHelper​(TypeHelper typeHelper)
        INTERNAL Stores the specified type helper in this context.
      • addParameter

        public void addParameter​(java.lang.String parameterName)
        INTERNAL Add a parameter.
      • defineParameterType

        public void defineParameterType​(java.lang.String parameterName,
                                        java.lang.Object parameterType,
                                        int line,
                                        int column)
        INTERNAL Defines the type of the parameter with the specified name.
      • hasParameters

        public boolean hasParameters()
        INTERNAL Returns true if the query has at least one parameter.
      • getParameterType

        public java.lang.Object getParameterType​(java.lang.String parameter)
        INTERNAL Return the type of the specified parameter.
      • getParameterNames

        public java.util.List getParameterNames()
        INTERNAL Return the parameter names.