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 java.lang.Object implements Expression
This is the abstract definition of all the parts used to create the tree hierarchy representing the parsed JPQL query.- Version:
- 2.6
- See Also:
ExpressionFactory,JPQLGrammar- Author:
- Pascal Filion
- Since:
- 2.3
-
-
Field Summary
Fields Modifier and Type Field Description static charCOMMAThe constant for ','.static charDOTThe constant for '.'.static charDOUBLE_QUOTEThe constant for '"'.static charLEFT_CURLY_BRACKETThe constant for '{'.static charLEFT_PARENTHESISThe constant for '('.static charNOT_DEFINEDThe constant for a character that is not defined.static charRIGHT_CURLY_BRACKETThe constant for '}'.static charRIGHT_PARENTHESISThe constant for ')'.static charSINGLE_QUOTEThe constant for '''.static charSPACEThe constant for ' '.static charUNDERSCOREThe 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
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractExpression(AbstractExpression parent)Creates a newAbstractExpression.protectedAbstractExpression(AbstractExpression parent, java.lang.String text)Creates a newAbstractExpression.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected booleanacceptUnknownVisitor(ExpressionVisitor visitor)The givenExpressionVisitorneeds to visit this class but it is defined by a third- party provider.protected voidacceptUnknownVisitor(ExpressionVisitor visitor, java.lang.Class<?> type, java.lang.Class<?> parameterType)The givenExpressionVisitorneeds to visit this class but it is defined by a third- party provider.protected voidaddChildrenTo(java.util.Collection<Expression> children)Adds the children of thisAbstractExpressionto the given collection.protected voidaddOrderedChildrenTo(java.util.List<Expression> children)Adds the children of thisAbstractExpressionto the given list.protected AbstractExpressionbuildExpressionFromFallingBack(WordParser wordParser, java.lang.String word, JPQLQueryBNF queryBNF, AbstractExpression expression, boolean tolerant)No factories were found to create anExpressionwith the content ofWordParser, this method will retrieve the fallbackExpressionFactorydefined in the givenBNF.protected AbstractExpressionbuildNullExpression()Creates a newnull-Expressionparented with this one.protected ExpressionbuildStringExpression(char value)Creates a newExpressionwrapping the given character value.protected ExpressionbuildStringExpression(java.lang.String value)Creates a newExpressionwrapping the given string value.protected AbstractExpressionbuildUnknownExpression(java.lang.String text)Creates anExpressionthat contains a malformed expression.protected intcalculatePosition(Expression expression, int length)Calculates the position of the givenExpressionby calculating the length of what is before.ListIterable<Expression>children()Returns the children of thisExpression.protected ExpressionFactoryfindFallBackExpressionFactory(JPQLQueryBNF queryBNF)Retrieve theExpressionFactoryfrom the givenJPQLQueryBNFby following the path of fallbackJPQLQueryBNFsand then returns theExpressionFactoryfrom the leafJPQLQueryBNF.JPQLQueryBNFfindQueryBNF(Expression expression)Retrieves theJPQLQueryBNFthat represents the fragment of thisExpressionthat was used when parsing the givenExpression.protected ExpressionFactorygetExpressionFactory(java.lang.String expressionFactoryId)Retrieves the registeredExpressionFactorythat was registered for the given unique identifier.protected ExpressionRegistrygetExpressionRegistry()Returns the registry containing theJPQLQueryBNFsand theExpressionFactoriesthat are used to properly parse a JPQL query.JPQLGrammargetGrammar()Returns theJPQLGrammarthat defines how the JPQL query was parsed.JPAVersiongetIdentifierVersion(java.lang.String identifier)Retrieves the JPA version in which the identifier was first introduced.protected JPAVersiongetJPAVersion()Returns the version of the Java Persistence to support.intgetLength()Returns the length of the string representation of thisExpression, which is the length of the text generated byExpression.toActualText().intgetOffset()Returns the position of thisExpressionwithin its parent hierarchy.AbstractExpressiongetParent()Returns the parent of thisExpression.JPQLQueryBNFgetQueryBNF(java.lang.String queryBNFID)Retrieves the BNF object that was registered for the given unique identifier.JPQLExpressiongetRoot()Retrieves the root node of the parsed tree hierarchy.protected java.lang.StringgetText()Returns the encapsulated text of thisAbstractExpression, which can be used in various ways, it can be a keyword, a literal, etc.protected booleanhandleAggregate(JPQLQueryBNF queryBNF)Determines whether the givenJPQLQueryBNFhandles aggregate expressions.protected booleanhandleCollection(JPQLQueryBNF queryBNF)Determines whether the givenJPQLQueryBNFhandles a collection of sub-expressions that are separated by commas.booleanisAncestor(Expression expression)Determines whether thisExpressionis a parent of the givenExpression.protected booleanisIdentifier(java.lang.String word)Determines if the given word is a JPQL identifier.protected booleanisNull()Determines whether this expression is anullExpressionor any other subclass.protected booleanisParsingComplete(WordParser wordParser, java.lang.String word, Expression expression)Determines whether the parsing is complete based on what is left in the given text.protected booleanisTolerant()Determines if the parser is in tolerant mode or is in fast mode.protected booleanisUnknown()Determines whether this expression is an unknownExpressionor any other subclass.protected booleanisVirtual()Determines whether thisAbstractExpressionis virtual, meaning it's not part of the query but is required for proper navigability.ListIterable<Expression>orderedChildren()Returns the list representing thisExpressionand its children.protected abstract voidparse(WordParser wordParser, boolean tolerant)Parses the query by starting at the current position, which is part of the givenWordParser.protected AbstractExpressionparse(WordParser wordParser, java.lang.String queryBNFId, boolean tolerant)Parses the given text by using the specified BNF.protected AbstractExpressionparseUsingExpressionFactory(WordParser wordParser, java.lang.String queryBNFId, boolean tolerant)Right away parses the text by retrieving theExpressionFactoryfor the first word that is extracted fromWordParserat the current location.voidpopulatePosition(QueryPosition queryPosition, int position)Retrieves theExpressionlocated at the given position using the actual query, which may have extra whitespace.protected voidrebuildActualText()Rebuilds the actual parsed text if it has been cached.protected voidrebuildParsedText()Rebuilds the parsed parsed text if it has been cached.protected voidsetParent(AbstractExpression parent)Re-parents thisExpressionto be a child of the givenExpression.protected voidsetText(java.lang.String text)Sets the text of thisExpression.protected booleanshouldParseWithFactoryFirst()Determines whether the parsing of the query should be performed using thefactoriesfirst or it should automatically fallback to the fallback factory.protected booleanshouldSkipLiteral(AbstractExpression 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.java.lang.StringtoActualText()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.java.lang.StringtoParsedText()Returns a string representation of thisExpressionand its children.protected abstract voidtoParsedText(java.lang.StringBuilder writer, boolean actual)Generates a string representation of thisExpression, including its children, if it has any.java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, 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
-
-
Constructor Detail
-
AbstractExpression
protected AbstractExpression(AbstractExpression parent)
Creates a newAbstractExpression.- Parameters:
parent- The parent of this expression
-
AbstractExpression
protected AbstractExpression(AbstractExpression parent, java.lang.String text)
Creates a newAbstractExpression.- Parameters:
parent- The parent of this expressiontext- The text to be stored in this expression,nullcannot be passed
-
-
Method Detail
-
acceptUnknownVisitor
protected boolean acceptUnknownVisitor(ExpressionVisitor visitor)
The givenExpressionVisitorneeds to visit this class but it is defined by a third- party provider. This method will programmatically invoke the visit method defined on the visitor. The method signature should be:{public|protected|private} void visit(ThirdPartyExpression expression)or
{public|protected|private} void visit(Expression expression)Note: The package protected visibility (default) should be used with care, if the code is running inside OSGi, then the method will not be accessible, even through reflection.
- Parameters:
visitor- TheExpressionVisitorto visit thisExpressionprogrammatically- Returns:
trueif the call was successfully executed;falseotherwise- Since:
- 2.4
-
acceptUnknownVisitor
protected void acceptUnknownVisitor(ExpressionVisitor visitor, java.lang.Class<?> type, java.lang.Class<?> parameterType) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
The givenExpressionVisitorneeds to visit this class but it is defined by a third- party provider. This method will programmatically invoke the visit method defined on the visitor. The method signature should be:{public|protected|private} void visit(ThirdPartyExpression expression)or
{public|protected|private} void visit(Expression expression)- Parameters:
visitor- TheExpressionVisitorto visit thisExpressionprogrammaticallytype- The type found in the hierarchy of the givenExpressionVisitorthat will be used to retrieve the visit methodparameterType- The parameter type of the visit method- Throws:
java.lang.NoSuchMethodExceptionjava.lang.IllegalAccessExceptionjava.lang.reflect.InvocationTargetException- See Also:
acceptUnknownVisitor(ExpressionVisitor)- Since:
- 2.4
-
addChildrenTo
protected void addChildrenTo(java.util.Collection<Expression> children)
Adds the children of thisAbstractExpressionto the given collection.- Parameters:
children- The collection used to store the children
-
addOrderedChildrenTo
protected void addOrderedChildrenTo(java.util.List<Expression> children)
Adds the children of thisAbstractExpressionto the given list.- Parameters:
children- The list used to store the string representation of thisAbstractExpression
-
buildExpressionFromFallingBack
protected final AbstractExpression buildExpressionFromFallingBack(WordParser wordParser, java.lang.String word, JPQLQueryBNF queryBNF, AbstractExpression expression, boolean tolerant)
No factories were found to create anExpressionwith the content ofWordParser, this method will retrieve the fallbackExpressionFactorydefined in the givenBNF.- Parameters:
wordParser- The text to parse based on the current position of the cursorword- The word that was retrieved from the given text, which is the first word in the textqueryBNF- TheJPQLQueryBNFused to determine how to parse from the current position of the cursor within the JPQL queryexpression- TheExpressionthat has just been parsed ornulltolerant- Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries- Returns:
- The
Expressionrepresenting the given sub-query
-
buildNullExpression
protected final AbstractExpression buildNullExpression()
Creates a newnull-Expressionparented with this one.- Returns:
- A new
nullversion of anExpression
-
buildStringExpression
protected final Expression buildStringExpression(char value)
Creates a newExpressionwrapping the given character value.- Parameters:
value- The character to wrap as aExpression- Returns:
- The
Expressionrepresentation of the given identifier where the owningExpressionis this one
-
buildStringExpression
protected final Expression buildStringExpression(java.lang.String value)
Creates a newExpressionwrapping the given string value.- Parameters:
value- The string to wrap as aExpression- Returns:
- The
Expressionrepresentation of the given identifier where the owningExpressionis this one
-
buildUnknownExpression
protected final AbstractExpression buildUnknownExpression(java.lang.String text)
Creates anExpressionthat contains a malformed expression.- Parameters:
text- The text causing the expression to be malformed- Returns:
- A new
ExpressionwheretoActualText()returns the given text
-
calculatePosition
protected final int calculatePosition(Expression expression, int length)
Calculates the position of the givenExpressionby calculating the length of what is before.- Parameters:
expression- TheExpressionfor which its position within the parsed tree needs to be determinedlength- The current cursor position within the JPQL query while digging into the tree until the search reaches the expression- Returns:
- The length of the string representation for what is coming before the given
Expression - Since:
- 2.4
-
children
public final ListIterable<Expression> children()
Returns the children of thisExpression.- Specified by:
childrenin interfaceExpression- Returns:
- The children of this
Expressionor an emptyListIterable
-
findFallBackExpressionFactory
protected final ExpressionFactory findFallBackExpressionFactory(JPQLQueryBNF queryBNF)
Retrieve theExpressionFactoryfrom the givenJPQLQueryBNFby following the path of fallbackJPQLQueryBNFsand then returns theExpressionFactoryfrom the leafJPQLQueryBNF.- Parameters:
queryBNF- TheJPQLQueryBNFfor which its associated fallbackExpressionFactorywill be searched- Returns:
- Either the fallback
ExpressionFactorylinked to the givenJPQLQueryBNFornullif none was declared
-
findQueryBNF
public JPQLQueryBNF findQueryBNF(Expression expression)
Retrieves theJPQLQueryBNFthat represents the fragment of thisExpressionthat was used when parsing the givenExpression.- Specified by:
findQueryBNFin interfaceExpression- Parameters:
expression- TheExpressionthat is a descendant of this one- Returns:
- The
JPQLQueryBNFthat was used to parse the given expression
-
getExpressionFactory
protected final ExpressionFactory getExpressionFactory(java.lang.String expressionFactoryId)
Retrieves the registeredExpressionFactorythat was registered for the given unique identifier.- Parameters:
expressionFactoryId- The unique identifier of theExpressionFactoryto retrieve- Returns:
- The
ExpressionFactorymapped with the given unique identifier - See Also:
ExpressionRegistry.getExpressionFactory(String)
-
getExpressionRegistry
protected final ExpressionRegistry getExpressionRegistry()
Returns the registry containing theJPQLQueryBNFsand theExpressionFactoriesthat are used to properly parse a JPQL query.- Returns:
- The registry containing the information related to the JPQL grammar
-
getGrammar
public JPQLGrammar getGrammar()
Returns theJPQLGrammarthat defines how the JPQL query was parsed.- Specified by:
getGrammarin interfaceExpression- Returns:
- The
JPQLGrammarthat was used to parse thisExpression
-
getIdentifierVersion
public JPAVersion getIdentifierVersion(java.lang.String identifier)
Retrieves the JPA version in which the identifier was first introduced.- Returns:
- The version in which the identifier was introduced
-
getJPAVersion
protected JPAVersion getJPAVersion()
Returns the version of the Java Persistence to support.- Returns:
- The JPA version supported by the grammar
- See Also:
JPQLGrammar
-
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:
getLengthin interfaceExpression- Returns:
- The length of the string representation of this
Expression
-
getOffset
public final int getOffset()
Returns the position of thisExpressionwithin its parent hierarchy.- Specified by:
getOffsetin 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:
getParentin interfaceExpression- Returns:
- The parent of this
Expression, which is nevernullexcept for the root of the tree
-
getQueryBNF
public JPQLQueryBNF getQueryBNF(java.lang.String queryBNFID)
Retrieves the BNF object that was registered for the given unique identifier.- Parameters:
queryBNFID- The unique identifier of theJPQLQueryBNFto retrieve- Returns:
- The
JPQLQueryBNFrepresenting a section of the grammar
-
getRoot
public final JPQLExpression getRoot()
Retrieves the root node of the parsed tree hierarchy.- Specified by:
getRootin interfaceExpression- Returns:
- The root of the
Expressiontree
-
getText
protected java.lang.String getText()
Returns the encapsulated text of thisAbstractExpression, which can be used in various ways, it can be a keyword, a literal, etc.- Returns:
- Either the JPQL identifier for this
AbstractExpression, the literal it encapsulates or an empty string
-
handleAggregate
protected boolean handleAggregate(JPQLQueryBNF queryBNF)
Determines whether the givenJPQLQueryBNFhandles aggregate expressions.- Parameters:
queryBNF- TheJPQLQueryBNFused to determine if the parsing should handle aggregate expressions- Returns:
trueif the given BNF handles aggregate expressions;falseotherwise
-
handleCollection
protected boolean handleCollection(JPQLQueryBNF queryBNF)
Determines whether the givenJPQLQueryBNFhandles a collection of sub-expressions that are separated by commas.- Parameters:
queryBNF- TheJPQLQueryBNFused to determine if the parsing should handle collection of sub-expressions- Returns:
trueif the sub-expression to parse might have several sub-expressions separated by commas;falseotherwise
-
isAncestor
public boolean isAncestor(Expression expression)
Determines whether thisExpressionis a parent of the givenExpression.- Specified by:
isAncestorin interfaceExpression- Parameters:
expression- TheExpressionto verify its paternity with thisExpression- Returns:
trueif thisExpressionis the same as the givenExpressionor one of its parent;falseotherwise
-
isIdentifier
protected final boolean isIdentifier(java.lang.String word)
Determines if the given word is a JPQL identifier. The check is case insensitive.- Parameters:
word- The word to test if it is a JPQL identifier- Returns:
trueif the word is an identifier,falseotherwise- See Also:
ExpressionRegistry.isIdentifier(String)
-
isNull
protected boolean isNull()
Determines whether this expression is anullExpressionor any other subclass.- Returns:
falseby default
-
isParsingComplete
protected boolean isParsingComplete(WordParser wordParser, java.lang.String word, Expression expression)
Determines whether the parsing is complete based on what is left in the given text. The text is never empty.- Parameters:
wordParser- The text to parse based on the current position of the cursorword- The word that was retrieved from the given text, which is the first word in the textexpression- TheExpressionthat has already been parsed- Returns:
trueif the text no longer can't be parsed by the current expression;falseif more can be parsed
-
isTolerant
protected boolean isTolerant()
Determines if the parser is in tolerant mode or is in fast mode. When the tolerant is turned on, it means the parser will attempt to parse incomplete or invalid queries.- Returns:
trueif the parsing system should parse invalid or incomplete queries;falsewhen the query is well-formed and valid
-
isUnknown
protected boolean isUnknown()
Determines whether this expression is an unknownExpressionor any other subclass.- Returns:
falseby default
-
isVirtual
protected boolean isVirtual()
Determines whether thisAbstractExpressionis virtual, meaning it's not part of the query but is required for proper navigability.- Returns:
trueif thisAbstractExpressionwas virtually created to fully qualify path expression;falseif it was parsed
-
orderedChildren
public final ListIterable<Expression> orderedChildren()
Returns the list representing thisExpressionand its children.- Specified by:
orderedChildrenin interfaceExpression- Returns:
- The
Expressionsrepresenting thisExpression
-
parse
protected abstract void parse(WordParser wordParser, boolean tolerant)
Parses the query by starting at the current position, which is part of the givenWordParser.- Parameters:
wordParser- The text to parse based on the current position of the cursortolerant- Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries
-
parse
protected AbstractExpression parse(WordParser wordParser, java.lang.String queryBNFId, boolean tolerant)
Parses the given text by using the specified BNF.- Parameters:
wordParser- The text to parse based on the current position of the cursorqueryBNFId- The unique identifier of theJPQLQueryBNFthat is used to determine how to parse the text at the current cursor position within the JPQL querytolerant- Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries- Returns:
- The
Expressionrepresenting the given sub-query
-
parseUsingExpressionFactory
protected AbstractExpression parseUsingExpressionFactory(WordParser wordParser, java.lang.String queryBNFId, boolean tolerant)
Right away parses the text by retrieving theExpressionFactoryfor the first word that is extracted fromWordParserat the current location.- Parameters:
wordParser- The text to parse based on the current position of the cursorqueryBNFId- The unique identifier of theJPQLQueryBNFthat is used to determine how to parse the text at the current cursor position within the JPQL querytolerant- Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries- Returns:
- The
Expressionrepresenting the given sub-query
-
populatePosition
public void populatePosition(QueryPosition queryPosition, int position)
Retrieves theExpressionlocated at the given position using the actual query, which may have extra whitespace.- Specified by:
populatePositionin interfaceExpressionposition- The array has one element and is the position of theExpressionto retrieve
-
rebuildActualText
protected final void rebuildActualText()
Rebuilds the actual parsed text if it has been cached.
-
rebuildParsedText
protected final void rebuildParsedText()
Rebuilds the parsed parsed text if it has been cached.
-
setParent
protected final void setParent(AbstractExpression parent)
Re-parents thisExpressionto be a child of the givenExpression.- Parameters:
parent- The new parent of this object
-
setText
protected final void setText(java.lang.String text)
Sets the text of thisExpression.- Parameters:
text- The immutable text wrapped by thisExpression, which cannot benull
-
shouldParseWithFactoryFirst
protected boolean shouldParseWithFactoryFirst()
Determines whether the parsing of the query should be performed using thefactoriesfirst or it should automatically fallback to the fallback factory.- Returns:
trueis returned by default so the factories are used before falling back
-
shouldSkipLiteral
protected boolean shouldSkipLiteral(AbstractExpression 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. Example: BETWEEN 10 20, when parsing 20, it should not be parsed as part of the lower bound expression.- Parameters:
expression- TheExpressionthat has just been parsed ornull- Returns:
true
-
toActualText
public java.lang.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:
toActualTextin interfaceExpression- Returns:
- The string representation of this
Expression
-
toParsedText
public java.lang.String toParsedText()
Returns a string representation of thisExpressionand 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:
toParsedTextin interfaceExpression- Returns:
- The string representation of this
Expression
-
toParsedText
protected abstract void toParsedText(java.lang.StringBuilder writer, boolean actual)Generates a string representation of thisExpression, including its children, if it has any.- Parameters:
writer- The buffer used to append thisExpression's string representationactual- 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
-
toString
public final java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-