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

public abstract Class JPQLQueryBNF

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.persistence.jpa.jpql.parser.JPQLStatementBNF, org.eclipse.persistence.jpa.jpql.parser.LikeExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.LikeExpressionEscapeCharacterBNF, org.eclipse.persistence.jpa.jpql.parser.LiteralBNF, org.eclipse.persistence.jpa.jpql.parser.LocalDateTypeBNF, org.eclipse.persistence.jpa.jpql.parser.NewValueBNF, org.eclipse.persistence.jpa.jpql.parser.NullComparisonExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.NullIfExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.NumericLiteralBNF, org.eclipse.persistence.jpa.jpql.parser.ObjectExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.OrderByClauseBNF, org.eclipse.persistence.jpa.jpql.parser.OrderByItemBNF, org.eclipse.persistence.jpa.jpql.parser.OrderSiblingsByClauseBNF, org.eclipse.persistence.jpa.jpql.parser.PatternValueBNF, org.eclipse.persistence.jpa.jpql.parser.QualifiedIdentificationVariableBNF, org.eclipse.persistence.jpa.jpql.parser.RangeDeclarationBNF, org.eclipse.persistence.jpa.jpql.parser.RangeVariableDeclarationBNF, org.eclipse.persistence.jpa.jpql.parser.RegexpExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.ResultVariableBNF, org.eclipse.persistence.jpa.jpql.parser.ScalarExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.SelectClauseBNF, org.eclipse.persistence.jpa.jpql.parser.SelectExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.SelectStatementBNF, org.eclipse.persistence.jpa.jpql.parser.SimpleArithmeticExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.SimpleCaseExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.SimpleConditionalExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.SimpleEntityExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.SimpleEntityOrValueExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.SimpleResultVariableBNF, org.eclipse.persistence.jpa.jpql.parser.SimpleSelectClauseBNF, org.eclipse.persistence.jpa.jpql.parser.SimpleSelectExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.SingleValuedObjectPathExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.SingleValuedPathExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.StartWithClauseBNF, org.eclipse.persistence.jpa.jpql.parser.StateFieldPathExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.StringExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.StringLiteralBNF, org.eclipse.persistence.jpa.jpql.parser.StringPrimaryBNF, org.eclipse.persistence.jpa.jpql.parser.SubqueryBNF, org.eclipse.persistence.jpa.jpql.parser.SubqueryFromClauseBNF, org.eclipse.persistence.jpa.jpql.parser.SubSelectIdentificationVariableDeclarationBNF, org.eclipse.persistence.jpa.jpql.parser.TableExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.TableVariableDeclarationBNF, org.eclipse.persistence.jpa.jpql.parser.TreatExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.TypeExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.UnionClauseBNF, org.eclipse.persistence.jpa.jpql.parser.UpdateClauseBNF, org.eclipse.persistence.jpa.jpql.parser.UpdateItemBNF, org.eclipse.persistence.jpa.jpql.parser.UpdateItemStateFieldPathExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.UpdateStatementBNF, org.eclipse.persistence.jpa.jpql.parser.VirtualJPQLQueryBNF, org.eclipse.persistence.jpa.jpql.parser.WhenClauseBNF, org.eclipse.persistence.jpa.jpql.parser.WhereClauseBNF, org.eclipse.persistence.jpa.jpql.parser.AbstractSchemaNameBNF, org.eclipse.persistence.jpa.jpql.parser.AggregateExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.ArithmeticExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.ArithmeticFactorBNF, org.eclipse.persistence.jpa.jpql.parser.ArithmeticPrimaryBNF, org.eclipse.persistence.jpa.jpql.parser.ArithmeticTermBNF, org.eclipse.persistence.jpa.jpql.parser.AsOfClauseBNF, org.eclipse.persistence.jpa.jpql.parser.BadExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.BetweenExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.BooleanExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.BooleanLiteralBNF, org.eclipse.persistence.jpa.jpql.parser.BooleanPrimaryBNF, org.eclipse.persistence.jpa.jpql.parser.CaseExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.CaseOperandBNF, org.eclipse.persistence.jpa.jpql.parser.AllOrAnyExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.CastExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.ExtractExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.GeneralIdentificationVariableBNF, org.eclipse.persistence.jpa.jpql.parser.InternalBetweenExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.InternalOrderByClauseBNF, org.eclipse.persistence.jpa.jpql.parser.LocalExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.OnClauseBNF, org.eclipse.persistence.jpa.jpql.parser.CoalesceExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.CollectionMemberDeclarationBNF, org.eclipse.persistence.jpa.jpql.parser.CollectionMemberExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.CollectionValuedPathExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.ComparisonExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.ConditionalExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.ConditionalFactorBNF, org.eclipse.persistence.jpa.jpql.parser.ConditionalPrimaryBNF, org.eclipse.persistence.jpa.jpql.parser.ConditionalTermBNF, org.eclipse.persistence.jpa.jpql.parser.ConnectByClauseBNF, org.eclipse.persistence.jpa.jpql.parser.ConstructorExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.ConstructorItemBNF, org.eclipse.persistence.jpa.jpql.parser.DatabaseTypeQueryBNF, org.eclipse.persistence.jpa.jpql.parser.DatetimeExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.DateTimePrimaryBNF, org.eclipse.persistence.jpa.jpql.parser.DateTimeTimestampLiteralBNF, org.eclipse.persistence.jpa.jpql.parser.DeleteClauseBNF, org.eclipse.persistence.jpa.jpql.parser.DeleteClauseRangeVariableDeclarationBNF, org.eclipse.persistence.jpa.jpql.parser.DeleteStatementBNF, org.eclipse.persistence.jpa.jpql.parser.DerivedCollectionMemberDeclarationBNF, org.eclipse.persistence.jpa.jpql.parser.ElseExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.EmptyCollectionComparisonExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.EntityExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.EntityOrValueExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.EntityTypeExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.EntityTypeLiteralBNF, org.eclipse.persistence.jpa.jpql.parser.EnumExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.EnumLiteralBNF, org.eclipse.persistence.jpa.jpql.parser.EnumPrimaryBNF, org.eclipse.persistence.jpa.jpql.parser.ExistsExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.FromClauseBNF, org.eclipse.persistence.jpa.jpql.parser.FunctionExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.FunctionItemBNF, org.eclipse.persistence.jpa.jpql.parser.FunctionsReturningDatetimeBNF, org.eclipse.persistence.jpa.jpql.parser.FunctionsReturningNumericsBNF, org.eclipse.persistence.jpa.jpql.parser.FunctionsReturningStringsBNF, org.eclipse.persistence.jpa.jpql.parser.GeneralCaseExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.GenericQueryBNF, org.eclipse.persistence.jpa.jpql.parser.GroupByClauseBNF, org.eclipse.persistence.jpa.jpql.parser.GroupByItemBNF, org.eclipse.persistence.jpa.jpql.parser.HavingClauseBNF, org.eclipse.persistence.jpa.jpql.parser.HierarchicalQueryClauseBNF, org.eclipse.persistence.jpa.jpql.parser.IdentificationVariableBNF, org.eclipse.persistence.jpa.jpql.parser.IdentificationVariableDeclarationBNF, org.eclipse.persistence.jpa.jpql.parser.InExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.InExpressionExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.InExpressionItemBNF, org.eclipse.persistence.jpa.jpql.parser.InputParameterBNF, org.eclipse.persistence.jpa.jpql.parser.InternalAggregateFunctionBNF, org.eclipse.persistence.jpa.jpql.parser.InternalCoalesceExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.InternalColumnExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.InternalConcatExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.InternalConnectByClauseBNF, org.eclipse.persistence.jpa.jpql.parser.InternalCountBNF, org.eclipse.persistence.jpa.jpql.parser.InternalEntityTypeExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.InternalFromClauseBNF, org.eclipse.persistence.jpa.jpql.parser.InternalJoinBNF, org.eclipse.persistence.jpa.jpql.parser.InternalLengthExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.InternalLocateStringExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.InternalLocateThirdExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.InternalLowerExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.InternalModExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.InternalOrderByItemBNF, org.eclipse.persistence.jpa.jpql.parser.InternalPowerExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.InternalRoundExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.InternalSelectExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.InternalSimpleFromClauseBNF, org.eclipse.persistence.jpa.jpql.parser.InternalSimpleSelectExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.InternalSqrtExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.InternalSubstringPositionExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.InternalSubstringStringExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.InternalUpdateClauseBNF, org.eclipse.persistence.jpa.jpql.parser.InternalUpperExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.InternalWhenClauseBNF, org.eclipse.persistence.jpa.jpql.parser.JoinAssociationPathExpressionBNF, org.eclipse.persistence.jpa.jpql.parser.JoinBNF, org.eclipse.persistence.jpa.jpql.parser.JoinFetchBNF
Annotations
@SuppressWarnings:nls
Imports
java.util.Arrays, .HashMap, .HashSet, .LinkedList, .List, .Locale, .Map, .Set, org.eclipse.persistence.jpa.jpql.utility.filter.Filter, .NullFilter, org.eclipse.persistence.jpa.jpql.utility.iterable.ArrayIterable

