EclipseLink 2.4.2, build 'v20130514-5956486' API Reference

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

java.lang.Object
  extended by org.eclipse.persistence.jpa.jpql.model.query.AbstractStateObject
      extended by org.eclipse.persistence.jpa.jpql.model.query.AbstractListHolderStateObject<OrderByItemStateObject>
          extended by org.eclipse.persistence.jpa.jpql.model.query.OrderByClauseStateObject
All Implemented Interfaces:
ListHolderStateObject<OrderByItemStateObject>, StateObject

public class OrderByClauseStateObject
extends AbstractListHolderStateObject<OrderByItemStateObject>

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}*

Version:
2.4
See Also:
OrderByClause
Author:
Pascal Filion
Since:
2.4

Field Summary
static java.lang.String ORDER_BY_ITEMS_LIST
          Notify the list of StateObjects representing the ORDER BY items.
 
Constructor Summary
OrderByClauseStateObject(SelectStatementStateObject parent)
          Creates a new OrderByClauseStateObject.
 
Method Summary
 void accept(StateObjectVisitor visitor)
          Visits this StateObject by the given visitor.
 OrderByItemStateObject addItem()
          Adds a new ORDER BY item to this clause.
 OrderByItemStateObject addItem(OrderByItem.Ordering ordering)
          Adds a new ORDER BY item to this clause.
 OrderByItemStateObject addItem(java.lang.String... paths)
          Adds a new ORDER BY item to this clause.
 OrderByItemStateObject addItem(java.lang.String variable)
          Adds a new ORDER BY item to this clause.
 OrderByItemStateObject addItem(java.lang.String path, OrderByItem.Ordering ordering)
          Adds a new ORDER BY item to this clause.
 OrderByItemStateObject addItemAsc(java.lang.String variable)
          Adds a new ORDER BY item to this clause with ASC.
 OrderByItemStateObject addItemDesc(java.lang.String variable)
          Adds a new ORDER BY item to this clause with DESC.
 OrderByItemStateObject addOrderByItem(java.lang.String[] paths, OrderByItem.Ordering ordering)
          Adds a new ORDER BY item to this clause.
 OrderByClause getExpression()
          Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.
 SelectStatementStateObject getParent()
          Returns the parent of this StateObject.
 boolean isEquivalent(StateObject stateObject)
          Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.
protected  java.lang.String listName()
          Returns the name that is uniquely identifying the list.
 void parse(java.lang.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.
 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.
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.AbstractListHolderStateObject
addChildren, addItem, addItems, addListChangeListener, areChildrenEquivalent, canMoveDown, canMoveUp, getItem, hasItems, initialize, items, itemsSize, moveDown, moveUp, removeItem, removeItems, removeListChangeListener, toStringItems
 
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, findIdentificationVariable, firePropertyChanged, getChangeSupport, getDeclaration, getDecorator, getGrammar, getManagedTypeProvider, 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
addPropertyChangeListener, children, decorate, findIdentificationVariable, getDeclaration, getDecorator, getGrammar, getManagedTypeProvider, getQueryBuilder, getRoot, isDecorated, removePropertyChangeListener, setParent, toString, toText
 

Field Detail

ORDER_BY_ITEMS_LIST

public static final java.lang.String ORDER_BY_ITEMS_LIST
Notify the list of StateObjects representing the ORDER BY items.

See Also:
Constant Field Values
Constructor Detail

OrderByClauseStateObject

public OrderByClauseStateObject(SelectStatementStateObject parent)
Creates a new OrderByClauseStateObject.

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

accept

public void accept(StateObjectVisitor visitor)
Visits this StateObject by the given visitor.

Parameters:
visitor - The visitor to visit this object

addItem

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

Returns:
The newly added OrderByItemStateObject

addItem

public OrderByItemStateObject addItem(OrderByItem.Ordering ordering)
Adds a new ORDER BY item to this clause.

Parameters:
ordering - The ascending order
Returns:
The newly added OrderByItemStateObject

addItem

public OrderByItemStateObject addItem(java.lang.String... paths)
Adds a new ORDER BY item to this clause.

Returns:
The newly added OrderByItemStateObject

addItem

public OrderByItemStateObject addItem(java.lang.String variable)
Adds a new ORDER BY item to this clause.

Parameters:
variable - The identification variable or the result variable
Returns:
The newly added OrderByItemStateObject

addItem

public OrderByItemStateObject addItem(java.lang.String path,
                                      OrderByItem.Ordering ordering)
Adds a new ORDER BY item to this clause.

Parameters:
path - The identification variable or the result variable
ordering - The ascending order
Returns:
The newly added OrderByItemStateObject

addItemAsc

public OrderByItemStateObject addItemAsc(java.lang.String variable)
Adds a new ORDER BY item to this clause with ASC.

Parameters:
variable - The identification variable or the result variable
Returns:
The newly added OrderByItemStateObject

addItemDesc

public OrderByItemStateObject addItemDesc(java.lang.String variable)
Adds a new ORDER BY item to this clause with DESC.

Parameters:
variable - The identification variable or the result variable
Returns:
The newly added OrderByItemStateObject

addOrderByItem

public OrderByItemStateObject addOrderByItem(java.lang.String[] paths,
                                             OrderByItem.Ordering ordering)
Adds a new ORDER BY item to this clause.

Parameters:
paths - The paths or the item
ordering - The ascending order
Returns:
The newly added OrderByItemStateObject

getExpression

public OrderByClause 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)

getParent

public SelectStatementStateObject getParent()
Returns the parent of this StateObject.

Specified by:
getParent in interface StateObject
Overrides:
getParent in class AbstractStateObject
Returns:
Returns the parent of this StateObject, which is null only when this is the root of the hierarchy

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

listName

protected java.lang.String listName()
Returns the name that is uniquely identifying the list.

Specified by:
listName in class AbstractListHolderStateObject<OrderByItemStateObject>
Returns:
The unique name identifying the list

parse

public void parse(java.lang.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 - The portion of the query to parse

setExpression

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 - The parsed object representing an ORDER BY

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