Top Description Fields Constructors Methods
org.eclipse.persistence.jpa.jpql.tools.model.query

public Class ResultVariableStateObject

extends AbstractStateObject
Class Inheritance
Annotations
@SuppressWarnings:nls, unused
Imports
java.io.IOException, java.util.List, org.eclipse.persistence.jpa.jpql.parser.ResultVariable, .SelectExpressionBNF

A result variable may be used to name a select item in the query result.

BNF: select_item ::= select_expression [[AS] result_variable]

Author
Pascal Filion
Since
2.4
Version
2.4
See Also
ResultVariable

Field Summary

Modifier and TypeField and Description
private boolean
as

Flag used to determine if the AS identifier is used or not.

public static final String
AS_PROPERTY

Notifies the visibility of the AS identifier has changed.

public static final String
RESULT_VARIABLE_PROPERTY

Notifies the result variable property has changed.

private IdentificationVariableStateObject
resultVariable

The result variable identifies the select expression, which can be used in the ORDER BY clause.

public static final String
STATE_OBJECT_PROPERTY

Notifies the select state object property has changed.

private StateObject
stateObject

The state object representing the select expression that is named with a result variable.

Constructor Summary

AccessConstructor and Description
public
ResultVariableStateObject(SelectClauseStateObject
The parent of this state object, which cannot be null
parent
)

Creates a new ResultVariableStateObject.

public
ResultVariableStateObject(SelectClauseStateObject
The parent of this state object, which cannot be null
parent
,
StateObject
The StateObject representing the select item
stateObject
,
boolean
Determines whether the AS identifier is used or not
as
,
String
The variable identifying the select item
resultVariable
)

Creates a new ResultVariableStateObject.

public
ResultVariableStateObject(SelectClauseStateObject
The parent of this state object, which cannot be null
parent
,
StateObject
The StateObject representing the select item
stateObject
,
String
The variable identifying the select item
resultVariable
)

Creates a new ResultVariableStateObject.

Method Summary

Modifier and TypeMethod and Description
public void
public ResultVariableStateObject

Returns:

This object
addAs
()

Makes sure the AS identifier is used.

