Class AbstractJPQLQueryBuilder
- java.lang.Object
-
- org.eclipse.persistence.jpa.jpql.tools.model.AbstractJPQLQueryBuilder
-
- All Implemented Interfaces:
IJPQLQueryBuilder
- Direct Known Subclasses:
EclipseLinkJPQLQueryBuilder
,JPQLQueryBuilder1_0
,JPQLQueryBuilder2_0
,JPQLQueryBuilder2_1
public abstract class AbstractJPQLQueryBuilder extends java.lang.Object implements IJPQLQueryBuilder
An abstract implementation ofIJPQLQueryBuilder
that parses a JPQL query or any JPQL fragments and creates theStateObject
representation by delegating the creation to an instance ofBasicStateObjectBuilder
.- Version:
- 2.4
- See Also:
DefaultJPQLQueryBuilder
,EclipseLinkJPQLQueryBuilder
- Author:
- Pascal Filion
- Since:
- 2.4
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractJPQLQueryBuilder()
Creates a newAbstractJPQLQueryBuilder
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ICaseExpressionStateObjectBuilder
buildCaseExpressionStateObjectBuilder(StateObject parent)
Creates a builder that can create aCASE
expression programmatically.StateObject
buildStateObject(StateObject parent, java.lang.CharSequence jpqlFragment, java.lang.String queryBNFId)
Creates aStateObject
representation of the given JPQL fragment.JPQLQueryStateObject
buildStateObject(IManagedTypeProvider provider, java.lang.CharSequence jpqlQuery, boolean tolerant)
Creates a state model representation of a JPQL query that can be edited.JPQLQueryStateObject
buildStateObject(IManagedTypeProvider provider, java.lang.CharSequence jpqlQuery, java.lang.String queryBNFId, boolean tolerant)
Creates a state model representation of a JPQL query that can be edited.protected abstract BasicStateObjectBuilder
buildStateObjectBuilder()
Creates the builder that creates theStateObject
for eachExpression
.protected BasicStateObjectBuilder
getStateObjectBuilder()
Returns the builder that creates theStateObject
for eachExpression
.protected JPQLExpression
parse(java.lang.CharSequence jpqlQuery, JPQLGrammar jpqlGrammar, boolean tolerant)
Parses the given JPQL query with tolerant mode turned on.protected JPQLExpression
parse(java.lang.CharSequence jpqFragment, JPQLGrammar jpqlGrammar, java.lang.String queryBNFId)
Parses the given JPQL fragment with tolerant mode turned on.protected ExpressionVisitor
wrap(BasicStateObjectBuilder builder)
If a subclass needs to wrap the givenBasicStateObjectBuilder
with another visitor can do so by simply overriding this method.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.persistence.jpa.jpql.tools.model.IJPQLQueryBuilder
buildStateObjectBuilder, buildStateObjectBuilder, buildStateObjectBuilder, buildStateObjectBuilder, getGrammar
-
-
-
-
Method Detail
-
buildCaseExpressionStateObjectBuilder
public ICaseExpressionStateObjectBuilder buildCaseExpressionStateObjectBuilder(StateObject parent)
Creates a builder that can create aCASE
expression programmatically. Once the expression is complete,ICaseExpressionStateObjectBuilder.buildStateObject()
will return the result.- Specified by:
buildCaseExpressionStateObjectBuilder
in interfaceIJPQLQueryBuilder
- Parameters:
parent
- TheStateObject
that will be the parent of the newly created model- Returns:
- The builder of a
CASE
expression
-
buildStateObject
public JPQLQueryStateObject buildStateObject(IManagedTypeProvider provider, java.lang.CharSequence jpqlQuery, boolean tolerant)
Creates a state model representation of a JPQL query that can be edited.- Specified by:
buildStateObject
in interfaceIJPQLQueryBuilder
- Parameters:
provider
- The provider of managed typesjpqlQuery
- The JPQL query to parse into aStateObject
modeltolerant
- Determines if the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries- Returns:
- The root of the
StateObject
model that represents the edited form of the JPQL query
-
buildStateObject
public JPQLQueryStateObject buildStateObject(IManagedTypeProvider provider, java.lang.CharSequence jpqlQuery, java.lang.String queryBNFId, boolean tolerant)
Creates a state model representation of a JPQL query that can be edited.- Specified by:
buildStateObject
in interfaceIJPQLQueryBuilder
- Parameters:
provider
- The provider of managed typesjpqlQuery
- The JPQL query to parse into aStateObject
modelqueryBNFId
- The unique identifier of the query BNF that will be used to parse the fragmenttolerant
- Determines if the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries- Returns:
- The root of the
StateObject
model that represents the edited form of the JPQL query
-
buildStateObject
public StateObject buildStateObject(StateObject parent, java.lang.CharSequence jpqlFragment, java.lang.String queryBNFId)
Creates aStateObject
representation of the given JPQL fragment. In order to properly parse the fragment, the given unique identifier of theJPQLQueryBNF
will determine how to parse it.It is possible the given JPQL fragment has more than one expression, in this case, parsing should stop at the first comma (x, y) or space (x y) where x and y are two separate expressions.
- Specified by:
buildStateObject
in interfaceIJPQLQueryBuilder
- Parameters:
parent
- TheStateObject
that will be the parent of the newly created modeljpqlFragment
- A portion of a JPQL query that will be parsed and theStateObject
representation will be createdqueryBNFId
- The unique identifier of the query BNF that will be used to parse the fragment- Returns:
- The
StateObject
representation of the given JPQL fragment
-
buildStateObjectBuilder
protected abstract BasicStateObjectBuilder buildStateObjectBuilder()
Creates the builder that creates theStateObject
for eachExpression
.- Returns:
- The builder that will be visiting the
Expression
-
getStateObjectBuilder
protected final BasicStateObjectBuilder getStateObjectBuilder()
Returns the builder that creates theStateObject
for eachExpression
.- Returns:
- The builder that will be visiting the
Expression
-
parse
protected JPQLExpression parse(java.lang.CharSequence jpqlQuery, JPQLGrammar jpqlGrammar, boolean tolerant)
Parses the given JPQL query with tolerant mode turned on.- Parameters:
jpqlQuery
- The string representation of the JPQL query to parsejpqlGrammar
- The JPQL grammar that defines how to parse a JPQL querytolerant
- Determines if the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries- Returns:
- The root of the parsed tree representation of the JPQL query
-
parse
protected JPQLExpression parse(java.lang.CharSequence jpqFragment, JPQLGrammar jpqlGrammar, java.lang.String queryBNFId)
Parses the given JPQL fragment with tolerant mode turned on.- Parameters:
jpqFragment
- The string representation of the portion of a JPQL query to parsejpqlGrammar
- The JPQL grammar that defines how to parse a JPQL queryqueryBNFId
- The unique identifier of theJPQLQueryBNF
- Returns:
- The root of the parsed tree representation of the JPQL fragment
-
wrap
protected ExpressionVisitor wrap(BasicStateObjectBuilder builder)
If a subclass needs to wrap the givenBasicStateObjectBuilder
with another visitor can do so by simply overriding this method.buildStateObjectBuilder()
can't be easily overridden with anExpressionVisitor
due to the constraint on the return type.- Parameters:
builder
- The builder to wrap- Returns:
- By default the given builder is returned
-
-