Top Description Fields Constructors Methods
org.eclipse.persistence.jpa.jpql.tools.model.query

public Class SelectStatementStateObject

extends AbstractSelectStatementStateObject
Class Inheritance
Annotations
@SuppressWarnings:nls
Imports
java.io.IOException, java.util.List, org.eclipse.persistence.jpa.jpql.parser.SelectStatement, org.eclipse.persistence.jpa.jpql.tools.model.ISelectExpressionStateObjectBuilder

This state object represents a select statement, which has at least a SELECT clause and a FROM clause. The other clauses are optional.
BNF: select_statement ::= select_clause from_clause [where_clause] [groupby_clause] [having_clause] [orderby_clause]
Author
Pascal Filion
Since
2.4
Version
2.4
See Also
FromClauseStateObject, GroupByClauseStateObject, HavingClauseStateObject, OrderByClauseStateObject, SelectClauseStateObject, WhereClauseStateObject, SelectStatement

Field Summary

Modifier and TypeField and Description
public static final String
ORDER_BY_CLAUSE_PROPERTY

Notify the state object representing the ORDER BY clause has changed.

private OrderByClauseStateObject
orderByClause

The state object representing the ORDER BY clause.

Inherited from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject:
GROUP_BY_CLAUSE_PROPERTYHAVING_CLAUSE_PROPERTYWHERE_CLAUSE_PROPERTY

Constructor Summary

AccessConstructor and Description
public
SelectStatementStateObject(JPQLQueryStateObject
The parent of this state object, which cannot be null
parent
)

Creates a new SelectStatementStateObject.

Method Summary