This defines a single Backus-Naur Form (BNF) of the JPQL grammar. The Java Persistence functional specifications are:

Provisional API: This interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.

Author
Pascal Filion
Since
2.3
Version
2.5.1

Field Summary

Modifier and TypeField and Description
private Map<String, ExpressionFactory>
cachedExpressionFactories

Caches the ExpressionFactory mapped by their the JPQL identifier registered with those ExpressionFactory.

private String[]
cachedExpressionFactoryIds

Caches the collection of unique identifiers of the ExpressionFactory registered with this BNF rule.

private String[]
cachedIdentifiers

The list of JPQL identifiers that are known by this BNF rule and its children, they are retrieved by scanning the list of ExpressionFactory registered with this BNF rule and its children.

private JPQLQueryBNF[]
childQueryBNFs

Caches the children of this BNF rule (which actually includes this one as well).

private List<String>
children

The children BNF of this one.

private boolean
compound

Determines whether this BNF has child BNFs registered only to properly parse a query or if the child BNFs are part of the BNF.

private List<String>
expressionFactoryIds

The list of unique identifiers for the ExpressionFactory that are registered with this BNF rule.

private ExpressionRegistry
expressionRegistry

The ExpressionRegistry with which this JPQLQueryBNF was registered.

private String
fallbackBNFId

