Class ResultVariableStateObject
- java.lang.Object
-
- org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
-
- org.eclipse.persistence.jpa.jpql.tools.model.query.ResultVariableStateObject
-
- All Implemented Interfaces:
StateObject
public class ResultVariableStateObject extends AbstractStateObject
A result variable may be used to name a select item in the query result.BNF:select_item ::= select_expression [[AS] result_variable]- Version:
- 2.4
- See Also:
ResultVariable- Author:
- Pascal Filion
- Since:
- 2.4
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAS_PROPERTYNotifies the visibility of theASidentifier has changed.static java.lang.StringRESULT_VARIABLE_PROPERTYNotifies the result variable property has changed.static java.lang.StringSTATE_OBJECT_PROPERTYNotifies the select state object property has changed.
-
Constructor Summary
Constructors Constructor Description ResultVariableStateObject(SelectClauseStateObject parent)Creates a newResultVariableStateObject.ResultVariableStateObject(SelectClauseStateObject parent, StateObject stateObject, boolean as, java.lang.String resultVariable)Creates a newResultVariableStateObject.ResultVariableStateObject(SelectClauseStateObject parent, StateObject stateObject, java.lang.String resultVariable)Creates a newResultVariableStateObject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(StateObjectVisitor visitor)Visits thisStateObjectby the givenvisitor.ResultVariableStateObjectaddAs()Makes sure theASidentifier is used.protected voidaddChildren(java.util.List<StateObject> children)Adds the children of thisStateObjectto the given list.ResultVariablegetExpression()Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.SelectClauseStateObjectgetParent()Returns the parent of thisStateObject.java.lang.StringgetResultVariable()Returns the result variable identifies the select expression, which can be used in theORDER BYclause.StateObjectgetStateObject()Returns theStateObjectrepresenting a single select expression.booleanhasAs()Determines whether theASidentifier is used.booleanhasResultVariable()Determines whether the result variable has been defined.booleanhasStateObject()Determines whether the select item has been defined.protected voidinitialize()Initializes this state object.booleanisEquivalent(StateObject stateObject)Determines whether the givenStateObjectis equivalent to this one, i.e. the information of bothStateObjectis the same.voidparse(java.lang.String jpqlFragment)Parses the given JPQL fragment, which represents a single select expression, and creates theStateObject.voidremoveAs()Makes sure theASidentifier is not used.voidsetAs(boolean as)Sets whether theASidentifier should be used.voidsetExpression(ResultVariable expression)Keeps a reference of theparsed objectobject, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects.voidsetResultVariable(java.lang.String resultVariable)Sets the result variable that identifies the select expression, which can be used in theORDER BYclause.voidsetStateObject(StateObject stateObject)Sets theStateObjectrepresenting a single select expression.voidtoggleAs()Toggles the visibility of theASidentifier; either adds it if it's not present otherwise removes it if it's present.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.AbstractStateObject
acceptUnknownVisitor, acceptUnknownVisitor, addProblems, addPropertyChangeListener, areEquivalent, buildProblem, buildProblem, buildStateObject, buildStateObjects, checkParent, children, decorate, equals, findIdentificationVariable, firePropertyChanged, getChangeSupport, getDeclaration, getDecorator, getGrammar, getManagedTypeProvider, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, isDecorated, parent, parent, parent, removePropertyChangeListener, setExpression, setParent, toString, toString, toStringInternal, toStringItems, toText
-
-
-
-
Field Detail
-
AS_PROPERTY
public static final java.lang.String AS_PROPERTY
Notifies the visibility of theASidentifier has changed.- See Also:
- Constant Field Values
-
RESULT_VARIABLE_PROPERTY
public static final java.lang.String RESULT_VARIABLE_PROPERTY
Notifies the result variable property has changed.- See Also:
- Constant Field Values
-
STATE_OBJECT_PROPERTY
public static final java.lang.String STATE_OBJECT_PROPERTY
Notifies the select state object property has changed.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ResultVariableStateObject
public ResultVariableStateObject(SelectClauseStateObject parent)
Creates a newResultVariableStateObject.- Parameters:
parent- The parent of this state object, which cannot benull- Throws:
java.lang.NullPointerException- The given parent cannot benull
-
ResultVariableStateObject
public ResultVariableStateObject(SelectClauseStateObject parent, StateObject stateObject, boolean as, java.lang.String resultVariable)
Creates a newResultVariableStateObject.- Parameters:
parent- The parent of this state object, which cannot benullstateObject- TheStateObjectrepresenting the select itemas- Determines whether theASidentifier is used or notresultVariable- The variable identifying the select item- Throws:
java.lang.NullPointerException- The given parent cannot benull
-
ResultVariableStateObject
public ResultVariableStateObject(SelectClauseStateObject parent, StateObject stateObject, java.lang.String resultVariable)
Creates a newResultVariableStateObject.- Parameters:
parent- The parent of this state object, which cannot benullstateObject- TheStateObjectrepresenting the select itemresultVariable- The variable identifying the select item- Throws:
java.lang.NullPointerException- The given parent cannot benull
-
-
Method Detail
-
accept
public void accept(StateObjectVisitor visitor)
Visits thisStateObjectby the givenvisitor.- Parameters:
visitor- Thevisitorto visit this object
-
addAs
public ResultVariableStateObject addAs()
Makes sure theASidentifier is used.- Returns:
- This object
-
addChildren
protected void addChildren(java.util.List<StateObject> children)
Adds the children of thisStateObjectto the given list.- Overrides:
addChildrenin classAbstractStateObject- Parameters:
children- The list used to store the children
-
getExpression
public ResultVariable 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)
-
getParent
public SelectClauseStateObject 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
-
getResultVariable
public java.lang.String getResultVariable()
Returns the result variable identifies the select expression, which can be used in theORDER BYclause.- Returns:
- The unique identifier declaring the select expression
-
getStateObject
public StateObject getStateObject()
Returns theStateObjectrepresenting a single select expression.- Returns:
- The
StateObjectrepresenting a single select expression
-
hasAs
public boolean hasAs()
Determines whether theASidentifier is used.- Returns:
trueif theASidentifier is used;falseotherwise
-
hasResultVariable
public boolean hasResultVariable()
Determines whether the result variable has been defined.- Returns:
trueif the result variable is defined;falseotherwise
-
hasStateObject
public boolean hasStateObject()
Determines whether the select item has been defined.- Returns:
trueif there the selected expression has been defined;falseif it's missing
-
initialize
protected void initialize()
Initializes this state object.- Overrides:
initializein classAbstractStateObject
-
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
-
parse
public void parse(java.lang.String jpqlFragment)
Parses the given JPQL fragment, which represents a single select expression, and creates theStateObject.- Parameters:
jpqlFragment- The portion of the query representing a single select expression
-
removeAs
public void removeAs()
Makes sure theASidentifier is not used.
-
setAs
public void setAs(boolean as)
Sets whether theASidentifier should be used.- Parameters:
as-trueif theASidentifier should be used part;falseotherwise
-
setExpression
public void setExpression(ResultVariable expression)
Keeps a reference of theparsed objectobject, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects.- Parameters:
expression- Theparsed objectrepresenting a result variable expression
-
setResultVariable
public void setResultVariable(java.lang.String resultVariable)
Sets the result variable that identifies the select expression, which can be used in theORDER BYclause.- Parameters:
resultVariable- The unique identifier declaring the select expression
-
setStateObject
public void setStateObject(StateObject stateObject)
Sets theStateObjectrepresenting a single select expression.- Parameters:
stateObject- TheStateObjectrepresenting a single select expression
-
toggleAs
public void toggleAs()
Toggles the visibility of theASidentifier; either adds it if it's not present otherwise removes it if it's present.
-
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
-
-