Top Description Fields Constructors Methods
org.eclipse.persistence.internal.jpa.parsing

public Class ParseTree

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.persistence.internal.jpa.parsing.JPQLParseTree
Imports
org.eclipse.persistence.expressions.Expression, .ExpressionBuilder, org.eclipse.persistence.internal.localization.ToStringLocalization, org.eclipse.persistence.internal.sessions.AbstractSession, org.eclipse.persistence.queries.DatabaseQuery, .DeleteAllQuery, .ModifyAllQuery, .ObjectLevelReadQuery, .UpdateAllQuery, java.util.Iterator, .Set

INTERNAL

Purpose: A ParseTree contains Node(s). This contains a root Node and provides traversal utilities.

Responsibilities:

Author
Jon Driscoll and Joel Lucuik
Since
TopLink 4.0

Field Summary

Modifier and TypeField and Description
private ClassLoader
private ParseTreeContext
private short
private FromNode
private GroupByNode
private HavingNode
private OrderByNode
private QueryNode
private SetNode
private Set<String>
private boolean
private WhereNode

Constructor Summary

AccessConstructor and Description
public
ParseTree()

Return a new ParseTree.

Method Summary

Modifier and TypeMethod and Description
public void
addGroupingToQuery(ObjectLevelReadQuery theQuery, GenerationContext generationContext)

INTERNAL Add the grouping to the passed query

public void
addHavingToQuery(ObjectLevelReadQuery theQuery, GenerationContext generationContext)

INTERNAL Add the having to the passed query

public void
public void
addOrderingToQuery(ObjectLevelReadQuery theQuery, GenerationContext generationContext)

INTERNAL Add the ordering to the passed query

public void
addParametersToQuery(DatabaseQuery query)

INTERNAL Add parameters to the query

public void
addUpdatesToQuery(UpdateAllQuery theQuery, GenerationContext generationContext)

INTERNAL Add the updates to the passed query

public void
adjustReferenceClassForQuery(DatabaseQuery theQuery, GenerationContext generationContext)

INTERNAL Adjust the reference class of the passed query if necessary Need to test this for Employee, employee.getAddress(), report query

public void
applyQueryNodeToQuery(DatabaseQuery theQuery, GenerationContext generationContext)

INTERNAL Apply the select or update to the passed query.

public GenerationContext
buildContext(DatabaseQuery query, AbstractSession sessionForContext)

INTERNAL Build the context to be used when generating the expression from the parse tree

public GenerationContext
buildContextForReadQuery(AbstractSession sessionForContext)

INTERNAL Build the context to be used when generating the expression from the parse tree

public DatabaseQuery
createDatabaseQuery()

INTERNAL Returns a DatabaseQuery instance for this ParseTree.

public Expression
generateExpression(DatabaseQuery readQuery, GenerationContext generationContext)

INTERNAL Build a context for the expression generation

private Class<?>
public ClassLoader

Returns:

java.lang.ClassLoader
getClassLoader
()

INTERNAL Return a class loader

public ParseTreeContext
getContext()

Return the context for this parse tree

public short
getDistinctState()

INTERNAL Return the DISTINCT state for the tree

public FromNode
getFromNode()

INTERNAL Return the FROM Node

public GroupByNode
getGroupByNode()

INTERNAL Return the GroupByNode

public HavingNode
getHavingNode()

INTERNAL Return the HavingNode

public OrderByNode
getOrderByNode()

INTERNAL Return the OrderByNode

public QueryNode
getQueryNode()

INTERNAL Return the root node for the tree

public Class<?>
getReferenceClass(DatabaseQuery query, GenerationContext generationContext)

getReferenceClass(): Answer the class which will be the reference class for the query.

public SetNode
getSetNode()

INTERNAL Return the set node for the tree

public WhereNode
getWhereNode()

INTERNAL Return the Where node

public boolean
hasGroupBy()

INTERNAL Does this EJBQL have a Grouping Clause

public boolean
hasHaving()

INTERNAL Does this EJBQL have a Having Clause

public boolean
hasOrderBy()

INTERNAL Does this EJBQL have an Ordering Clause

public void
initBaseExpression(ObjectLevelReadQuery theQuery, GenerationContext generationContext)

INTERNAL Initialize the base expression in the generation context.

public void
initBaseExpression(ModifyAllQuery theQuery, GenerationContext generationContext)

INTERNAL Initialize the base expression in the generation context.

protected void
qualifyAttributeAccess(ParseTreeContext context)

INTERNAL This method handles any unqualified field access in bulk UPDATE and DELETE statements.

public void
setClassLoader(ClassLoader loader)

INTERNAL: Set the class loader for this parse tree