The unique identifier of the JPQLQueryBNF to use in the last resort.

private String
fallbackExpressionFactoryId

The unique identifier of the ExpressionFactory to use when no other factories can be used automatically.

private Boolean
handleAggregate

Caches the property since any BNF rule is static.

private Boolean
handleCollection

Caches the property since any BNF rule is static.

private boolean
handleNestedArray

Determines whether this BNF handles parsing a nested array or not.

private boolean
handleSubExpression

This flag can be used to determine if this BNF handles parsing a sub-expression, i.e. an expression encapsulated by parenthesis.

private String
id

The unique identifier of this BNF rule.

private JPQLQueryBNF[]
nonCompoundChildren

Caches the children of this BNF rule (which actually includes this one as well) but do not includes BNF rules that are used for compounding a rule.

private static final Filter<JPQLQueryBNF>
nonCompoundFilter

Only keep one instance of the Filter used when initializing nonCompoundChildren JPQLQueryBNF.

Constructor Summary

AccessConstructor and Description
protected
JPQLQueryBNF(String
The unique identifier of this BNF rule
id
)

Creates a new JPQLQueryBNF.

Method Summary

Modifier and TypeMethod and Description
private void
addChildren(Set<JPQLQueryBNF>
The set to add the child BNF rules
queryBNFs
,
Filter<JPQLQueryBNF>
The Filter determines if the children of a given BNF should be added
filter
)

Adds to the given set the child BNF rules and requests them to add their children as long as they have not been traversed already.

