org.apache.openjpa.persistence.query
Class AbstractPath

java.lang.Object
  extended by org.apache.openjpa.persistence.query.AbstractVisitable
      extended by org.apache.openjpa.persistence.query.ExpressionImpl
          extended by org.apache.openjpa.persistence.query.AbstractPath
All Implemented Interfaces:
Serializable, Expression, OrderByItem, PathExpression, PredicateOperand, SelectItem, Visitable
Direct Known Subclasses:
AbstractDomainObject

abstract class AbstractPath
extends ExpressionImpl
implements PathExpression

An abstract path is formed by two parts : the first part is a parent path. The second part can be an attribute or an operation (e.g. KEY() or VALUE()) or a join type operation. Based on the exact nature of the second part, concrete derivation of this class combines the two constituent parts to arrive at complete path name. For example, a navigation path adds the two part with a navigation '.' operator, while a OperatorPath will combine the parts as KEY(parent). The constituent parts are immutable and supplied at construction. Hence concrete implementations know what exact type they are dealing with, but this receiver maintains it state as more generic type to accommodate concrete types to cast/interpret these state variables.

Author:
Pinaki Poddar

Field Summary
protected  PathOperator _operator
           
protected  QueryDefinitionImpl _owner
           
protected  AbstractPath _parent
           
protected  Object _part2
           
 
Fields inherited from class org.apache.openjpa.persistence.query.AbstractVisitable
CLOSE_BRACE, COMMA, EMPTY, OPEN_BRACE, SPACE
 
Constructor Summary
protected AbstractPath(QueryDefinitionImpl owner, AbstractPath parent, PathOperator op, Object part2)
           
 
Method Summary
 Aggregate avg()
          Specify that the avg operation is to be applied.
 Aggregate count()
          Specify that the count operation is to be applied.
 Object getLastSegment()
          Gets the last segment of this path.
 PathOperator getOperator()
          Gets operator that derived this receiver from its parent.
(package private)  QueryDefinitionImpl getOwner()
           
 AbstractPath getParent()
          Gets the parent from which this receiver has been derived.
 Predicate isEmpty()
          Add a restriction that the path expression must correspond to an association or element collection that is empty (has no elements).
 Aggregate max()
          Specify that the max operation is to be applied.
 Aggregate min()
          Specify that the min operation is to be applied.
 Expression size()
          Return an expression that corresponds to the number of elements association or element collection corresponding to the path expression.
(package private)  LinkedList<AbstractPath> split()
           
 Aggregate sum()
          Specify that the sum operation is to be applied.
 Expression type()
          Return an expression that corresponds to the type of the entity.
 
Methods inherited from class org.apache.openjpa.persistence.query.ExpressionImpl
abs, asc, between, between, between, between, between, between, between, between, between, between, between, between, between, concat, concat, desc, dividedBy, dividedBy, equal, equal, equal, equal, equal, equal, equal, equal, getAliasHint, greaterEqual, greaterEqual, greaterEqual, greaterEqual, greaterEqual, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, in, in, in, in, in, in, isNull, length, lessEqual, lessEqual, lessEqual, lessEqual, lessEqual, lessThan, lessThan, lessThan, lessThan, lessThan, like, like, like, like, like, like, locate, locate, locate, locate, locate, locate, lower, member, minus, minus, minus, mod, mod, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, plus, plus, sqrt, substring, substring, substring, substring, substring, substring, times, times, trim, trim, trim, trim, trim, trim, upper
 
Methods inherited from class org.apache.openjpa.persistence.query.AbstractVisitable
asExpression, asJoinable, asProjection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.openjpa.persistence.query.PathExpression
get
 
Methods inherited from interface org.apache.openjpa.persistence.query.Expression
abs, concat, concat, dividedBy, dividedBy, in, in, in, in, in, in, isNull, length, locate, locate, locate, locate, locate, locate, lower, member, minus, minus, minus, mod, mod, plus, plus, sqrt, substring, substring, substring, substring, substring, substring, times, times, trim, trim, trim, trim, trim, trim, upper
 
