EclipseLink 2.4.2, build 'v20130514-5956486' API Reference

org.eclipse.persistence.jpa.jpql.parser
Class AbstractJPQLGrammar

java.lang.Object
  extended by org.eclipse.persistence.jpa.jpql.parser.AbstractJPQLGrammar
All Implemented Interfaces:
JPQLGrammar
Direct Known Subclasses:
EclipseLinkJPQLGrammar1, EclipseLinkJPQLGrammar2_0, EclipseLinkJPQLGrammar2_1, EclipseLinkJPQLGrammar2_2, EclipseLinkJPQLGrammar2_3, EclipseLinkJPQLGrammar2_4, JPQLGrammar1_0, JPQLGrammar2_0, JPQLGrammar2_1

public abstract class AbstractJPQLGrammar
extends java.lang.Object
implements JPQLGrammar

The abstract definition of a JPQLGrammar. The grammar defines how a JPQL query is parsed, which is based on the BNF defined for that grammar. 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.

Version:
2.4
Author:
Pascal Filion
Since:
2.4

Constructor Summary
protected AbstractJPQLGrammar()
          Creates a new AbstractJPQLGrammar.
protected AbstractJPQLGrammar(AbstractJPQLGrammar jpqlGrammar)
          Creates a new AbstractJPQLGrammar.
 
Method Summary
 void addChildBNF(java.lang.String queryBNFId, java.lang.String childQueryBNFId)
          Adds to the given query BNF a child BNF.
 void addChildFactory(java.lang.String queryBNFId, java.lang.String childExpressionFactoryId)
          Adds to the given unique identifier of an ExpressionFactory to the given query BNF.
 void addIdentifier(java.lang.String expressionFactoryId, java.lang.String identifier)
          Adds the given JPQL identifier to this factory.
 void addIdentifiers(java.lang.String expressionFactoryId, java.lang.String... identifiers)
          Adds the given JPQL identifiers to this factory.
protected abstract  JPQLGrammar buildBaseGrammar()
          Creates the base JPQLGrammar this one extends, if one exists.
protected  ExpressionRegistry buildExpressionRegistry()
          Creates a new ExpressionRegistry that will be used to store the definition of the JPQL grammar.
 JPQLGrammar getBaseGrammar()
          Creates the base JPQLGrammar this one extends.
 ExpressionRegistry getExpressionRegistry()
          Returns the registry containing the JPQLQueryBNFs and the ExpressionFactories that are used to properly parse a JPQL query.
protected  void initialize()
          Initializes this JPQL grammar.
protected abstract  void initializeBNFs()
          Registers the JPQL query BNFs defining the JPQL grammar.
protected abstract  void initializeExpressionFactories()
          Registers the ExpressionFactories required to properly parse JPQL queries.
protected abstract  void initializeIdentifiers()
          Registers the JPQL identifiers support by this IJPQLExtension.
protected  void registerBNF(JPQLQueryBNF queryBNF)
          Registers the given JPQLQueryBNF.
protected  void registerFactory(ExpressionFactory expressionFactory)
          Registers the given ExpressionFactory by storing it for all its identifiers.
protected  void registerIdentifierRole(java.lang.String identifier, IdentifierRole role)
          Registers the IdentifierRole for the given JPQL identifier.
protected  void registerIdentifierVersion(java.lang.String identifier, JPAVersion version)
          Registers the JPAVersion for which the given JPQL identifier was defined.
 void setFallbackBNFId(java.lang.String queryBNFId, java.lang.String fallbackBNFId)
          When parsing the query and no JPQLQueryBNFs can help to parse the query, then it will fall back on the given one.
 void setFallbackExpressionFactoryId(java.lang.String queryBNFId, java.lang.String fallbackExpressionFactoryId)
          Sets the unique identifier of the ExpressionFactory to use when the fall back BNF ID is not null.
 void setHandleSubExpression(java.lang.String queryBNFId, boolean handleSubExpression)
           
 
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.parser.JPQLGrammar
getJPAVersion, getProviderVersion
 

Constructor Detail

AbstractJPQLGrammar

protected AbstractJPQLGrammar()
Creates a new AbstractJPQLGrammar.


AbstractJPQLGrammar

protected AbstractJPQLGrammar(AbstractJPQLGrammar jpqlGrammar)
Creates a new AbstractJPQLGrammar.

Parameters:
jpqlGrammar - The JPQLGrammar to extend with the content of this one without instantiating the base JPQLGrammar
Method Detail

addChildBNF

public void addChildBNF(java.lang.String queryBNFId,
                        java.lang.String childQueryBNFId)
Adds to the given query BNF a child BNF.

Parameters:
queryBNFId - The unique identifier of the parent BNF to add a child BNF
childQueryBNFId - The unique identifier of the child to add to the parent BNF