private JPQLQueryBNF[]
private static Filter<JPQLQueryBNF>
private void
private void
private boolean
private boolean
public Iterable<JPQLQueryBNF>

Returns:

The children BNFs describing this BNF rule
children
()

Returns the set of all the query BNFs that are part of this BNF.

private JPQLQueryBNF[]
public ExpressionFactory

Returns:

The ExpressionFactory responsible to parse a portion of the query starting with the given identifier; null if nothing was registered for it
getExpressionFactory
(String
The JPQL identifier (in theory) that is used to retrieve the factory responsible to parse a portion of the query starting with that identifier
identifier
)

Retrieves the ExpressionFactory that is associated with the given identifier, if the given string is indeed a JPQL identifier.

public Iterable<String>

Returns:

The list of unique identifiers of the ExpressionFactory registered with this BNF rule and with its children
getExpressionFactoryIds
()

Returns the unique identifiers of the ExpressionFactory handled by this BNF rule, which includes those from the children as well.

private String[]
public 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 String

Returns:

The unique identifier of the JPQLQueryBNF to use in the last resort
getFallbackBNFId
()

When parsing the query and no JPQLQueryBNFs can help to parse the query, then it will fall back on this one.

public String

Returns:

The unique identifier of the ExpressionFactory
getFallbackExpressionFactoryId
()

Returns the unique identifier of the ExpressionFactory to use when the fall back BNF ID is not null.

public String

Returns:

The identifier used to register this JPQLQueryBNF with AbstractExpression
getId
()

Returns the unique identifier of this JPQLQueryBNF.

public Iterable<String>

Returns:

The list of JPQL identifiers that are supported by this BNF
getIdentifiers
()

Retrieves the JPQL identifiers that are supported by this BNF rule.

public boolean

Returns:

true if the sub-expression to parse might have several logical and/or arithmetic expressions; false otherwise
handleAggregate
()

Determines whether the Expression handles a collection of sub-expressions that are aggregated by logical or arithmetic operators.

public boolean

Returns:

true if the sub-expression to parse might have several sub-expressions separated by commas; false otherwise
handleCollection
()

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

public boolean
public boolean

Returns:

true if this BNF handles parsing a sub-expression; false otherwise
handleSubExpression
()

Determines whether this BNF handles parsing a sub-expression, i.e. parsing an expression encapsulated by parenthesis.

public boolean

Returns:

true if the BNF with the given ID is
hasChild
(String
The unique identifier of the BNF rule to check if it's a child of this one
queryBNFId
)

Determines whether the BNF with the given ID is part of this BNF or not.

public boolean

Returns:

true if the given word is a JPQL identifier and it is supported by this BNF; false otherwise
hasIdentifier
(String
A word that could be a JPQL identifier or anything else
word
)

Determines if this query BNF support the given word, which can be an identifier.

protected void
initialize()

Initializes this BNF by registering child JPQLQueryBNFs and ExpressionFactories.

private void
initialize(String
The unique identifier of this BNF rule
id
)

Initializes this JPQLQueryBNF.

public boolean

Returns:

false by default
isCompound
()

Determines whether this BNF has child BNFs registered only to properly parse a query or if the child BNFs are part of the BNF.

public Iterable<JPQLQueryBNF>

Returns:

The children BNFs describing this BNF rule. The set excludes BNF rules that are used to complete a BNF, such as the BNF rules defined for BETWEEN since they are required to properly parse the query
nonCompoundChildren
()

Returns the set of all the query BNFs that are part of this BNF.

protected final void
registerChild(String
The unique identifier of the BNF rule to add as a child
queryBNFId
)

Registers the unique identifier of the BNF rule as a child of this BNF rule.

protected final void
registerExpressionFactory(String
The unique identifier of the ExpressionFactory
expressionFactoryId
)

Registers a unique identifier of the ExpressionFactory to register with this BNF rule.

public void
setCompound(boolean
true if this BNF represents a compound BNF and its children are not part of this BNF but only to support compound expression; false otherwise
compound
)