Methods inherited from interface org.apache.openjpa.persistence.query.SelectItem
asc, desc
 
Methods inherited from interface org.apache.openjpa.persistence.query.PredicateOperand
between, between, between, between, between, between, between, between, between, between, between, between, between, equal, equal, equal, equal, equal, equal, equal, equal, greaterEqual, greaterEqual, greaterEqual, greaterEqual, greaterEqual, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, lessEqual, lessEqual, lessEqual, lessEqual, lessEqual, lessThan, lessThan, lessThan, lessThan, lessThan, like, like, like, like, like, like, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual
 
Methods inherited from interface org.apache.openjpa.persistence.query.Visitable
asExpression, asJoinable, asProjection
 

Field Detail

_parent

protected final AbstractPath _parent

_part2

protected final Object _part2

_operator

protected final PathOperator _operator

_owner

protected final QueryDefinitionImpl _owner
Constructor Detail

AbstractPath

protected AbstractPath(QueryDefinitionImpl owner,
                       AbstractPath parent,
                       PathOperator op,
                       Object part2)
Method Detail

getOwner

final QueryDefinitionImpl getOwner()

getParent

public AbstractPath getParent()
Gets the parent from which this receiver has been derived. Can be null for a root path.


getOperator

public PathOperator getOperator()
Gets operator that derived this receiver from its parent.


getLastSegment

public Object getLastSegment()
Gets the last segment of this path. Concrete implementation should return a covariant type.


avg

public Aggregate avg()
Description copied from interface: PathExpression
Specify that the avg operation is to be applied. The path expression must correspond to an attribute of a numeric type. It is not permitted to invoke this method on a path expression that corresponds to a multi-valued association or element collection.

Specified by:
avg in interface PathExpression
Returns:
the resulting aggregate

count

public Aggregate count()
Description copied from interface: PathExpression
Specify that the count operation is to be applied. It is not permitted to invoke this method on a path expression that corresponds to a multi-valued association or element collection.

Specified by:
count in interface PathExpression
Returns:
the resulting aggregate

isEmpty

public Predicate isEmpty()
Description copied from interface: PathExpression
Add a restriction that the path expression must correspond to an association or element collection that is empty (has no elements). This method can only be invoked on a path expression that corresponds to a multi-valued association or to an element collection.

Specified by:
isEmpty in interface PathExpression
Returns:
predicate corresponding to the restriction

max

public Aggregate max()
Description copied from interface: PathExpression
Specify that the max operation is to be applied. The path expression must correspond to an attribute of an orderable type. It is not permitted to invoke this method on a path expression that corresponds to a multi-valued association or element collection.

Specified by:
max in interface PathExpression
Returns:
the resulting aggregate

min

public Aggregate min()
Description copied from interface: PathExpression
Specify that the min operation is to be applied. The path expression must correspond to an attribute of an orderable type. It is not permitted to invoke this method on a path expression that corresponds to a multi-valued association or element collection.

Specified by:
min in interface PathExpression
Returns:
the resulting aggregate

size

public Expression size()
Description copied from interface: PathExpression
Return an expression that corresponds to the number of elements association or element collection corresponding to the path expression. This method can only be invoked on a path expression that corresponds to a multi-valued association or to an element collection.

Specified by:
size in interface PathExpression
Returns:
expression denoting the size

sum

public Aggregate sum()
Description copied from interface: PathExpression
Specify that the sum operation is to be applied. The path expression must correspond to an attribute of a numeric type. It is not permitted to invoke this method on a path expression that corresponds to a multi-valued association or element collection.

Specified by:
sum in interface PathExpression
Returns:
the resulting aggregate

type

public Expression type()
Description copied from interface: PathExpression
Return an expression that corresponds to the type of the entity. This method can only be invoked on a path expression corresponding to an entity. It is not permitted to invoke this method on a path expression that corresponds to a multi-valued association.

Specified by:
type in interface PathExpression
Returns:
expression denoting the entity's type

split

LinkedList<AbstractPath> split()


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