Class ParseTreeContext
- java.lang.Object
-
- org.eclipse.persistence.internal.jpa.parsing.ParseTreeContext
-
public class ParseTreeContext extends Object
INTERNALPurpose: 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, String queryInfo)
INTERNAL Return a new initialized ParseTreeContext
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addParameter(String parameterName)
INTERNAL Add a parameter.Class
classForSchemaName(String schemaName, GenerationContext context)
INTERNAL Answer the class associated with the provided schema namevoid
defineParameterType(String parameterName, Object parameterType, int line, int column)
INTERNAL Defines the type of the parameter with the specified name.void
enterScope()
INTERNAL Enters a new scope.String
getBaseVariable()
List
getFetchJoins(String variableName)
Returns a list of FETCH JOIN nodes for the specified attached to the specified variable.NodeFactory
getNodeFactory()
Set
getOuterScopeVariables()
INTERNAL Returns the set of outer scope variables.List
getParameterNames()
INTERNAL Return the parameter names.Object
getParameterType(String parameter)
INTERNAL Return the type of the specified parameter.String
getQueryInfo()
TypeHelper
getTypeHelper()
INTERNAL Returns the type helper stored in this context.Set
getUnusedVariables()
Returns s set of variables that are declared in the current scope, but not used in the query.String
getVariableNameForClass(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(String variable)
INTERNAL Returns true if the specified string denotes a variable declared in an outer scope.boolean
isRangeVariable(String variable)
boolean
isVariable(String variable)
INTERNAL Returns true if the specified string denotes a variable.void
leaveScope()
INTERNAL Leaves the current scope.Node
pathForVariable(String variable)
INTERNAL Returns the path if the specified string denotes a join or collection member variable.void
registerFetchJoin(String variableName, Node node)
Associate the given variableName with the given node representing a JOIN FETCH node.void
registerJoinVariable(String variable, Node path, int line, int column)
INTERNAL Associate the given path with the given variable.void
registerOuterScopeVariable(String variable)
INTERNAL Adds the specified variable to the set of outer scope variables.void
registerSchema(String variable, 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(Set variables)
INTERNAL Resets the set of outer scope variables.String
schemaForVariable(String variable)
INTERNAL Returns the abstract schema name if the specified string denotes a range variable.void
setBaseVariable(String variable)
void
setScopeOfVariable(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(String variable)
INTERNALvoid
usedVariable(String variable)
Mark the specified variable as used if it is declared in the current scope.
-
-
-
Constructor Detail
-
ParseTreeContext
public ParseTreeContext(NodeFactory nodeFactory, String queryInfo)
INTERNAL Return a new initialized ParseTreeContext
-
-
Method Detail
-
registerSchema
public void registerSchema(String variable, String schema, int line, int column)
INTERNAL Associate the given schema with the given variable.
-
registerJoinVariable
public void registerJoinVariable(String variable, Node path, int line, int column)
INTERNAL Associate the given path with the given variable.
-
unregisterVariable
public void unregisterVariable(String variable)
INTERNAL
-
isVariable
public boolean isVariable(String variable)
INTERNAL Returns true if the specified string denotes a variable.
-
isRangeVariable
public boolean isRangeVariable(String variable)
-
schemaForVariable
public String schemaForVariable(String variable)
INTERNAL Returns the abstract schema name if the specified string denotes a range variable.
-
classForSchemaName
public Class classForSchemaName(String schemaName, GenerationContext context)
INTERNAL Answer the class associated with the provided schema name
-
getVariableNameForClass
public String getVariableNameForClass(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(String variable)
INTERNAL Returns the path if the specified string denotes a join or collection member variable.
-
getBaseVariable
public String getBaseVariable()
-
setBaseVariable
public void setBaseVariable(String variable)
-
getNodeFactory
public NodeFactory getNodeFactory()
-
getQueryInfo
public String getQueryInfo()
-
isDeclaredInOuterScope
public boolean isDeclaredInOuterScope(String variable)
INTERNAL Returns true if the specified string denotes a variable declared in an outer scope.
-
setScopeOfVariable
public void setScopeOfVariable(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(String variable)
INTERNAL Adds the specified variable to the set of outer scope variables.
-
getOuterScopeVariables
public 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(Set variables)
INTERNAL Resets the set of outer scope variables.
-
registerFetchJoin
public void registerFetchJoin(String variableName, Node node)
Associate the given variableName with the given node representing a JOIN FETCH node.
-
getFetchJoins
public List getFetchJoins(String variableName)
Returns a list of FETCH JOIN nodes for the specified attached to the specified variable.
-
usedVariable
public void usedVariable(String variable)
Mark the specified variable as used if it is declared in the current scope.
-
getUnusedVariables
public 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(String parameterName)
INTERNAL Add a parameter.
-
defineParameterType
public void defineParameterType(String parameterName, 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 Object getParameterType(String parameter)
INTERNAL Return the type of the specified parameter.
-
getParameterNames
public List getParameterNames()
INTERNAL Return the parameter names.
-
-