Determines whether this BNF has child BNFs registered only to properly parse a query or if the child BNFs are part of the BNF.

pack-priv final void
setExpressionRegistry(ExpressionRegistry
The registry for a given JPQL grammar
expressionRegistry
)

Sets the backpointer to the ExpressionRegistry with which this JPQLQueryBNF was registered.

public void
setFallbackBNFId(String
The unique identifier of the JPQLQueryBNF to use in the last resort
fallbackBNFId
)

When parsing the query and no JPQLQueryBNFs can help to parse the query, then it will fall back on the given one.

public void
setFallbackExpressionFactoryId(String
The unique identifier of the ExpressionFactory
fallbackExpressionFactoryId
)

Sets the unique identifier of the ExpressionFactory to use when the fall back BNF ID is not null.

public void
setHandleAggregate(boolean
true if the sub-expression to parse might have several logical and/or arithmetic expressions; false otherwise
handleAggregate
)

Sets whether the Expression handles a collection of sub-expressions that are aggregated by logical or arithmetic operators.

public void
setHandleCollection(boolean
true if the sub-expression to parse might have several sub-expressions separated by commas; false otherwise
handleCollection
)

Sets whether the Expression handles a collection of sub-expressions that are separated by commas.

public void
setHandleNestedArray(boolean
true if the expression represented by this BNF can be a nested array; false otherwise
handleNestedArray
)

Sets whether this BNF supports nested array or not.

public void
setHandleSubExpression(boolean
true to let the creation of a sub-expression be created by the fallback ExpressionFactory registered with this BNF; false otherwise (which is the default value)
handleSubExpression
)

Sets whether this BNF handles parsing a sub-expression, i.e. parsing an expression encapsulated by parenthesis.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
protected void
toString(StringBuilder
The builder used to add information about this class
sb
)

Adds to the given builder more information about this JPQLQueryBNF.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

cachedExpressionFactoriesback to summary
private Map<String, ExpressionFactory> cachedExpressionFactories

Caches the ExpressionFactory mapped by their the JPQL identifier registered with those ExpressionFactory.

cachedExpressionFactoryIdsback to summary
private String[] cachedExpressionFactoryIds

Caches the collection of unique identifiers of the ExpressionFactory registered with this BNF rule.

cachedIdentifiersback to summary
private String[] cachedIdentifiers

The list of JPQL identifiers that are known by this BNF rule and its children, they are retrieved by scanning the list of ExpressionFactory registered with this BNF rule and its children.

childQueryBNFsback to summary
private JPQLQueryBNF[] childQueryBNFs

Caches the children of this BNF rule (which actually includes this one as well).

childrenback to summary
private List<String> children

The children BNF of this one.

compoundback to summary
private boolean compound

Determines whether this BNF has child BNFs registered only to properly parse a query or if the child BNFs are part of the BNF. An example if a compound BNF is BetweenExpressionBNF, it registers a series of children BNFs but they shouldn't be used to determine if they are part of that BNF since the comparator identifiers are.

expressionFactoryIdsback to summary
private List<String> expressionFactoryIds

The list of unique identifiers for the ExpressionFactory that are registered with this BNF rule.

expressionRegistryback to summary
private ExpressionRegistry expressionRegistry

The ExpressionRegistry with which this JPQLQueryBNF was registered.

fallbackBNFIdback to summary
private String fallbackBNFId

The unique identifier of the JPQLQueryBNF to use in the last resort.

fallbackExpressionFactoryIdback to summary
private String fallbackExpressionFactoryId

The unique identifier of the ExpressionFactory to use when no other factories can be used automatically.

handleAggregateback to summary
private Boolean handleAggregate

Caches the property since any BNF rule is static.

handleCollectionback to summary
private Boolean handleCollection

Caches the property since any BNF rule is static.

handleNestedArrayback to summary
private boolean handleNestedArray

Determines whether this BNF handles parsing a nested array or not.

handleSubExpressionback to summary
private boolean handleSubExpression

This flag can be used to determine if this BNF handles parsing a sub-expression, i.e. an expression encapsulated by parenthesis. See setHandleSubExpression(boolean) for more details.