public void
setContext(ParseTreeContext newContext)

INTERNAL Set the context for this parse tree

public void
setDistinctState(short newDistinctState)

INTERNAL Set the DISTINCT state for the tree

public void
setFromNode(FromNode fromNode)

INTERNAL Set the FROM node for the query

public void
setGroupByNode(GroupByNode newGroupByNode)

INTERNAL Set the Group by node

public void
setHavingNode(HavingNode newHavingNode)

INTERNAL Set the Having node

public void
setOrderByNode(OrderByNode newOrderByNode)

INTERNAL Set the Order by node

public void
setQueryNode(QueryNode newQueryNode)

INTERNAL Set the Select node

public void
public void
setSetNode(SetNode newSetNode)

INTERNAL Set the Where node

public void
setWhereNode(WhereNode newWhereNode)

INTERNAL Set the Where node

public String
toString()

Overrides java.lang.Object.toString.

INTERNAL Print the contents of the parse tree on a string
public boolean
usesDistinct()

INTERNAL Answer true if DISTINCT has been chosen.

protected void
validate(AbstractSession session, ClassLoader classLoader)

INTERNAL Validate the parse tree.

public void
validate(TypeHelper typeHelper)

INTERNAL Validate the parse tree.

public void
validate(ParseTreeContext context)

INTERNAL Validate the parse tree.

public void
verifySelect(DatabaseQuery theQuery, GenerationContext generationContext)

INTERNAL Verify that the alias in the SELECT is valid.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

classLoaderback to summary
private ClassLoader classLoader
contextback to summary
private ParseTreeContext context
distinctStateback to summary
private short distinctState
fromNodeback to summary
private FromNode fromNode
groupByNodeback to summary
private GroupByNode groupByNode
havingNodeback to summary
private HavingNode havingNode
orderByNodeback to summary
private OrderByNode orderByNode
queryNodeback to summary
private QueryNode queryNode
setNodeback to summary
private SetNode setNode
unusedVariablesback to summary
private Set<String> unusedVariables
validatedback to summary
private boolean validated
whereNodeback to summary
private WhereNode whereNode

Constructor Detail

ParseTreeback to summary
public ParseTree()

Return a new ParseTree.

Method Detail

addGroupingToQueryback to summary
public void addGroupingToQuery(ObjectLevelReadQuery theQuery, GenerationContext generationContext)

INTERNAL Add the grouping to the passed query

addHavingToQueryback to summary
public void addHavingToQuery(ObjectLevelReadQuery theQuery, GenerationContext generationContext)

INTERNAL Add the having to the passed query

addNonFetchJoinAttributesback to summary
public void addNonFetchJoinAttributes(ObjectLevelReadQuery theQuery, GenerationContext generationContext)

INTERNAL

addOrderingToQueryback to summary
public void addOrderingToQuery(ObjectLevelReadQuery theQuery, GenerationContext generationContext)

INTERNAL Add the ordering to the passed query

addParametersToQueryback to summary
public void addParametersToQuery(DatabaseQuery query)

INTERNAL Add parameters to the query

addUpdatesToQueryback to summary
public void addUpdatesToQuery(UpdateAllQuery theQuery, GenerationContext generationContext)

INTERNAL Add the updates to the passed query

adjustReferenceClassForQueryback to summary
public void adjustReferenceClassForQuery(DatabaseQuery theQuery, GenerationContext generationContext)

INTERNAL Adjust the reference class of the passed query if necessary Need to test this for Employee, employee.getAddress(), report query

applyQueryNodeToQueryback to summary
public void applyQueryNodeToQuery(DatabaseQuery theQuery, GenerationContext generationContext)

INTERNAL Apply the select or update to the passed query. If there is a single attribute being selected, add it to the query result set If an aggregate is being used, add it to the query result set

buildContextback to summary
public GenerationContext buildContext(DatabaseQuery query, AbstractSession sessionForContext)

INTERNAL Build the context to be used when generating the expression from the parse tree

buildContextForReadQueryback to summary
public GenerationContext buildContextForReadQuery(AbstractSession sessionForContext)

INTERNAL Build the context to be used when generating the expression from the parse tree

createDatabaseQueryback to summary
public DatabaseQuery createDatabaseQuery()

INTERNAL Returns a DatabaseQuery instance for this ParseTree.

generateExpressionback to summary
public Expression generateExpression(DatabaseQuery readQuery, GenerationContext generationContext)

INTERNAL Build a context for the expression generation

getBaseExpressionClassback to summary
private Class<?> getBaseExpressionClass(Node node, GenerationContext generationContext)
getClassLoaderback to summary
public ClassLoader getClassLoader()

INTERNAL Return a class loader

