org.apache.openjpa.persistence.criteria
Class PathImpl<Z,X>

java.lang.Object
  extended by org.apache.openjpa.persistence.criteria.SelectionImpl<X>
      extended by org.apache.openjpa.persistence.criteria.ExpressionImpl<X>
          extended by org.apache.openjpa.persistence.criteria.PathImpl<Z,X>
Type Parameters:
Z - the type of the parent path
X - the type of this path
All Implemented Interfaces:
Expression<X>, Path<X>, Selection<X>, TupleElement<X>, CriteriaExpression
Direct Known Subclasses:
FetchPathImpl, FromImpl, Joins.MapKey

 class PathImpl<Z,X>
extends ExpressionImpl<X>
implements Path<X>

Path is an expression often representing a persistent attribute traversed from another (parent) path. The type of the path is the type of the persistent attribute. If the persistent attribute is bindable, then further path can be traversed from this path.

Author:
Pinaki Poddar, Fay Wang

Field Summary
protected  Members.Member<? super Z,?> _member
           
protected  PathImpl<?,Z> _parent
           
 
Constructor Summary
protected PathImpl(Class<X> cls)
          Protected constructor use by root path which neither represent a member nor has a parent.
  PathImpl(PathImpl<?,Z> parent, Members.Member<? super Z,?> member, Class<X> cls)
          Create a path from the given non-null parent representing the given non-null member.
 
Method Summary
 StringBuilder asValue(AliasContext q)
          Get a string representation of this node as a value in the context of the given query.
 StringBuilder asVariable(AliasContext q)
          Get a string representation of this node as a variable in the context of the given query.
<K,V,M extends Map<K,V>>
Expression<M>
get(MapAttribute<X,K,V> map)
          Gets a new path that represents the given map-valued attribute from this path.
<E,C extends Collection<E>>
Expression<C>
get(PluralAttribute<X,C,E> coll)
          Gets a new path that represents the given multi-valued attribute from this path.
<Y> Path<Y>
get(SingularAttribute<? super X,Y> attr)
          Gets a new path that represents the given single-valued attribute from this path.
<Y> Path<Y>
get(String attName)
          Gets a new path that represents the attribute of the given name from this path.
 PathImpl<?,?> getCorrelatedJoin(PathImpl<?,?> path)
           
 PathImpl<?,?> getCorrelatedPath()
          Gets the path correlated to this path, if any.
 PathImpl<?,?> getCorrelatedRoot(SubqueryImpl<?> subquery)
           
protected  FieldMetaData getEmbeddedFieldMetaData(FieldMetaData fmd)
           
protected  Members.Member<?,?> getInnermostMember(PathImpl<?,?> parent, Members.Member<?,?> member)
           
 PathImpl<?,?> getInnermostParentPath()
          Gets the path that originates this traversal.
 Members.Member<? extends Z,X> getMember()
           
 Bindable<X> getModel()
          Returns the bindable object that corresponds to the path expression.
 Path<Z> getParentPath()
          Return the parent "node" in the path or null if no parent.
 Type<?> getType()
           
 boolean inSubquery(SubqueryImpl<?> subquery)
          Affirms if this receiver occurs in the roots of the given subquery.
 boolean isCorrelated()
          Affirms if this path is correlated to another path.
 void setCorrelatedPath(PathImpl<?,?> correlatedPath)
          Makes this path correlated to the given path.
 Value toValue(ExpressionFactory factory, CriteriaQueryImpl<?> q)
          Convert this path to a kernel path.
protected  void traversePath(PathImpl<?,?> parent, Path path, FieldMetaData fmd)
           
 Expression<Class<? extends X>> type()
          Get the type() expression corresponding to this path.
 
Methods inherited from class org.apache.openjpa.persistence.criteria.ExpressionImpl
as, in, in, in, in, isNotNull, isNull, toKernelExpression
 
Methods inherited from class org.apache.openjpa.persistence.criteria.SelectionImpl
acceptVisit, alias, asProjection, assertValidName, getAlias, getCompoundSelectionItems, getJavaType, isAliased, isAutoAliased, isCompoundSelection, setAutoAlias
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.persistence.criteria.Expression
as, in, in, in, in, isNotNull, isNull
 
