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

public Class SelectClauseStateObject

extends AbstractSelectClauseStateObject
implements ListHolderStateObject<StateObject>
Class Inheritance
All Implemented Interfaces
org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject, org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject
Annotations
@SuppressWarnings:nls, unused
Imports
java.io.IOException, java.util.ArrayList, .Collection, .List, org.eclipse.persistence.jpa.jpql.parser.InternalSelectExpressionBNF, .SelectClause, .SelectExpressionBNF, org.eclipse.persistence.jpa.jpql.tools.model.IListChangeListener, .ISelectExpressionStateObjectBuilder, org.eclipse.persistence.jpa.jpql.utility.iterable.ListIterable, .SnapshotCloneListIterable

The SELECT statement queries data from entities, which determines the type of the objects or values to be selected.
BNF: select_clause ::= SELECT [DISTINCT] select_expression {, select_expression}*
    select_expression ::= single_valued_path_expression |
                          aggregate_expression |
                          identification_variable |
                          OBJECT(identification_variable) |
                          constructor_expression
Author
Pascal Filion
Since
2.4
Version
2.4
See Also
SelectStatementStateObject, SelectClause

Field Summary

Modifier and TypeField and Description
private ISelectExpressionStateObjectBuilder
builder

The builder is cached during the creation of the select expression.

private List<StateObject>
items

The list of select expressions.

public static final String
SELECT_ITEMS_LIST

A constant used to notify the list of select expressions has changed.

Inherited from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectClauseStateObject:
DISTINCT_PROPERTY

Constructor Summary

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

Creates a new SelectClauseStateObject.

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.AbstractStateObject.addChildren.

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

Returns:

