EclipseLink 2.4.2, build 'v20130514-5956486' API Reference

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

java.lang.Object
  extended by org.eclipse.persistence.jpa.jpql.model.query.AbstractStateObject
      extended by org.eclipse.persistence.jpa.jpql.model.query.AbstractSelectStatementStateObject
All Implemented Interfaces:
StateObject
Direct Known Subclasses:
SelectStatementStateObject, SimpleSelectStatementStateObject

public abstract class AbstractSelectStatementStateObject
extends AbstractStateObject

This state object represents the select statement, which has at least a SELECT clause and a FROM clause.

Version:
2.4
See Also:
SelectStatementStateObject, FromClauseStateObject, GroupByClauseStateObject, HavingClauseStateObject, SelectClauseStateObject, WhereClauseStateObject, AbstractSelectStatement
Author:
Pascal Filion
Since:
2.4

Field Summary
static java.lang.String GROUP_BY_CLAUSE_PROPERTY
          Notify the state object representing the GROUP BY clause has changed.
static java.lang.String HAVING_CLAUSE_PROPERTY
          Notify the state object representing the HAVING clause has changed.
static java.lang.String WHERE_CLAUSE_PROPERTY
          Notify the state object representing the WHERE clause has changed.
 
Constructor Summary
protected AbstractSelectStatementStateObject(StateObject parent)
          Creates a new AbstractSelectStatementStateObject.
 
Method Summary
protected  void addChildren(java.util.List<StateObject> children)
          Adds the children of this StateObject to the given list.
 CollectionMemberDeclarationStateObject addCollectionDeclaration()
          Adds a new collection declaration to the FROM clause.
 CollectionMemberDeclarationStateObject addCollectionDeclaration(java.lang.String collectionValuedPath, java.lang.String identificationVariable)
          Adds a new collection declaration to the FROM clause.
 GroupByClauseStateObject addGroupByClause()
          Adds the GROUP BY clause.
 GroupByClauseStateObject addGroupByClause(java.lang.String jpqlFragment)
          Adds the GROUP BY clause and parses the given JPQL fragment.
 HavingClauseStateObject addHavingClause()
          Adds the HAVING clause.
 HavingClauseStateObject addHavingClause(java.lang.String jpqlFragment)
          Adds the HAVING clause and parses the given JPQL fragment.
 IdentificationVariableDeclarationStateObject addRangeDeclaration()
          Adds a new range variable declaration to the FROM clause.
 IdentificationVariableDeclarationStateObject addRangeDeclaration(IEntity entity, java.lang.String identificationVariable)
          Adds to this select statement a new range variable declaration.
 IdentificationVariableDeclarationStateObject addRangeDeclaration(java.lang.String entityName, java.lang.String identificationVariable)
          Adds to this select statement a new range variable declaration.
 WhereClauseStateObject addWhereClause()
          Adds the WHERE clause.
 WhereClauseStateObject addWhereClause(java.lang.String jpqlFragment)
          Adds the WHERE clause and parses the given JPQL fragment.
protected abstract  AbstractFromClauseStateObject buildFromClause()
          Creates the state object representing the FROM clause.
protected abstract  AbstractSelectClauseStateObject buildSelectClause()
          Creates the state object representing the SELECT clause.
 IterableListIterator<? extends VariableDeclarationStateObject> declarations()
          Returns the list of VariableDeclarationStateObject defining the variable declarations, which are mapping an entity to a variable or a collection-valued member to a variable.
 IdentificationVariableStateObject findIdentificationVariable(java.lang.String identificationVariable)
          Returns the IdentificationVariableStateObject representing the given identification variable.
 DeclarationStateObject getDeclaration()
          Returns the declaration clause which defines the domain of the query by declaring identification variables.
 AbstractSelectStatement getExpression()
          Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.
 AbstractFromClauseStateObject getFromClause()
          Returns the state object representing the FROM clause.
 GroupByClauseStateObject getGroupByClause()
          Returns the state object representing the GROUP BY clause.
 HavingClauseStateObject getHavingClause()
          Returns the state object representing the HAVING clause.
 AbstractSelectClauseStateObject getSelectClause()
          Returns the state object representing the SELECT clause.
 WhereClauseStateObject getWhereClause()
          Returns the state object representing the WHERE clause.
 boolean hasGroupByClause()
          Returns the state object representing the GROUP BY clause.
 boolean hasHavingClause()
          Returns the state object representing the HAVING clause.
 boolean hasWhereClause()
          Returns the state object representing the WHERE clause.
 java.util.Iterator<IdentificationVariableStateObject> identificationVariables()
          Returns the IdentificationVariableStateObjects holding onto the identification variables, which are the variables defined in the FROM clause.
