EclipseLink 2.4.2, build 'v20130514-5956486' API Reference

org.eclipse.persistence.jpa.jpql.model.query
Class JPQLQueryStateObject

java.lang.Object
  extended by org.eclipse.persistence.jpa.jpql.model.query.AbstractStateObject
      extended by org.eclipse.persistence.jpa.jpql.model.query.JPQLQueryStateObject
All Implemented Interfaces:
StateObject

public class JPQLQueryStateObject
extends AbstractStateObject

This is the root of the StateObject hierarchy that represents a JPQL query. The only child of this state object is one of the three possible query statements.

Version:
2.4
See Also:
DeleteStatementStateObject, SelectStatementStateObject, UpdateStatementStateObject, JPQLExpression
Author:
Pascal Filion
Since:
2.4

Field Summary
static java.lang.String QUERY_STATEMENT_PROPERTY
          Notifies the query statement has changed.
 
Constructor Summary
JPQLQueryStateObject(IJPQLQueryBuilder queryBuilder, IManagedTypeProvider provider)
          Creates a new JPQLQueryStateObject.
 
Method Summary
 void accept(StateObjectVisitor visitor)
          Visits this StateObject by the given visitor.
protected  void addChildren(java.util.List<StateObject> children)
          Adds the children of this StateObject to the given list.
 DeleteStatementStateObject addDeleteStatement()
          Changes the query statement to be a DELETE statement.
 SelectStatementStateObject addDistinctSelectStatement()
          Changes the query statement to be a SELECT statement.
 SelectStatementStateObject addSelectStatement()
          Changes the query statement to be a SELECT statement.
 SelectStatementStateObject addSelectStatement(java.lang.String jpqlFragment)
          Changes the query statement to be a SELECT statement.
 UpdateStatementStateObject addUpdateStatement()
          Changes the query statement to be a UPDATE statement.
 UpdateStatementStateObject addUpdateStatement(java.lang.String jpqlFragment)
          Changes the query statement to be a UPDATE statement.
protected  StateObject checkParent(StateObject parent)
          Checks whether the given parent is null or not.
 DeclarationStateObject getDeclaration()
          Returns the declaration clause which defines the domain of the query by declaring identification variables.
 JPQLExpression getExpression()
          Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.
 JPQLGrammar getGrammar()
          Returns the grammar that defines how to parse a JPQL query.
 IManagedTypeProvider getManagedTypeProvider()
          Returns the provider of managed types.
 StateObject getParent()
          Returns the parent of this StateObject.
 IJPQLQueryBuilder getQueryBuilder()
          Returns the IJPQLQueryBuilder that is responsible to create various part of the StateObject hierarchy.
 StateObject getQueryStatement()
          Returns the only child of this state object, which represents one of the three query statement.
 JPQLQueryStateObject getRoot()
          Returns the root of the StateObject hierarchy.
 boolean hasQueryStatement()
          Determines whether a query statement has been defined.
protected  void initialize(IJPQLQueryBuilder queryBuilder, IManagedTypeProvider provider)
          Initializes this JPQLQueryStateObject.
 boolean isEquivalent(StateObject stateObject)
          Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.
 void parse(java.lang.CharSequence jpqlFragment, java.lang.String queryBNFId)
          Parses the given JPQL fragment as this state object's query statement.
 void setExpression(JPQLExpression expression)
          Keeps a reference of the parsed object object, which should only be done when this object is instantiated during the conversion of a parsed JPQL query into StateObjects.
 void setQueryStatement(StateObject queryStatement)
          Sets the only child of this state object, which represents one of the three query statement.
protected  void toTextInternal(java.lang.Appendable writer)
          Prints out a string representation of this StateObject, which should not be used to define a true string representation of a JPQL query but should be used for debugging purposes.
 
Methods inherited from class org.eclipse.persistence.jpa.jpql.model.query.AbstractStateObject
acceptUnknownVisitor, acceptUnknownVisitor, addProblems, addPropertyChangeListener, areEquivalent, buildProblem, buildProblem, buildStateObject, buildStateObjects, children, decorate, equals, findIdentificationVariable, firePropertyChanged, getChangeSupport, getDecorator, getType, getType, getTypeHelper, getTypeRepository, hashCode, initialize, isDecorated, parent, parent, parent, removePropertyChangeListener, setExpression, setParent, toString, toString, toStringInternal, toStringItems, toText
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

QUERY_STATEMENT_PROPERTY

public static final java.lang.String QUERY_STATEMENT_PROPERTY
Notifies the query statement has changed.

See Also:
Constant Field Values
Constructor Detail

JPQLQueryStateObject

public JPQLQueryStateObject(IJPQLQueryBuilder queryBuilder,
                            IManagedTypeProvider provider)
Creates a new JPQLQueryStateObject.

Parameters:
queryBuilder - The builder that can create any StateObject for any given JPQL fragment when using a parse method
provider - The external form of a provider that gives access to the JPA metadata
Throws:
java.lang.NullPointerException - If one of the given arguments is null
Method Detail

accept

public void accept(StateObjectVisitor visitor)
Visits this StateObject by the given visitor.

Parameters:
visitor - The visitor to visit this object

addChildren

protected void addChildren(java.util.List<StateObject> children)
Adds the children of this StateObject to the given list.

Overrides:
addChildren in class AbstractStateObject
Parameters:
children - The list used to store the children

addDeleteStatement

public DeleteStatementStateObject addDeleteStatement()
Changes the query statement to be a DELETE statement.

Returns:
The new root object of the DELETE statement

addDistinctSelectStatement

public SelectStatementStateObject addDistinctSelectStatement()
Changes the query statement to be a SELECT statement. The SELECT clause will have the DISTINCT identifier set.

