public abstract class AbstractStateObject extends java.lang.Object implements StateObject
StateObject.| Modifier | Constructor and Description |
|---|---|
protected |
AbstractStateObject(StateObject parent)
Creates a new
AbstractStateObject. |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
acceptUnknownVisitor(StateObjectVisitor visitor)
The given
StateObjectVisitor needs to visit this class but it is defined by a
third-party provider. |
protected void |
acceptUnknownVisitor(StateObjectVisitor visitor,
java.lang.Class<?> type,
java.lang.Class<?> parameterType)
The given
StateObjectVisitor needs to visit this class but it is defined by a
third-party provider. |
protected void |
addChildren(java.util.List<StateObject> children)
Adds the children of this
StateObject to the given list. |
protected void |
addProblems(java.util.List<Problem> problems)
Adds to the given list the problems that were found with the current state of this
StateObject, which means there are validation issues. |
void |
addPropertyChangeListener(java.lang.String propertyName,
IPropertyChangeListener<?> listener)
Registers the given
IPropertyChangeListener for the specified property. |
protected boolean |
areEquivalent(StateObject stateObject1,
StateObject stateObject2)
Determines whether the given two
StateObject are equivalent, i.e. the information of
both StateObject is the same. |
protected Problem |
buildProblem(java.lang.String messageKey)
Creates a new
Problem describing a single issue found with the information contained
in this StateObject. |
protected Problem |
buildProblem(java.lang.String messageKey,
java.lang.String... arguments)
Creates a new
Problem describing a single issue found with the information contained
in this StateObject. |
protected <T extends StateObject> |
buildStateObject(java.lang.CharSequence jpqlFragment,
java.lang.String queryBNFId)
Parses the given JPQL fragment using the given JPQL query BNF.
|
protected <T extends StateObject> |
buildStateObjects(java.lang.CharSequence jpqlFragment,
java.lang.String queryBNFId)
Parses the given JPQL fragment using the given JPQL query BNF.
|
protected StateObject |
checkParent(StateObject parent)
Checks whether the given parent is
null or not. |
java.lang.Iterable<StateObject> |
children()
Returns the ordered children of this
StateObject. |
void |
decorate(StateObject decorator)
Decorates this
StateObject with the given decorator. |
boolean |
equals(java.lang.Object object) |
IdentificationVariableStateObject |
findIdentificationVariable(java.lang.String identificationVariable)
Returns the
IdentificationVariableStateObject representing the given identification
variable. |
protected void |
firePropertyChanged(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
Notifies the
IPropertyChangeListeners that have been registered
with the given property name that the property has changed. |
protected ChangeSupport |
getChangeSupport()
Returns the object responsible to actually register the listeners and to notify them upon
changes made to this
StateObject. |
DeclarationStateObject |
getDeclaration()
Returns the declaration clause which defines the domain of the query by declaring
identification variables.
|
StateObject |
getDecorator()
Returns the
StateObject decorating this one if one has been set, which means the
behavior of this StateObject is modified by the decorator. |
Expression |
getExpression()
Returns the actual parsed object if this
StateObject representation of the JPQL query
was created by parsing an existing JPQL query. |
JPQLGrammar |
getGrammar()
Returns the grammar that defines how to parse a JPQL query.
|
IManagedTypeProvider |
getManagedTypeProvider()
Returns the provider of managed types.
|
StateObject |
getParent()
Returns the parent of this
StateObject. |
IJPQLQueryBuilder |
getQueryBuilder()
Returns the
IJPQLQueryBuilder that is responsible to create various part of the StateObject hierarchy. |
JPQLQueryStateObject |
getRoot()
Returns the root of the
StateObject hierarchy. |
IType |
getType(java.lang.Class<?> type)
Retrieves the external type for the given Java type.
|
IType |
getType(java.lang.String typeName)
Retrieves the external class for the given fully qualified class name.
|
TypeHelper |
getTypeHelper()
Returns a helper that gives access to the most common
types. |
ITypeRepository |
getTypeRepository()
Returns the type repository for the application.
|
int |
hashCode() |
protected void |
initialize()
Initializes this state object.
|
boolean |
isDecorated()
Determines whether this
StateObject is being decorated by another StateObject,
which means the behavior is modified by the given one. |
boolean |
isEquivalent(StateObject stateObject)
Determines whether the given
StateObject is equivalent to this one, i.e. the
information of both StateObject is the same. |
protected <T extends StateObject> |
parent(java.util.List<T> stateObjects)
Makes sure the given list of
StateObject has this one as its parent. |
protected <T extends StateObject> |
parent(T... stateObjects)
Makes sure the given list of
StateObject has this one as its parent. |
protected <T extends StateObject> |
parent(T stateObject)
Makes sure the given
StateObject has this one as its parent. |
void |
removePropertyChangeListener(java.lang.String propertyName,
IPropertyChangeListener<?> listener)
Unregisters the given
IPropertyChangeListener that was registered for the specified
property. |
void |
setExpression(Expression expression)
Sets the actual parsed object if this
StateObject representation of the JPQL query
is created by converting the parsed representation of the JPQL query. |
void |
setParent(StateObject parent)
Sets the given
StateObject to become the parent of this one. |
java.lang.String |
toString() |
void |
toString(java.lang.Appendable writer)
Prints out a string representation of this
StateObject, which should not be used to
define a true string representation of a JPQL query but should be used for
debugging purposes. |
protected void |
toStringInternal(java.lang.Appendable writer)
Prints out a string representation of this
StateObject. |
protected void |
toStringItems(java.lang.Appendable writer,
java.util.List<? extends StateObject> items,
boolean useComma) |
void |
toText(java.lang.Appendable writer)
Prints out a string representation of this
StateObject, which should not be used to
define a true string representation of a JPQL query but should be used for
debugging purposes. |
protected abstract void |
toTextInternal(java.lang.Appendable writer)
Prints out a string representation of this
StateObject, which should not be used to
define a true string representation of a JPQL query but should be used for
debugging purposes. |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitacceptprotected AbstractStateObject(StateObject parent)
AbstractStateObject.The - parent of this state object, which cannot be nulljava.lang.NullPointerException - The given parent cannot be null, unless changeSupport is overridden and does not throw the exceptionprotected boolean acceptUnknownVisitor(StateObjectVisitor visitor)
StateObjectVisitor needs 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)visitor - The StateObjectVisitor to visit this StateObject programmaticallytrue if the call was successfully executed; false otherwiseprotected void acceptUnknownVisitor(StateObjectVisitor visitor, java.lang.Class<?> type, java.lang.Class<?> parameterType) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
StateObjectVisitor needs 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)visitor - The StateObjectVisitor to visit this StateObject programmaticallytype - The type found in the hierarchy of the given StateObjectVisitor that will
be used to retrieve the visit methodparameterType - The parameter type of the visit methodjava.lang.NoSuchMethodExceptionjava.lang.IllegalAccessExceptionjava.lang.reflect.InvocationTargetException#acceptUnknownVisitor(ExpressionVisitor)protected void addChildren(java.util.List<StateObject> children)
StateObject to the given list.children - The list used to store the childrenprotected void addProblems(java.util.List<Problem> problems)
StateObject, which means there are validation issues.problems - The list to which the problems are addedpublic final void addPropertyChangeListener(java.lang.String propertyName,
IPropertyChangeListener<?> listener)
IPropertyChangeListener for the specified property. The listener
will be notified only for changes to the specified property.addPropertyChangeListener in interface StateObjectpropertyName - The name of the property for which the listener was registeredlistener - The listener to be notified upon changesprotected final boolean areEquivalent(StateObject stateObject1, StateObject stateObject2)
StateObject are equivalent, i.e. the information of
both StateObject is the same.stateObject1 - The first StateObject to compare its content with the other onestateObject2 - The second StateObject to compare its content with the other onetrue if both objects are equivalent; false otherwiseprotected final Problem buildProblem(java.lang.String messageKey)
Problem describing a single issue found with the information contained
in this StateObject.messageKey - The key used to retrieve the localized message describing the problem found
with the current state of this StateObjectProblemprotected final Problem buildProblem(java.lang.String messageKey, java.lang.String... arguments)
Problem describing a single issue found with the information contained
in this StateObject.messageKey - The key used to retrieve the localized message describing the problem found
with the current state of this StateObjectarguments - A list of arguments that can be used to complete the message or an empty list
if no additional information is necessaryProblemprotected <T extends StateObject> T buildStateObject(java.lang.CharSequence jpqlFragment, java.lang.String queryBNFId)
jpqlFragment - A portion of a JPQL query that will be parsed and converted into a StateObjectqueryBNFId - The unique identifier of the BNF that determines how to parse the fragmentStateObject representation of the given JPQL fragmentprotected <T extends StateObject> java.util.List<T> buildStateObjects(java.lang.CharSequence jpqlFragment, java.lang.String queryBNFId)
jpqlFragment - A portion of a JPQL query that will be parsed and converted into either a
single StateObject or a list of StateObject, 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 fragmentStateObjects representing the given JPQL fragment, which
means the list may contain a single StateObject or a multiple StateObjects if 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 objectsprotected StateObject checkParent(StateObject parent)
null or not. If it's null then
throw a NullPointerException.parent - The parent of this state objectpublic final java.lang.Iterable<StateObject> children()
StateObject.children in interface StateObjectStateObject or an empty iterable this state object does
not have childrenpublic void decorate(StateObject decorator)
StateObject with the given decorator. It means the behavior of this
StateObject is modified by the given one. By default, this StateObject
becomes the parent of the given one.decorate in interface StateObjectdecorator - The StateObject decorating this onepublic final boolean equals(java.lang.Object object)
equals in class java.lang.Objectpublic IdentificationVariableStateObject findIdentificationVariable(java.lang.String identificationVariable)
IdentificationVariableStateObject representing the given identification
variable.findIdentificationVariable in interface StateObjectIdentificationVariableStateObject defining the given identification variableprotected final void firePropertyChanged(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
IPropertyChangeListeners that have been registered
with the given property name that the property has changed.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 changedprotected final ChangeSupport getChangeSupport()
StateObject.public DeclarationStateObject getDeclaration()
getDeclaration in interface StateObjectStateObject is 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 subquerypublic StateObject getDecorator()
StateObject decorating this one if one has been set, which means the
behavior of this StateObject is modified by the decorator.getDecorator in interface StateObjectStateObject decorating this onepublic Expression getExpression()
StateObject representation of the JPQL query
was created by parsing an existing JPQL query.getExpression in interface StateObjectStateObject
or null when the JPQL query is manually created (i.e. not from a string)public JPQLGrammar getGrammar()
getGrammar in interface StateObjectpublic IManagedTypeProvider getManagedTypeProvider()
getManagedTypeProvider in interface StateObjectpublic StateObject getParent()
StateObject.getParent in interface StateObjectStateObject, which is null only when
this is the root of the hierarchypublic IJPQLQueryBuilder getQueryBuilder()
IJPQLQueryBuilder that is responsible to create various part of the StateObject hierarchy.getQueryBuilder in interface StateObjectStateObject from a JPQL query or that gives
access to various sub-builderspublic JPQLQueryStateObject getRoot()
StateObject hierarchy.getRoot in interface StateObjectpublic IType getType(java.lang.Class<?> type)
type - The Java type to wrap with an external formpublic IType getType(java.lang.String typeName)
typeName - The fully qualified class name of the class to retrievepublic TypeHelper getTypeHelper()
types.ITypepublic ITypeRepository getTypeRepository()
ITypespublic final int hashCode()
hashCode in class java.lang.Objectprotected void initialize()
public boolean isDecorated()
StateObject is being decorated by another StateObject,
which means the behavior is modified by the given one.
return true if this StateObject is being decorated; false
otherwiseisDecorated in interface StateObjectpublic boolean isEquivalent(StateObject stateObject)
StateObject is equivalent to this one, i.e. the
information of both StateObject is the same.isEquivalent in interface StateObjectstateObject - The StateObject to compare its content to this onetrue if both object are equivalent; false otherwiseprotected <T extends StateObject> java.util.List<T> parent(java.util.List<T> stateObjects)
StateObject has this one as its parent.stateObjects - The list of StateObject to have this one as its parentStateObjectprotected <T extends StateObject> T[] parent(T... stateObjects)
StateObject has this one as its parent.stateObjects - The list of StateObject to have this one as its parentStateObjectprotected <T extends StateObject> T parent(T stateObject)
StateObject has this one as its parent.stateObject - The StateObject to have this one as its parentStateObjectpublic final void removePropertyChangeListener(java.lang.String propertyName,
IPropertyChangeListener<?> listener)
IPropertyChangeListener that was registered for the specified
property. The listener will no longer be notified when the property changes.removePropertyChangeListener in interface StateObjectpropertyName - The name of the property for which the listener was registeredlistener - The listener to unregisterpublic void setExpression(Expression expression)
StateObject representation of the JPQL query
is created by converting the parsed representation of the JPQL query.expression - The parsed object when a JPQL query is parsedpublic final void setParent(StateObject parent)
StateObject to become the parent of this one.setParent in interface StateObjectparent - The new parent StateObject of this one, which cannot be nullpublic final java.lang.String toString()
toString in class java.lang.Objectpublic final void toString(java.lang.Appendable writer)
StateObject, which should not be used to
define a true string representation of a JPQL query but should be used for
debugging purposes.
Important: If this StateObject is decorated by another one, then StateObject.toString(Appendable) from that decorator is invoked, otherwise the information contained in
this one will be printed out.
toString in interface StateObjectwriter - The writer used to print out the string representationStateObject.toText(Appendable)protected final void toStringInternal(java.lang.Appendable writer)
throws java.io.IOException
StateObject.
Important: If this StateObject is decorated by another one, then toString(Appendable) from that decorator is invoked, otherwise toTextInternal(Appendable)
from this one is invoked.
writer - The writer used to print out the string representationjava.io.IOException - This should never happens, it is only required because
Appendable.append(CharSequence) throws an IOExceptionprotected void toStringItems(java.lang.Appendable writer,
java.util.List<? extends StateObject> items,
boolean useComma)
throws java.io.IOException
java.io.IOExceptionpublic final void toText(java.lang.Appendable writer)
StateObject, which should not be used to
define a true string representation of a JPQL query but should be used for
debugging purposes.
Important: Even if this StateObject is decorated by another one, the decorator
will not be used to print out a string representation of this one.
toText in interface StateObjectwriter - The writer used to print out the string representationStateObject.toString(Appendable)protected abstract void toTextInternal(java.lang.Appendable writer)
throws java.io.IOException
StateObject, which should not be used to
define a true string representation of a JPQL query but should be used for
debugging purposes.writer - The writer used to print out the string representationjava.io.IOException - This should never happens, it is only required because Appendable
is used instead of any concrete class