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

public Class JPQLQueryStateObject

extends AbstractStateObject
Class Inheritance
Annotations
@SuppressWarnings:nls
Imports
java.io.IOException, java.util.List, org.eclipse.persistence.jpa.jpql.Assert, org.eclipse.persistence.jpa.jpql.parser.JPQLExpression, .JPQLGrammar, org.eclipse.persistence.jpa.jpql.tools.model.IJPQLQueryBuilder, org.eclipse.persistence.jpa.jpql.tools.spi.IManagedTypeProvider

This is the root of the StateObject hierarchy that represents a JPQL query. The only child of this state object is one of the three possible query statements.
Author
Pascal Filion
Since
2.4
Version
2.4
See Also
DeleteStatementStateObject, SelectStatementStateObject, UpdateStatementStateObject, JPQLExpression

Field Summary

Modifier and TypeField and Description
private IManagedTypeProvider
provider

The external form of a provider that gives access to the JPA metadata.

public static final String
QUERY_STATEMENT_PROPERTY

Notifies the query statement has changed.

private IJPQLQueryBuilder
queryBuilder

The builder that can create any StateObject for any given JPQL fragment.

private StateObject
queryStatement

One of the possible three statements.

Constructor Summary

AccessConstructor and Description
public
JPQLQueryStateObject(IJPQLQueryBuilder
The builder that can create any StateObject for any given JPQL fragment when using a parse method
queryBuilder
,
IManagedTypeProvider
The external form of a provider that gives access to the JPA metadata
provider
)

Creates a new JPQLQueryStateObject.

Method Summary

Modifier and TypeMethod and Description
public void
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 DeleteStatementStateObject

Returns:

The new root object of the DELETE statement
addDeleteStatement
()

Changes the query statement to be a DELETE statement.

public SelectStatementStateObject

Returns:

The new root object of the SELECT statement
addDistinctSelectStatement
()

Changes the query statement to be a SELECT statement.

public SelectStatementStateObject

Returns:

The new root object of the SELECT statement
addSelectStatement
()

Changes the query statement to be a SELECT statement.

public SelectStatementStateObject

Returns:

The new root object of the SELECT statement
addSelectStatement
(String
The portion of the query representing the select items, excluding the SELECT identifier
jpqlFragment
)

Changes the query statement to be a SELECT statement.

public UpdateStatementStateObject

Returns:

The new root object of the UPDTE statement
addUpdateStatement
()

Changes the query statement to be a UPDATE statement.

public UpdateStatementStateObject

Returns:

The new root object of the UPDATE statement
addUpdateStatement
(String
The portion of the query representing the select items, excluding the UPDATE identifier
jpqlFragment
)

Changes the query statement to be a UPDATE statement.

protected StateObject
checkParent(StateObject
The parent of this state object
parent
)

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

Checks whether the given parent is null or not.
public DeclarationStateObject
getDeclaration()

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

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

Returns the declaration clause which defines the domain of the query by declaring identification variables.
public JPQLExpression
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 JPQLGrammar
public IManagedTypeProvider
public StateObject
public IJPQLQueryBuilder
public StateObject

Returns:

The state object representing the query statement, which was created based on the query type
getQueryStatement
()

Returns the only child of this state object, which represents one of the three query statement.

public JPQLQueryStateObject
public boolean

Returns:

true if there is a query statement defined; false otherwise
hasQueryStatement
()

Determines whether a query statement has been defined.

protected void
initialize(IJPQLQueryBuilder
The builder that can create any StateObject for any given JPQL fragment
queryBuilder
,
IManagedTypeProvider
The external form that gives access to the JPA metadata
provider
)

Initializes this JPQLQueryStateObject.

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(CharSequence
The portion of the query to parse
jpqlFragment
,
String
The unique identifier of the BNF that determines how to parse the fragment
queryBNFId
)

Parses the given JPQL fragment as this state object's query statement.

