EclipseLink 2.4.2, build 'v20130514-5956486' API Reference

org.eclipse.persistence.jpa.jpql.model.query
Class ResultVariableStateObject

java.lang.Object
  extended by org.eclipse.persistence.jpa.jpql.model.query.AbstractStateObject
      extended by org.eclipse.persistence.jpa.jpql.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
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 Summary
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.
 
Method Summary
 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.
 
Methods inherited from class org.eclipse.persistence.jpa.jpql.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
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

AS_PROPERTY

public static final java.lang.String AS_PROPERTY
Notifies the visibility of the AS identifier 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 new ResultVariableStateObject.

Parameters:
parent - The parent of this state object, which cannot be null
Throws:
java.lang.NullPointerException - The given parent cannot be null

ResultVariableStateObject

public ResultVariableStateObject(SelectClauseStateObject parent,
                                 StateObject stateObject,
                                 boolean as,
                                 java.lang.String resultVariable)
Creates a new ResultVariableStateObject.

Parameters:
parent - The parent of this state object, which cannot be null
stateObject - The StateObject representing the select item
as - Determines whether the AS identifier is used or not
resultVariable - The variable identifying the select item
Throws:
java.lang.NullPointerException - The given parent cannot be null

ResultVariableStateObject

public ResultVariableStateObject(SelectClauseStateObject parent,
                                 StateObject stateObject,
                                 java.lang.String resultVariable)
Creates a new ResultVariableStateObject.

Parameters:
parent - The parent of this state object, which cannot be null
stateObject - The StateObject representing the select item
resultVariable - The variable identifying the select item
Throws:
java.lang.NullPointerException - The given parent cannot be null
Method Detail

accept

public void accept(StateObjectVisitor visitor)
Visits this StateObject by the given visitor.

Parameters:
visitor - The visitor to visit this object

addAs

public ResultVariableStateObject addAs()
Makes sure the AS identifier is used.

Returns:
This object

addChildren

protected void addChildren(java.util.List<StateObject> children)
Adds the children of this StateObject to the given list.

Overrides:
addChildren in class AbstractStateObject
Parameters:
children - The list used to store the children

getExpression

public ResultVariable getExpression()
Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.

Specified by:
getExpression in interface StateObject
Overrides:
getExpression in class AbstractStateObject
Returns:
The parsed object when a JPQL query is parsed and converted into a StateObject or null when the JPQL query is manually created (i.e. not from a string)

getParent

public SelectClauseStateObject getParent()
Returns the parent of this StateObject.

Specified by:
getParent in interface StateObject
Overrides:
getParent in class AbstractStateObject
Returns:
Returns the parent of this StateObject, which is null only 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 the ORDER BY clause.

Returns:
The unique identifier declaring the select expression

getStateObject

public StateObject getStateObject()
Returns the StateObject representing a single select expression.

Returns:
The StateObject representing a single select expression

hasAs

public boolean hasAs()
Determines whether the AS identifier is used.

Returns:
true if the AS identifier is used; false otherwise

hasResultVariable

public boolean hasResultVariable()
Determines whether the result variable has been defined.

Returns:
true if the result variable is defined; false otherwise

hasStateObject

public boolean hasStateObject()
Determines whether the select item has been defined.

Returns:
true if there the selected expression has been defined; false if it's missing

initialize

protected void initialize()
Initializes this state object.

Overrides:
initialize in class AbstractStateObject

isEquivalent

public boolean isEquivalent(StateObject stateObject)
Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.

Specified by:
isEquivalent in interface StateObject
Overrides:
isEquivalent in class AbstractStateObject
Parameters:
stateObject - The StateObject to compare its content to this one
Returns:
true if both object are equivalent; false otherwise

parse

public void parse(java.lang.String jpqlFragment)
Parses the given JPQL fragment, which represents a single select expression, and creates the StateObject.

Parameters:
jpqlFragment - The portion of the query representing a single select expression

removeAs

public void removeAs()
Makes sure the AS identifier is not used.


setAs

public void setAs(boolean as)
Sets whether the AS identifier should be used.

Parameters:
as - true if the AS identifier should be used part; false otherwise

setExpression

public 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.

Parameters:
expression - The parsed object representing 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 the ORDER BY clause.

Parameters:
resultVariable - The unique identifier declaring the select expression

setStateObject

public void setStateObject(StateObject stateObject)
Sets the StateObject representing a single select expression.

Parameters:
stateObject - The StateObject representing a single select expression

toggleAs

public void toggleAs()
Toggles the visibility of the AS identifier; 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.IOException
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.

Specified by:
toTextInternal in class AbstractStateObject
Parameters:
writer - The writer used to print out the string representation
Throws:
java.io.IOException - This should never happens, it is only required because Appendable is used instead of any concrete class

EclipseLink 2.4.2, build 'v20130514-5956486' API Reference