addChildFactory

public void addChildFactory(java.lang.String queryBNFId,
                            java.lang.String childExpressionFactoryId)
Adds to the given unique identifier of an ExpressionFactory to the given query BNF.

Parameters:
queryBNFId - The unique identifier of the parent BNF
childExpressionFactoryId - The unique identifier of the ExpressionFactory to add to the given query BNF

addIdentifier

public void addIdentifier(java.lang.String expressionFactoryId,
                          java.lang.String identifier)
Adds the given JPQL identifier to this factory.

Parameters:
expressionFactoryId - The unique identifier of the ExpressionFactory to add more JPQL identifiers
identifier - The JPQL identifier this factory will parse

addIdentifiers

public void addIdentifiers(java.lang.String expressionFactoryId,
                           java.lang.String... identifiers)
Adds the given JPQL identifiers to this factory.

Parameters:
expressionFactoryId - The unique identifier of the ExpressionFactory to add more JPQL identifiers
identifiers - The JPQL identifiers this factory will parse

buildBaseGrammar

protected abstract JPQLGrammar buildBaseGrammar()
Creates the base JPQLGrammar this one extends, if one exists.

IMPORTANT: The singleton instance of any JPQLGrammar (for example JPQLGrammar1_0.instance() cannot be used, the API does not support extending it, a new instance has to be created.

Returns:
The base JPQLGrammar or null if there is no base grammar

buildExpressionRegistry

protected ExpressionRegistry buildExpressionRegistry()
Creates a new ExpressionRegistry that will be used to store the definition of the JPQL grammar. This method is invoked if #buildJPQLGrammar() returns null.

Returns:
The registry of JPQLQueryBNFs, ExpressionFactories and the JPQL identifiers

getBaseGrammar

public JPQLGrammar getBaseGrammar()
Creates the base JPQLGrammar this one extends.

Returns:
The base JPQLGrammar or null if this is the base grammar

getExpressionRegistry

public ExpressionRegistry getExpressionRegistry()
Returns the registry containing the JPQLQueryBNFs and the ExpressionFactories that are used to properly parse a JPQL query.

Specified by:
getExpressionRegistry in interface JPQLGrammar
Returns:
The registry containing the information related to the JPQL grammar

initialize

protected void initialize()
Initializes this JPQL grammar.


initializeBNFs

protected abstract void initializeBNFs()
Registers the JPQL query BNFs defining the JPQL grammar.


initializeExpressionFactories

protected abstract void initializeExpressionFactories()
Registers the ExpressionFactories required to properly parse JPQL queries. An ExpressionFactory is responsible to create an Expression object that represents a portion of the JPQL query.


initializeIdentifiers

protected abstract void initializeIdentifiers()
Registers the JPQL identifiers support by this IJPQLExtension. The registration involves registering the JPAVersion and the IdentifierRole.


registerBNF

protected void registerBNF(JPQLQueryBNF queryBNF)
Registers the given JPQLQueryBNF. The BNF will be registered using its unique identifier.

Parameters:
queryBNF - The JPQLQueryBNF to store

registerFactory

protected void registerFactory(ExpressionFactory expressionFactory)
Registers the given ExpressionFactory by storing it for all its identifiers.

Parameters:
expressionFactory - The ExpressionFactory to store

registerIdentifierRole

protected void registerIdentifierRole(java.lang.String identifier,
                                      IdentifierRole role)
Registers the IdentifierRole for the given JPQL identifier.

Parameters:
identifier - The JPQL identifier to register its role within a JPQL query
role - The role of the given JPQL identifier

registerIdentifierVersion

protected void registerIdentifierVersion(java.lang.String identifier,
                                         JPAVersion version)
Registers the JPAVersion for which the given JPQL identifier was defined.

Parameters:
identifier - The JPQL identifier to register in which version it was added to the grammar
version - The version when the JPQL identifier was added to the grammar

setFallbackBNFId

public void setFallbackBNFId(java.lang.String queryBNFId,
                             java.lang.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:
queryBNFId - The unique identifier of the BNF to modify its fallback BNF unique identifier
fallbackBNFId - The unique identifier of the JPQLQueryBNF to use in the last resort

setHandleSubExpression

public void setHandleSubExpression(java.lang.String queryBNFId,
                                   boolean handleSubExpression)

setFallbackExpressionFactoryId

public void setFallbackExpressionFactoryId(java.lang.String queryBNFId,
                                           java.lang.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 JPQLQueryBNF. getFallbackBNFId() does not return null.

Parameters:
queryBNFId - The unique identifier of the BNF to modify its fallback expression factory unique identifier

EclipseLink 2.4.2, build 'v20130514-5956486' API Reference