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

public Class TreatExpressionStateObject

extends AbstractStateObject
Class Inheritance
Annotations
@SuppressWarnings:nls
Static Imports
org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.LEFT_PARENTHESIS, .AbstractExpression.RIGHT_PARENTHESIS, .AbstractExpression.SPACE, .Expression.AS, .Expression.TREAT

Returns an expression that allows to treat its base as if it were a subclass of the class returned by the base.

Note

EclipseLinkStateObjectVisitor needs to be used to traverse this state object.

BNF: join_treat ::= TREAT(collection_valued_path_expression [AS] entity_type_literal)

Author
Pascal Filion
Since
2.4
Version
2.4
See Also
TreatExpression

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
ENTITY_TYPE_NAME_PROPERTY

Notifies the entity type name property has changed.

private EntityTypeLiteralStateObject
entityTypeName

The StateObject representing the entity type name.

private JoinStateObject
joinStateObject

Keeps a reference onto the JoinStateObject since it owns the StateObject representing the collection-valued path expression.

Constructor Summary

AccessConstructor and Description
public
TreatExpressionStateObject(JoinStateObject
The parent of this state object, which is temporary since this state object will be parented with the state object representing the join's association path expression
parent
)

Creates a new TreatExpressionStateObject.

public
TreatExpressionStateObject(JoinStateObject
The parent of this state object, which is temporary since this state object will be parented with the state object representing the join's association path expression
parent
,
boolean
Determines whether the AS identifier is used or not
as
,
String
The entity type name used to cast the base expression
entityTypeName
)

Creates a new TreatExpressionStateObject.

public
TreatExpressionStateObject(JoinStateObject
The parent of this state object, which is temporary since this state object will be parented with the state object representing the join's association path expression
parent
,
String
The entity type name used to cast the base expression
entityTypeName
)

Creates a new TreatExpressionStateObject.

Method Summary

Modifier and TypeMethod and Description
public void
public TreatExpressionStateObject

Returns:

This object
addAs
()

Makes sure the AS identifier is specified.

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 void
appendToEntityTypeName(String
The text to append to the entity type name property or nothing is done if the given value is null
text
)

Appends the given text to the existing entity type name property.

public IEntity

Returns:

Either the IEntity with the same entity type name or null if the managed type provider does not have an entity with that name
getEntity
()

Resolves the entity type name to the external form of the actual IEntity.

public String

Returns:

The name of the entity used for down casting
getEntityTypeName
()

Returns the name of the entity that is used to downcast the join association path.

public TreatExpression
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 JoinStateObject

Returns:

The "owning" of this object
getJoin
()

Returns the reference of the JoinStateObject.

public StateObject

Returns:

The root of the path expression
getJoinAssociationIdentificationVariable
()

Returns the StateObject representing the identification variable that starts the path expression, which can be a sample identification variable, a map value, map key or map entry expression.

public CollectionValuedPathExpressionStateObject

Returns:

The state object representing the join association path
getJoinAssociationPathStateObject
()

Returns the CollectionValuedPathExpressionStateObject representing the join association path.

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 entity type name has been defined; false otherwise
hasEntityTypeName
()

Determines whether the.

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
removeAs()

Makes sure the AS identifier is not specified.

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
setEntityTypeName(Class<?>
The Java class representing the entity type
entityType
)

Sets the name of the entity that is used to downcast the join association path.

public void
setEntityTypeName(IEntity
The external form of the entity type
entityType
)

Sets the name of the entity that is used to downcast the join association path.

public void
setEntityTypeName(String
The new name of the entity used for down casting
entityTypeName
)

Sets the name of the entity that is used to downcast the join association path.

