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

public final Class DateTime

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

This Expression represents a date or time. It supports the following identifiers:

CURRENT_DATE: This function returns the value of current date on the database server.

CURRENT_TIME: This function returns the value of current time on the database server.

CURRENT_TIMESTAMP: This function returns the value of current timestamp on the database server.

BNF: functions_returning_datetime ::= CURRENT_DATE | CURRENT_TIME | CURRENT_TIMESTAMP

The JDBC escape syntax may be used for the specification of date, time, and timestamp literals.

BNF: expression ::= {d 'yyyy-mm-dd'} | {t 'hh:mm:ss'} | {ts 'yyyy-mm-dd hh:mm:ss.f...'}
Author
Pascal Filion
Since
2.3
Version
2.4

Field Summary

Modifier and TypeField and Description
private String
identifier

The actual 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
DateTime(AbstractExpression
The parent of this expression
parent
)

Creates a new DateTime.

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

Returns:

The identifier that was actually parsed
getActualIdentifier
()

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

public JPQLQueryBNF
public String
getText()

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

Returns the encapsulated text of this AbstractExpression, which can be used in various ways, it can be a keyword, a literal, etc.
public boolean

Returns:

true if this Expression represents CURRENT_DATE; false otherwise
isCurrentDate
()

Determines whether this DateTime represents the JPQL identifier CURRENT_DATE.

public boolean

Returns:

true if this Expression represents CURRENT_TIME; false otherwise
isCurrentTime
()

Determines whether this DateTime represents the JPQL identifier CURRENT_TIME.

public boolean

Returns:

true if this Expression represents CURRENT_TIMESTAMP; false otherwise
isCurrentTimestamp
()

Determines whether this DateTime represents the JPQL identifier CURRENT_TIMESTAMP.

public boolean

Returns:

true if this Expression represents a JDBC escape syntax; false otherwise
isJDBCDate
()

Determines whether this DateTime represents the JDBC escape syntax for date, time, timestamp formats.

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.
private String
private void
public String
toActualText()

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

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

Generates a string representation of this Expression, which needs 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.
public String
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:
acceptUnknownVisitoracceptUnknownVisitoraddChildrenTobuildExpressionFromFallingBackbuildNullExpressionbuildStringExpressionbuildStringExpressionbuildUnknownExpressioncalculatePositionchildrenfindFallBackExpressionFactoryfindQueryBNFgetExpressionFactorygetExpressionRegistrygetGrammargetIdentifierVersiongetJPAVersiongetLengthgetOffsetgetParentgetQueryBNFgetRoothandleAggregatehandleCollectionisAncestorisIdentifierisNullisParsingCompleteisTolerantisUnknownisVirtualorderedChildrenparseparseUsingExpressionFactorypopulatePositionrebuildActualTextrebuildParsedTextsetParentsetTextshouldParseWithFactoryFirstshouldSkipLiteraltoString

Field Detail

identifierback to summary
private String identifier

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

Constructor Detail

DateTimeback to summary
public DateTime(AbstractExpression parent)

Creates a new DateTime.

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
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
getActualIdentifierback to summary
public String getActualIdentifier()

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

Returns:String

The identifier that was actually parsed

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
getTextback to summary
public String getText()

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

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

Returns the encapsulated text of this AbstractExpression, which can be used in various ways, it can be a keyword, a literal, etc.

Returns:String

Either the JPQL identifier for this AbstractExpression, the literal it encapsulates or an empty string

Annotations
@Override
isCurrentDateback to summary
public boolean isCurrentDate()

Determines whether this DateTime represents the JPQL identifier CURRENT_DATE.

Returns:boolean

true if this Expression represents CURRENT_DATE; false otherwise

isCurrentTimeback to summary
public boolean isCurrentTime()

Determines whether this DateTime represents the JPQL identifier CURRENT_TIME.

Returns:boolean

true if this Expression represents CURRENT_TIME; false otherwise

isCurrentTimestampback to summary
public boolean isCurrentTimestamp()

Determines whether this DateTime represents the JPQL identifier CURRENT_TIMESTAMP.

Returns:boolean

true if this Expression represents CURRENT_TIMESTAMP; false otherwise

isJDBCDateback to summary
public boolean isJDBCDate()

Determines whether this DateTime represents the JDBC escape syntax for date, time, timestamp formats.

Returns:boolean

true if this Expression represents a JDBC escape syntax; false otherwise

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
parseIdentifierback to summary
private String parseIdentifier(WordParser wordParser)
parseJDBCEscapeFormatback to summary
private void parseJDBCEscapeFormat(WordParser wordParser)
toActualTextback to summary
public String toActualText()

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

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

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

Generates a string representation of this Expression, which needs 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.

Returns:String

The string representation of this Expression

Annotations
@Override
toParsedTextback to summary
public String toParsedText()

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

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

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

Returns a string representation of this Expression and its children. The expression should contain whitespace even if the beautified version would not have any. For instance, "SELECT e " should be returned where Expression#toActualText() would return "SELECT e".

Returns:String

The string representation of this Expression

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