public class ResultVariableStateObject extends AbstractStateObject
select_item ::= select_expression [[AS] result_variable]
ResultVariable
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AS_PROPERTY
Notifies the visibility of the
AS identifier has changed. |
static java.lang.String |
RESULT_VARIABLE_PROPERTY
Notifies the result variable property has changed.
|
static java.lang.String |
STATE_OBJECT_PROPERTY
Notifies the select state object property has changed.
|
Constructor and Description |
---|
ResultVariableStateObject(SelectClauseStateObject parent)
Creates a new
ResultVariableStateObject . |
ResultVariableStateObject(SelectClauseStateObject parent,
StateObject stateObject,
boolean as,
java.lang.String resultVariable)
Creates a new
ResultVariableStateObject . |
ResultVariableStateObject(SelectClauseStateObject parent,
StateObject stateObject,
java.lang.String resultVariable)
Creates a new
ResultVariableStateObject . |
Modifier and Type | Method and Description |
---|---|
void |
accept(StateObjectVisitor visitor)
Visits this
StateObject by the given visitor . |
ResultVariableStateObject |
addAs()
Makes sure the
AS identifier is used. |
protected void |
addChildren(java.util.List<StateObject> children)
Adds the children of this
StateObject to the given list. |
ResultVariable |
getExpression()
Returns the actual parsed object if this
StateObject representation of the JPQL query
was created by parsing an existing JPQL query. |
SelectClauseStateObject |
getParent()
Returns the parent of this
StateObject . |
java.lang.String |
getResultVariable()
Returns the result variable identifies the select expression, which can be used in the
ORDER BY clause. |
StateObject |
getStateObject()
Returns the
StateObject representing a single select expression. |
boolean |
hasAs()
Determines whether the
AS identifier is used. |
boolean |
hasResultVariable()
Determines whether the result variable has been defined.
|
boolean |
hasStateObject()
Determines whether the select item has been defined.
|
protected void |
initialize()
Initializes this state object.
|
boolean |
isEquivalent(StateObject stateObject)
Determines whether the given
StateObject is equivalent to this one, i.e. the
information of both StateObject is the same. |
void |
parse(java.lang.String jpqlFragment)
Parses the given JPQL fragment, which represents a single select expression, and creates the
StateObject . |
void |
removeAs()
Makes sure the
AS identifier is not used. |
void |
setAs(boolean as)
Sets whether the
AS identifier should be used. |
void |
setExpression(ResultVariable expression)
Keeps a reference of the
parsed object object, which should only be
done when this object is instantiated during the conversion of a parsed JPQL query into
StateObjects . |
void |
setResultVariable(java.lang.String resultVariable)
Sets the result variable that identifies the select expression, which can be used in the
ORDER BY clause. |
void |
setStateObject(StateObject stateObject)
Sets the
StateObject representing a single select expression. |
void |
toggleAs()
Toggles the visibility of the
AS identifier; either adds it if it's not
present otherwise removes it if it's present. |
protected 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. |
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
public static final java.lang.String AS_PROPERTY
AS
identifier has changed.public static final java.lang.String RESULT_VARIABLE_PROPERTY
public static final java.lang.String STATE_OBJECT_PROPERTY
public ResultVariableStateObject(SelectClauseStateObject parent)
ResultVariableStateObject
.parent
- The parent of this state object, which cannot be null
java.lang.NullPointerException
- The given parent cannot be null
public ResultVariableStateObject(SelectClauseStateObject parent, StateObject stateObject, boolean as, java.lang.String resultVariable)
ResultVariableStateObject
.parent
- The parent of this state object, which cannot be null
stateObject
- The StateObject
representing the select itemas
- Determines whether the AS
identifier is used or notresultVariable
- The variable identifying the select itemjava.lang.NullPointerException
- The given parent cannot be null
public ResultVariableStateObject(SelectClauseStateObject parent, StateObject stateObject, java.lang.String resultVariable)
ResultVariableStateObject
.parent
- The parent of this state object, which cannot be null
stateObject
- The StateObject
representing the select itemresultVariable
- The variable identifying the select itemjava.lang.NullPointerException
- The given parent cannot be null
public void accept(StateObjectVisitor visitor)
StateObject
by the given visitor
.visitor
- The visitor
to visit this objectpublic ResultVariableStateObject addAs()
AS
identifier is used.protected void addChildren(java.util.List<StateObject> children)
StateObject
to the given list.addChildren
in class AbstractStateObject
children
- The list used to store the childrenpublic ResultVariable getExpression()
StateObject
representation of the JPQL query
was created by parsing an existing JPQL query.getExpression
in interface StateObject
getExpression
in class AbstractStateObject
StateObject
or null
when the JPQL query is manually created (i.e. not from a string)public SelectClauseStateObject getParent()
StateObject
.getParent
in interface StateObject
getParent
in class AbstractStateObject
StateObject
, which is null
only when
this is the root of the hierarchypublic java.lang.String getResultVariable()
ORDER BY
clause.public StateObject getStateObject()
StateObject
representing a single select expression.StateObject
representing a single select expressionpublic boolean hasAs()
AS
identifier is used.true
if the AS
identifier is used; false
otherwisepublic boolean hasResultVariable()
true
if the result variable is defined; false
otherwisepublic boolean hasStateObject()
true
if there the selected expression has been defined; false
if it's missingprotected void initialize()
initialize
in class AbstractStateObject
public boolean isEquivalent(StateObject stateObject)
StateObject
is equivalent to this one, i.e. the
information of both StateObject
is the same.isEquivalent
in interface StateObject
isEquivalent
in class AbstractStateObject
stateObject
- The StateObject
to compare its content to this onetrue
if both object are equivalent; false
otherwisepublic void parse(java.lang.String jpqlFragment)
StateObject
.jpqlFragment
- The portion of the query representing a single select expressionpublic void removeAs()
AS
identifier is not used.public void setAs(boolean as)
AS
identifier should be used.as
- true
if the AS
identifier should be used part;
false
otherwisepublic void setExpression(ResultVariable expression)
parsed object
object, which should only be
done when this object is instantiated during the conversion of a parsed JPQL query into
StateObjects
.expression
- The parsed object
representing a result variable
expressionpublic void setResultVariable(java.lang.String resultVariable)
ORDER BY
clause.resultVariable
- The unique identifier declaring the select expressionpublic void setStateObject(StateObject stateObject)
StateObject
representing a single select expression.stateObject
- The StateObject
representing a single select expressionpublic void toggleAs()
AS
identifier; either adds it if it's not
present otherwise removes it if it's present.protected 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.toTextInternal
in class AbstractStateObject
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