Class AbstractFromClauseStateObject
- java.lang.Object
-
- org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
-
- org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractListHolderStateObject<VariableDeclarationStateObject>
-
- org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractFromClauseStateObject
-
- All Implemented Interfaces:
DeclarationStateObject,ListHolderStateObject<VariableDeclarationStateObject>,StateObject
- Direct Known Subclasses:
FromClauseStateObject,SimpleFromClauseStateObject
public abstract class AbstractFromClauseStateObject extends AbstractListHolderStateObject<VariableDeclarationStateObject> implements DeclarationStateObject
This state object represents the abstract definition of aFROMclause, which is either theFROMclause of the query or of a sub-query expression.- Version:
- 2.5
- See Also:
AbstractSelectStatementStateObject,FromClauseStateObject,AbstractFromClause- Author:
- Pascal Filion
- Since:
- 2.4
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringVARIABLE_DECLARATIONS_LISTNotifies the content of the list ofVariableDeclarationStateObjecthas changed.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractFromClauseStateObject(AbstractSelectStatementStateObject parent)Creates a newAbstractFromClauseStateObject.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description CollectionMemberDeclarationStateObjectaddCollectionDeclaration()Adds a new collection declaration to theFROMclause.CollectionMemberDeclarationStateObjectaddCollectionDeclaration(java.lang.String collectionValuedPath, java.lang.String identificationVariable)Adds a new collection declaration to theFROMclause.protected voidaddProblems(java.util.List<Problem> currentProblems)Adds to the given list the problems that were found with the current state of thisStateObject, which means there are validation issues.IdentificationVariableDeclarationStateObjectaddRangeDeclaration()Adds a new range variable declaration to theFROMclause.IdentificationVariableDeclarationStateObjectaddRangeDeclaration(java.lang.String entityName, java.lang.String identificationVariable)Adds a new range variable declaration.IdentificationVariableDeclarationStateObjectaddRangeDeclaration(IEntity entity, java.lang.String identificationVariable)Adds to this select statement a new range variable declaration.protected abstract java.lang.StringdeclarationBNF()Returns the BNF of the declaration part of this clause.ListIterable<? extends VariableDeclarationStateObject>declarations()Returns the list of declarations declared in the declaration clause of the current query.IdentificationVariableStateObjectfindIdentificationVariable(java.lang.String variable)Returns theIdentificationVariableStateObjectrepresenting the given identification variable.DeclarationStateObjectgetDeclaration()Returns the declaration clause which defines the domain of the query by declaring identification variables.AbstractFromClausegetExpression()Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.IManagedTypegetManagedType(StateObject stateObject)Returns theIManagedTypefor the given identification variable.AbstractSelectStatementStateObjectgetParent()Returns the parent of thisStateObject.java.lang.Iterable<IdentificationVariableStateObject>identificationVariables()Returns theIdentificationVariableStateObjectsholding onto the identification variables, which are the variables defined in theFROMclause.booleanisEquivalent(StateObject stateObject)Determines whether the givenStateObjectis equivalent to this one, i.e. the information of bothStateObjectis the same.protected java.lang.StringlistName()Returns the name that is uniquely identifying the list.voidparse(java.lang.String jpqlFragment)Parses the given JPQL fragment and create the select item.protected voidtoTextInternal(java.lang.Appendable writer)Prints out a string representation of thisStateObject, which should not be used to define atruestring representation of a JPQL query but should be used for debugging purposes.-
Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractListHolderStateObject
addChildren, addItem, addItems, addListChangeListener, areChildrenEquivalent, canMoveDown, canMoveUp, getItem, hasItems, initialize, items, itemsSize, moveDown, moveUp, removeItem, removeItems, removeListChangeListener, toStringItems
-
Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
acceptUnknownVisitor, acceptUnknownVisitor, addPropertyChangeListener, areEquivalent, buildProblem, buildProblem, buildStateObject, buildStateObjects, checkParent, children, decorate, equals, firePropertyChanged, getChangeSupport, getDecorator, getGrammar, getManagedTypeProvider, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, isDecorated, parent, parent, parent, removePropertyChangeListener, setExpression, setParent, toString, toString, toStringInternal, toStringItems, toText
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.persistence.jpa.jpql.tools.model.query.DeclarationStateObject
findManagedType
-
Methods inherited from interface org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject
accept, addPropertyChangeListener, children, decorate, getDecorator, getGrammar, getManagedTypeProvider, getQueryBuilder, getRoot, isDecorated, removePropertyChangeListener, setParent, toString, toText
-
-
-
-
Field Detail
-
VARIABLE_DECLARATIONS_LIST
public static final java.lang.String VARIABLE_DECLARATIONS_LIST
Notifies the content of the list ofVariableDeclarationStateObjecthas changed.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractFromClauseStateObject
protected AbstractFromClauseStateObject(AbstractSelectStatementStateObject parent)
Creates a newAbstractFromClauseStateObject.- Parameters:
parent- The parent of this state object, which cannot benull- Throws:
java.lang.NullPointerException- The given parent cannot benull
-
-
Method Detail
-
addCollectionDeclaration
public CollectionMemberDeclarationStateObject addCollectionDeclaration()
Adds a new collection declaration to theFROMclause.- Returns:
- The
CollectionMemberDeclarationStateObjectrepresenting the collection declaration
-
addCollectionDeclaration
public CollectionMemberDeclarationStateObject addCollectionDeclaration(java.lang.String collectionValuedPath, java.lang.String identificationVariable)
Adds a new collection declaration to theFROMclause.- Parameters:
collectionValuedPath- The collection-valued path expressionidentificationVariable- The variable defining the collection-valued path expression- Returns:
- The
CollectionMemberDeclarationStateObjectrepresenting the collection declaration
-
addProblems
protected void addProblems(java.util.List<Problem> currentProblems)
Adds to the given list the problems that were found with the current state of thisStateObject, which means there are validation issues.- Overrides:
addProblemsin classAbstractStateObject- Parameters:
currentProblems- The list to which the problems are added
-
addRangeDeclaration
public IdentificationVariableDeclarationStateObject addRangeDeclaration()
Adds a new range variable declaration to theFROMclause.- Returns:
- The
StateObjectrepresenting the range variable declaration
-
addRangeDeclaration
public IdentificationVariableDeclarationStateObject addRangeDeclaration(IEntity entity, java.lang.String identificationVariable)
Adds to this select statement a new range variable declaration.- Parameters:
entity- The external form of the entity to add to the declaration listidentificationVariable- The unique identifier identifying the abstract schema name- Returns:
- The state object of the new declaration
-
addRangeDeclaration
public IdentificationVariableDeclarationStateObject addRangeDeclaration(java.lang.String entityName, java.lang.String identificationVariable)
Adds a new range variable declaration.- Parameters:
entityName- The name of the entity nameidentificationVariable- The new identification variable- Returns:
- The state object of the new declaration
-
declarationBNF
protected abstract java.lang.String declarationBNF()
Returns the BNF of the declaration part of this clause.- Returns:
- The BNF of the declaration part of this clause
-
declarations
public ListIterable<? extends VariableDeclarationStateObject> declarations()
Returns the list of declarations declared in the declaration clause of the current query.- Specified by:
declarationsin interfaceDeclarationStateObject- Returns:
- The list of
VariableDeclarationStateObjectthat define the domain of the query
-
findIdentificationVariable
public IdentificationVariableStateObject findIdentificationVariable(java.lang.String variable)
Returns theIdentificationVariableStateObjectrepresenting the given identification variable.- Specified by:
findIdentificationVariablein interfaceStateObject- Overrides:
findIdentificationVariablein classAbstractStateObject- Parameters:
variable- The name of the identification variable to retrieve its state object- Returns:
- The
IdentificationVariableStateObjectdefining the given identification variable
-
getDeclaration
public DeclarationStateObject getDeclaration()
Returns the declaration clause which defines the domain of the query by declaring identification variables.- Specified by:
getDeclarationin interfaceStateObject- Overrides:
getDeclarationin classAbstractStateObject- Returns:
- The declaration clause of which this
StateObjectis a child; i.e. either the top-level declaration if this is part of the top query or the sub-level declaration if this is part of a subquery
-
getExpression
public AbstractFromClause getExpression()
Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.- Specified by:
getExpressionin interfaceStateObject- Overrides:
getExpressionin classAbstractStateObject- Returns:
- The parsed object when a JPQL query is parsed and converted into a
StateObjectornullwhen the JPQL query is manually created (i.e. not from a string)
-
getManagedType
public IManagedType getManagedType(StateObject stateObject)
Returns theIManagedTypefor the given identification variable. The search does not traverse up the query hierarchy if this declaration is for a subquery.
In the above query, the managed type associated with the identification variable:SELECT e FROM Department d JOIN KEY(d.employees).addresses a- d is "Department"
- a is "Address"
- Specified by:
getManagedTypein interfaceDeclarationStateObject- Parameters:
stateObject- TheStateObjectthat should be an simple identification variable or an encapsulated identification variable with the identifierKEYorVALUE- Returns:
- The
IManagedTyperepresenting the domain object declared by the given identification variable - See Also:
DeclarationStateObject.findManagedType(StateObject)
-
getParent
public AbstractSelectStatementStateObject getParent()
Returns the parent of thisStateObject.- Specified by:
getParentin interfaceStateObject- Overrides:
getParentin classAbstractStateObject- Returns:
- Returns the parent of this
StateObject, which isnullonly when this is the root of the hierarchy
-
identificationVariables
public java.lang.Iterable<IdentificationVariableStateObject> identificationVariables()
Returns theIdentificationVariableStateObjectsholding onto the identification variables, which are the variables defined in theFROMclause.Example:
Employee e; e is returnedIN (e.employees) AS emps; emps is returnedManager m JOIN m.employees emps; m and emps are returned
- Returns:
- The list of
IdentificationVariableStateObjects
-
isEquivalent
public boolean isEquivalent(StateObject stateObject)
Determines whether the givenStateObjectis equivalent to this one, i.e. the information of bothStateObjectis the same.- Specified by:
isEquivalentin interfaceStateObject- Overrides:
isEquivalentin classAbstractStateObject- Parameters:
stateObject- TheStateObjectto compare its content to this one- Returns:
trueif both object are equivalent;falseotherwise
-
listName
protected java.lang.String listName()
Returns the name that is uniquely identifying the list.- Specified by:
listNamein classAbstractListHolderStateObject<VariableDeclarationStateObject>- Returns:
- The unique name identifying the list
-
parse
public void parse(java.lang.String jpqlFragment)
Parses the given JPQL fragment and create the select item. For the top-level query, the fragment can contain several select items but for a subquery, it can represent only one.- Parameters:
jpqlFragment- The portion of the query representing one or several select items
-
toTextInternal
protected void toTextInternal(java.lang.Appendable writer) throws java.io.IOExceptionPrints out a string representation of thisStateObject, which should not be used to define atruestring representation of a JPQL query but should be used for debugging purposes.- Specified by:
toTextInternalin classAbstractStateObject- Parameters:
writer- The writer used to print out the string representation- Throws:
java.io.IOException- This should never happens, it is only required becauseAppendableis used instead of any concrete class
-
-