Returns:
The new root object of the SELECT statement

addSelectStatement

public SelectStatementStateObject addSelectStatement()
Changes the query statement to be a SELECT statement.

Returns:
The new root object of the SELECT statement

addSelectStatement

public SelectStatementStateObject addSelectStatement(java.lang.String jpqlFragment)
Changes the query statement to be a SELECT statement.

Parameters:
jpqlFragment - The portion of the query representing the select items, excluding the SELECT identifier
Returns:
The new root object of the SELECT statement

addUpdateStatement

public UpdateStatementStateObject addUpdateStatement()
Changes the query statement to be a UPDATE statement.

Returns:
The new root object of the UPDTE statement

addUpdateStatement

public UpdateStatementStateObject addUpdateStatement(java.lang.String jpqlFragment)
Changes the query statement to be a UPDATE statement.

Parameters:
jpqlFragment - The portion of the query representing the select items, excluding the UPDATE identifier
Returns:
The new root object of the UPDATE statement

checkParent

protected StateObject checkParent(StateObject parent)
Checks whether the given parent is null or not. If it's null then throw a NullPointerException.

Overrides:
checkParent in class AbstractStateObject
Parameters:
parent - The parent of this state object
Returns:
The given object

getDeclaration

public DeclarationStateObject getDeclaration()
Returns the declaration clause which defines the domain of the query by declaring identification variables.

Specified by:
getDeclaration in interface StateObject
Overrides:
getDeclaration in class AbstractStateObject
Returns:
The declaration clause of which this StateObject is a child; i.e. either the top-level declaration if this is part of the top query or the sub-level declaration if this is part of a subquery

getExpression

public JPQLExpression getExpression()
Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.

Specified by:
getExpression in interface StateObject
Overrides:
getExpression in class AbstractStateObject
Returns:
The parsed object when a JPQL query is parsed and converted into a StateObject or null when the JPQL query is manually created (i.e. not from a string)

getGrammar

public JPQLGrammar getGrammar()
Returns the grammar that defines how to parse a JPQL query.

Specified by:
getGrammar in interface StateObject
Overrides:
getGrammar in class AbstractStateObject
Returns:
The grammar that was used to parse the JPQL query

getManagedTypeProvider

public IManagedTypeProvider getManagedTypeProvider()
Returns the provider of managed types.

Specified by:
getManagedTypeProvider in interface StateObject
Overrides:
getManagedTypeProvider in class AbstractStateObject
Returns:
The provider that gives access to the managed types

getParent

public StateObject getParent()
Returns the parent of this StateObject.

Specified by:
getParent in interface StateObject
Overrides:
getParent in class AbstractStateObject
Returns:
Returns the parent of this StateObject, which is null only when this is the root of the hierarchy

getQueryBuilder

public IJPQLQueryBuilder getQueryBuilder()
Returns the IJPQLQueryBuilder that is responsible to create various part of the StateObject hierarchy.

Specified by:
getQueryBuilder in interface StateObject
Overrides:
getQueryBuilder in class AbstractStateObject
Returns:
The builder that created this StateObject from a JPQL query or that gives access to various sub-builders

getQueryStatement

public StateObject getQueryStatement()
Returns the only child of this state object, which represents one of the three query statement.

Returns:
The state object representing the query statement, which was created based on the query type

getRoot

public JPQLQueryStateObject getRoot()
Returns the root of the StateObject hierarchy.

Specified by:
getRoot in interface StateObject
Overrides:
getRoot in class AbstractStateObject
Returns:
The root of the state model representing the JPQL query

hasQueryStatement

public boolean hasQueryStatement()
Determines whether a query statement has been defined.

Returns:
true if there is a query statement defined; false otherwise

initialize

protected void initialize(IJPQLQueryBuilder queryBuilder,
                          IManagedTypeProvider provider)
Initializes this JPQLQueryStateObject.

Parameters:
queryBuilder - The builder that can create any StateObject for any given JPQL fragment
provider - The external form that gives access to the JPA metadata
Throws:
java.lang.NullPointerException - If one of the given arguments is null

isEquivalent

public boolean isEquivalent(StateObject stateObject)
Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.

Specified by:
isEquivalent in interface StateObject
Overrides:
isEquivalent in class AbstractStateObject
Parameters:
stateObject - The StateObject to compare its content to this one
Returns:
true if both object are equivalent; false otherwise

parse

public void parse(java.lang.CharSequence jpqlFragment,
                  java.lang.String queryBNFId)
Parses the given JPQL fragment as this state object's query statement.

Parameters:
jpqlFragment - The portion of the query to parse
queryBNFId - The unique identifier of the BNF that determines how to parse the fragment

setExpression

public void setExpression(JPQLExpression expression)
Keeps a reference of the parsed object object, which should only be done when this object is instantiated during the conversion of a parsed JPQL query into StateObjects.

Parameters:
expression - The parsed object representing the JPQL query

setQueryStatement

public void setQueryStatement(StateObject queryStatement)
Sets the only child of this state object, which represents one of the three query statement.

Parameters:
queryStatement - The state object representing the query statement, which was created based on the query type

toTextInternal

protected void toTextInternal(java.lang.Appendable writer)
                       throws java.io.IOException
Prints out a string representation of this StateObject, which should not be used to define a true string representation of a JPQL query but should be used for debugging purposes.

Specified by:
toTextInternal in class AbstractStateObject
Parameters:
writer - The writer used to print out the string representation
Throws:
java.io.IOException - This should never happens, it is only required because Appendable is used instead of any concrete class

EclipseLink 2.4.2, build 'v20130514-5956486' API Reference