EclipseLink 2.4.2, build 'v20130514-5956486' API Reference

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

java.lang.Object
  extended by org.eclipse.persistence.jpa.jpql.parser.ExpressionFactory
All Implemented Interfaces:
java.lang.Comparable<ExpressionFactory>
Direct Known Subclasses:
AbsExpressionFactory, AbstractLiteralExpressionFactory, AbstractSchemaNameFactory, AllOrAnyExpressionFactory, AndExpressionFactory, ArithmeticExpressionFactory, AvgFunctionFactory, BadExpressionFactory, BetweenExpressionFactory, CaseExpressionFactory, CastExpressionFactory, CoalesceExpressionFactory, CollectionMemberDeclarationFactory, CollectionMemberExpressionFactory, ComparisonExpressionFactory, ConcatExpressionFactory, ConstructorExpressionFactory, CountFunctionFactory, DatabaseTypeFactory, DateTimeFactory, DeleteClauseFactory, DeleteStatementFactory, EmptyCollectionComparisonExpressionFactory, EntryExpressionFactory, ExistsExpressionFactory, ExtractExpressionFactory, FromClauseFactory, FunctionExpressionFactory, GeneralIdentificationExpressionFactory, GroupByClauseFactory, GroupByItemFactory, HavingClauseFactory, IdentificationVariableDeclarationFactory, IdentificationVariableFactory, IndexExpressionFactory, InExpressionFactory, InternalOrderByItemFactory, IsExpressionFactory, JoinFactory, KeywordExpressionFactory, LengthExpressionFactory, LikeExpressionFactory, LocateExpressionFactory, LowerExpressionFactory, MaxFunctionFactory, MinFunctionFactory, ModExpressionFactory, NotExpressionFactory, NullComparisonExpressionFactory, NullIfExpressionFactory, ObjectExpressionFactory, OnClauseFactory, OrderByClauseFactory, OrderByItemFactory, OrExpressionFactory, RangeDeclarationFactory, RangeVariableDeclarationFactory, RegexpExpressionFactory, ResultVariableFactory, SelectClauseFactory, SelectStatementFactory, SimpleSelectStatementFactory, SizeExpressionFactory, SqrtExpressionFactory, StringLiteralFactory, SubstringExpressionFactory, SumFunctionFactory, TableExpressionFactory, TableVariableDeclarationFactory, TreatExpressionFactory, TrimExpressionFactory, TypeExpressionFactory, UnionClauseFactory, UnknownExpressionFactory, UpdateClauseFactory, UpdateItemFactory, UpdateItemStateFieldPathExpressionFactory, UpdateStatementFactory, UpperExpressionFactory, WhenClauseFactory, WhereClauseFactory

public abstract class ExpressionFactory
extends java.lang.Object
implements java.lang.Comparable<ExpressionFactory>

An ExpressionFactory is responsible to parse a portion of JPQL query that starts with one of the factory's identifiers. 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.3

Constructor Summary
protected ExpressionFactory(java.lang.String id, java.lang.String... identifiers)
          Creates a new ExpressionFactory.
 
Method Summary
protected abstract  AbstractExpression buildExpression(AbstractExpression parent, WordParser wordParser, java.lang.String word, JPQLQueryBNF queryBNF, AbstractExpression expression, boolean tolerant)
          Creates a new Expression.
 int compareTo(ExpressionFactory expressionFactory)
          
 boolean equals(java.lang.Object object)
          
 ExpressionRegistry getExpressionRegistry()
          Returns the registry containing the JPQLQueryBNFs and the ExpressionFactories that are used to properly parse a JPQL query.
 java.lang.String getFallBackExpressionFactoryId()
          Returns the unique identifier of the ExpressionFactory to use when this one cannot create the right Expression based on the JPQL fragment to parse.
 java.lang.String getId()
          Returns the unique identifier of this ExpressionFactory.
 int hashCode()
          
 java.lang.String[] identifiers()
          Returns the JPQL identifiers handled by this factory.
 void setFallBackExpressionFactory(java.lang.String expressionFactoryId)
          Sets the unique identifier of the ExpressionFactory to use when this one cannot create the right Expression based on the JPQL fragment to parse.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExpressionFactory

protected ExpressionFactory(java.lang.String id,
                            java.lang.String... identifiers)
Creates a new ExpressionFactory.

Parameters:
id - The unique identifier of this ExpressionFactory
identifiers - The JPQL identifiers handled by this factory
Throws:
java.lang.NullPointerException - The given unique identifier cannot be null or the list of JPQL identifiers was null
Method Detail

buildExpression

protected abstract AbstractExpression buildExpression(AbstractExpression parent,
                                                      WordParser wordParser,
                                                      java.lang.String word,
                                                      JPQLQueryBNF queryBNF,
                                                      AbstractExpression expression,
                                                      boolean tolerant)
Creates a new Expression.

Parameters:
parent - The parent expression
wordParser - The text to parse based on the current position of the cursor
word - The current word to parse
queryBNF - The BNF grammar that was used to identifier this factory to be capable to parse a portion of the query
expression - During the parsing, it is possible the first part of an expression was parsed which needs to be used as a sub-expression of the newly created expression
Returns:
A new Expression representing a portion or the totality of the given text

compareTo

public final int compareTo(ExpressionFactory expressionFactory)

Specified by:
compareTo in interface java.lang.Comparable<ExpressionFactory>

equals

public final boolean equals(java.lang.Object object)

Overrides:
equals in class java.lang.Object

getExpressionRegistry

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

Returns:
The registry containing the information related to the JPQL grammar

getFallBackExpressionFactoryId

public java.lang.String getFallBackExpressionFactoryId()
Returns the unique identifier of the ExpressionFactory to use when this one cannot create the right Expression based on the JPQL fragment to parse.

Note: Only PreLiteralExpressionFactory and LiteralExpressionFactory currently support this feature.

A good example is JoinCollectionValuedPathExpressionFactory giving the fallback factory to PreLiteralExpressionFactory, which in return gives it to LiteralExpressionFactory. This allows parsing incomplete queries correctly but changes the object being created, rather than creating an IdentificationVariable, an AbstractSchemaName is instead.

Returns:
The unique identifier of the ExpressionFactory

getId

public final java.lang.String getId()
Returns the unique identifier of this ExpressionFactory.

Returns:
The identifier used to register this ExpressionFactory with ExpressionRegistry

hashCode

public final int hashCode()

Overrides:
hashCode in class java.lang.Object

identifiers

public final java.lang.String[] identifiers()
Returns the JPQL identifiers handled by this factory.

Returns:
The list of JPQL identifiers this factory knows how to parse

setFallBackExpressionFactory

public void setFallBackExpressionFactory(java.lang.String expressionFactoryId)
Sets the unique identifier of the ExpressionFactory to use when this one cannot create the right Expression based on the JPQL fragment to parse.

Note: Only PreLiteralExpressionFactory and LiteralExpressionFactory currently support this feature.

A good example is JoinCollectionValuedPathExpressionFactory giving the fallback factory to PreLiteralExpressionFactory, which in return gives it to LiteralExpressionFactory. This allows parsing incomplete queries correctly but changes the object being created, rather than creating an IdentificationVariable, an AbstractSchemaName is instead.

Parameters:
fallbackExpressionFactoryId - The unique identifier of the ExpressionFactory

toString

public final java.lang.String toString()

Overrides:
toString in class java.lang.Object

EclipseLink 2.4.2, build 'v20130514-5956486' API Reference