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

public Class OrderByItemStateObject

extends AbstractStateObject
Class Inheritance
Annotations
@SuppressWarnings:nls
Imports
java.io.IOException, java.util.List, org.eclipse.persistence.jpa.jpql.Assert, org.eclipse.persistence.jpa.jpql.parser.OrderByItem, .OrderByItem.Ordering, .OrderByItemBNF

An ORDER BY item must be one of the following:
  1. A state_field_path_expression that evaluates to an orderable state field of an entity or embeddable class abstract schema type designated in the SELECT clause by one of the following:
    • A general_identification_variable
    • A single_valued_object_path_expression
  2. A state_field_path_expression that evaluates to the same state field of the same entity or embeddable abstract schema type as a state_field_path_expression in the SELECT clause
  3. A result_variable that refers to an orderable item in the SELECT clause for which the same result_variable has been specified. This may be the result of an aggregate_expression, a scalar_expression, or a state_field_path_expression in the SELECT clause.

The keyword ASC specifies that ascending ordering be used for the associated ORDER BY item; the keyword DESC specifies that descending ordering be used. Ascending ordering is the default.

JPA 1.0:

BNF: orderby_item ::= state_field_path_expression [ ASC | DESC ]

JPA 2.0

BNF: orderby_item ::= state_field_path_expression | result_variable [ ASC | DESC ]

Author
Pascal Filion
Since
2.4
Version
2.4
See Also
OrderByItem

Field Summary

Modifier and TypeField and Description
private OrderByItem.Ordering
ordering

The ascending ordering.

public static final String
ORDERING_PROPERTY

Notifies the ordering property has changed.

public static final String
STATE_OBJECT_PROPERTY

Notifies the ordering property has changed.

private StateObject
stateObject

The StateObject representing the order by item.

Constructor Summary

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

Creates a new OrderByItemStateObject.

public
OrderByItemStateObject(OrderByClauseStateObject
The parent of this state object, which cannot be null
parent
,
OrderByItem.Ordering ordering)

Creates a new OrderByItemStateObject.

public
OrderByItemStateObject(OrderByClauseStateObject
The parent of this state object, which cannot be null
parent
,
StateObject
The StateObject of the item
stateObject
,
OrderByItem.Ordering
One of the possible Ordering choice
ordering
)

Creates a new OrderByItemStateObject.

public
OrderByItemStateObject(OrderByClauseStateObject
The parent of this state object, which cannot be null
parent
,
String
The JPQL fragment representing the ordering item
jpqlFragment
,
OrderByItem.Ordering
One of the possible Ordering choice
ordering
)

Creates a new OrderByItemStateObject.

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 OrderByItem
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 OrderByItem.Ordering

Returns:

The constant representing the ordering, in the case the ordering was not parsed, then Ordering#DEFAULT is returned
getOrdering
()

Returns the enum constant representing the ordering type.

public OrderByClauseStateObject
public StateObject

Returns:

The StateObject representing the value used for ordering
getStateObject
()

Returns the StateObject representing the value used for ordering.

public boolean

Returns:

true if the ordering value is defined; false otherwise
hasStateObject
()

Determines whether the StateObject representing the value used for ordering has been defined.

public boolean

Returns:

true if ASC was parsed; false otherwise
isAscending
()

Determines whether the ordering was specified as being ascendant.

public boolean

Returns:

true if no ordering was parsed; false otherwise
isDefault
()

Determines whether the ordering was not specified.

public boolean

Returns:

true if DESC was parsed; false otherwise
isDescending
()

Determines whether the ordering was specified as being descendant.

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.
public void
parse(String
The portion of the query representing a state-field path expression or result variable
jpqlFragment
)

Parses the given JPQL fragment, which represents either a state-field pathe expression or a result variable, and creates the StateObject.

public void
removeOrdering()

Removes the ordering if it's specified, otherwise do nothing.

