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

public abstract Class AbstractExpression

extends Object
implements Expression
Class Inheritance
All Implemented Interfaces
org.eclipse.persistence.jpa.jpql.parser.Expression
Known Direct Subclasses
org.eclipse.persistence.jpa.jpql.parser.AbstractFromClause, org.eclipse.persistence.jpa.jpql.parser.AbstractPathExpression, org.eclipse.persistence.jpa.jpql.parser.AbstractSchemaName, org.eclipse.persistence.jpa.jpql.parser.AbstractSelectClause, org.eclipse.persistence.jpa.jpql.parser.AbstractSelectStatement, org.eclipse.persistence.jpa.jpql.parser.ArithmeticFactor, org.eclipse.persistence.jpa.jpql.parser.AsOfClause, org.eclipse.persistence.jpa.jpql.parser.BadExpression, org.eclipse.persistence.jpa.jpql.parser.BetweenExpression, org.eclipse.persistence.jpa.jpql.parser.CaseExpression, org.eclipse.persistence.jpa.jpql.parser.AbstractOrderByClause, org.eclipse.persistence.jpa.jpql.parser.DeleteClause, org.eclipse.persistence.jpa.jpql.parser.IdentificationVariableDeclaration, org.eclipse.persistence.jpa.jpql.parser.Join, org.eclipse.persistence.jpa.jpql.parser.StringLiteral, org.eclipse.persistence.jpa.jpql.parser.TableVariableDeclaration, org.eclipse.persistence.jpa.jpql.parser.UpdateClause, org.eclipse.persistence.jpa.jpql.parser.CollectionExpression, org.eclipse.persistence.jpa.jpql.parser.CollectionMemberDeclaration, org.eclipse.persistence.jpa.jpql.parser.CollectionMemberExpression, org.eclipse.persistence.jpa.jpql.parser.CompoundExpression, org.eclipse.persistence.jpa.jpql.parser.ConnectByClause, org.eclipse.persistence.jpa.jpql.parser.ConstructorExpression, org.eclipse.persistence.jpa.jpql.parser.DateTime, org.eclipse.persistence.jpa.jpql.parser.DefaultStringExpression, org.eclipse.persistence.jpa.jpql.parser.DeleteStatement, org.eclipse.persistence.jpa.jpql.parser.EmptyCollectionComparisonExpression, org.eclipse.persistence.jpa.jpql.parser.EntityTypeLiteral, org.eclipse.persistence.jpa.jpql.parser.GroupByClause, org.eclipse.persistence.jpa.jpql.parser.HierarchicalQueryClause, org.eclipse.persistence.jpa.jpql.parser.IdentificationVariable, org.eclipse.persistence.jpa.jpql.parser.InExpression, org.eclipse.persistence.jpa.jpql.parser.InputParameter, org.eclipse.persistence.jpa.jpql.parser.JPQLExpression, org.eclipse.persistence.jpa.jpql.parser.KeywordExpression, org.eclipse.persistence.jpa.jpql.parser.LikeExpression, org.eclipse.persistence.jpa.jpql.parser.LocalDateTime, org.eclipse.persistence.jpa.jpql.parser.LocalExpression, org.eclipse.persistence.jpa.jpql.parser.NotExpression, org.eclipse.persistence.jpa.jpql.parser.NullComparisonExpression, org.eclipse.persistence.jpa.jpql.parser.NullExpression, org.eclipse.persistence.jpa.jpql.parser.NumericLiteral, org.eclipse.persistence.jpa.jpql.parser.OrderByItem, org.eclipse.persistence.jpa.jpql.parser.RangeVariableDeclaration, org.eclipse.persistence.jpa.jpql.parser.RegexpExpression, org.eclipse.persistence.jpa.jpql.parser.ResultVariable, org.eclipse.persistence.jpa.jpql.parser.UnionClause, org.eclipse.persistence.jpa.jpql.parser.UnknownExpression, org.eclipse.persistence.jpa.jpql.parser.UpdateItem, org.eclipse.persistence.jpa.jpql.parser.UpdateStatement, org.eclipse.persistence.jpa.jpql.parser.WhenClause, org.eclipse.persistence.jpa.jpql.parser.AbstractConditionalClause, org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression
Annotations
@SuppressWarnings:nls
Imports
java.lang.reflect.InvocationTargetException, .Method, java.util.ArrayList, .Collection, .LinkedList, .List, org.eclipse.persistence.jpa.jpql.ExpressionTools, .JPAVersion, .WordParser, .WordParser.WordType, org.eclipse.persistence.jpa.jpql.utility.iterable.ListIterable, .SnapshotCloneListIterable

This is the abstract definition of all the parts used to create the tree hierarchy representing the parsed JPQL query.
Author
Pascal Filion
Since
2.3
Version
2.6
See Also
ExpressionFactory, JPQLGrammar

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
AbstractExpression.Info

Rather than creating three lists when performing a single parsing operation (parse(WordParser, String, boolean)), this class will act as a simple chained list and postponing the creation of those three lists only when needed (which is when the parsed expression needs to be a collection of expressions).