protected void
addChildren(List<StateObject>
The list used to store the children
children
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.addChildren.

Adds the children of this StateObject to the given list.
public ResultVariable
getExpression()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.getExpression.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getExpression.

Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.
public SelectClauseStateObject
public String

Returns:

The unique identifier declaring the select expression
getResultVariable
()

Returns the result variable identifies the select expression, which can be used in the ORDER BY clause.

public StateObject

Returns:

The StateObject representing a single select expression
getStateObject
()

Returns the StateObject representing a single select expression.

public boolean

Returns:

true if the AS identifier is used; false otherwise
hasAs
()

Determines whether the AS identifier is used.

public boolean

Returns:

true if the result variable is defined; false otherwise
hasResultVariable
()

Determines whether the result variable has been defined.

public boolean

Returns:

true if there the selected expression has been defined; false if it's missing
hasStateObject
()

Determines whether the select item has been defined.

protected void
public boolean
isEquivalent(StateObject
The StateObject to compare its content to this one
stateObject
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.isEquivalent.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.isEquivalent.

Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.
public void
parse(String
The portion of the query representing a single select expression
jpqlFragment
)

Parses the given JPQL fragment, which represents a single select expression, and creates the StateObject.

public void
removeAs()

Makes sure the AS identifier is not used.

public void
setAs(boolean
true if the AS identifier should be used part; false otherwise
as
)

Sets whether the AS identifier should be used.

public void
setExpression(ResultVariable
The parsed object representing a result variable expression
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.

public void
setResultVariable(String
The unique identifier declaring the select expression
resultVariable
)

Sets the result variable that identifies the select expression, which can be used in the ORDER BY clause.

public void
setStateObject(StateObject
The StateObject representing a single select expression
stateObject
)

Sets the StateObject representing a single select expression.

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.

protected void
toTextInternal(Appendable
The writer used to print out the string representation
writer
)

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.toTextInternal.

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.
Inherited from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject:
acceptUnknownVisitoracceptUnknownVisitoraddProblemsaddPropertyChangeListenerareEquivalentbuildProblembuildProblembuildStateObjectbuildStateObjectscheckParentchildrendecorateequalsfindIdentificationVariablefirePropertyChangedgetChangeSupportgetDeclarationgetDecoratorgetGrammargetManagedTypeProvidergetQueryBuildergetRootgetTypegetTypegetTypeHelpergetTypeRepositoryhashCodeisDecoratedparentparentparentremovePropertyChangeListenersetExpressionsetParenttoStringtoStringtoStringInternaltoStringItemstoText

Field Detail

asback to summary
private boolean as

Flag used to determine if the AS identifier is used or not.

AS_PROPERTYback to summary
public static final String AS_PROPERTY

Notifies the visibility of the AS identifier has changed.

RESULT_VARIABLE_PROPERTYback to summary
public static final String RESULT_VARIABLE_PROPERTY

Notifies the result variable property has changed.

resultVariableback to summary
private IdentificationVariableStateObject resultVariable

The result variable identifies the select expression, which can be used in the ORDER BY clause.

STATE_OBJECT_PROPERTYback to summary
public static final String STATE_OBJECT_PROPERTY

Notifies the select state object property has changed.

stateObjectback to summary
private StateObject stateObject

The state object representing the select expression that is named with a result variable.

Constructor Detail

ResultVariableStateObjectback to summary
public ResultVariableStateObject(SelectClauseStateObject parent)

Creates a new ResultVariableStateObject.

Parameters
parent:SelectClauseStateObject

The parent of this state object, which cannot be null

Exceptions
NullPointerException:
The given parent cannot be null
ResultVariableStateObjectback to summary
public ResultVariableStateObject(SelectClauseStateObject parent, StateObject stateObject, boolean as, String resultVariable)

Creates a new ResultVariableStateObject.

Parameters
parent:SelectClauseStateObject

The parent of this state object, which cannot be null

stateObject:StateObject

The StateObject representing the select item

as:boolean

Determines whether the AS identifier is used or not

resultVariable:String

The variable identifying the select item

Exceptions
NullPointerException:
The given parent cannot be null
ResultVariableStateObjectback to summary
public ResultVariableStateObject(SelectClauseStateObject parent, StateObject stateObject, String resultVariable)

Creates a new ResultVariableStateObject.

Parameters
parent:SelectClauseStateObject

The parent of this state object, which cannot be null

stateObject:StateObject

The StateObject representing the select item

resultVariable:String

The variable identifying the select item

Exceptions
NullPointerException:
The given parent cannot be null

Method Detail

acceptback to summary
public void accept(StateObjectVisitor visitor)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.accept.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.accept.

Visits this StateObject by the given visitor.

Parameters
visitor:StateObjectVisitor

The visitor to visit this object

Annotations
@Override
addAsback to summary
public ResultVariableStateObject addAs()

Makes sure the AS identifier is used.

Returns:ResultVariableStateObject

This object

addChildrenback to summary
protected void addChildren(List<StateObject> children)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.addChildren.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.addChildren.

Adds the children of this StateObject to the given list.

Parameters
children:List<StateObject>

The list used to store the children

Annotations
@Override
getExpressionback to summary
public ResultVariable getExpression()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.getExpression.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getExpression.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getExpression.

Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.

Returns:ResultVariable

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)

Annotations
@Override
getParentback to summary
public SelectClauseStateObject getParent()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.getParent.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getParent.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getParent.

Returns the parent of this StateObject.

Returns:SelectClauseStateObject

Returns the parent of this StateObject, which is null only when this is the root of the hierarchy

Annotations
@Override
getResultVariableback to summary
public String getResultVariable()

Returns the result variable identifies the select expression, which can be used in the ORDER BY clause.

Returns:String

The unique identifier declaring the select expression

getStateObjectback to summary
public StateObject getStateObject()

Returns the StateObject representing a single select expression.

Returns:StateObject

The StateObject representing a single select expression

hasAsback to summary
public boolean hasAs()

Determines whether the AS identifier is used.

Returns:boolean

true if the AS identifier is used; false otherwise

hasResultVariableback to summary
public boolean hasResultVariable()

Determines whether the result variable has been defined.

Returns:boolean

true if the result variable is defined; false otherwise

hasStateObjectback to summary
public boolean hasStateObject()

Determines whether the select item has been defined.

Returns:boolean

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

initializeback to summary
protected void initialize()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.initialize.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.initialize.

Initializes this state object.

Annotations
@Override
isEquivalentback to summary
public boolean isEquivalent(StateObject stateObject)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.isEquivalent.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.isEquivalent.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.isEquivalent.

Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.

Parameters
stateObject:StateObject

The StateObject to compare its content to this one

Returns:boolean

true if both object are equivalent; false otherwise

Annotations
@Override
parseback to summary
public void parse(String jpqlFragment)

Parses the given JPQL fragment, which represents a single select expression, and creates the StateObject.

Parameters
jpqlFragment:String

The portion of the query representing a single select expression

removeAsback to summary
public void removeAs()

Makes sure the AS identifier is not used.

setAsback to summary
public void setAs(boolean as)

Sets whether the AS identifier should be used.

Parameters
as:boolean

true if the AS identifier should be used part; false otherwise

setExpressionback to summary
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:ResultVariable

The parsed object representing a result variable expression

setResultVariableback to summary
public void setResultVariable(String resultVariable)

Sets the result variable that identifies the select expression, which can be used in the ORDER BY clause.

Parameters
resultVariable:String

The unique identifier declaring the select expression

setStateObjectback to summary
public void setStateObject(StateObject stateObject)

Sets the StateObject representing a single select expression.

Parameters
stateObject:StateObject

The StateObject representing a single select expression

toggleAsback to summary
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.

toTextInternalback to summary
protected void toTextInternal(Appendable writer) throws IOException

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.toTextInternal.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.toTextInternal.

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.

Parameters
writer:Appendable

The writer used to print out the string representation

Annotations
@Override
Exceptions
IOException:
This should never happens, it is only required because Appendable is used instead of any concrete class