Top Description Inners Fields Constructors Methods
org.eclipse.persistence.jpa.jpql.parser

public final Class OrderByItem

extends AbstractExpression
Class Inheritance
Annotations
@SuppressWarnings:nls
Imports
java.util.Collection, .List, org.eclipse.persistence.jpa.jpql.ExpressionTools, .WordParser

An orderby_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 orderby_item; the keyword DESC specifies that descending ordering be used. Ascending ordering is the default.
The keyword NULLS FIRST specifies that nulls first ordering be used for the associated orderby_item; the keyword NULLS LAST specifies that nulls last 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 ]

EclipseLink 2.4:
BNF: orderby_item ::= state_field_path_expression | result_variable [ ASC | DESC ] [ NULLS FIRST | NULLS LAST ]
Author
Pascal Filion
Since
2.3
Version
2.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
OrderByItem.NullOrdering

This enumeration lists all the possible choices for ordering nulls in an item.

public static enum
OrderByItem.Ordering

This enumeration lists all the possible choices for ordering an item.

Field Summary

Modifier and TypeField and Description
private AbstractExpression
expression

The Expression representing the order by expression.

private String
firstIdentifier

The actual 'FIRST' identifier found in the string representation of the JPQL query.

private boolean
hasSpaceAfterExpression

Determines whether a whitespace was parsed after the order by expression.

private boolean
hasSpaceAfterNulls

Determines whether a whitespace was parsed after NULLS.

private boolean
hasSpaceAfterOrdering

Determines whether a whitespace was parsed after the ordering.

private String
lastIdentifier

The actual 'LAST' identifier found in the string representation of the JPQL query.

private OrderByItem.NullOrdering
nullOrdering

The keyword NULLS FIRST specifies ordering null first; the keyword NULLS LAST specifies ordering nulls last.

private String
nullsIdentifier

The actual 'NULLS' identifier found in the string representation of the JPQL query.

private OrderByItem.Ordering
ordering

The keyword ASC specifies that ascending ordering be used; the keyword DESC specifies that descending ordering be used.

private String
orderingIdentifier

The actual ordering identifier found in the string representation of the JPQL query.

Inherited from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression:
COMMADOTDOUBLE_QUOTELEFT_CURLY_BRACKETLEFT_PARENTHESISNOT_DEFINEDRIGHT_CURLY_BRACKETRIGHT_PARENTHESISSINGLE_QUOTESPACEUNDERSCORE

Constructor Summary

AccessConstructor and Description
public
OrderByItem(AbstractExpression
The parent of this expression
parent
)

Creates a new OrderByItem.

Method Summary

Modifier and TypeMethod and Description
public void
accept(ExpressionVisitor
The ExpressionVisitor to visit this object
visitor
)

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.accept.

Visits this Expression by the given visitor.
public void
acceptChildren(ExpressionVisitor
The visitor to visit the children of this object.
visitor
)

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.acceptChildren.

