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

public abstract Class AggregateFunction

extends AbstractSingleEncapsulatedExpression
Class Inheritance
Known Direct Subclasses
org.eclipse.persistence.jpa.jpql.parser.AvgFunction, org.eclipse.persistence.jpa.jpql.parser.CountFunction, org.eclipse.persistence.jpa.jpql.parser.MaxFunction, org.eclipse.persistence.jpa.jpql.parser.MinFunction, org.eclipse.persistence.jpa.jpql.parser.SumFunction
Imports
java.util.List, org.eclipse.persistence.jpa.jpql.ExpressionTools, .WordParser

In the SELECT clause the result of a query may be the result of an aggregate function applied to a path expression. The following aggregate functions can be used in the SELECT clause of a query: AVG, COUNT, MAX, MIN, SUM.

A single_valued_association_field is designated by the name of an association-field in a one-to-one or many-to-one relationship. The type of a single_valued_association_field and thus a single_valued_association_path_expression is the abstract schema type of the related entity.

The argument to an aggregate function may be preceded by the keyword DISTINCT to specify that duplicate values are to be eliminated before the aggregate function is applied. Null values are eliminated before the aggregate function is applied, regardless of whether the keyword DISTINCT is specified.

BNF: aggregate_expression ::= { AVG | MAX | MIN | SUM } ([DISTINCT] state_field_path_expression) | COUNT ([DISTINCT] identification_variable | state_field_path_expression | single_valued_object_path_expression)
Author
Pascal Filion
Since
2.3
Version
2.5
See Also
AvgFunction, CountFunction, MaxFunction, MinFunction, SumFunction

Field Summary

Modifier and TypeField and Description
private String
distinctIdentifier

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

private boolean
hasSpaceAfterDistinct

Determines whether whitespace was found after the identifier DISTINCT.

Constructor Summary

AccessConstructor and Description
protected
AggregateFunction(AbstractExpression
The parent of this expression
parent
,
String
The JPQL identifier that starts this expression
identifier
)

Creates a new AggregateFunction.

Method Summary

Modifier and TypeMethod and Description
protected void
addOrderedEncapsulatedExpressionTo(List<Expression>
The list used to store the string representation of the encapsulated Expression
children
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression.addOrderedEncapsulatedExpressionTo.

Adds the Expressions representing the encapsulated Expression.
protected AbstractExpression

Returns:

The encapsulated AbstractExpression
buildEncapsulatedExpression
(WordParser wordParser, String
The word that was parsed
word
)

Creates the AbstractExpression to represent the given word.

public String

Returns:

The DISTINCT identifier that was actually parsed, or an empty string if it was not parsed
getActualDistinctIdentifier
()

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

public String
public JPQLQueryBNF
public final boolean

Returns:

true if the query has DISTINCT; false otherwise
hasDistinct
()

Determines whether the DISTINCT identifier was specified in the query.

public final boolean

Returns:

true if there was a whitespace after DISTINCT; false otherwise
hasSpaceAfterDistinct
()

Determines whether a whitespace was parsed after DISTINCT.

protected final void
parseEncapsulatedExpression(WordParser
The text to parse based on the current position of the cursor
wordParser
,
int
The number of whitespace characters that were parsed after '('
whitespaceCount
,
boolean
Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries
tolerant
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression.parseEncapsulatedExpression.

Parses the encapsulated expression by starting at the current position, which is part of the given WordParser.
protected void
toParsedTextEncapsulatedExpression(StringBuilder
The buffer used to append the encapsulated Expression's string representation
writer
,
boolean
Determines whether to include any characters that are considered virtual, i.e. that was parsed when the query is incomplete and is needed for functionality like content assist
actual
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression.toParsedTextEncapsulatedExpression.

Generates a string representation of the encapsulated Expression.
Inherited from org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression:
acceptChildrenaddChildrenTofindQueryBNFgetExpressionhasEncapsulatedExpressionhasExpressionremoveEncapsulatedExpressionsetExpression

Field Detail

distinctIdentifierback to summary
private String distinctIdentifier

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

hasSpaceAfterDistinctback to summary
private boolean hasSpaceAfterDistinct

Determines whether whitespace was found after the identifier DISTINCT.

Constructor Detail

AggregateFunctionback to summary
protected AggregateFunction(AbstractExpression parent, String identifier)

Creates a new AggregateFunction.

Parameters
parent:AbstractExpression

The parent of this expression

identifier:String

The JPQL identifier that starts this expression

Method Detail

addOrderedEncapsulatedExpressionToback to summary
protected void addOrderedEncapsulatedExpressionTo(List<Expression> children)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression.addOrderedEncapsulatedExpressionTo.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.addOrderedEncapsulatedExpressionTo.

Adds the Expressions representing the encapsulated Expression.

Parameters
children:List<Expression>

The list used to store the string representation of the encapsulated Expression

Annotations
@Override
buildEncapsulatedExpressionback to summary
protected AbstractExpression buildEncapsulatedExpression(WordParser wordParser, String word)

Creates the AbstractExpression to represent the given word.

Parameters
word:String

The word that was parsed

Returns:AbstractExpression

The encapsulated AbstractExpression

getActualDistinctIdentifierback to summary
public String getActualDistinctIdentifier()

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

Returns:String

The DISTINCT identifier that was actually parsed, or an empty string if it was not parsed

getEncapsulatedExpressionQueryBNFIdback to summary
public String getEncapsulatedExpressionQueryBNFId()

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression.getEncapsulatedExpressionQueryBNFId.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression.getEncapsulatedExpressionQueryBNFId.

Returns the BNF used to parse the encapsulated expression.

Returns:String

The BNF used to parse the encapsulated expression

Annotations
@Override
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
hasDistinctback to summary
public final boolean hasDistinct()

Determines whether the DISTINCT identifier was specified in the query.

Returns:boolean

true if the query has DISTINCT; false otherwise

hasSpaceAfterDistinctback to summary
public final boolean hasSpaceAfterDistinct()

Determines whether a whitespace was parsed after DISTINCT.

Returns:boolean

true if there was a whitespace after DISTINCT; false otherwise

parseEncapsulatedExpressionback to summary
protected final void parseEncapsulatedExpression(WordParser wordParser, int whitespaceCount, boolean tolerant)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression.parseEncapsulatedExpression.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.parseEncapsulatedExpression.

Parses the encapsulated expression 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

whitespaceCount:int

The number of whitespace characters that were parsed after '('

tolerant:boolean

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

Annotations
@Override
toParsedTextEncapsulatedExpressionback to summary
protected void toParsedTextEncapsulatedExpression(StringBuilder writer, boolean actual)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression.toParsedTextEncapsulatedExpression.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.toParsedTextEncapsulatedExpression.

Generates a string representation of the encapsulated Expression.

Parameters
writer:StringBuilder

The buffer used to append the encapsulated Expression's string representation

actual:boolean

Determines whether to include any characters that are considered virtual, i.e. that was parsed when the query is incomplete and is needed for functionality like content assist

Annotations
@Override