public void
setExpression(TreatExpression
The parsed object representing the TREAD 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
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:
acceptUnknownVisitoracceptUnknownVisitoraddProblemsaddPropertyChangeListenerareEquivalentbuildProblembuildProblembuildStateObjectbuildStateObjectscheckParentchildrendecorateequalsfindIdentificationVariablefirePropertyChangedgetChangeSupportgetDeclarationgetDecoratorgetGrammargetManagedTypeProvidergetParentgetQueryBuildergetRootgetTypegetTypegetTypeHelpergetTypeRepositoryhashCodeisDecoratedparentparentparentremovePropertyChangeListenersetExpressionsetParenttoStringtoStringtoStringInternaltoStringItemstoText

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.

ENTITY_TYPE_NAME_PROPERTYback to summary
public static final String ENTITY_TYPE_NAME_PROPERTY

Notifies the entity type name property has changed.

entityTypeNameback to summary
private EntityTypeLiteralStateObject entityTypeName

The StateObject representing the entity type name.

joinStateObjectback to summary
private JoinStateObject joinStateObject

Keeps a reference onto the JoinStateObject since it owns the StateObject representing the collection-valued path expression.

Constructor Detail

TreatExpressionStateObjectback to summary
public TreatExpressionStateObject(JoinStateObject parent)

Creates a new TreatExpressionStateObject.

Parameters
parent:JoinStateObject

The parent of this state object, which is temporary since this state object will be parented with the state object representing the join's association path expression

TreatExpressionStateObjectback to summary
public TreatExpressionStateObject(JoinStateObject parent, boolean as, String entityTypeName)

Creates a new TreatExpressionStateObject.

Parameters
parent:JoinStateObject

The parent of this state object, which is temporary since this state object will be parented with the state object representing the join's association path expression

as:boolean

Determines whether the AS identifier is used or not

entityTypeName:String

The entity type name used to cast the base expression

TreatExpressionStateObjectback to summary
public TreatExpressionStateObject(JoinStateObject parent, String entityTypeName)

Creates a new TreatExpressionStateObject.

Parameters
parent:JoinStateObject

The parent of this state object, which is temporary since this state object will be parented with the state object representing the join's association path expression

entityTypeName:String

The entity type name used to cast the base expression

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 TreatExpressionStateObject addAs()

Makes sure the AS identifier is specified.

Returns:TreatExpressionStateObject

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
appendToEntityTypeNameback to summary
public void appendToEntityTypeName(String text)

Appends the given text to the existing entity type name property.

Parameters
text:String

The text to append to the entity type name property or nothing is done if the given value is null

getEntityback to summary
public IEntity getEntity()

Resolves the entity type name to the external form of the actual IEntity.

Returns:IEntity

Either the IEntity with the same entity type name or null if the managed type provider does not have an entity with that name

getEntityTypeNameback to summary
public String getEntityTypeName()

Returns the name of the entity that is used to downcast the join association path.

Returns:String

The name of the entity used for down casting

getExpressionback to summary
public TreatExpression 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:TreatExpression

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
getJoinback to summary
public JoinStateObject getJoin()

Returns the reference of the JoinStateObject.

Returns:JoinStateObject

The "owning" of this object

getJoinAssociationIdentificationVariableback to summary
public StateObject getJoinAssociationIdentificationVariable()

Returns the StateObject representing the identification variable that starts the path expression, which can be a sample identification variable, a map value, map key or map entry expression.

Returns:StateObject

The root of the path expression

getJoinAssociationPathStateObjectback to summary
public CollectionValuedPathExpressionStateObject getJoinAssociationPathStateObject()

Returns the CollectionValuedPathExpressionStateObject representing the join association path.

Returns:CollectionValuedPathExpressionStateObject

The state object representing the join association path

hasAsback to summary
public boolean hasAs()

Determines whether the AS identifier is used.

Returns:boolean

true if the AS identifier is used; false otherwise

hasEntityTypeNameback to summary
public boolean hasEntityTypeName()

Determines whether the.

Returns:boolean

true if the entity type name has been defined; false otherwise

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
removeAsback to summary
public void removeAs()

Makes sure the AS identifier is not specified.

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

setEntityTypeNameback to summary
public void setEntityTypeName(Class<?> entityType)

Sets the name of the entity that is used to downcast the join association path.

Parameters
entityType:Class<?>

The Java class representing the entity type

setEntityTypeNameback to summary
public void setEntityTypeName(IEntity entityType)

Sets the name of the entity that is used to downcast the join association path.

Parameters
entityType:IEntity

The external form of the entity type

setEntityTypeNameback to summary
public void setEntityTypeName(String entityTypeName)

Sets the name of the entity that is used to downcast the join association path.

Parameters
entityTypeName:String

The new name of the entity used for down casting

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

The parsed object representing the TREAD 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