public void
setExpression(OrderByItem
The parsed object representing an order by item
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
setOrdering(OrderByItem.Ordering
The constant representing the ordering, in the case the ordering was not parsed, then Ordering#DEFAULT should be used
ordering
)

Sets the enum constant representing the ordering type.

public void
setStateObject(StateObject
The StateObject representing the value used for ordering
stateObject
)

Sets the StateObject representing the value used for ordering.

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.
private void
Inherited from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject:
acceptUnknownVisitoracceptUnknownVisitoraddProblemsaddPropertyChangeListenerareEquivalentbuildProblembuildProblembuildStateObjectbuildStateObjectscheckParentchildrendecorateequalsfindIdentificationVariablefirePropertyChangedgetChangeSupportgetDeclarationgetDecoratorgetGrammargetManagedTypeProvidergetQueryBuildergetRootgetTypegetTypegetTypeHelpergetTypeRepositoryhashCodeinitializeisDecoratedparentparentparentremovePropertyChangeListenersetExpressionsetParenttoStringtoStringtoStringInternaltoStringItemstoText

Field Detail

orderingback to summary
private OrderByItem.Ordering ordering

The ascending ordering.

ORDERING_PROPERTYback to summary
public static final String ORDERING_PROPERTY

Notifies the ordering property has changed.

STATE_OBJECT_PROPERTYback to summary
public static final String STATE_OBJECT_PROPERTY

Notifies the ordering property has changed.

stateObjectback to summary
private StateObject stateObject

The StateObject representing the order by item.

Constructor Detail

OrderByItemStateObjectback to summary
public OrderByItemStateObject(OrderByClauseStateObject parent)

Creates a new OrderByItemStateObject.

Parameters
parent:OrderByClauseStateObject

The parent of this state object, which cannot be null

Exceptions
NullPointerException:
The given parent cannot be null
OrderByItemStateObjectback to summary
public OrderByItemStateObject(OrderByClauseStateObject parent, OrderByItem.Ordering ordering)

Creates a new OrderByItemStateObject.

Parameters
parent:OrderByClauseStateObject

The parent of this state object, which cannot be null

Exceptions
NullPointerException:
The given parent cannot be null
OrderByItemStateObjectback to summary
public OrderByItemStateObject(OrderByClauseStateObject parent, StateObject stateObject, OrderByItem.Ordering ordering)

Creates a new OrderByItemStateObject.

Parameters
parent:OrderByClauseStateObject

The parent of this state object, which cannot be null

stateObject:StateObject

The StateObject of the item

ordering:OrderByItem.Ordering

One of the possible Ordering choice

Exceptions
NullPointerException:
The given parent cannot be null
OrderByItemStateObjectback to summary
public OrderByItemStateObject(OrderByClauseStateObject parent, String jpqlFragment, OrderByItem.Ordering ordering)

Creates a new OrderByItemStateObject.

Parameters
parent:OrderByClauseStateObject

The parent of this state object, which cannot be null

jpqlFragment:String

The JPQL fragment representing the ordering item

ordering:OrderByItem.Ordering

One of the possible Ordering choice

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
getExpressionback to summary
public OrderByItem 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:OrderByItem

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
getOrderingback to summary
public OrderByItem.Ordering getOrdering()

Returns the enum constant representing the ordering type.

Returns:OrderByItem.Ordering

The constant representing the ordering, in the case the ordering was not parsed, then Ordering#DEFAULT is returned

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

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

Annotations
@Override
getStateObjectback to summary
public StateObject getStateObject()

Returns the StateObject representing the value used for ordering.

Returns:StateObject

The StateObject representing the value used for ordering

hasStateObjectback to summary
public boolean hasStateObject()

Determines whether the StateObject representing the value used for ordering has been defined.

Returns:boolean

true if the ordering value is defined; false otherwise

isAscendingback to summary
public boolean isAscending()

Determines whether the ordering was specified as being ascendant.

Returns:boolean

true if ASC was parsed; false otherwise

isDefaultback to summary
public boolean isDefault()

Determines whether the ordering was not specified.

Returns:boolean

true if no ordering was parsed; false otherwise

isDescendingback to summary
public boolean isDescending()

Determines whether the ordering was specified as being descendant.

Returns:boolean

true if DESC was parsed; false otherwise

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
parseback to summary
public void parse(String jpqlFragment)

Parses the given JPQL fragment, which represents either a state-field pathe expression or a result variable, and creates the StateObject.

Parameters
jpqlFragment:String

The portion of the query representing a state-field path expression or result variable

removeOrderingback to summary
public void removeOrdering()

Removes the ordering if it's specified, otherwise do nothing.

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

The parsed object representing an order by item

setOrderingback to summary
public void setOrdering(OrderByItem.Ordering ordering)

Sets the enum constant representing the ordering type.

Parameters
ordering:OrderByItem.Ordering

The constant representing the ordering, in the case the ordering was not parsed, then Ordering#DEFAULT should be used

setStateObjectback to summary
public void setStateObject(StateObject stateObject)

Sets the StateObject representing the value used for ordering.

Parameters
stateObject:StateObject

The StateObject representing the value used for ordering

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
validateOrderingback to summary
private void validateOrdering(OrderByItem.Ordering ordering)