Field Summary

Modifier and TypeField and Description
private String
actualText

The string representation of this AbstractExpression (which includes its children).

private List<Expression>
children

The children of this AbstractExpression.

public static final char
COMMA

The constant for ','.

public static final char
DOT

The constant for '.'.

public static final char
DOUBLE_QUOTE

The constant for '"'.

public static final char
LEFT_CURLY_BRACKET

The constant for '{'.

public static final char
LEFT_PARENTHESIS

The constant for '('.

public static final char
NOT_DEFINED

The constant for a character that is not defined.

private int
offset

The position of this AbstractExpression in relation to its parent hierarchy by calculating the length of the string representation of what comes before.

private List<Expression>
orderedChildren

The string representation of this AbstractExpression.

private AbstractExpression
parent

The parent of this AbstractExpression or null if this object is JPQLExpression - the root of the parsed tree hierarchy.

private String
parsedText

The string representation of this AbstractExpression (which includes its children).

public static final char
RIGHT_CURLY_BRACKET

The constant for '}'.

public static final char
RIGHT_PARENTHESIS

The constant for ')'.

public static final char
SINGLE_QUOTE

The constant for '''.

public static final char
SPACE

The constant for ' '.

private String
text

This attribute can be used to store the AbstractExpression's JPQL identifier or a literal.

public static final char
UNDERSCORE

The constant for '_'.

Constructor Summary

AccessConstructor and Description
protected
AbstractExpression(AbstractExpression
The parent of this expression
parent
)

Creates a new AbstractExpression.

protected
AbstractExpression(AbstractExpression
The parent of this expression
parent
,
String
The text to be stored in this expression, null cannot be passed
text
)

Creates a new AbstractExpression.

Method Summary

Modifier and TypeMethod and Description
protected boolean

Returns:

true if the call was successfully executed; false otherwise
acceptUnknownVisitor
(ExpressionVisitor
The ExpressionVisitor to visit this Expression programmatically
visitor
)

The given ExpressionVisitor needs to visit this class but it is defined by a third- party provider.

protected void
acceptUnknownVisitor(ExpressionVisitor
The ExpressionVisitor to visit this Expression programmatically
visitor
,
Class<?>
The type found in the hierarchy of the given ExpressionVisitor that will be used to retrieve the visit method
type
,
Class<?>
The parameter type of the visit method
parameterType
)

The given ExpressionVisitor needs to visit this class but it is defined by a third- party provider.

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

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
)

Adds the children of this AbstractExpression to the given list.

protected final AbstractExpression

Returns:

The Expression representing the given sub-query
buildExpressionFromFallingBack
(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
,
JPQLQueryBNF
The JPQLQueryBNF used to determine how to parse from the current position of the cursor within the JPQL query
queryBNF
,
AbstractExpression
The Expression that has just been parsed or null
expression
,
boolean
Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries
tolerant
)

No factories were found to create an Expression with the content of WordParser, this method will retrieve the fallback ExpressionFactory defined in the given BNF.

protected final AbstractExpression

Returns:

A new null version of an Expression
buildNullExpression
()

Creates a new null-Expression parented with this one.

protected final Expression

Returns:

The Expression representation of the given identifier where the owning Expression is this one
buildStringExpression
(char
The character to wrap as a Expression
value
)

Creates a new Expression wrapping the given character value.

protected final Expression

Returns:

The Expression representation of the given identifier where the owning Expression is this one
buildStringExpression
(String
The string to wrap as a Expression
value
)

Creates a new Expression wrapping the given string value.

protected final AbstractExpression

Returns:

A new Expression where toActualText() returns the given text
buildUnknownExpression
(String
The text causing the expression to be malformed
text
)

Creates an Expression that contains a malformed expression.

protected final int

Returns:

The length of the string representation for what is coming before the given Expression
calculatePosition
(Expression
The Expression for which its position within the parsed tree needs to be determined
expression
,
int
The current cursor position within the JPQL query while digging into the tree until the search reaches the expression
length
)

Calculates the position of the given Expression by calculating the length of what is before.

public final ListIterable<Expression>
protected final ExpressionFactory

Returns:

Either the fallback ExpressionFactory linked to the given JPQLQueryBNF or null if none was declared
findFallBackExpressionFactory
(JPQLQueryBNF
The JPQLQueryBNF for which its associated fallback ExpressionFactory will be searched
queryBNF
)

Retrieve the ExpressionFactory from the given JPQLQueryBNF by following the path of fallback JPQLQueryBNFs and then returns the ExpressionFactory from the leaf JPQLQueryBNF.

public JPQLQueryBNF
findQueryBNF(Expression
The Expression that is a descendant of this one
expression
)

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.
protected final ExpressionFactory

Returns:

The ExpressionFactory mapped with the given unique identifier
getExpressionFactory
(String
The unique identifier of the ExpressionFactory to retrieve
expressionFactoryId
)

Retrieves the registered ExpressionFactory that was registered for the given unique identifier.

protected final ExpressionRegistry

Returns:

The registry containing the information related to the JPQL grammar
getExpressionRegistry
()

Returns the registry containing the JPQLQueryBNFs and the ExpressionFactories that are used to properly parse a JPQL query.

public JPQLGrammar
getGrammar()

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

Returns the JPQLGrammar that defines how the JPQL query was parsed.
public JPAVersion

Returns:

The version in which the identifier was introduced
getIdentifierVersion
(String identifier)

Retrieves the JPA version in which the identifier was first introduced.

protected JPAVersion

Returns:

The JPA version supported by the grammar
getJPAVersion
()

Returns the version of the Java Persistence to support.

public final int
getLength()

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

Returns the length of the string representation of this Expression, which is the length of the text generated by toActualText().
public final int
getOffset()

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

Returns the position of this Expression within its parent hierarchy.
public final AbstractExpression
public JPQLQueryBNF

Returns:

The JPQLQueryBNF representing a section of the grammar
getQueryBNF
(String
The unique identifier of the JPQLQueryBNF to retrieve
queryBNFID
)

Retrieves the BNF object that was registered for the given unique identifier.

public final JPQLExpression
getRoot()

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

Retrieves the root node of the parsed tree hierarchy.
protected String

Returns:

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

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

protected boolean

Returns:

true if the given BNF handles aggregate expressions; false otherwise
handleAggregate
(JPQLQueryBNF
The JPQLQueryBNF used to determine if the parsing should handle aggregate expressions
queryBNF
)

Determines whether the given JPQLQueryBNF handles aggregate expressions.

protected boolean

Returns:

true if the sub-expression to parse might have several sub-expressions separated by commas; false otherwise
handleCollection
(JPQLQueryBNF
The JPQLQueryBNF used to determine if the parsing should handle collection of sub-expressions
queryBNF
)

Determines whether the given JPQLQueryBNF handles a collection of sub-expressions that are separated by commas.

public boolean
isAncestor(Expression
The Expression to verify its paternity with this Expression
expression
)

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

Determines whether this Expression is a parent of the given Expression.
protected final boolean

Returns:

true if the word is an identifier, false otherwise
isIdentifier
(String
The word to test if it is a JPQL identifier
word
)

Determines if the given word is a JPQL identifier.

protected boolean

Returns:

false by default
isNull
()

Determines whether this expression is a null Expression or any other subclass.

protected boolean

Returns:

true if the text no longer can't be parsed by the current expression; false if more can be parsed
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
)

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

protected boolean

Returns:

true if the parsing system should parse invalid or incomplete queries; false when the query is well-formed and valid
isTolerant
()

Determines if the parser is in tolerant mode or is in fast mode.

protected boolean

Returns:

false by default
isUnknown
()

Determines whether this expression is an unknown Expression or any other subclass.

protected boolean

Returns:

true if this AbstractExpression was virtually created to fully qualify path expression; false if it was parsed
isVirtual
()

Determines whether this AbstractExpression is virtual, meaning it's not part of the query but is required for proper navigability.

public final ListIterable<Expression>
orderedChildren()

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

Returns the list representing this Expression and its children.
protected abstract 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
)

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

protected AbstractExpression

Returns:

The Expression representing the given sub-query
parse
(WordParser
The text to parse based on the current position of the cursor
wordParser
,
String
The unique identifier of the JPQLQueryBNF that is used to determine how to parse the text at the current cursor position within the JPQL query
queryBNFId
,
boolean
Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries
tolerant
)

Parses the given text by using the specified BNF.

protected AbstractExpression

Returns:

The Expression representing the given sub-query
parseUsingExpressionFactory
(WordParser
The text to parse based on the current position of the cursor
wordParser
,
String
The unique identifier of the JPQLQueryBNF that is used to determine how to parse the text at the current cursor position within the JPQL query
queryBNFId
,
boolean
Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries
tolerant
)

Right away parses the text by retrieving the ExpressionFactory for the first word that is extracted from WordParser at the current location.

public void
populatePosition(QueryPosition queryPosition, int
The array has one element and is the position of the Expression to retrieve
position
)

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

Retrieves the Expression located at the given position using the actual query, which may have extra whitespace.
protected final void
rebuildActualText()

Rebuilds the actual parsed text if it has been cached.

protected final void
rebuildParsedText()

Rebuilds the parsed parsed text if it has been cached.

protected final void
setParent(AbstractExpression
The new parent of this object
parent
)

Re-parents this Expression to be a child of the given Expression.

protected final void
setText(String
The immutable text wrapped by this Expression, which cannot be null
text
)

Sets the text of this Expression.

protected boolean

Returns:

true is returned by default so the factories are used before falling back
shouldParseWithFactoryFirst
()

Determines whether the parsing of the query should be performed using the factories first or it should automatically fallback to the fallback factory.

protected boolean

Returns:

true
shouldSkipLiteral
(AbstractExpression
The Expression that has just been parsed or null
expression
)

When parsing an invalid or incomplete query, it is possible two literals would be parsed but in some cases, a CollectionExpression should not be created and the parsing should actually stop here.

public String
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
toParsedText()

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

Returns a string representation of this Expression and its children.
protected abstract 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
)

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

public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait