Class AbstractExpression
- java.lang.Object
-
- org.eclipse.persistence.jpa.jpql.parser.AbstractExpression
-
- All Implemented Interfaces:
Expression
- Direct Known Subclasses:
AbstractConditionalClause
,AbstractEncapsulatedExpression
,AbstractFromClause
,AbstractOrderByClause
,AbstractPathExpression
,AbstractSchemaName
,AbstractSelectClause
,AbstractSelectStatement
,ArithmeticFactor
,AsOfClause
,BadExpression
,BetweenExpression
,CaseExpression
,CollectionExpression
,CollectionMemberDeclaration
,CollectionMemberExpression
,CompoundExpression
,ConnectByClause
,ConstructorExpression
,DateTime
,DefaultStringExpression
,DeleteClause
,DeleteStatement
,EmptyCollectionComparisonExpression
,EntityTypeLiteral
,GroupByClause
,HierarchicalQueryClause
,IdentificationVariable
,IdentificationVariableDeclaration
,InExpression
,InputParameter
,Join
,JPQLExpression
,KeywordExpression
,LikeExpression
,NotExpression
,NullComparisonExpression
,NullExpression
,NumericLiteral
,OrderByItem
,RangeVariableDeclaration
,RegexpExpression
,ResultVariable
,StringLiteral
,TableVariableDeclaration
,UnionClause
,UnknownExpression
,UpdateClause
,UpdateItem
,UpdateStatement
,WhenClause
public abstract class AbstractExpression extends Object implements Expression
This is the abstract definition of all the parts used to create the tree hierarchy representing the parsed JPQL query.- Since:
- 2.3
- Version:
- 2.6
- Author:
- Pascal Filion
- See Also:
ExpressionFactory
,JPQLGrammar
-
-
Field Summary
Fields Modifier and Type Field Description static char
COMMA
The constant for ','.static char
DOT
The constant for '.'.static char
DOUBLE_QUOTE
The constant for '"'.static char
LEFT_CURLY_BRACKET
The constant for '{'.static char
LEFT_PARENTHESIS
The constant for '('.static char
NOT_DEFINED
The constant for a character that is not defined.static char
RIGHT_CURLY_BRACKET
The constant for '}'.static char
RIGHT_PARENTHESIS
The constant for ')'.static char
SINGLE_QUOTE
The constant for '''.static char
SPACE
The constant for ' '.static char
UNDERSCORE
The constant for '_'.-
Fields inherited from interface org.eclipse.persistence.jpa.jpql.parser.Expression
ABS, ALL, AND, ANY, AS, AS_OF, ASC, AVG, BETWEEN, BIT_LENGTH, BOTH, CASE, CAST, CHAR_LENGTH, CHARACTER_LENGTH, CLASS, COALESCE, COLUMN, CONCAT, CONNECT_BY, COUNT, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, DELETE, DELETE_FROM, DESC, DIFFERENT, DISTINCT, DIVISION, ELSE, EMPTY, END, ENTRY, EQUAL, ESCAPE, EXCEPT, EXISTS, EXTRACT, FALSE, FETCH, FIRST, FROM, FUNC, FUNCTION, GREATER_THAN, GREATER_THAN_OR_EQUAL, GROUP_BY, HAVING, IN, INDEX, INNER, INNER_JOIN, INNER_JOIN_FETCH, INTERSECT, IS, IS_EMPTY, IS_NOT_EMPTY, IS_NOT_NULL, IS_NULL, JOIN, JOIN_FETCH, KEY, LAST, LEADING, LEFT, LEFT_JOIN, LEFT_JOIN_FETCH, LEFT_OUTER_JOIN, LEFT_OUTER_JOIN_FETCH, LENGTH, LIKE, LOCATE, LOWER, LOWER_THAN, LOWER_THAN_OR_EQUAL, MAX, MEMBER, MEMBER_OF, MIN, MINUS, MOD, MULTIPLICATION, NAMED_PARAMETER, NEW, NOT, NOT_BETWEEN, NOT_EQUAL, NOT_EXISTS, NOT_IN, NOT_LIKE, NOT_MEMBER, NOT_MEMBER_OF, NULL, NULLIF, NULLS, NULLS_FIRST, NULLS_LAST, OBJECT, OF, ON, OPERATOR, OR, ORDER_BY, ORDER_SIBLINGS_BY, OUTER, PLUS, POSITION, POSITIONAL_PARAMETER, QUOTE, REGEXP, SCN, SELECT, SET, SIZE, SOME, SQL, SQRT, START_WITH, SUBSTRING, SUM, TABLE, THEN, TIMESTAMP, TRAILING, TREAT, TRIM, TRUE, TYPE, UNION, UNKNOWN, UPDATE, UPPER, VALUE, WHEN, WHERE
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ListIterable<Expression>
children()
Returns the children of thisExpression
.JPQLQueryBNF
findQueryBNF(Expression expression)
Retrieves theJPQLQueryBNF
that represents the fragment of thisExpression
that was used when parsing the givenExpression
.JPQLGrammar
getGrammar()
Returns theJPQLGrammar
that defines how the JPQL query was parsed.JPAVersion
getIdentifierVersion(String identifier)
Retrieves the JPA version in which the identifier was first introduced.int
getLength()
Returns the length of the string representation of thisExpression
, which is the length of the text generated byExpression.toActualText()
.int
getOffset()
Returns the position of thisExpression
within its parent hierarchy.AbstractExpression
getParent()
Returns the parent of thisExpression
.JPQLQueryBNF
getQueryBNF(String queryBNFID)
Retrieves the BNF object that was registered for the given unique identifier.JPQLExpression
getRoot()
Retrieves the root node of the parsed tree hierarchy.boolean
isAncestor(Expression expression)
Determines whether thisExpression
is a parent of the givenExpression
.ListIterable<Expression>
orderedChildren()
Returns the list representing thisExpression
and its children.void
populatePosition(QueryPosition queryPosition, int position)
Retrieves theExpression
located at the given position using the actual query, which may have extra whitespace.String
toActualText()
Generates a string representation of thisExpression
, which needs to include any characters that are considered virtual, i.e.String
toParsedText()
Returns a string representation of thisExpression
and its children.String
toString()
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.persistence.jpa.jpql.parser.Expression
accept, acceptChildren, getQueryBNF
-
-
-
-
Field Detail
-
COMMA
public static final char COMMA
The constant for ','.- See Also:
- Constant Field Values
-
DOT
public static final char DOT
The constant for '.'.- See Also:
- Constant Field Values
-
DOUBLE_QUOTE
public static final char DOUBLE_QUOTE
The constant for '"'.- See Also:
- Constant Field Values
-
LEFT_CURLY_BRACKET
public static final char LEFT_CURLY_BRACKET
The constant for '{'.- See Also:
- Constant Field Values
-
LEFT_PARENTHESIS
public static final char LEFT_PARENTHESIS
The constant for '('.- See Also:
- Constant Field Values
-
NOT_DEFINED
public static final char NOT_DEFINED
The constant for a character that is not defined.- See Also:
- Constant Field Values
-
RIGHT_CURLY_BRACKET
public static final char RIGHT_CURLY_BRACKET
The constant for '}'.- See Also:
- Constant Field Values
-
RIGHT_PARENTHESIS
public static final char RIGHT_PARENTHESIS
The constant for ')'.- See Also:
- Constant Field Values
-
SINGLE_QUOTE
public static final char SINGLE_QUOTE
The constant for '''.- See Also:
- Constant Field Values
-
SPACE
public static final char SPACE
The constant for ' '.- See Also:
- Constant Field Values
-
UNDERSCORE
public static final char UNDERSCORE
The constant for '_'.- See Also:
- Constant Field Values
-
-
Method Detail
-
children
public final ListIterable<Expression> children()
Returns the children of thisExpression
.- Specified by:
children
in interfaceExpression
- Returns:
- The children of this
Expression
or an emptyListIterable
-
findQueryBNF
public JPQLQueryBNF findQueryBNF(Expression expression)
Retrieves theJPQLQueryBNF
that represents the fragment of thisExpression
that was used when parsing the givenExpression
.- Specified by:
findQueryBNF
in interfaceExpression
- Parameters:
expression
- TheExpression
that is a descendant of this one- Returns:
- The
JPQLQueryBNF
that was used to parse the given expression
-
getGrammar
public JPQLGrammar getGrammar()
Returns theJPQLGrammar
that defines how the JPQL query was parsed.- Specified by:
getGrammar
in interfaceExpression
- Returns:
- The
JPQLGrammar
that was used to parse thisExpression
-
getIdentifierVersion
public JPAVersion getIdentifierVersion(String identifier)
Retrieves the JPA version in which the identifier was first introduced.- Returns:
- The version in which the identifier was introduced
-
getLength
public final int getLength()
Returns the length of the string representation of thisExpression
, which is the length of the text generated byExpression.toActualText()
.- Specified by:
getLength
in interfaceExpression
- Returns:
- The length of the string representation of this
Expression
-
getOffset
public final int getOffset()
Returns the position of thisExpression
within its parent hierarchy.- Specified by:
getOffset
in interfaceExpression
- Returns:
- The length of the string representation of what is coming before this object
-
getParent
public final AbstractExpression getParent()
Returns the parent of thisExpression
.- Specified by:
getParent
in interfaceExpression
- Returns:
- The parent of this
Expression
, which is nevernull
except for the root of the tree
-
getQueryBNF
public JPQLQueryBNF getQueryBNF(String queryBNFID)
Retrieves the BNF object that was registered for the given unique identifier.- Parameters:
queryBNFID
- The unique identifier of theJPQLQueryBNF
to retrieve- Returns:
- The
JPQLQueryBNF
representing a section of the grammar
-
getRoot
public final JPQLExpression getRoot()
Retrieves the root node of the parsed tree hierarchy.- Specified by:
getRoot
in interfaceExpression
- Returns:
- The root of the
Expression
tree
-
isAncestor
public boolean isAncestor(Expression expression)
Determines whether thisExpression
is a parent of the givenExpression
.- Specified by:
isAncestor
in interfaceExpression
- Parameters:
expression
- TheExpression
to verify its paternity with thisExpression
- Returns:
true
if thisExpression
is the same as the givenExpression
or one of its parent;false
otherwise
-
orderedChildren
public final ListIterable<Expression> orderedChildren()
Returns the list representing thisExpression
and its children.- Specified by:
orderedChildren
in interfaceExpression
- Returns:
- The
Expressions
representing thisExpression
-
populatePosition
public void populatePosition(QueryPosition queryPosition, int position)
Retrieves theExpression
located at the given position using the actual query, which may have extra whitespace.- Specified by:
populatePosition
in interfaceExpression
position
- The array has one element and is the position of theExpression
to retrieve
-
toActualText
public String toActualText()
Generates a string representation of thisExpression
, 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.- Specified by:
toActualText
in interfaceExpression
- Returns:
- The string representation of this
Expression
-
toParsedText
public String toParsedText()
Returns a string representation of thisExpression
and its children. The expression should contain whitespace even if the beautified version would not have any. For instance, "SELECT e " should be returned whereExpression.toParsedText()
would return "SELECT e".- Specified by:
toParsedText
in interfaceExpression
- Returns:
- The string representation of this
Expression
-
-