Returns:ClassLoader

java.lang.ClassLoader

getContextback to summary
public ParseTreeContext getContext()

Return the context for this parse tree

getDistinctStateback to summary
public short getDistinctState()

INTERNAL Return the DISTINCT state for the tree

getFromNodeback to summary
public FromNode getFromNode()

INTERNAL Return the FROM Node

getGroupByNodeback to summary
public GroupByNode getGroupByNode()

INTERNAL Return the GroupByNode

getHavingNodeback to summary
public HavingNode getHavingNode()

INTERNAL Return the HavingNode

getOrderByNodeback to summary
public OrderByNode getOrderByNode()

INTERNAL Return the OrderByNode

getQueryNodeback to summary
public QueryNode getQueryNode()

INTERNAL Return the root node for the tree

getReferenceClassback to summary
public Class<?> getReferenceClass(DatabaseQuery query, GenerationContext generationContext)

getReferenceClass(): Answer the class which will be the reference class for the query. Resolve this using the node parsed from the "SELECT" of the EJBQL query string

getSetNodeback to summary
public SetNode getSetNode()

INTERNAL Return the set node for the tree

getWhereNodeback to summary
public WhereNode getWhereNode()

INTERNAL Return the Where node

hasGroupByback to summary
public boolean hasGroupBy()

INTERNAL Does this EJBQL have a Grouping Clause

hasHavingback to summary
public boolean hasHaving()

INTERNAL Does this EJBQL have a Having Clause

hasOrderByback to summary
public boolean hasOrderBy()

INTERNAL Does this EJBQL have an Ordering Clause

initBaseExpressionback to summary
public void initBaseExpression(ObjectLevelReadQuery theQuery, GenerationContext generationContext)

INTERNAL Initialize the base expression in the generation context.

initBaseExpressionback to summary
public void initBaseExpression(ModifyAllQuery theQuery, GenerationContext generationContext)

INTERNAL Initialize the base expression in the generation context.

qualifyAttributeAccessback to summary
protected void qualifyAttributeAccess(ParseTreeContext context)

INTERNAL This method handles any unqualified field access in bulk UPDATE and DELETE statements. A UPDATE or DELETE statement may not define an identification variable. In this case any field accessed from the current class is not qualified with an identification variable, e.g. UPDATE Customer SET name = :newname The method goes through the expressions of the SET clause and the WHERE clause of such an DELETE and UPDATE statement and qualifies the field access using the abstract schema name as qualifier.

setClassLoaderback to summary
public void setClassLoader(ClassLoader loader)

INTERNAL: Set the class loader for this parse tree

setContextback to summary
public void setContext(ParseTreeContext newContext)

INTERNAL Set the context for this parse tree

setDistinctStateback to summary
public void setDistinctState(short newDistinctState)

INTERNAL Set the DISTINCT state for the tree

setFromNodeback to summary
public void setFromNode(FromNode fromNode)

INTERNAL Set the FROM node for the query

setGroupByNodeback to summary
public void setGroupByNode(GroupByNode newGroupByNode)

INTERNAL Set the Group by node

setHavingNodeback to summary
public void setHavingNode(HavingNode newHavingNode)

INTERNAL Set the Having node

setOrderByNodeback to summary
public void setOrderByNode(OrderByNode newOrderByNode)

INTERNAL Set the Order by node

setQueryNodeback to summary
public void setQueryNode(QueryNode newQueryNode)

INTERNAL Set the Select node

setSelectionCriteriaForQueryback to summary
public void setSelectionCriteriaForQuery(DatabaseQuery theQuery, GenerationContext generationContext)
setSetNodeback to summary
public void setSetNode(SetNode newSetNode)

INTERNAL Set the Where node

setWhereNodeback to summary
public void setWhereNode(WhereNode newWhereNode)

INTERNAL Set the Where node

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

INTERNAL Print the contents of the parse tree on a string

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

Annotations
@Override
usesDistinctback to summary
public boolean usesDistinct()

INTERNAL Answer true if DISTINCT has been chosen.

validateback to summary
protected void validate(AbstractSession session, ClassLoader classLoader)

INTERNAL Validate the parse tree.

validateback to summary
public void validate(TypeHelper typeHelper)

INTERNAL Validate the parse tree.

validateback to summary
public void validate(ParseTreeContext context)

INTERNAL Validate the parse tree.

verifySelectback to summary
public void verifySelect(DatabaseQuery theQuery, GenerationContext generationContext)

INTERNAL Verify that the alias in the SELECT is valid. Invalid: SELECT OBJECT(badAlias) FROM Employee employee.... Valid: SELECT OBJECT(employee) FROM Employee employee....