idback to summary
private String id

The unique identifier of this BNF rule.

nonCompoundChildrenback to summary
private JPQLQueryBNF[] nonCompoundChildren

Caches the children of this BNF rule (which actually includes this one as well) but do not includes BNF rules that are used for compounding a rule.

nonCompoundFilterback to summary
private static final Filter<JPQLQueryBNF> nonCompoundFilter

Only keep one instance of the Filter used when initializing nonCompoundChildren JPQLQueryBNF. This should help with performance since the filter won't be created for each JPQLQueryBNF.

Constructor Detail

JPQLQueryBNFback to summary
protected JPQLQueryBNF(String id)

Creates a new JPQLQueryBNF.

Parameters
id:String

The unique identifier of this BNF rule

Exceptions
NullPointerException:
The given unique identifier cannot be null

Method Detail

addChildrenback to summary
private void addChildren(Set<JPQLQueryBNF> queryBNFs, Filter<JPQLQueryBNF> filter)

Adds to the given set the child BNF rules and requests them to add their children as long as they have not been traversed already.

Parameters
queryBNFs:Set<JPQLQueryBNF>

The set to add the child BNF rules

filter:Filter<JPQLQueryBNF>

The Filter determines if the children of a given BNF should be added

buildChildrenback to summary
private JPQLQueryBNF[] buildChildren(Filter<JPQLQueryBNF> filter)
buildNonCompoundFilterback to summary
private static Filter<JPQLQueryBNF> buildNonCompoundFilter()
calculateExpressionFactoriesback to summary
private void calculateExpressionFactories()
calculateExpressionFactoryIdsback to summary
private void calculateExpressionFactoryIds(Set<JPQLQueryBNF> queryBNFs, Set<String> factoryIds)
calculateHandleAggregateback to summary
private boolean calculateHandleAggregate(Set<JPQLQueryBNF> queryBNFs)
calculateHandleCollectionback to summary
private boolean calculateHandleCollection(Set<JPQLQueryBNF> queryBNFs)
childrenback to summary
public Iterable<JPQLQueryBNF> children()

Returns the set of all the query BNFs that are part of this BNF. The set always include this BNF as well.

Returns:Iterable<JPQLQueryBNF>

The children BNFs describing this BNF rule

getChildrenback to summary
private JPQLQueryBNF[] getChildren()
getExpressionFactoryback to summary
public ExpressionFactory getExpressionFactory(String identifier)

Retrieves the ExpressionFactory that is associated with the given identifier, if the given string is indeed a JPQL identifier.

Parameters
identifier:String

The JPQL identifier (in theory) that is used to retrieve the factory responsible to parse a portion of the query starting with that identifier

Returns:ExpressionFactory

The ExpressionFactory responsible to parse a portion of the query starting with the given identifier; null if nothing was registered for it

getExpressionFactoryIdsback to summary
public Iterable<String> getExpressionFactoryIds()

Returns the unique identifiers of the ExpressionFactory handled by this BNF rule, which includes those from the children as well.

Returns:Iterable<String>

The list of unique identifiers of the ExpressionFactory registered with this BNF rule and with its children

getExpressionFactoryIdsImpback to summary
private String[] getExpressionFactoryIdsImp()
getExpressionRegistryback to summary
public ExpressionRegistry getExpressionRegistry()

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

Returns:ExpressionRegistry

The registry containing the information related to the JPQL grammar

getFallbackBNFIdback to summary
public String getFallbackBNFId()

When parsing the query and no JPQLQueryBNFs can help to parse the query, then it will fall back on this one.

Returns:String

The unique identifier of the JPQLQueryBNF to use in the last resort

getFallbackExpressionFactoryIdback to summary
public String getFallbackExpressionFactoryId()

Returns the unique identifier of the ExpressionFactory to use when the fall back BNF ID is not null. This will be used to parse a portion of the query when the registered expression factories cannot parse it.

Note

This method is only called if getFallbackBNFId() does not return null.

Returns:String

The unique identifier of the ExpressionFactory

getIdback to summary
public String getId()

Returns the unique identifier of this JPQLQueryBNF.

Returns:String

The identifier used to register this JPQLQueryBNF with AbstractExpression

getIdentifiersback to summary
public Iterable<String> getIdentifiers()

Retrieves the JPQL identifiers that are supported by this BNF rule. The JPQL identifiers are retrieved by scanning the ExpressionFactory registered with this BNF rule and the child BNF rules.

Returns:Iterable<String>

The list of JPQL identifiers that are supported by this BNF

handleAggregateback to summary
public boolean handleAggregate()

Determines whether the Expression handles a collection of sub-expressions that are aggregated by logical or arithmetic operators.

Returns:boolean

true if the sub-expression to parse might have several logical and/or arithmetic expressions; false otherwise

handleCollectionback to summary
public boolean handleCollection()

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

Returns:boolean

true if the sub-expression to parse might have several sub-expressions separated by commas; false otherwise

handlesNestedArrayback to summary
public boolean handlesNestedArray()
Since
2.5
handleSubExpressionback to summary
public boolean handleSubExpression()

Determines whether this BNF handles parsing a sub-expression, i.e. parsing an expression encapsulated by parenthesis. See setHandleSubExpression(boolean) for more details.

Returns:boolean

true if this BNF handles parsing a sub-expression; false otherwise

hasChildback to summary
public boolean hasChild(String queryBNFId)

Determines whether the BNF with the given ID is part of this BNF or not.

Parameters
queryBNFId:String

The unique identifier of the BNF rule to check if it's a child of this one

Returns:boolean

true if the BNF with the given ID is

Since
2.5.1
hasIdentifierback to summary
public boolean hasIdentifier(String word)

Determines if this query BNF support the given word, which can be an identifier.

Parameters
word:String

A word that could be a JPQL identifier or anything else

Returns:boolean

true if the given word is a JPQL identifier and it is supported by this BNF; false otherwise

initializeback to summary
protected void initialize()

Initializes this BNF by registering child JPQLQueryBNFs and ExpressionFactories.

initializeback to summary
private void initialize(String id)

Initializes this JPQLQueryBNF.

Parameters
id:String

The unique identifier of this BNF rule

Exceptions
NullPointerException:
The given unique identifier cannot be null
isCompoundback to summary
public boolean isCompound()

Determines whether this BNF has child BNFs registered only to properly parse a query or if the child BNFs are part of the BNF. An example if a compound BNF is BetweenExpressionBNF, it registers a series of children BNFs but they shouldn't be used to determine if they are part of that BNF since the comparator identifiers are.

Returns:boolean

false by default

nonCompoundChildrenback to summary
public Iterable<JPQLQueryBNF> nonCompoundChildren()

Returns the set of all the query BNFs that are part of this BNF. The set always include this BNF as well.

Returns:Iterable<JPQLQueryBNF>

The children BNFs describing this BNF rule. The set excludes BNF rules that are used to complete a BNF, such as the BNF rules defined for BETWEEN since they are required to properly parse the query

registerChildback to summary
protected final void registerChild(String queryBNFId)

Registers the unique identifier of the BNF rule as a child of this BNF rule.

Parameters
queryBNFId:String

The unique identifier of the BNF rule to add as a child

Exceptions
NullPointerException:
The queryBNFId cannot be null
registerExpressionFactoryback to summary
protected final void registerExpressionFactory(String expressionFactoryId)

Registers a unique identifier of the ExpressionFactory to register with this BNF rule.

Parameters
expressionFactoryId:String

The unique identifier of the ExpressionFactory

Exceptions
NullPointerException:
The expressionFactoryId cannot be null
setCompoundback to summary
public void setCompound(boolean compound)

Determines whether this BNF has child BNFs registered only to properly parse a query or if the child BNFs are part of the BNF. An example if a compound BNF is BetweenExpressionBNF, it registers a series of children BNFs but they shouldn't be used to determine if they are part of that BNF since the comparator identifiers are.

Parameters
compound:boolean

true if this BNF represents a compound BNF and its children are not part of this BNF but only to support compound expression; false otherwise