protected  void initialize()
          Initializes this state object.
 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 parseSelect(java.lang.String jpqlFragment)
          Parses the given JPQL fragment and create the select item.
 void removeGroupByClause()
          Removes the GROUP BY clause.
 void removeHavingClause()
          Removes the HAVING clause.
 void removeWhereClause()
          Removes the WHERE clause.
 void toggleGroupByClause()
          Either adds or removes the state object representing the GROUP BY clause.
 void toggleHavingClause()
          Either adds or removes the state object representing the HAVING clause.
 void toggleWhereClause()
          Either adds or removes the state object representing the WHERE clause.
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, checkParent, children, decorate, equals, firePropertyChanged, getChangeSupport, getDecorator, getGrammar, getManagedTypeProvider, getParent, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, 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
 
Methods inherited from interface org.eclipse.persistence.jpa.jpql.model.query.StateObject
accept
 

Field Detail

GROUP_BY_CLAUSE_PROPERTY

public static java.lang.String GROUP_BY_CLAUSE_PROPERTY
Notify the state object representing the GROUP BY clause has changed.


HAVING_CLAUSE_PROPERTY

public static java.lang.String HAVING_CLAUSE_PROPERTY
Notify the state object representing the HAVING clause has changed.


WHERE_CLAUSE_PROPERTY

public static java.lang.String WHERE_CLAUSE_PROPERTY
Notify the state object representing the WHERE clause has changed.

Constructor Detail

AbstractSelectStatementStateObject

protected AbstractSelectStatementStateObject(StateObject parent)
Creates a new AbstractSelectStatementStateObject.

Parameters:
parent - The parent of this state object, which cannot be null
Throws:
java.lang.NullPointerException - The given parent cannot be null
Method Detail

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

addCollectionDeclaration

public CollectionMemberDeclarationStateObject addCollectionDeclaration()
Adds a new collection declaration to the FROM clause.

Returns:
The CollectionMemberDeclarationStateObject representing the collection declaration

addCollectionDeclaration

public CollectionMemberDeclarationStateObject addCollectionDeclaration(java.lang.String collectionValuedPath,
                                                                       java.lang.String identificationVariable)
Adds a new collection declaration to the FROM clause.

Parameters:
collectionValuedPath - The collection-valued path expression
identificationVariable - The variable defining the collection-valued path expression
Returns:
The CollectionMemberDeclarationStateObject representing the collection declaration

addGroupByClause

public GroupByClauseStateObject addGroupByClause()
Adds the GROUP BY clause. The clause is not added if it's already present.

Returns:
The GroupByClauseStateObject

addGroupByClause

public GroupByClauseStateObject addGroupByClause(java.lang.String jpqlFragment)
Adds the GROUP BY clause and parses the given JPQL fragment. The clause is not added if it's already present.

Parameters:
jpqlFragment - The fragment of the JPQL to parse that represents the group by items, the fragment cannot start with GROUP BY
Returns:
The GroupByClauseStateObject

addHavingClause

public HavingClauseStateObject addHavingClause()
Adds the HAVING clause. The clause is not added if it's already present.

Returns:
The GroupByClauseStateObject

addHavingClause

public HavingClauseStateObject addHavingClause(java.lang.String jpqlFragment)
Adds the HAVING clause and parses the given JPQL fragment. The clause is not added if it's already present.

Parameters:
jpqlFragment - The fragment of the JPQL to parse that represents the conditional expression, the fragment cannot start with HAVING
Returns:
The HavingClauseStateObject

addRangeDeclaration

public IdentificationVariableDeclarationStateObject addRangeDeclaration()
Adds a new range variable declaration to the FROM clause.

Returns:
The StateObject representing the new range variable declaration

addRangeDeclaration

public IdentificationVariableDeclarationStateObject addRangeDeclaration(IEntity entity,
                                                                        java.lang.String identificationVariable)
Adds to this select statement a new range variable declaration.

Parameters:
entity - The external form of the entity to add to the declaration list
identificationVariable - The unique identifier identifying the given IEntity
Returns:
The StateObject representing the new range variable declaration

addRangeDeclaration

public IdentificationVariableDeclarationStateObject addRangeDeclaration(java.lang.String entityName,
                                                                        java.lang.String identificationVariable)
Adds to this select statement a new range variable declaration.

Parameters:
entityName - The name of the entity
identificationVariable - The unique identifier identifying the entity
Returns:
The StateObject representing the range variable declaration

addWhereClause

public WhereClauseStateObject addWhereClause()
Adds the WHERE clause. The clause is not added if it's already present.

Returns:
The GroupByClauseStateObject

addWhereClause

public WhereClauseStateObject addWhereClause(java.lang.String jpqlFragment)
Adds the WHERE clause and parses the given JPQL fragment. The clause is not added if it's already present.

Parameters:
jpqlFragment - The fragment of the JPQL to parse that represents the conditional expression, the fragment cannot start with WHERE
Returns:
The WhereClauseStateObject

buildFromClause

protected abstract AbstractFromClauseStateObject buildFromClause()
Creates the state object representing the FROM clause.

Returns:
A concrete instance of AbstractFromClauseStateObject

buildSelectClause

protected abstract AbstractSelectClauseStateObject buildSelectClause()
Creates the state object representing the SELECT clause.

Returns:
A concrete instance of AbstractSelectClauseStateObject

declarations

public IterableListIterator<? extends VariableDeclarationStateObject> declarations()
Returns the list of VariableDeclarationStateObject defining the variable declarations, which are mapping an entity to a variable or a collection-valued member to a variable.

Example:

Returns:
The list of VariableDeclarationStateObject

findIdentificationVariable

public IdentificationVariableStateObject findIdentificationVariable(java.lang.String identificationVariable)
Returns the IdentificationVariableStateObject representing the given identification variable.

Specified by:
findIdentificationVariable in interface StateObject
Overrides:
findIdentificationVariable in class AbstractStateObject
Returns:
The IdentificationVariableStateObject defining the given identification variable

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 AbstractSelectStatement 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)

getFromClause

public AbstractFromClauseStateObject getFromClause()
Returns the state object representing the FROM clause.

Returns:
The state object representing the FROM clause, which is never null

getGroupByClause

public GroupByClauseStateObject getGroupByClause()
Returns the state object representing the GROUP BY clause.

Returns:
Either the actual state object representing the GROUP BY clause or null if it's not present

getHavingClause

public HavingClauseStateObject getHavingClause()
Returns the state object representing the HAVING clause.

Returns:
Either the actual state object representing the HAVING clause or null if it's not present

getSelectClause

public AbstractSelectClauseStateObject getSelectClause()
Returns the state object representing the SELECT clause.

Returns:
Either the actual state object representing the SELECT clause, which is never null

getWhereClause

public WhereClauseStateObject getWhereClause()
Returns the state object representing the WHERE clause.

Returns:
Either the actual state object representing the WHERE clause or the null state object since null is never returned

hasGroupByClause

public boolean hasGroupByClause()
Returns the state object representing the GROUP BY clause.

Returns:
Either the actual state object representing the GROUP BY clause or null if it's not present

hasHavingClause

public boolean hasHavingClause()
Returns the state object representing the HAVING clause.

Returns:
Either the actual state object representing the HAVING clause or null if it's not present

hasWhereClause

public boolean hasWhereClause()
Returns the state object representing the WHERE clause.

Returns:
Either the actual state object representing the WHERE clause or null if it's not present

identificationVariables

public java.util.Iterator<IdentificationVariableStateObject> identificationVariables()
Returns the IdentificationVariableStateObjects holding onto the identification variables, which are the variables defined in the FROM clause.

Example:

Returns:
The list of IdentificationVariableStateObjects

initialize

protected void initialize()
Initializes this state object.

Overrides:
initialize in class AbstractStateObject

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

parseSelect

public void parseSelect(java.lang.String jpqlFragment)
Parses the given JPQL fragment and create the select item. For the top-level query, the fragment can contain several select items but for a subquery, it can represent only one.

Parameters:
jpqlFragment - The portion of the query representing one or several select items

removeGroupByClause

public void removeGroupByClause()
Removes the GROUP BY clause.


removeHavingClause

public void removeHavingClause()
Removes the HAVING clause.


removeWhereClause

public void removeWhereClause()
Removes the WHERE clause.


toggleGroupByClause

public void toggleGroupByClause()
Either adds or removes the state object representing the GROUP BY clause.


toggleHavingClause

public void toggleHavingClause()
Either adds or removes the state object representing the HAVING clause.


toggleWhereClause

public void toggleWhereClause()
Either adds or removes the state object representing the WHERE clause.


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