Methods inherited from interface javax.persistence.criteria.Selection
alias, getCompoundSelectionItems, isCompoundSelection
 
Methods inherited from interface javax.persistence.TupleElement
getAlias, getJavaType
 

Field Detail

_parent

protected final PathImpl<?,Z> _parent

_member

protected final Members.Member<? super Z,?> _member
Constructor Detail

PathImpl

protected PathImpl(Class<X> cls)
Protected constructor use by root path which neither represent a member nor has a parent.


PathImpl

public PathImpl(PathImpl<?,Z> parent,
                Members.Member<? super Z,?> member,
                Class<X> cls)
Create a path from the given non-null parent representing the given non-null member. The given class denotes the type expressed by this path.

Method Detail

getModel

public Bindable<X> getModel()
Returns the bindable object that corresponds to the path expression.

Specified by:
getModel in interface Path<X>

getParentPath

public final Path<Z> getParentPath()
Return the parent "node" in the path or null if no parent.

Specified by:
getParentPath in interface Path<X>

getInnermostParentPath

public PathImpl<?,?> getInnermostParentPath()
Gets the path that originates this traversal. Can be itself if this itself is the origin.


getEmbeddedFieldMetaData

protected FieldMetaData getEmbeddedFieldMetaData(FieldMetaData fmd)

getInnermostMember

protected Members.Member<?,?> getInnermostMember(PathImpl<?,?> parent,
                                                 Members.Member<?,?> member)

setCorrelatedPath

public void setCorrelatedPath(PathImpl<?,?> correlatedPath)
Makes this path correlated to the given path.


getCorrelatedPath

public PathImpl<?,?> getCorrelatedPath()
Gets the path correlated to this path, if any.


isCorrelated

public boolean isCorrelated()
Affirms if this path is correlated to another path.


toValue

public Value toValue(ExpressionFactory factory,
                     CriteriaQueryImpl<?> q)
Convert this path to a kernel path.

Specified by:
toValue in class ExpressionImpl<X>
Parameters:
factory - creates the kernel expression
q - the query definition context of this expression
Returns:
an equivalent kernel value

getCorrelatedRoot

public PathImpl<?,?> getCorrelatedRoot(SubqueryImpl<?> subquery)

getCorrelatedJoin

public PathImpl<?,?> getCorrelatedJoin(PathImpl<?,?> path)

inSubquery

public boolean inSubquery(SubqueryImpl<?> subquery)
Affirms if this receiver occurs in the roots of the given subquery.


traversePath

protected void traversePath(PathImpl<?,?> parent,
                            Path path,
                            FieldMetaData fmd)

get

public <Y> Path<Y> get(SingularAttribute<? super X,Y> attr)
Gets a new path that represents the given single-valued attribute from this path.

Specified by:
get in interface Path<X>

get

public <E,C extends Collection<E>> Expression<C> get(PluralAttribute<X,C,E> coll)
Gets a new path that represents the given multi-valued attribute from this path.

Specified by:
get in interface Path<X>

get

public <K,V,M extends Map<K,V>> Expression<M> get(MapAttribute<X,K,V> map)
Gets a new path that represents the given map-valued attribute from this path.

Specified by:
get in interface Path<X>

get

public <Y> Path<Y> get(String attName)
Gets a new path that represents the attribute of the given name from this path.

Specified by:
get in interface Path<X>
Throws:
IllegalArgumentException - if this path represents a basic attribute that is can not be traversed further.

getType

public Type<?> getType()

getMember

public Members.Member<? extends Z,X> getMember()

type

public Expression<Class<? extends X>> type()
Get the type() expression corresponding to this path.

Specified by:
type in interface Path<X>

asValue

public StringBuilder asValue(AliasContext q)
Description copied from interface: CriteriaExpression
Get a string representation of this node as a value in the context of the given query.

Specified by:
asValue in interface CriteriaExpression
Overrides:
asValue in class SelectionImpl<X>

asVariable

public StringBuilder asVariable(AliasContext q)
Description copied from interface: CriteriaExpression
Get a string representation of this node as a variable in the context of the given query.

Specified by:
asVariable in interface CriteriaExpression
Overrides:
asVariable in class SelectionImpl<X>


Copyright © 2006-2012 Apache Software Foundation. All Rights Reserved.