The newly created ResultVariableStateObject
addItem
(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
addItem
(String
The select expression to parse as a select item
jpqlFragment
)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.addItem.

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
addItem
(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 <S extends StateObject> S
addItem(S
The child StateObject to become a child of this one return The given item
item
)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.addItem.

Adds the given StateObject as a child of this one.
public ResultVariableStateObject

Returns:

The newly created ResultVariableStateObject
addItemAs
(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
addItemAs
(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 JPQL fragment as a select item.

public void
addItems(List<? extends StateObject>
The StateObjects to become children of this one
items
)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.addItems.

Adds the given list of StateObjects as children of this one.
public void
addListChangeListener(String
The name of the list for which the listener will be notified when the content of the list has changed
listName
,
IListChangeListener<StateObject>
The listener to be notified upon changes
listener
)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.addListChangeListener.

Registers the given IListChangeListener for the specified list.
protected boolean

Returns:

true if both have equivalent children; false otherwise
areChildrenEquivalent
(SelectClauseStateObject
The StateObject to compare its children to this one's children
stateObject
)

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

public boolean
canMoveDown(StateObject
The StateObject that could potentially be moved down
item
)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.canMoveDown.

Determines whether the given StateObject can be moved down by one position in the list owned by its parent.
public boolean
canMoveUp(StateObject
The StateObject that could potentially be moved up
item
)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.canMoveUp.

Determines whether the given StateObject can be moved up by one position in the list owned by its parent.
public ISelectExpressionStateObjectBuilder

Returns:

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

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 SelectClause
getExpression()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectClauseStateObject.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 StateObject
getItem(int
The position of the StateObject to retrieve
index
)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.getItem.

Returns the StateObject at the given positions from the list
public SelectStatementStateObject
public boolean
public boolean
hasSelectItem()

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectClauseStateObject.hasSelectItem.

Determines whether this SELECT clause has a select item defined (only one can be set for a subquery's SELECT clause and many for a top-level query).
protected void
public boolean
isEquivalent(StateObject
The StateObject to compare its content to this one
stateObject
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectClauseStateObject.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 ListIterable<StateObject>
public int
itemsSize()

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.itemsSize.

Returns the number of children this list holder has.
public StateObject
moveDown(StateObject
The StateObject to move down in the list
item
)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.moveDown.

Moves the given StateObject down by one position in the list owned by its parent.
public StateObject
moveUp(StateObject
The StateObject to move up in the list
item
)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.moveUp.

Moves the given StateObject up by one position in the list owned by its parent.
public void
parse(String
The portion of the query representing one or several select items
jpqlFragment
)

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectClauseStateObject.parse.

Parses the given JPQL fragment and create the select item.
public void
removeItem(StateObject
The child StateObject to not longer be a child
stateObject
)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.removeItem.

Removes the given StateObject from the list of children.
public void
removeItems(Collection<StateObject>
The StateObjects to remove from this one
items
)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.removeItems.

Removes the given StateObject from the list of children.
public void
removeListChangeListener(String
The name of the list for which the listener was registered
listName
,
IListChangeListener<StateObject>
The listener to unregister
listener
)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.removeListChangeListener.

Unregisters the given IListChangeListener that was registered for the specified list.
public void
setExpression(SelectClause
The parsed object representing a SELECT clause
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.

public void
setItems(List<StateObject>
The new select expressions
stateObjects
)

Sets the select expression to be those contained on the given collection.

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

Implements abstract 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.
Inherited from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectClauseStateObject:
hasDistinctsetDistincttoggleDistinct

Field Detail

builderback to summary
private ISelectExpressionStateObjectBuilder builder

The builder is cached during the creation of the select expression.

itemsback to summary
private List<StateObject> items

The list of select expressions.

SELECT_ITEMS_LISTback to summary
public static final String SELECT_ITEMS_LIST

A constant used to notify the list of select expressions has changed.

Constructor Detail

SelectClauseStateObjectback to summary
public SelectClauseStateObject(SelectStatementStateObject parent)

Creates a new SelectClauseStateObject.

Parameters
parent:SelectStatementStateObject

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.AbstractStateObject.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
addItemback to summary
public ResultVariableStateObject addItem(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

addItemback to summary
public StateObject addItem(String jpqlFragment)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.addItem.

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

Parameters
jpqlFragment:String

The select expression to parse as a select item

Returns:StateObject

The StateObject encapsulating the given path

addItemback to summary
public ResultVariableStateObject addItem(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

addItemback to summary
public <S extends StateObject> S addItem(S item)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.addItem.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.addItem.

Adds the given StateObject as a child of this one.

Parameters
item:S

The child StateObject to become a child of this one return The given item

Annotations
@Override
addItemAsback to summary
public ResultVariableStateObject addItemAs(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

addItemAsback to summary
public ResultVariableStateObject addItemAs(String jpqlFragment, String resultVariable)

Adds the given JPQL fragment 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

addItemsback to summary
public void addItems(List<? extends StateObject> items)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.addItems.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.addItems.

Adds the given list of StateObjects as children of this one.

Parameters
items:List<? extends StateObject>

The StateObjects to become children of this one

Annotations
@Override
addListChangeListenerback to summary
public void addListChangeListener(String listName, IListChangeListener<StateObject> listener)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.addListChangeListener.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.addListChangeListener.

Registers the given IListChangeListener for the specified list. The listener will be notified only when items are added, removed, moved from the list.

Parameters
listName:String

The name of the list for which the listener will be notified when the content of the list has changed

listener:IListChangeListener<StateObject>

The listener to be notified upon changes

Annotations
@Override
areChildrenEquivalentback to summary
protected boolean areChildrenEquivalent(SelectClauseStateObject stateObject)

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

Parameters
stateObject:SelectClauseStateObject

The StateObject to compare its children to this one's children

Returns:boolean

true if both have equivalent children; false otherwise

canMoveDownback to summary
public boolean canMoveDown(StateObject item)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.canMoveDown.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.canMoveDown.

Determines whether the given StateObject can be moved down by one position in the list owned by its parent.

Parameters
item:StateObject

The StateObject that could potentially be moved down

Returns:boolean

true if the object can be moved down by one unit; false otherwise

Annotations
@Override
canMoveUpback to summary
public boolean canMoveUp(StateObject item)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.canMoveUp.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.canMoveUp.

Determines whether the given StateObject can be moved up by one position in the list owned by its parent.

Parameters
item:StateObject

The StateObject that could potentially be moved up

Returns:boolean

true if the object can be moved up by one unit; false otherwise

Annotations
@Override
getBuilderback to summary
public ISelectExpressionStateObjectBuilder getBuilder()

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

getExpressionback to summary
public SelectClause getExpression()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectClauseStateObject.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:SelectClause

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.AbstractSelectClauseStateObject.getFromClause.

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

Returns the AbstractFromClauseStateObject representing the FROM clause.

Returns:FromClauseStateObject

The state object representing the FROM clause

Annotations
@Override
getItemback to summary
public StateObject getItem(int index)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.getItem.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.getItem.

Returns the StateObject at the given positions from the list

Parameters
index:int

The position of the StateObject to retrieve

Returns:StateObject

The StateObject at the given position

Annotations
@Override
getParentback to summary
public SelectStatementStateObject getParent()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectClauseStateObject.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:SelectStatementStateObject

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

Annotations
@Override
hasItemsback to summary
public boolean hasItems()

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.hasItems.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.hasItems.

Determines whether this StateObject has any children.

Returns:boolean

true if this StateObject has children; false otherwise

Annotations
@Override
hasSelectItemback to summary
public boolean hasSelectItem()

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectClauseStateObject.hasSelectItem.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectClauseStateObject.hasSelectItem.

Determines whether this SELECT clause has a select item defined (only one can be set for a subquery's SELECT clause and many for a top-level query).

Returns:boolean

true if this state object has children; false otherwise

Annotations
@Override
initializeback to summary
protected void initialize()

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

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

Initializes this state object.

Annotations
@Override
isEquivalentback to summary
public boolean isEquivalent(StateObject stateObject)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectClauseStateObject.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
itemsback to summary
public ListIterable<StateObject> items()

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.items.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.items.

Returns an ListIterable over the children.

Returns:ListIterable<StateObject>

An ListIterable that is iterating over the children

Annotations
@Override
itemsSizeback to summary
public int itemsSize()

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.itemsSize.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.itemsSize.

Returns the number of children this list holder has.

Returns:int

The count of StateObjects that are children of this one

Annotations
@Override
moveDownback to summary
public StateObject moveDown(StateObject item)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.moveDown.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.moveDown.

Moves the given StateObject down by one position in the list owned by its parent.

Parameters
item:StateObject

The StateObject to move down in the list

Returns:StateObject

The given item

Annotations
@Override
moveUpback to summary
public StateObject moveUp(StateObject item)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.moveUp.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.moveUp.

Moves the given StateObject up by one position in the list owned by its parent.

Parameters
item:StateObject

The StateObject to move up in the list

Returns:StateObject

The given item

Annotations
@Override
parseback to summary
public void parse(String jpqlFragment)

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectClauseStateObject.parse.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectClauseStateObject.parse.

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:String

The portion of the query representing one or several select items

Annotations
@Override
removeItemback to summary
public void removeItem(StateObject stateObject)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.removeItem.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.removeItem.

Removes the given StateObject from the list of children.

Parameters
stateObject:StateObject

The child StateObject to not longer be a child

Annotations
@Override
removeItemsback to summary
public void removeItems(Collection<StateObject> items)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.removeItems.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.removeItems.

Removes the given StateObject from the list of children.

Parameters
items:Collection<StateObject>

The StateObjects to remove from this one

Annotations
@Override
removeListChangeListenerback to summary
public void removeListChangeListener(String listName, IListChangeListener<StateObject> listener)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.removeListChangeListener.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.ListHolderStateObject.removeListChangeListener.

Unregisters the given IListChangeListener that was registered for the specified list. The listener will no longer be notified only when items are added, removed, moved from the list.

Parameters
listName:String

The name of the list for which the listener was registered

listener:IListChangeListener<StateObject>

The listener to unregister

Annotations
@Override
setExpressionback to summary
public void setExpression(SelectClause 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:SelectClause

The parsed object representing a SELECT clause

setItemsback to summary
public void setItems(List<StateObject> stateObjects)

Sets the select expression to be those contained on the given collection. If any select items were already set, they will be removed.

Parameters
stateObjects:List<StateObject>

The new select expressions

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

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.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