public void
setExpression(JPQLExpression
The parsed object representing the JPQL query
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
setQueryStatement(StateObject
The state object representing the query statement, which was created based on the query type
queryStatement
)

Sets the only child of this state object, which represents one of the three query statement.

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:
acceptUnknownVisitoracceptUnknownVisitoraddProblemsaddPropertyChangeListenerareEquivalentbuildProblembuildProblembuildStateObjectbuildStateObjectschildrendecorateequalsfindIdentificationVariablefirePropertyChangedgetChangeSupportgetDecoratorgetTypegetTypegetTypeHelpergetTypeRepositoryhashCodeinitializeisDecoratedparentparentparentremovePropertyChangeListenersetExpressionsetParenttoStringtoStringtoStringInternaltoStringItemstoText

Field Detail

providerback to summary
private IManagedTypeProvider provider

The external form of a provider that gives access to the JPA metadata.

QUERY_STATEMENT_PROPERTYback to summary
public static final String QUERY_STATEMENT_PROPERTY

Notifies the query statement has changed.

queryBuilderback to summary
private IJPQLQueryBuilder queryBuilder

The builder that can create any StateObject for any given JPQL fragment.

queryStatementback to summary
private StateObject queryStatement

One of the possible three statements.

Constructor Detail

JPQLQueryStateObjectback to summary
public JPQLQueryStateObject(IJPQLQueryBuilder queryBuilder, IManagedTypeProvider provider)

Creates a new JPQLQueryStateObject.

Parameters
queryBuilder:IJPQLQueryBuilder

The builder that can create any StateObject for any given JPQL fragment when using a parse method

provider:IManagedTypeProvider

The external form of a provider that gives access to the JPA metadata

Exceptions
NullPointerException:
If one of the given arguments is 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
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
addDeleteStatementback to summary
public DeleteStatementStateObject addDeleteStatement()

Changes the query statement to be a DELETE statement.

Returns:DeleteStatementStateObject

The new root object of the DELETE statement

addDistinctSelectStatementback to summary
public SelectStatementStateObject addDistinctSelectStatement()

Changes the query statement to be a SELECT statement. The SELECT clause will have the DISTINCT identifier set.

Returns:SelectStatementStateObject

The new root object of the SELECT statement

addSelectStatementback to summary
public SelectStatementStateObject addSelectStatement()

Changes the query statement to be a SELECT statement.

Returns:SelectStatementStateObject

The new root object of the SELECT statement

addSelectStatementback to summary
public SelectStatementStateObject addSelectStatement(String jpqlFragment)

Changes the query statement to be a SELECT statement.

Parameters
jpqlFragment:String

The portion of the query representing the select items, excluding the SELECT identifier

Returns:SelectStatementStateObject

The new root object of the SELECT statement

addUpdateStatementback to summary
public UpdateStatementStateObject addUpdateStatement()

Changes the query statement to be a UPDATE statement.

Returns:UpdateStatementStateObject

The new root object of the UPDTE statement

addUpdateStatementback to summary
public UpdateStatementStateObject addUpdateStatement(String jpqlFragment)

Changes the query statement to be a UPDATE statement.

Parameters
jpqlFragment:String

The portion of the query representing the select items, excluding the UPDATE identifier

Returns:UpdateStatementStateObject

The new root object of the UPDATE statement

checkParentback to summary
protected StateObject checkParent(StateObject parent)

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

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

Checks whether the given parent is null or not. If it's null then throw a NullPointerException.

Parameters
parent:StateObject

The parent of this state object

Returns:StateObject

The given object

Annotations
@Override
getDeclarationback to summary
public DeclarationStateObject getDeclaration()

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

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

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

Returns the declaration clause which defines the domain of the query by declaring identification variables.

Returns:DeclarationStateObject

The declaration clause of which this StateObject 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 subquery

Annotations
@Override
getExpressionback to summary
public JPQLExpression 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:JPQLExpression

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
getGrammarback to summary
public JPQLGrammar getGrammar()

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

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

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

Returns the grammar that defines how to parse a JPQL query.

Returns:JPQLGrammar

The grammar that was used to parse the JPQL query

Annotations
@Override
getManagedTypeProviderback to summary
public IManagedTypeProvider getManagedTypeProvider()

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

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

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

Returns the provider of managed types.

Returns:IManagedTypeProvider

The provider that gives access to the managed types

Annotations
@Override
getParentback to summary
public StateObject 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:StateObject

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

Annotations
@Override
getQueryBuilderback to summary
public IJPQLQueryBuilder getQueryBuilder()

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

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

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

Returns the IJPQLQueryBuilder that is responsible to create various part of the StateObject hierarchy.

Returns:IJPQLQueryBuilder

The builder that created this StateObject from a JPQL query or that gives access to various sub-builders

Annotations
@Override
getQueryStatementback to summary
public StateObject getQueryStatement()

Returns the only child of this state object, which represents one of the three query statement.

Returns:StateObject

The state object representing the query statement, which was created based on the query type

getRootback to summary
public JPQLQueryStateObject getRoot()

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

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

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

Returns the root of the StateObject hierarchy.

Returns:JPQLQueryStateObject

The root of the state model representing the JPQL query

Annotations
@Override
hasQueryStatementback to summary
public boolean hasQueryStatement()

Determines whether a query statement has been defined.

Returns:boolean

true if there is a query statement defined; false otherwise

initializeback to summary
protected void initialize(IJPQLQueryBuilder queryBuilder, IManagedTypeProvider provider)

Initializes this JPQLQueryStateObject.

Parameters
queryBuilder:IJPQLQueryBuilder

The builder that can create any StateObject for any given JPQL fragment

provider:IManagedTypeProvider

The external form that gives access to the JPA metadata

Exceptions
NullPointerException:
If one of the given arguments is null
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(CharSequence jpqlFragment, String queryBNFId)

Parses the given JPQL fragment as this state object's query statement.

Parameters
jpqlFragment:CharSequence

The portion of the query to parse

queryBNFId:String

The unique identifier of the BNF that determines how to parse the fragment

setExpressionback to summary
public void setExpression(JPQLExpression 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:JPQLExpression

The parsed object representing the JPQL query

setQueryStatementback to summary
public void setQueryStatement(StateObject queryStatement)

Sets the only child of this state object, which represents one of the three query statement.

Parameters
queryStatement:StateObject

The state object representing the query statement, which was created based on the query type

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