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

public final Class ExtractExpression

extends AbstractSingleEncapsulatedExpression
Class Inheritance
Imports
java.util.List, org.eclipse.persistence.jpa.jpql.ExpressionTools, .WordParser

The EXTRACT function extracts a date part from a date/time value. The date part can be YEAR, MONTH, DAY, HOUR, MINUTE, SECOND. Some databases may support other parts.
BNF: extract_expression ::= EXTRACT(date_part_literal [FROM] scalar_expression)

date_part_literal ::= { MICROSECOND | SECOND | MINUTE | HOUR | DAY | WEEK | MONTH | QUARTER | YEAR | SECOND_MICROSECOND | MINUTE_MICROSECOND | MINUTE_SECOND | HOUR_MICROSECOND | HOUR_SECOND | HOUR_MINUTE | DAY_MICROSECOND | DAY_SECOND | DAY_MINUTE | DAY_HOUR | YEAR_MONTH, etc }

Author
James Sutherland
Since
2.4
Version
2.5

Field Summary

Modifier and TypeField and Description
private String
datePart

The date part to extract from the date/time.

private String
fromIdentifier

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

private boolean
hasSpaceAfterDatePart

Determines whether a space was parsed after the date part.

private boolean
hasSpaceAfterFrom

Determines whether a space was parsed after the identifier FROM.

Constructor Summary

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

Creates a new ExtractExpression.

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.
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.
public String

Returns:

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

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

public String

Returns:

The part of the date/time to retrieve
getDatePart
()

Returns the date part that was parsed, it is used to extract a single part of a date/time, such as year, month, day, your, etc.

public String
public JPQLQueryBNF
public boolean

Returns:

true if the date part literal was parsed; false otherwise
hasDatePart
()

Determines whether the date part literal was parsed or not.

public boolean
public boolean

Returns:

true if the identifier FROM was parsed; false otherwise
hasFrom
()

Determines whether the identifier FROM was part of the query.

public boolean

Returns:

true if there was a whitespace after the date part literal; false otherwise
hasSpaceAfterDatePart
()

Determines whether a whitespace was found after the date part literal.

public boolean

Returns:

true if there was a whitespace after FROM; false otherwise
hasSpaceAfterFrom
()

Determines whether a whitespace was found after FROM.

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.AbstractEncapsulatedExpression.isParsingComplete.

Determines whether the parsing is complete based on what is left in the given text.
protected 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
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:
acceptChildrenaddChildrenTofindQueryBNFgetExpressionhasExpressionsetExpression

Field Detail

datePartback to summary
private String datePart

The date part to extract from the date/time.

fromIdentifierback to summary
private String fromIdentifier

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

hasSpaceAfterDatePartback to summary
private boolean hasSpaceAfterDatePart

Determines whether a space was parsed after the date part.

hasSpaceAfterFromback to summary
private boolean hasSpaceAfterFrom

Determines whether a space was parsed after the identifier FROM.

Constructor Detail

ExtractExpressionback to summary
public ExtractExpression(AbstractExpression parent)

Creates a new ExtractExpression.

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
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
getActualFromIdentifierback to summary
public String getActualFromIdentifier()

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

Returns:String

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

getDatePartback to summary
public String getDatePart()

Returns the date part that was parsed, it is used to extract a single part of a date/time, such as year, month, day, your, etc.

Returns:String

The part of the date/time to retrieve

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
hasDatePartback to summary
public boolean hasDatePart()

Determines whether the date part literal was parsed or not.

Returns:boolean

true if the date part literal was parsed; false otherwise

hasEncapsulatedExpressionback to summary
public boolean hasEncapsulatedExpression()

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

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

Determines whether something was parsed after the left parenthesis.

Returns:boolean

true if something was parsed; false otherwise

Annotations
@Override
hasFromback to summary
public boolean hasFrom()

Determines whether the identifier FROM was part of the query.

Returns:boolean

true if the identifier FROM was parsed; false otherwise

hasSpaceAfterDatePartback to summary
public boolean hasSpaceAfterDatePart()

Determines whether a whitespace was found after the date part literal.

Returns:boolean

true if there was a whitespace after the date part literal; false otherwise

hasSpaceAfterFromback to summary
public boolean hasSpaceAfterFrom()

Determines whether a whitespace was found after FROM.

Returns:boolean

true if there was a whitespace after FROM; false otherwise

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

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.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
parseEncapsulatedExpressionback to summary
protected 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
removeEncapsulatedExpressionback to summary
protected void removeEncapsulatedExpression()

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

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

Removes the encapsulated Expression that was parsed, it should not be part of this one. This happens when the parsed information does not have both '(' and ')'.

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