Class AbstractStateObject
java.lang.Object
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
- All Implemented Interfaces:
StateObject
- Direct Known Subclasses:
AbstractConditionalClauseStateObject,AbstractEncapsulatedExpressionStateObject,AbstractListHolderStateObject,AbstractModifyClauseStateObject,AbstractModifyStatementStateObject,AbstractPathExpressionStateObject,AbstractRangeVariableDeclarationStateObject,AbstractSelectClauseStateObject,AbstractSelectStatementStateObject,ArithmeticFactorStateObject,BetweenExpressionStateObject,CollectionExpressionStateObject,CollectionMemberDeclarationStateObject,CollectionMemberExpressionStateObject,CompoundExpressionStateObject,EmptyCollectionComparisonExpressionStateObject,FunctionExpressionStateObject,JoinStateObject,JPQLQueryStateObject,LikeExpressionStateObject,NotExpressionStateObject,NullComparisonExpressionStateObject,OrderByItemStateObject,ResultVariableStateObject,SimpleStateObject,TreatExpressionStateObject,UpdateItemStateObject
The abstract definition of a
StateObject.- Since:
- 2.4
- Version:
- 2.5
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractStateObject(StateObject parent) Creates a newAbstractStateObject. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanacceptUnknownVisitor(StateObjectVisitor visitor) The givenStateObjectVisitorneeds to visit this class but it is defined by a third-party provider.protected voidacceptUnknownVisitor(StateObjectVisitor visitor, Class<?> type, Class<?> parameterType) The givenStateObjectVisitorneeds to visit this class but it is defined by a third-party provider.protected voidaddChildren(List<StateObject> children) Adds the children of thisStateObjectto the given list.protected voidaddProblems(List<Problem> problems) Adds to the given list the problems that were found with the current state of thisStateObject, which means there are validation issues.final voidaddPropertyChangeListener(String propertyName, IPropertyChangeListener<?> listener) Registers the givenIPropertyChangeListenerfor the specified property.protected final booleanareEquivalent(StateObject stateObject1, StateObject stateObject2) Determines whether the given twoStateObjectare equivalent, i.e.protected final ProblembuildProblem(String messageKey) Creates a newProblemdescribing a single issue found with the information contained in thisStateObject.protected final ProblembuildProblem(String messageKey, String... arguments) Creates a newProblemdescribing a single issue found with the information contained in thisStateObject.protected <T extends StateObject>
TbuildStateObject(CharSequence jpqlFragment, String queryBNFId) Parses the given JPQL fragment using the given JPQL query BNF.protected <T extends StateObject>
List<T> buildStateObjects(CharSequence jpqlFragment, String queryBNFId) Parses the given JPQL fragment using the given JPQL query BNF.protected StateObjectcheckParent(StateObject parent) Checks whether the given parent isnullor not.final Iterable<StateObject> children()Returns the ordered children of thisStateObject.voiddecorate(StateObject decorator) Decorates thisStateObjectwith the given decorator.final booleanfindIdentificationVariable(String identificationVariable) Returns theIdentificationVariableStateObjectrepresenting the given identification variable.protected final voidfirePropertyChanged(String propertyName, Object oldValue, Object newValue) Notifies theIPropertyChangeListenersthat have been registered with the given property name that the property has changed.protected final ChangeSupportReturns the object responsible to actually register the listeners and to notify them upon changes made to thisStateObject.Returns the declaration clause which defines the domain of the query by declaring identification variables.Returns theStateObjectdecorating this one if one has been set, which means the behavior of thisStateObjectis modified by the decorator.Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.Returns the grammar that defines how to parse a JPQL query.Returns the provider of managed types.Returns the parent of thisStateObject.Returns theIJPQLQueryBuilderthat is responsible to create various part of theStateObjecthierarchy.getRoot()Returns the root of theStateObjecthierarchy.Retrieves the external type for the given Java type.Retrieves the external class for the given fully qualified class name.Returns a helper that gives access to the most commontypes.Returns the type repository for the application.final inthashCode()protected voidInitializes this state object.booleanDetermines whether thisStateObjectis being decorated by anotherStateObject, which means the behavior is modified by the given one.booleanisEquivalent(StateObject stateObject) Determines whether the givenStateObjectis equivalent to this one, i.e.protected <T extends StateObject>
List<T> Makes sure the given list ofStateObjecthas this one as its parent.protected <T extends StateObject>
Tparent(T stateObject) Makes sure the givenStateObjecthas this one as its parent.protected final <T extends StateObject>
T[]parent(T... stateObjects) Makes sure the given list ofStateObjecthas this one as its parent.final voidremovePropertyChangeListener(String propertyName, IPropertyChangeListener<?> listener) Unregisters the givenIPropertyChangeListenerthat was registered for the specified property.voidsetExpression(Expression expression) Sets the actual parsed object if thisStateObjectrepresentation of the JPQL query is created by converting the parsed representation of the JPQL query.final voidsetParent(StateObject parent) Sets the givenStateObjectto become the parent of this one.final StringtoString()final voidtoString(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.protected final voidtoStringInternal(Appendable writer) Prints out a string representation of thisStateObject.protected voidtoStringItems(Appendable writer, List<? extends StateObject> items, boolean useComma) final voidtoText(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.protected abstract voidtoTextInternal(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 java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject
accept
-
Constructor Details
-
AbstractStateObject
Creates a newAbstractStateObject.- Parameters:
parent- The parent of this state object, which cannot benull- Throws:
NullPointerException- The given parent cannot benull, unlesschangeSupportis overridden and does not throw the exception
-
-
Method Details
-
acceptUnknownVisitor
The givenStateObjectVisitorneeds to visit this class but it is defined by a third-party provider. This method will programmatically invoke the visit method defined on the given visitor which signature should be.{public|protected|private} void visit(ThirdPartyStateObject stateObject)or
{public|protected|private} void visit(StateObject stateObject)- Parameters:
visitor- TheStateObjectVisitorto visit thisStateObjectprogrammatically- Returns:
trueif the call was successfully executed;falseotherwise- Since:
- 2.4
-
acceptUnknownVisitor
protected void acceptUnknownVisitor(StateObjectVisitor visitor, Class<?> type, Class<?> parameterType) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException The givenStateObjectVisitorneeds to visit this class but it is defined by a third-party provider. This method will programmatically invoke the visit method defined on the given visitor which signature should be.or{public|protected|private} void visit(ThirdPartyStateObject stateObject){public|protected|private} void visit(StateObject stateObject)- Parameters:
visitor- TheStateObjectVisitorto visit thisStateObjectprogrammaticallytype- The type found in the hierarchy of the givenStateObjectVisitorthat will be used to retrieve the visit methodparameterType- The parameter type of the visit method- Throws:
NoSuchMethodExceptionIllegalAccessExceptionInvocationTargetException- Since:
- 2.4
- See Also:
-
addChildren
Adds the children of thisStateObjectto the given list.- Parameters:
children- The list used to store the children
-
addProblems
Adds to the given list the problems that were found with the current state of thisStateObject, which means there are validation issues.- Parameters:
problems- The list to which the problems are added
-
addPropertyChangeListener
public final void addPropertyChangeListener(String propertyName, IPropertyChangeListener<?> listener) Description copied from interface:StateObjectRegisters the givenIPropertyChangeListenerfor the specified property. The listener will be notified only for changes to the specified property.- Specified by:
addPropertyChangeListenerin interfaceStateObject- Parameters:
propertyName- The name of the property for which the listener was registeredlistener- The listener to be notified upon changes
-
areEquivalent
Determines whether the given twoStateObjectare equivalent, i.e. the information of bothStateObjectis the same.- Parameters:
stateObject1- The firstStateObjectto compare its content with the other onestateObject2- The secondStateObjectto compare its content with the other one- Returns:
trueif both objects are equivalent;falseotherwise
-
buildProblem
Creates a newProblemdescribing a single issue found with the information contained in thisStateObject.- Parameters:
messageKey- The key used to retrieve the localized message describing the problem found with the current state of thisStateObject- Returns:
- The new
Problem
-
buildProblem
Creates a newProblemdescribing a single issue found with the information contained in thisStateObject.- Parameters:
messageKey- The key used to retrieve the localized message describing the problem found with the current state of thisStateObjectarguments- A list of arguments that can be used to complete the message or an empty list if no additional information is necessary- Returns:
- The new
Problem
-
buildStateObject
Parses the given JPQL fragment using the given JPQL query BNF.- Parameters:
jpqlFragment- A portion of a JPQL query that will be parsed and converted into aStateObjectqueryBNFId- The unique identifier of the BNF that determines how to parse the fragment- Returns:
- A
StateObjectrepresentation of the given JPQL fragment
-
buildStateObjects
protected <T extends StateObject> List<T> buildStateObjects(CharSequence jpqlFragment, String queryBNFId) Parses the given JPQL fragment using the given JPQL query BNF.- Parameters:
jpqlFragment- A portion of a JPQL query that will be parsed and converted into either a singleStateObjector a list ofStateObject, which happens when the fragment contains a collection of items separated by either a comma or a spacequeryBNFId- The unique identifier of the BNF that will be used to parse the fragment- Returns:
- A list of
StateObjectsrepresenting the given JPQL fragment, which means the list may contain a singleStateObjector a multipleStateObjectsif the fragment contains more than one expression of the same type. Example: "JOIN e.employees e LEFT JOIN e.address a", this would be parsed in two state objects
-
checkParent
- Parameters:
parent- The parent of this state object- Returns:
- The given object
-
children
Description copied from interface:StateObjectReturns the ordered children of thisStateObject.- Specified by:
childrenin interfaceStateObject- Returns:
- The children of this
StateObjector an empty iterable this state object does not have children
-
decorate
Description copied from interface:StateObjectDecorates thisStateObjectwith the given decorator. It means the behavior of thisStateObjectis modified by the given one. By default, thisStateObjectbecomes the parent of the given one.- Specified by:
decoratein interfaceStateObject- Parameters:
decorator- TheStateObjectdecorating this one
-
equals
-
findIdentificationVariable
Description copied from interface:StateObjectReturns theIdentificationVariableStateObjectrepresenting the given identification variable.- Specified by:
findIdentificationVariablein interfaceStateObject- Parameters:
identificationVariable- The name of the identification variable to retrieve its state object- Returns:
- The
IdentificationVariableStateObjectdefining the given identification variable
-
firePropertyChanged
Notifies theIPropertyChangeListenersthat have been registered with the given property name that the property has changed.- Parameters:
propertyName- The name of the property associated with the property changeoldValue- The old value of the property that changednewValue- The new value of the property that changed
-
getChangeSupport
Returns the object responsible to actually register the listeners and to notify them upon changes made to thisStateObject.- Returns:
- The manager of listeners and notification
-
getDeclaration
Description copied from interface:StateObjectReturns the declaration clause which defines the domain of the query by declaring identification variables.- Specified by:
getDeclarationin interfaceStateObject- 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
-
getDecorator
Description copied from interface:StateObjectReturns theStateObjectdecorating this one if one has been set, which means the behavior of thisStateObjectis modified by the decorator.- Specified by:
getDecoratorin interfaceStateObject- Returns:
- The
StateObjectdecorating this one
-
getExpression
Description copied from interface:StateObjectReturns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.- Specified by:
getExpressionin interfaceStateObject- 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)
-
getGrammar
Description copied from interface:StateObjectReturns the grammar that defines how to parse a JPQL query.- Specified by:
getGrammarin interfaceStateObject- Returns:
- The grammar that was used to parse the JPQL query
-
getManagedTypeProvider
Description copied from interface:StateObjectReturns the provider of managed types.- Specified by:
getManagedTypeProviderin interfaceStateObject- Returns:
- The provider that gives access to the managed types
-
getParent
Description copied from interface:StateObjectReturns the parent of thisStateObject.- Specified by:
getParentin interfaceStateObject- Returns:
- Returns the parent of this
StateObject, which isnullonly when this is the root of the hierarchy
-
getQueryBuilder
Description copied from interface:StateObjectReturns theIJPQLQueryBuilderthat is responsible to create various part of theStateObjecthierarchy.- Specified by:
getQueryBuilderin interfaceStateObject- Returns:
- The builder that created this
StateObjectfrom a JPQL query or that gives access to various sub-builders
-
getRoot
Description copied from interface:StateObjectReturns the root of theStateObjecthierarchy.- Specified by:
getRootin interfaceStateObject- Returns:
- The root of the state model representing the JPQL query
-
getType
Retrieves the external type for the given Java type.- Parameters:
type- The Java type to wrap with an external form- Returns:
- The external form of the given type
-
getType
Retrieves the external class for the given fully qualified class name.- Parameters:
typeName- The fully qualified class name of the class to retrieve- Returns:
- The external form of the class to retrieve
-
getTypeHelper
Returns a helper that gives access to the most commontypes.- Returns:
- A helper containing a collection of methods related to
IType
-
getTypeRepository
Returns the type repository for the application.- Returns:
- The repository of
ITypes
-
hashCode
public final int hashCode() -
initialize
protected void initialize()Initializes this state object. -
isDecorated
public boolean isDecorated()Description copied from interface:StateObjectDetermines whether thisStateObjectis being decorated by anotherStateObject, which means the behavior is modified by the given one. returntrueif thisStateObjectis being decorated;falseotherwise- Specified by:
isDecoratedin interfaceStateObject
-
isEquivalent
Description copied from interface:StateObjectDetermines whether the givenStateObjectis equivalent to this one, i.e. the information of bothStateObjectis the same.- Specified by:
isEquivalentin interfaceStateObject- Parameters:
stateObject- TheStateObjectto compare its content to this one- Returns:
trueif both object are equivalent;falseotherwise
-
parent
Makes sure the given list ofStateObjecthas this one as its parent.- Parameters:
stateObjects- The list ofStateObjectto have this one as its parent- Returns:
- The given list of
StateObject
-
parent
Makes sure the given list ofStateObjecthas this one as its parent.- Parameters:
stateObjects- The list ofStateObjectto have this one as its parent- Returns:
- The given list of
StateObject
-
parent
Makes sure the givenStateObjecthas this one as its parent.- Parameters:
stateObject- TheStateObjectto have this one as its parent- Returns:
- The given
StateObject
-
removePropertyChangeListener
public final void removePropertyChangeListener(String propertyName, IPropertyChangeListener<?> listener) Description copied from interface:StateObjectUnregisters the givenIPropertyChangeListenerthat was registered for the specified property. The listener will no longer be notified when the property changes.- Specified by:
removePropertyChangeListenerin interfaceStateObject- Parameters:
propertyName- The name of the property for which the listener was registeredlistener- The listener to unregister
-
setExpression
Sets the actual parsed object if thisStateObjectrepresentation of the JPQL query is created by converting the parsed representation of the JPQL query.- Parameters:
expression- The parsed object when a JPQL query is parsed
-
setParent
Description copied from interface:StateObjectSets the givenStateObjectto become the parent of this one.- Specified by:
setParentin interfaceStateObject- Parameters:
parent- The new parentStateObjectof this one, which cannot benull
-
toString
-
toString
Description copied from interface:StateObjectPrints 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.Important: If this
StateObjectis decorated by another one, thenStateObject.toText(Appendable)from that decorator is invoked, otherwise the information contained in this one will be printed out.- Specified by:
toStringin interfaceStateObject- Parameters:
writer- The writer used to print out the string representation- See Also:
-
toStringInternal
Prints out a string representation of thisStateObject.Important: If this
StateObjectis decorated by another one, thentoString(Appendable)from that decorator is invoked, otherwisetoTextInternal(Appendable)from this one is invoked.- Parameters:
writer- The writer used to print out the string representation- Throws:
IOException- This should never happens, it is only required becauseAppendable.append(CharSequence)throws anIOException
-
toStringItems
protected void toStringItems(Appendable writer, List<? extends StateObject> items, boolean useComma) throws IOException - Throws:
IOException
-
toText
Description copied from interface:StateObjectPrints 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.Important: Even if this
StateObjectis decorated by another one, the decorator will not be used to print out a string representation of this one.- Specified by:
toTextin interfaceStateObject- Parameters:
writer- The writer used to print out the string representation- See Also:
-
toTextInternal
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.- Parameters:
writer- The writer used to print out the string representation- Throws:
IOException- This should never happens, it is only required becauseAppendableis used instead of any concrete class
-