public class SelectStatementStateObject extends AbstractSelectStatementStateObject
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]
FromClauseStateObject
,
GroupByClauseStateObject
,
HavingClauseStateObject
,
OrderByClauseStateObject
,
SelectClauseStateObject
,
WhereClauseStateObject
,
SelectStatement
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ORDER_BY_CLAUSE_PROPERTY
Notify the state object representing the
ORDER BY clause has changed. |
GROUP_BY_CLAUSE_PROPERTY, HAVING_CLAUSE_PROPERTY, WHERE_CLAUSE_PROPERTY
Constructor and Description |
---|
SelectStatementStateObject(JPQLQueryStateObject parent)
Creates a new
SelectStatementStateObject . |
Modifier and Type | Method and Description |
---|---|
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. |
OrderByClauseStateObject |
addOrderByClause()
Adds the
ORDER BY clause. |
OrderByClauseStateObject |
addOrderByClause(java.lang.String jpqlFragment)
Adds the
ORDER BY clause and parses the given JPQL fragment, which should
represent one or many ordering items. |
void |
addSelectItem(StateObject stateObject)
Adds the given
StateObject as a select item. |
ResultVariableStateObject |
addSelectItem(StateObject stateObject,
java.lang.String resultVariable)
Adds the given
StateObject as a select item. |
StateObject |
addSelectItem(java.lang.String path)
Adds the given path as a select item, which can either be an identification variable or a
state-field path expression.
|
ResultVariableStateObject |
addSelectItem(java.lang.String jpqlFragment,
java.lang.String resultVariable)
Adds the given expression as a select item.
|
ResultVariableStateObject |
addSelectItemAs(StateObject stateObject,
java.lang.String resultVariable)
Adds the given
StateObject as a select item. |
ResultVariableStateObject |
addSelectItemAs(java.lang.String jpqlFragment,
java.lang.String resultVariable)
Adds the given expression as a select item.
|
protected AbstractFromClauseStateObject |
buildFromClause()
Creates the state object representing the
FROM clause. |
protected AbstractSelectClauseStateObject |
buildSelectClause()
Creates the state object representing the
SELECT clause. |
SelectStatement |
getExpression()
Returns the actual parsed object if this
StateObject representation of the JPQL query
was created by parsing an existing JPQL query. |
FromClauseStateObject |
getFromClause()
Returns the state object representing the
FROM clause. |
OrderByClauseStateObject |
getOrderByClause()
Returns the state object representing the
ORDER BY clause. |
JPQLQueryStateObject |
getParent()
Returns the parent of this
StateObject . |
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. |
SelectClauseStateObject |
getSelectClause()
Returns the state object representing the
SELECT clause. |
boolean |
hasOrderByClause()
Returns the state object representing the
ORDER BY clause. |
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 |
removeOrderByClause()
Removes the
ORDER BY clause. |
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 . |
void |
toggleOrderByClause()
Either adds or removes the
ORDER BY 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. |
addCollectionDeclaration, addCollectionDeclaration, addGroupByClause, addGroupByClause, addHavingClause, addHavingClause, addRangeDeclaration, addRangeDeclaration, addRangeDeclaration, addWhereClause, addWhereClause, declarations, findIdentificationVariable, getDeclaration, getGroupByClause, getHavingClause, getWhereClause, hasGroupByClause, hasHavingClause, hasWhereClause, identificationVariables, initialize, parseSelect, removeGroupByClause, removeHavingClause, removeWhereClause, toggleGroupByClause, toggleHavingClause, toggleWhereClause
acceptUnknownVisitor, acceptUnknownVisitor, addProblems, addPropertyChangeListener, areEquivalent, buildProblem, buildProblem, buildStateObject, buildStateObjects, checkParent, children, decorate, equals, firePropertyChanged, getChangeSupport, getDecorator, getGrammar, getManagedTypeProvider, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, isDecorated, parent, parent, parent, removePropertyChangeListener, setExpression, setParent, toString, toString, toStringInternal, toStringItems, toText
public static final java.lang.String ORDER_BY_CLAUSE_PROPERTY
ORDER BY
clause has changed.public SelectStatementStateObject(JPQLQueryStateObject parent)
SelectStatementStateObject
.parent
- The parent of this state object, which cannot be null
java.lang.NullPointerException
- The given parent cannot be null
public void accept(StateObjectVisitor visitor)
StateObject
by the given visitor
.visitor
- The visitor
to visit this objectprotected void addChildren(java.util.List<StateObject> children)
StateObject
to the given list.addChildren
in class AbstractSelectStatementStateObject
children
- The list used to store the childrenpublic OrderByClauseStateObject addOrderByClause()
ORDER BY
clause. The clause is not added if it's already present.ORDER BY
clausepublic OrderByClauseStateObject addOrderByClause(java.lang.String jpqlFragment)
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.jpqlFragment
- The fragment of the JPQL to parse that represents the ordering items, the
fragment cannot start with ORDER BY
OrderByClauseStateObject
public void addSelectItem(StateObject stateObject)
StateObject
as a select item.stateObject
- The StateObject
representing a select expressionpublic ResultVariableStateObject addSelectItem(StateObject stateObject, java.lang.String resultVariable)
StateObject
as a select item.stateObject
- The StateObject
representing the select expressionresultVariable
- The result variable identifying the select expressionResultVariableStateObject
public StateObject addSelectItem(java.lang.String path)
path
- The select expression to parse as a select itemStateObject
encapsulating the given pathpublic ResultVariableStateObject addSelectItem(java.lang.String jpqlFragment, java.lang.String resultVariable)
jpqlFragment
- The select expression to parse as a select itemresultVariable
- The result variable identifying the select expressionResultVariableStateObject
public ResultVariableStateObject addSelectItemAs(StateObject stateObject, java.lang.String resultVariable)
StateObject
as a select item.stateObject
- The StateObject
representing the select expressionresultVariable
- The result variable identifying the select expressionResultVariableStateObject
public ResultVariableStateObject addSelectItemAs(java.lang.String jpqlFragment, java.lang.String resultVariable)
jpqlFragment
- The portion of a JPQL query that represents a select expressionresultVariable
- The result variable identifying the select expressionResultVariableStateObject
protected AbstractFromClauseStateObject buildFromClause()
FROM
clause.buildFromClause
in class AbstractSelectStatementStateObject
AbstractFromClauseStateObject
protected AbstractSelectClauseStateObject buildSelectClause()
SELECT
clause.buildSelectClause
in class AbstractSelectStatementStateObject
AbstractSelectClauseStateObject
public SelectStatement getExpression()
StateObject
representation of the JPQL query
was created by parsing an existing JPQL query.getExpression
in interface StateObject
getExpression
in class AbstractSelectStatementStateObject
StateObject
or null
when the JPQL query is manually created (i.e. not from a string)public FromClauseStateObject getFromClause()
FROM
clause.getFromClause
in class AbstractSelectStatementStateObject
FROM
clause, which is never
null
public OrderByClauseStateObject getOrderByClause()
ORDER BY
clause.ORDER BY
clause or
null
if it's not presentpublic JPQLQueryStateObject getParent()
StateObject
.getParent
in interface StateObject
getParent
in class AbstractStateObject
StateObject
, which is null
only when
this is the root of the hierarchypublic ISelectExpressionStateObjectBuilder getSelectBuilder()
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 getSelectClause()
SELECT
clause.getSelectClause
in class AbstractSelectStatementStateObject
SELECT
clause,
which is never null
public boolean hasOrderByClause()
ORDER BY
clause.true
if the ORDER BY
clause is present;
false
otherwisepublic boolean isEquivalent(StateObject stateObject)
StateObject
is equivalent to this one, i.e. the
information of both StateObject
is the same.isEquivalent
in interface StateObject
isEquivalent
in class AbstractSelectStatementStateObject
stateObject
- The StateObject
to compare its content to this onetrue
if both object are equivalent; false
otherwisepublic void removeOrderByClause()
ORDER BY
clause.public void setExpression(SelectStatement expression)
parsed object
object, which should only be
done when this object is instantiated during the conversion of a parsed JPQL query into
StateObjects
.expression
- The parsed object
representing a SELECT
statementpublic void toggleOrderByClause()
ORDER BY
clause.protected void toTextInternal(java.lang.Appendable writer) throws java.io.IOException
StateObject
, which should not be used to
define a true
string representation of a JPQL query but should be used for
debugging purposes.toTextInternal
in class AbstractSelectStatementStateObject
writer
- The writer used to print out the string representationjava.io.IOException
- This should never happens, it is only required because Appendable
is used instead of any concrete class