setExpressionRegistryback to summary
pack-priv final void setExpressionRegistry(ExpressionRegistry expressionRegistry)

Sets the backpointer to the ExpressionRegistry with which this JPQLQueryBNF was registered.

Parameters
expressionRegistry:ExpressionRegistry

The registry for a given JPQL grammar

setFallbackBNFIdback to summary
public void setFallbackBNFId(String fallbackBNFId)

When parsing the query and no JPQLQueryBNFs can help to parse the query, then it will fall back on the given one.

Parameters
fallbackBNFId:String

The unique identifier of the JPQLQueryBNF to use in the last resort

setFallbackExpressionFactoryIdback to summary
public void setFallbackExpressionFactoryId(String fallbackExpressionFactoryId)

Sets the unique identifier of the ExpressionFactory to use when the fall back BNF ID is not null. This will be used to parse a portion of the query when the registered expression factories cannot parse it.

Note

This method is only called if getFallbackBNFId() does not return null.

Parameters
fallbackExpressionFactoryId:String

The unique identifier of the ExpressionFactory

setHandleAggregateback to summary
public void setHandleAggregate(boolean handleAggregate)

Sets whether the Expression handles a collection of sub-expressions that are aggregated by logical or arithmetic operators.

Parameters
handleAggregate:boolean

true if the sub-expression to parse might have several logical and/or arithmetic expressions; false otherwise

setHandleCollectionback to summary
public void setHandleCollection(boolean handleCollection)

Sets whether the Expression handles a collection of sub-expressions that are separated by commas.

Parameters
handleCollection:boolean

true if the sub-expression to parse might have several sub-expressions separated by commas; false otherwise

setHandleNestedArrayback to summary
public void setHandleNestedArray(boolean handleNestedArray)

Sets whether this BNF supports nested array or not. A nested array is a sub-expression with its child being a collection expression: (item_1, item_2, ..., item_n).

Parameters
handleNestedArray:boolean

true if the expression represented by this BNF can be a nested array; false otherwise

Since
2.5
setHandleSubExpressionback to summary
public void setHandleSubExpression(boolean handleSubExpression)

Sets whether this BNF handles parsing a sub-expression, i.e. parsing an expression encapsulated by parenthesis. Which in fact would be handled by the fallback ExpressionFactory. The default behavior is to not handle it.

A good example for using this option is when an Expression cannot use any ExpressionFactory for creating a child object, parsing will use the fallback ExpressionFactory, if one was specified. So when this is set to true, the fallback ExpressionFactory will be immediately invoked.

Let's say we want to parse "SELECT e FROM (SELECT a FROM Address a) e", FromClause cannot use a factory for parsing the entity name (that's what usually the FROM clause has) so it uses the fallback factory to create IdentificationVariableDeclaration. Then IdentificationVariableDeclaration also cannot use any factory to create its child object so it uses the fallback factory to create RangeVariableDeclaration. By changing the status of for handling the sub-expression for the BNFs for those objects, then a subquery can be created by RangeVariableDeclaration.

FromClause
 |- IdentificationVariableDeclaration
      |- RangeVariableDeclaration
           |- SubExpression(subquery)
In order to get this working, the following would have to be done into the grammar:
 public class MyJPQLGrammar extends AbstractJPQLGrammar {
  @Override
  protected void initializeBNFs() {
     setHandleSubExpression(InternalFromClauseBNF.ID,                true);
     setHandleSubExpression(InternalSimpleFromClauseBNF.ID,          true);
     setHandleSubExpression(IdentificationVariableDeclarationBNF.ID, true);
     setHandleSubExpression(RangeVariableDeclarationBNF.ID,          true);
  }
}
Parameters
handleSubExpression:boolean

true to let the creation of a sub-expression be created by the fallback ExpressionFactory registered with this BNF; false otherwise (which is the default value)

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
toStringback to summary
protected void toString(StringBuilder sb)

Adds to the given builder more information about this JPQLQueryBNF.

Parameters
sb:StringBuilder

The builder used to add information about this class