Visits the children of this Expression.
protected void
addChildrenTo(Collection<Expression>
The collection used to store the children
children
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addChildrenTo.

Adds the children of this AbstractExpression to the given collection.
protected void
addOrderedChildrenTo(List<Expression>
The list used to store the string representation of this AbstractExpression
children
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addOrderedChildrenTo.

Adds the children of this AbstractExpression to the given list.
public JPQLQueryBNF
findQueryBNF(Expression
The Expression that is a descendant of this one
expression
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.findQueryBNF.

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.findQueryBNF.

Retrieves the JPQLQueryBNF that represents the fragment of this Expression that was used when parsing the given Expression.
public String

Returns:

The null ordering identifier that was actually parsed, if one was present, otherwise an empty string is returned
getActualNullOrdering
()

Returns the actual null ordering identifier found in the string representation of the JPQL query, which has the actual case that was used.

public String

Returns:

The ordering identifier that was actually parsed, if one was present, otherwise an empty string is returned
getActualOrdering
()

Returns the actual ordering identifier found in the string representation of the JPQL query, which has the actual case that was used.

public Expression

Returns:

The expression that was parsed representing the order by expression
getExpression
()

Returns the Expression that represents the order by expression.

public OrderByItem.NullOrdering

Returns:

The constant representing the null ordering, in the case the ordering was not parsed, then NullOrdering#DEFAULT is returned
getNullOrdering
()

Returns the enum constant representing the null ordering type.

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 JPQLQueryBNF
public boolean

Returns:

true if the order by expression was parsed; false otherwise
hasExpression
()

Determines whether the order by expression was parsed.

public boolean

Returns:

true if the NULLS identifier was parsed; false otherwise
hasNulls
()

Determines whether the NULLS identifier was parsed.

public boolean

Returns:

true if the ordering status was parsed; false otherwise
hasOrdering
()

Determines whether ASC or DESC was parsed.

public boolean

Returns:

true if there was a whitespace after the order by expression; false otherwise
hasSpaceAfterExpression
()

Determines whether a whitespace was parsed after the order by expression.

public boolean

Returns:

true if there was a whitespace after the NULLS identifier; false otherwise
hasSpaceAfterNulls
()

Determines whether a whitespace was parsed after the NULLS identifier.

public boolean

Returns:

true if there was a whitespace after the ordering; false otherwise
hasSpaceAfterOrdering
()

Determines whether a whitespace was parsed after the ordering.

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

Returns:

true if NULLS FIRST was parsed; false otherwise
isNullsFirst
()

Determines whether the ordering was specified as being nulls first.

public boolean

Returns:

true if NULLS LAST was parsed; false otherwise
isNullsLast
()

Determines whether the ordering was specified as being nulls first.

protected boolean
isParsingComplete(WordParser
The text to parse based on the current position of the cursor
wordParser
,
String
The word that was retrieved from the given text, which is the first word in the text
word
,
Expression
The Expression that has already been parsed
expression
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.isParsingComplete.

Determines whether the parsing is complete based on what is left in the given text.
protected void
parse(WordParser
The text to parse based on the current position of the cursor
wordParser
,
boolean
Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries
tolerant
)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.parse.

Parses the query by starting at the current position, which is part of the given WordParser.
protected void
toParsedText(StringBuilder
The buffer used to append this Expression's string representation
writer
,
boolean
Determines whether the string representation should represent what was parsed, i.e. include any "virtual" whitespace (such as ending whitespace) and the actual case of the JPQL identifiers
actual
)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.toParsedText.

Generates a string representation of this Expression, including its children, if it has any.
Inherited from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression:
acceptUnknownVisitoracceptUnknownVisitorbuildExpressionFromFallingBackbuildNullExpressionbuildStringExpressionbuildStringExpressionbuildUnknownExpressioncalculatePositionchildrenfindFallBackExpressionFactorygetExpressionFactorygetExpressionRegistrygetGrammargetIdentifierVersiongetJPAVersiongetLengthgetOffsetgetParentgetQueryBNFgetRootgetTexthandleAggregatehandleCollectionisAncestorisIdentifierisNullisTolerantisUnknownisVirtualorderedChildrenparseparseUsingExpressionFactorypopulatePositionrebuildActualTextrebuildParsedTextsetParentsetTextshouldParseWithFactoryFirstshouldSkipLiteraltoActualTexttoParsedTexttoString

Field Detail

expressionback to summary
private AbstractExpression expression

The Expression representing the order by expression.

firstIdentifierback to summary
private String firstIdentifier

The actual 'FIRST' identifier found in the string representation of the JPQL query.

hasSpaceAfterExpressionback to summary
private boolean hasSpaceAfterExpression

Determines whether a whitespace was parsed after the order by expression.

hasSpaceAfterNullsback to summary
private boolean hasSpaceAfterNulls

Determines whether a whitespace was parsed after NULLS.

hasSpaceAfterOrderingback to summary
private boolean hasSpaceAfterOrdering

Determines whether a whitespace was parsed after the ordering.

lastIdentifierback to summary
private String lastIdentifier

The actual 'LAST' identifier found in the string representation of the JPQL query.

nullOrderingback to summary
private OrderByItem.NullOrdering nullOrdering

The keyword NULLS FIRST specifies ordering null first; the keyword NULLS LAST specifies ordering nulls last.

nullsIdentifierback to summary
private String nullsIdentifier

The actual 'NULLS' identifier found in the string representation of the JPQL query.

orderingback to summary
private OrderByItem.Ordering ordering

The keyword ASC specifies that ascending ordering be used; the keyword DESC specifies that descending ordering be used. Ascending ordering is the default.

orderingIdentifierback to summary
private String orderingIdentifier

The actual ordering identifier found in the string representation of the JPQL query.

Constructor Detail

OrderByItemback to summary
public OrderByItem(AbstractExpression parent)

Creates a new OrderByItem.

Parameters
parent:AbstractExpression

The parent of this expression

Method Detail

acceptback to summary
public void accept(ExpressionVisitor visitor)

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.accept.

Doc from org.eclipse.persistence.jpa.jpql.parser.Expression.accept.

Visits this Expression by the given visitor.

Parameters
visitor:ExpressionVisitor

The ExpressionVisitor to visit this object

Annotations
@Override
acceptChildrenback to summary
public void acceptChildren(ExpressionVisitor visitor)

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.acceptChildren.

Doc from org.eclipse.persistence.jpa.jpql.parser.Expression.acceptChildren.

Visits the children of this Expression. This method can be used to optimize traversing the children since a new list is not created every time children() is called.

This does not traverse the Expression sub-hierarchy, use a subclass of AbstractTraverseChildrenVisitor in order to traverse the entire sub-hierarchy.

Parameters
visitor:ExpressionVisitor

The visitor to visit the children of this object.

Annotations
@Override
addChildrenToback to summary
protected void addChildrenTo(Collection<Expression> children)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addChildrenTo.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addChildrenTo.

Adds the children of this AbstractExpression to the given collection.

Parameters
children:Collection<Expression>

The collection used to store the children

Annotations
@Override
addOrderedChildrenToback to summary
protected void addOrderedChildrenTo(List<Expression> children)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addOrderedChildrenTo.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addOrderedChildrenTo.

Adds the children of this AbstractExpression to the given list.

Parameters
children:List<Expression>

The list used to store the string representation of this AbstractExpression

Annotations
@Override
findQueryBNFback to summary
public JPQLQueryBNF findQueryBNF(Expression expression)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.findQueryBNF.

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.findQueryBNF.

Doc from org.eclipse.persistence.jpa.jpql.parser.Expression.findQueryBNF.

Retrieves the JPQLQueryBNF that represents the fragment of this Expression that was used when parsing the given Expression.

Parameters
expression:Expression

The Expression that is a descendant of this one

Returns:JPQLQueryBNF

The JPQLQueryBNF that was used to parse the given expression

Annotations
@Override
getActualNullOrderingback to summary
public String getActualNullOrdering()

Returns the actual null ordering identifier found in the string representation of the JPQL query, which has the actual case that was used.

Returns:String

The null ordering identifier that was actually parsed, if one was present, otherwise an empty string is returned

getActualOrderingback to summary
public String getActualOrdering()

Returns the actual ordering identifier found in the string representation of the JPQL query, which has the actual case that was used.

Returns:String

The ordering identifier that was actually parsed, if one was present, otherwise an empty string is returned

getExpressionback to summary
public Expression getExpression()

Returns the Expression that represents the order by expression.

Returns:Expression

The expression that was parsed representing the order by expression

getNullOrderingback to summary
public OrderByItem.NullOrdering getNullOrdering()

Returns the enum constant representing the null ordering type.

Returns:OrderByItem.NullOrdering

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

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

getQueryBNFback to summary
public JPQLQueryBNF getQueryBNF()

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.getQueryBNF.

Doc from org.eclipse.persistence.jpa.jpql.parser.Expression.getQueryBNF.

Returns the BNF of this Expression.

Returns:JPQLQueryBNF

The JPQLQueryBNF, which represents the grammar of this Expression

Annotations
@Override
hasExpressionback to summary
public boolean hasExpression()

Determines whether the order by expression was parsed.

Returns:boolean

true if the order by expression was parsed; false otherwise

hasNullsback to summary
public boolean hasNulls()

Determines whether the NULLS identifier was parsed.

Returns:boolean

true if the NULLS identifier was parsed; false otherwise

hasOrderingback to summary
public boolean hasOrdering()

Determines whether ASC or DESC was parsed.

Returns:boolean

true if the ordering status was parsed; false otherwise

Since
2.5
hasSpaceAfterExpressionback to summary
public boolean hasSpaceAfterExpression()

Determines whether a whitespace was parsed after the order by expression.

Returns:boolean

true if there was a whitespace after the order by expression; false otherwise

hasSpaceAfterNullsback to summary
public boolean hasSpaceAfterNulls()

Determines whether a whitespace was parsed after the NULLS identifier. If the composite identifier was fully parsed - NULLS FIRST or NULLS LAST - then this is always true, but if only NULLS was parsed, then this can be useful to determine if there was a space after.

Returns:boolean

true if there was a whitespace after the NULLS identifier; false otherwise

hasSpaceAfterOrderingback to summary
public boolean hasSpaceAfterOrdering()

Determines whether a whitespace was parsed after the ordering.

Returns:boolean

true if there was a whitespace after the ordering; 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

isNullsFirstback to summary
public boolean isNullsFirst()

Determines whether the ordering was specified as being nulls first.

Returns:boolean

true if NULLS FIRST was parsed; false otherwise

isNullsLastback to summary
public boolean isNullsLast()

Determines whether the ordering was specified as being nulls first.

Returns:boolean

true if NULLS LAST was parsed; false otherwise

isParsingCompleteback to summary
protected boolean isParsingComplete(WordParser wordParser, String word, Expression expression)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.isParsingComplete.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.isParsingComplete.

Determines whether the parsing is complete based on what is left in the given text. The text is never empty.

Parameters
wordParser:WordParser

The text to parse based on the current position of the cursor

word:String

The word that was retrieved from the given text, which is the first word in the text

expression:Expression

The Expression that has already been parsed

Returns:boolean

true if the text no longer can't be parsed by the current expression; false if more can be parsed

Annotations
@Override
parseback to summary
protected void parse(WordParser wordParser, boolean tolerant)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.parse.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.parse.

Parses the query by starting at the current position, which is part of the given WordParser.

Parameters
wordParser:WordParser

The text to parse based on the current position of the cursor

tolerant:boolean

Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries

Annotations
@Override
toParsedTextback to summary
protected void toParsedText(StringBuilder writer, boolean actual)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.toParsedText.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.toParsedText.

Generates a string representation of this Expression, including its children, if it has any.

Parameters
writer:StringBuilder

The buffer used to append this Expression's string representation

actual:boolean

Determines whether the string representation should represent what was parsed, i.e. include any "virtual" whitespace (such as ending whitespace) and the actual case of the JPQL identifiers

Annotations
@Override
org.eclipse.persistence.jpa.jpql.parser back to summary

public final Enum OrderByItem.NullOrdering

extends Enum<OrderByItem.NullOrdering>
Class Inheritance

This enumeration lists all the possible choices for ordering nulls in an item.

Field Summary

Modifier and TypeField and Description
public static final OrderByItem.NullOrdering
DEFAULT

The constant used when the ordering is not specify.

private String
identifier

The actual composite identifier.

public static final OrderByItem.NullOrdering
NULLS_FIRST

The constant for 'NULLS FIRST', which tells to order nulls first.

public static final OrderByItem.NullOrdering
NULLS_LAST

The constant for 'NULLS LAST', which tells to order nulls last.

Constructor Summary

AccessConstructor and Description
private
NullOrdering(String
The actual composite identifier
identifier
)

Creates a new NullOrdering.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

The composite identifiers
getIdentifier
()

Returns the actual JPQL composite identifiers identified by this enum constant.

public String
toString()

Overrides java.lang.Enum.toString.

Returns the name of this enum constant, as contained in the declaration.
public static OrderByItem.NullOrdering
public static OrderByItem.NullOrdering[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinalvalueOf

Field Detail

DEFAULTback to summary
public static final OrderByItem.NullOrdering DEFAULT

The constant used when the ordering is not specify.

identifierback to summary
private String identifier

The actual composite identifier.

NULLS_FIRSTback to summary
public static final OrderByItem.NullOrdering NULLS_FIRST

The constant for 'NULLS FIRST', which tells to order nulls first.

NULLS_LASTback to summary
public static final OrderByItem.NullOrdering NULLS_LAST

The constant for 'NULLS LAST', which tells to order nulls last.

Constructor Detail

NullOrderingback to summary
private NullOrdering(String identifier)

Creates a new NullOrdering.

Parameters
identifier:String

The actual composite identifier

Method Detail

getIdentifierback to summary
public String getIdentifier()

Returns the actual JPQL composite identifiers identified by this enum constant.

Returns:String

The composite identifiers

toStringback to summary
public String toString()

Overrides java.lang.Enum.toString.

Doc from java.lang.Enum.toString.

Returns the name of this enum constant, as contained in the declaration. This method may be overridden, though it typically isn't necessary or desirable. An enum class should override this method when a more "programmer-friendly" string form exists.

Returns:String

the name of this enum constant

Annotations
@Override
valueOfback to summary
public static OrderByItem.NullOrdering valueOf(String name)
valuesback to summary
public static OrderByItem.NullOrdering[] values()
org.eclipse.persistence.jpa.jpql.parser back to summary

public final Enum OrderByItem.Ordering

extends Enum<OrderByItem.Ordering>
Class Inheritance

This enumeration lists all the possible choices for ordering an item.

Field Summary

Modifier and TypeField and Description
public static final OrderByItem.Ordering
ASC

The constant for 'ASC', which tells to order the items in ascending ordering.

public static final OrderByItem.Ordering
DEFAULT

The constant used when the ordering is not specify, the default is ascending ordering.

public static final OrderByItem.Ordering
DESC

The constant for 'DESC', which tells to order the items in descending ordering.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static OrderByItem.Ordering
public static OrderByItem.Ordering[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ASCback to summary
public static final OrderByItem.Ordering ASC

The constant for 'ASC', which tells to order the items in ascending ordering.

DEFAULTback to summary
public static final OrderByItem.Ordering DEFAULT

The constant used when the ordering is not specify, the default is ascending ordering.

DESCback to summary
public static final OrderByItem.Ordering DESC

The constant for 'DESC', which tells to order the items in descending ordering.

Constructor Detail

Orderingback to summary
private Ordering()

Method Detail

valueOfback to summary
public static OrderByItem.Ordering valueOf(String name)
valuesback to summary
public static OrderByItem.Ordering[] values()