Modifier and TypeMethod and Description
public void
protected void
addChildren(List<StateObject>
The list used to store the children
children
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject.addChildren.

Adds the children of this StateObject to the given list.
public OrderByClauseStateObject

Returns:

The state object representing the ORDER BY clause
addOrderByClause
()

Adds the ORDER BY clause.

public OrderByClauseStateObject
addOrderByClause(String
The fragment of the JPQL to parse that represents the ordering items, the fragment cannot start with ORDER BY
jpqlFragment
)

Adds the ORDER BY clause and parses the given JPQL fragment, which should represent one or many ordering items.

public void
addSelectItem(StateObject
The StateObject representing a select expression
stateObject
)

Adds the given StateObject as a select item.

public ResultVariableStateObject

Returns:

The newly created ResultVariableStateObject
addSelectItem
(StateObject
The StateObject representing the select expression
stateObject
,
String
The result variable identifying the select expression
resultVariable
)

Adds the given StateObject as a select item.

public StateObject

Returns:

The StateObject encapsulating the given path
addSelectItem
(String
The select expression to parse as a select item
path
)

Adds the given path as a select item, which can either be an identification variable or a state-field path expression.

public ResultVariableStateObject

Returns:

The newly created ResultVariableStateObject
addSelectItem
(String
The select expression to parse as a select item
jpqlFragment
,
String
The result variable identifying the select expression
resultVariable
)

Adds the given expression as a select item.

public ResultVariableStateObject

Returns:

The newly created ResultVariableStateObject
addSelectItemAs
(StateObject
The StateObject representing the select expression
stateObject
,
String
The result variable identifying the select expression
resultVariable
)

Adds the given StateObject as a select item.

public ResultVariableStateObject

Returns:

The newly created ResultVariableStateObject
addSelectItemAs
(String
The portion of a JPQL query that represents a select expression
jpqlFragment
,
String
The result variable identifying the select expression
resultVariable
)

Adds the given expression as a select item.

protected AbstractFromClauseStateObject
buildFromClause()

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject.buildFromClause.

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

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject.buildSelectClause.

Creates the state object representing the SELECT clause.
public SelectStatement
getExpression()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject.getExpression.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getExpression.

Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.
public FromClauseStateObject
public OrderByClauseStateObject

Returns:

Either the actual state object representing the ORDER BY clause or null if it's not present
getOrderByClause
()

Returns the state object representing the ORDER BY clause.

public JPQLQueryStateObject
public ISelectExpressionStateObjectBuilder

Returns:

A new builder that can be used to quickly create a select expression
getSelectBuilder
()

Creates and returns a new ISelectExpressionStateObjectBuilder that can be used to programmatically create a single select expression and once the expression is complete, ISelectExpressionStateObjectBuilder#commit() will push the StateObject representation of that expression as this clause's select expression.

public SelectClauseStateObject
public boolean

Returns:

true if the ORDER BY clause is present; false otherwise
hasOrderByClause
()

Returns the state object representing the ORDER BY clause.

public boolean
isEquivalent(StateObject
The StateObject to compare its content to this one
stateObject
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject.isEquivalent.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.isEquivalent.

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

Removes the ORDER BY clause.

public void
setExpression(SelectStatement
The parsed object representing a SELECT statement
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.

private void
public void
toggleOrderByClause()

Either adds or removes the ORDER BY clause.

protected void
toTextInternal(Appendable
The writer used to print out the string representation
writer
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject.toTextInternal.

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.
Inherited from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject:
addCollectionDeclarationaddCollectionDeclarationaddGroupByClauseaddGroupByClauseaddHavingClauseaddHavingClauseaddRangeDeclarationaddRangeDeclarationaddRangeDeclarationaddWhereClauseaddWhereClausedeclarationsfindIdentificationVariablegetDeclarationgetGroupByClausegetHavingClausegetWhereClausehasGroupByClausehasHavingClausehasWhereClauseidentificationVariablesinitializeparseSelectremoveGroupByClauseremoveHavingClauseremoveWhereClausetoggleGroupByClausetoggleHavingClausetoggleWhereClause

Field Detail

ORDER_BY_CLAUSE_PROPERTYback to summary
public static final String ORDER_BY_CLAUSE_PROPERTY

Notify the state object representing the ORDER BY clause has changed.

orderByClauseback to summary
private OrderByClauseStateObject orderByClause

The state object representing the ORDER BY clause.

Constructor Detail

SelectStatementStateObjectback to summary
public SelectStatementStateObject(JPQLQueryStateObject parent)

Creates a new SelectStatementStateObject.

Parameters
parent:JPQLQueryStateObject

The parent of this state object, which cannot be null

Exceptions
NullPointerException:
The given parent cannot be null

Method Detail

acceptback to summary
public void accept(StateObjectVisitor visitor)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.accept.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.accept.

Visits this StateObject by the given visitor.

Parameters
visitor:StateObjectVisitor

The visitor to visit this object

Annotations
@Override
addChildrenback to summary
protected void addChildren(List<StateObject> children)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject.addChildren.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.addChildren.

Adds the children of this StateObject to the given list.

Parameters
children:List<StateObject>

The list used to store the children

Annotations
@Override
addOrderByClauseback to summary
public OrderByClauseStateObject addOrderByClause()

Adds the ORDER BY clause. The clause is not added if it's already present.

Returns:OrderByClauseStateObject

The state object representing the ORDER BY clause

addOrderByClauseback to summary
public OrderByClauseStateObject addOrderByClause(String jpqlFragment)

Adds the ORDER BY clause and parses the given JPQL fragment, which should represent one or many ordering items. The clause is not added if it's already present.

Parameters
jpqlFragment:String

The fragment of the JPQL to parse that represents the ordering items, the fragment cannot start with ORDER BY

Returns:OrderByClauseStateObject

The OrderByClauseStateObject

addSelectItemback to summary
public void addSelectItem(StateObject stateObject)

Adds the given StateObject as a select item.

Parameters
stateObject:StateObject

The StateObject representing a select expression

addSelectItemback to summary
public ResultVariableStateObject addSelectItem(StateObject stateObject, String resultVariable)

Adds the given StateObject as a select item.

Parameters
stateObject:StateObject

The StateObject representing the select expression

resultVariable:String

The result variable identifying the select expression

Returns:ResultVariableStateObject

The newly created ResultVariableStateObject

addSelectItemback to summary
public StateObject addSelectItem(String path)

Adds the given path as a select item, which can either be an identification variable or a state-field path expression.

Parameters
path:String

The select expression to parse as a select item

Returns:StateObject

The StateObject encapsulating the given path

addSelectItemback to summary
public ResultVariableStateObject addSelectItem(String jpqlFragment, String resultVariable)

Adds the given expression as a select item.

Parameters
jpqlFragment:String

The select expression to parse as a select item

resultVariable:String

The result variable identifying the select expression

Returns:ResultVariableStateObject

The newly created ResultVariableStateObject

addSelectItemAsback to summary
public ResultVariableStateObject addSelectItemAs(StateObject stateObject, String resultVariable)

Adds the given StateObject as a select item.

Parameters
stateObject:StateObject

The StateObject representing the select expression

resultVariable:String

The result variable identifying the select expression

Returns:ResultVariableStateObject

The newly created ResultVariableStateObject

addSelectItemAsback to summary
public ResultVariableStateObject addSelectItemAs(String jpqlFragment, String resultVariable)

Adds the given expression as a select item.

Parameters
jpqlFragment:String

The portion of a JPQL query that represents a select expression

resultVariable:String

The result variable identifying the select expression

Returns:ResultVariableStateObject

The newly created ResultVariableStateObject

buildFromClauseback to summary
protected AbstractFromClauseStateObject buildFromClause()

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject.buildFromClause.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject.buildFromClause.

Creates the state object representing the FROM clause.

Returns:AbstractFromClauseStateObject

A concrete instance of AbstractFromClauseStateObject

Annotations
@Override
buildSelectClauseback to summary
protected AbstractSelectClauseStateObject buildSelectClause()

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject.buildSelectClause.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject.buildSelectClause.

Creates the state object representing the SELECT clause.

Returns:AbstractSelectClauseStateObject

A concrete instance of AbstractSelectClauseStateObject

Annotations
@Override
getExpressionback to summary
public SelectStatement getExpression()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject.getExpression.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getExpression.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getExpression.

Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.

Returns:SelectStatement

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)

Annotations
@Override
getFromClauseback to summary
public FromClauseStateObject getFromClause()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject.getFromClause.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject.getFromClause.

Returns the state object representing the FROM clause.

Returns:FromClauseStateObject

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

Annotations
@Override
getOrderByClauseback to summary
public OrderByClauseStateObject getOrderByClause()

Returns the state object representing the ORDER BY clause.

Returns:OrderByClauseStateObject

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

getParentback to summary
public JPQLQueryStateObject getParent()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.getParent.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getParent.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getParent.

Returns the parent of this StateObject.

Returns:JPQLQueryStateObject

Returns the parent of this StateObject, which is null only when this is the root of the hierarchy

Annotations
@Override
getSelectBuilderback to summary
public ISelectExpressionStateObjectBuilder getSelectBuilder()

Creates and returns a new ISelectExpressionStateObjectBuilder that can be used to programmatically create a single select expression and once the expression is complete, ISelectExpressionStateObjectBuilder#commit() will push the StateObject representation of that expression as this clause's select expression.

Returns:ISelectExpressionStateObjectBuilder

A new builder that can be used to quickly create a select expression

getSelectClauseback to summary
public SelectClauseStateObject getSelectClause()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject.getSelectClause.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject.getSelectClause.

Returns the state object representing the SELECT clause.

Returns:SelectClauseStateObject

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

Annotations
@Override
hasOrderByClauseback to summary
public boolean hasOrderByClause()

Returns the state object representing the ORDER BY clause.

Returns:boolean

true if the ORDER BY clause is present; false otherwise

isEquivalentback to summary
public boolean isEquivalent(StateObject stateObject)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject.isEquivalent.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.isEquivalent.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.isEquivalent.

Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.

Parameters
stateObject:StateObject

The StateObject to compare its content to this one

Returns:boolean

true if both object are equivalent; false otherwise

Annotations
@Override
removeOrderByClauseback to summary
public void removeOrderByClause()

Removes the ORDER BY clause.

setExpressionback to summary
public void setExpression(SelectStatement 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:SelectStatement

The parsed object representing a SELECT statement

setOrderByClauseback to summary
private void setOrderByClause(OrderByClauseStateObject orderByClause)
toggleOrderByClauseback to summary
public void toggleOrderByClause()

Either adds or removes the ORDER BY clause.

toTextInternalback to summary
protected void toTextInternal(Appendable writer) throws IOException

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject.toTextInternal.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.toTextInternal.

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.

Parameters
writer:Appendable

The writer used to print out the string representation

Annotations
@Override
Exceptions
IOException:
This should never happens, it is only required because Appendable is used instead of any concrete class