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

public Class OrderByClauseStateObject

extends AbstractListHolderStateObject<OrderByItemStateObject>
Class Inheritance
Annotations
@SuppressWarnings:nls, unused
Imports
java.io.IOException, org.eclipse.persistence.jpa.jpql.parser.InternalOrderByItemBNF, .OrderByClause, .OrderByItem.Ordering, .OrderByItemBNF

The ORDER BY clause allows the objects or values that are returned by the query to be ordered.

BNF: orderby_clause ::= ORDER BY orderby_item {, orderby_item}*

Author
Pascal Filion
Since
2.4
Version
2.4
See Also
OrderByClause

Field Summary

Modifier and TypeField and Description
public static final String
ORDER_BY_ITEMS_LIST

Notify the list of StateObjects representing the ORDER BY items.

Constructor Summary

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

Creates a new OrderByClauseStateObject.

Method Summary

Modifier and TypeMethod and Description
public void
public OrderByItemStateObject

Returns:

The newly added OrderByItemStateObject
addItem
()

Adds a new ORDER BY item to this clause.

public OrderByItemStateObject
public OrderByItemStateObject

Returns:

The newly added OrderByItemStateObject
addItem
(String...
The child StateObject to become a child of this one return The given item
paths
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractListHolderStateObject.addItem.

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

Adds a new ORDER BY item to this clause.
public OrderByItemStateObject

Returns:

The newly added OrderByItemStateObject
addItem
(String
The identification variable or the result variable
variable
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractListHolderStateObject.addItem.

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

Adds a new ORDER BY item to this clause.
public OrderByItemStateObject

Returns:

The newly added OrderByItemStateObject
addItem
(String
The identification variable or the result variable
path
,
OrderByItem.Ordering
The ascending order
ordering
)

Adds a new ORDER BY item to this clause.

public OrderByItemStateObject

Returns:

The newly added OrderByItemStateObject
addItemAsc
(String
The identification variable or the result variable
variable
)

Adds a new ORDER BY item to this clause with ASC.

public OrderByItemStateObject

Returns:

The newly added OrderByItemStateObject
addItemDesc
(String
The identification variable or the result variable
variable
)

Adds a new ORDER BY item to this clause with DESC.

public OrderByItemStateObject

Returns:

The newly added OrderByItemStateObject
addOrderByItem
(String[]
The paths or the item
paths
,
OrderByItem.Ordering
The ascending order
ordering
)

Adds a new ORDER BY item to this clause.

public OrderByClause
getExpression()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.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 SelectStatementStateObject
public boolean
isEquivalent(StateObject
The StateObject to compare its content to this one
stateObject
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.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.
protected String
listName()

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractListHolderStateObject.listName.

Returns the name that is uniquely identifying the list.
public void
parse(String
The portion of the query to parse
jpqlFragment
)

Parses the given JPQL fragment, which represents either a single or many ordering items, the fragment will be parsed and converted into OrderByItemStateObject.

public void
setExpression(OrderByClause
The parsed object representing an ORDER BY 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.

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.AbstractListHolderStateObject:
addChildrenaddItemsaddListChangeListenerareChildrenEquivalentcanMoveDowncanMoveUpgetItemhasItemsinitializeitemsitemsSizemoveDownmoveUpremoveItemremoveItemsremoveListChangeListenertoStringItems

Field Detail

ORDER_BY_ITEMS_LISTback to summary
public static final String ORDER_BY_ITEMS_LIST

Notify the list of StateObjects representing the ORDER BY items.

Constructor Detail

OrderByClauseStateObjectback to summary
public OrderByClauseStateObject(SelectStatementStateObject parent)

Creates a new OrderByClauseStateObject.

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

Adds a new ORDER BY item to this clause.

Returns:OrderByItemStateObject

The newly added OrderByItemStateObject

addItemback to summary
public OrderByItemStateObject addItem(OrderByItem.Ordering ordering)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractListHolderStateObject.addItem.

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

Adds a new ORDER BY item to this clause.

Parameters
ordering:OrderByItem.Ordering

The ascending order

Returns:OrderByItemStateObject

The newly added OrderByItemStateObject

addItemback to summary
public OrderByItemStateObject addItem(String... paths)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractListHolderStateObject.addItem.

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

Adds a new ORDER BY item to this clause.

Parameters
paths:String[]

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

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

Returns:OrderByItemStateObject

The newly added OrderByItemStateObject

addItemback to summary
public OrderByItemStateObject addItem(String variable)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractListHolderStateObject.addItem.

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

Adds a new ORDER BY item to this clause.

Parameters
variable:String

The identification variable or the result variable

Returns:OrderByItemStateObject

The newly added OrderByItemStateObject

addItemback to summary
public OrderByItemStateObject addItem(String path, OrderByItem.Ordering ordering)

Adds a new ORDER BY item to this clause.

Parameters
path:String

The identification variable or the result variable

ordering:OrderByItem.Ordering

The ascending order

Returns:OrderByItemStateObject

The newly added OrderByItemStateObject

addItemAscback to summary
public OrderByItemStateObject addItemAsc(String variable)

Adds a new ORDER BY item to this clause with ASC.

Parameters
variable:String

The identification variable or the result variable

Returns:OrderByItemStateObject

The newly added OrderByItemStateObject

addItemDescback to summary
public OrderByItemStateObject addItemDesc(String variable)

Adds a new ORDER BY item to this clause with DESC.

Parameters
variable:String

The identification variable or the result variable

Returns:OrderByItemStateObject

The newly added OrderByItemStateObject

addOrderByItemback to summary
public OrderByItemStateObject addOrderByItem(String[] paths, OrderByItem.Ordering ordering)

Adds a new ORDER BY item to this clause.

Parameters
paths:String[]

The paths or the item

ordering:OrderByItem.Ordering

The ascending order

Returns:OrderByItemStateObject

The newly added OrderByItemStateObject

getExpressionback to summary
public OrderByClause getExpression()

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

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
getParentback to summary
public SelectStatementStateObject 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:SelectStatementStateObject

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

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

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.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
listNameback to summary
protected String listName()

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractListHolderStateObject.listName.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractListHolderStateObject.listName.

Returns the name that is uniquely identifying the list.

Returns:String

The unique name identifying the list

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

Parses the given JPQL fragment, which represents either a single or many ordering items, the fragment will be parsed and converted into OrderByItemStateObject.

Parameters
jpqlFragment:String

The portion of the query to parse

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

The parsed object representing an ORDER BY clause

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