Class OrderByClauseStateObject
- java.lang.Object
-
- org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
-
- org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractListHolderStateObject<OrderByItemStateObject>
-
- org.eclipse.persistence.jpa.jpql.tools.model.query.OrderByClauseStateObject
-
- All Implemented Interfaces:
ListHolderStateObject<OrderByItemStateObject>,StateObject
public class OrderByClauseStateObject extends AbstractListHolderStateObject<OrderByItemStateObject>
TheORDER BYclause allows the objects or values that are returned by the query to be ordered.BNF:orderby_clause ::= ORDER BYorderby_item{,orderby_item}*- Version:
- 2.4
- See Also:
OrderByClause- Author:
- Pascal Filion
- Since:
- 2.4
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringORDER_BY_ITEMS_LISTNotify the list ofStateObjectsrepresenting theORDER BYitems.
-
Constructor Summary
Constructors Constructor Description OrderByClauseStateObject(SelectStatementStateObject parent)Creates a newOrderByClauseStateObject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(StateObjectVisitor visitor)Visits thisStateObjectby the givenvisitor.OrderByItemStateObjectaddItem()Adds a newORDER BYitem to this clause.OrderByItemStateObjectaddItem(java.lang.String variable)Adds a newORDER BYitem to this clause.OrderByItemStateObjectaddItem(java.lang.String... paths)Adds a newORDER BYitem to this clause.OrderByItemStateObjectaddItem(java.lang.String path, OrderByItem.Ordering ordering)Adds a newORDER BYitem to this clause.OrderByItemStateObjectaddItem(OrderByItem.Ordering ordering)Adds a newORDER BYitem to this clause.OrderByItemStateObjectaddItemAsc(java.lang.String variable)Adds a newORDER BYitem to this clause withASC.OrderByItemStateObjectaddItemDesc(java.lang.String variable)Adds a newORDER BYitem to this clause withDESC.OrderByItemStateObjectaddOrderByItem(java.lang.String[] paths, OrderByItem.Ordering ordering)Adds a newORDER BYitem to this clause.OrderByClausegetExpression()Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.SelectStatementStateObjectgetParent()Returns the parent of thisStateObject.booleanisEquivalent(StateObject stateObject)Determines whether the givenStateObjectis equivalent to this one, i.e. the information of bothStateObjectis the same.protected java.lang.StringlistName()Returns the name that is uniquely identifying the list.voidparse(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 intoOrderByItemStateObject.voidsetExpression(OrderByClause expression)Keeps a reference of theparsed objectobject, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects.protected voidtoTextInternal(java.lang.Appendable writer)Prints out a string representation of thisStateObject, which should not be used to define atruestring representation of a JPQL query but should be used for debugging purposes.-
Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.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.tools.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.tools.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 ofStateObjectsrepresenting theORDER BYitems.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OrderByClauseStateObject
public OrderByClauseStateObject(SelectStatementStateObject parent)
Creates a newOrderByClauseStateObject.- Parameters:
parent- The parent of this state object, which cannot benull- Throws:
java.lang.NullPointerException- The given parent cannot benull
-
-
Method Detail
-
accept
public void accept(StateObjectVisitor visitor)
Visits thisStateObjectby the givenvisitor.- Parameters:
visitor- Thevisitorto visit this object
-
addItem
public OrderByItemStateObject addItem()
Adds a newORDER BYitem to this clause.- Returns:
- The newly added
OrderByItemStateObject
-
addItem
public OrderByItemStateObject addItem(OrderByItem.Ordering ordering)
Adds a newORDER BYitem to this clause.- Parameters:
ordering- The ascending order- Returns:
- The newly added
OrderByItemStateObject
-
addItem
public OrderByItemStateObject addItem(java.lang.String... paths)
Adds a newORDER BYitem to this clause.- Returns:
- The newly added
OrderByItemStateObject
-
addItem
public OrderByItemStateObject addItem(java.lang.String variable)
Adds a newORDER BYitem 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 newORDER BYitem to this clause.- Parameters:
path- The identification variable or the result variableordering- The ascending order- Returns:
- The newly added
OrderByItemStateObject
-
addItemAsc
public OrderByItemStateObject addItemAsc(java.lang.String variable)
Adds a newORDER BYitem to this clause withASC.- Parameters:
variable- The identification variable or the result variable- Returns:
- The newly added
OrderByItemStateObject
-
addItemDesc
public OrderByItemStateObject addItemDesc(java.lang.String variable)
Adds a newORDER BYitem to this clause withDESC.- 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 newORDER BYitem to this clause.- Parameters:
paths- The paths or the itemordering- The ascending order- Returns:
- The newly added
OrderByItemStateObject
-
getExpression
public OrderByClause getExpression()
Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.- Specified by:
getExpressionin interfaceStateObject- Overrides:
getExpressionin classAbstractStateObject- Returns:
- The parsed object when a JPQL query is parsed and converted into a
StateObjectornullwhen the JPQL query is manually created (i.e. not from a string)
-
getParent
public SelectStatementStateObject getParent()
Returns the parent of thisStateObject.- Specified by:
getParentin interfaceStateObject- Overrides:
getParentin classAbstractStateObject- Returns:
- Returns the parent of this
StateObject, which isnullonly when this is the root of the hierarchy
-
isEquivalent
public boolean isEquivalent(StateObject stateObject)
Determines whether the givenStateObjectis equivalent to this one, i.e. the information of bothStateObjectis the same.- Specified by:
isEquivalentin interfaceStateObject- Overrides:
isEquivalentin classAbstractStateObject- Parameters:
stateObject- TheStateObjectto compare its content to this one- Returns:
trueif both object are equivalent;falseotherwise
-
listName
protected java.lang.String listName()
Returns the name that is uniquely identifying the list.- Specified by:
listNamein classAbstractListHolderStateObject<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 intoOrderByItemStateObject.- Parameters:
jpqlFragment- The portion of the query to parse
-
setExpression
public void setExpression(OrderByClause expression)
Keeps a reference of theparsed objectobject, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects.- Parameters:
expression- Theparsed objectrepresenting anORDER BYclause
-
toTextInternal
protected void toTextInternal(java.lang.Appendable writer) throws java.io.IOExceptionPrints out a string representation of thisStateObject, which should not be used to define atruestring representation of a JPQL query but should be used for debugging purposes.- Specified by:
toTextInternalin classAbstractStateObject- Parameters:
writer- The writer used to print out the string representation- Throws:
java.io.IOException- This should never happens, it is only required becauseAppendableis used instead of any concrete class
-
-