Top Description Fields Constructors Methods
org.eclipse.persistence.jpa.jpql.parser

public abstract Class AbstractPathExpression

extends AbstractExpression
Class Inheritance
Known Direct Subclasses
org.eclipse.persistence.jpa.jpql.parser.CollectionValuedPathExpression, org.eclipse.persistence.jpa.jpql.parser.StateFieldPathExpression
Imports
java.util.ArrayList, .Collection, .List, org.eclipse.persistence.jpa.jpql.WordParser, org.eclipse.persistence.jpa.jpql.utility.iterable.ListIterable, .SnapshotCloneListIterable

An identification variable followed by the navigation operator (.) and a state field or association field is a path expression. The type of the path expression is the type computed as the result of navigation; that is, the type of the state field or association field to which the expression navigates.
Author
Pascal Filion
Since
2.3
Version
2.5
See Also
CollectionValuedPathExpression, IdentificationVariable

Field Summary

Modifier and TypeField and Description
private boolean
endsWithDot

Determines whether the path ends with a dot or not.

private AbstractExpression
identificationVariable

The identification variable that starts the path expression, which can be a sample identification variable, an entry expression, a value expression or a key expression.

private List<String>
paths

The state field path in a ordered list of string segments.

private int
pathSize

The cached number of segments representing the path expression.

private boolean
startsWithDot

Determines whether the path starts with a dot or not.

Inherited from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression:
COMMADOTDOUBLE_QUOTELEFT_CURLY_BRACKETLEFT_PARENTHESISNOT_DEFINEDRIGHT_CURLY_BRACKETRIGHT_PARENTHESISSINGLE_QUOTESPACEUNDERSCORE

Constructor Summary

AccessConstructor and Description
protected
AbstractPathExpression(AbstractExpression
The parent of this expression
parent
,
AbstractExpression
The identification variable that was already parsed, which means the beginning of the parsing should start with a dot
identificationVariable
)

Creates a new AbstractPathExpression.

public
AbstractPathExpression(AbstractExpression
The parent of this expression
parent
,
AbstractExpression
The identification variable that was already parsed, which means the beginning of the parsing should start with a dot
identificationVariable
,
String
The path expression that is following the identification variable
paths
)

Creates a new AbstractPathExpression.

protected
AbstractPathExpression(AbstractExpression
The parent of this expression
parent
,
String
The path expression
paths
)

Creates a new AbstractPathExpression.

Method Summary

Modifier and TypeMethod and Description
public void
acceptChildren(ExpressionVisitor
The visitor to visit the children of this object.
visitor
)

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.acceptChildren.

Visits the children of this Expression.
protected void
addChildrenTo(Collection<Expression>
The collection used to store the children
children
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addChildrenTo.

Adds the children of this AbstractExpression to the given collection.
protected final void
addOrderedChildrenTo(List<Expression>
The list used to store the string representation of this AbstractExpression
children
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addOrderedChildrenTo.

Adds the children of this AbstractExpression to the given list.
private void
public final boolean

Returns:

true if the path ends with a dot; false otherwise
endsWithDot
()

Determines whether the path ends with a dot or not.

public final JPQLQueryBNF
findQueryBNF(Expression
The Expression that is a descendant of this one
expression
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.findQueryBNF.

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.findQueryBNF.

Retrieves the JPQLQueryBNF that represents the fragment of this Expression that was used when parsing the given Expression.
public final Expression

Returns:

The root of the path expression
getIdentificationVariable
()

Returns 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 final String

Returns:

The specified segment
getPath
(int
The 0-based segment index
index
)

Returns the specified segment of the state field path.

public final boolean

Returns:

true the identification variable was parsed; false otherwise
hasIdentificationVariable
()

Determines whether the identification variable was parsed.

public final boolean

Returns:

true if this identification variable was virtually created to fully qualify path expression; false if it was parsed
hasVirtualIdentificationVariable
()

Determines whether the path's identification variable is virtual or not, meaning it's not part of the query but is required for proper navigability.

protected final void
parse(WordParser
The text to parse based on the current position of the cursor
wordParser
,
boolean
Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries
tolerant
)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.parse.

Parses the query by starting at the current position, which is part of the given WordParser.
public final ListIterable<String>

Returns:

An Iterator over the segments of the state field path
paths
()

Returns the segments in the state field path in order.

public final int

Returns:

The number of segments
pathSize
()

Returns the number of segments in the state field path.

protected final void
setVirtualIdentificationVariable(String
The identification variable that was generated to identify the "root" object
variableName
)

Sets a virtual identification variable because the abstract schema name was parsed without one.

public final boolean

Returns:

true if the path starts with a dot; false otherwise
startsWithDot
()

Determines whether the path starts with a dot or not.

public String

Returns:

The string representation of this path expression contained in the given range
toParsedText
(int
The beginning of the range to create the string representation
startIndex
,
int
When to stop creating the string representation, which is exclusive
stopIndex
)

Returns a string representation from the given range.

protected final void
toParsedText(StringBuilder
The buffer used to append this Expression's string representation
writer
,
boolean
Determines whether the string representation should represent what was parsed, i.e. include any "virtual" whitespace (such as ending whitespace) and the actual case of the JPQL identifiers
actual
)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.toParsedText.

Generates a string representation of this Expression, including its children, if it has any.
Inherited from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression:
acceptUnknownVisitoracceptUnknownVisitorbuildExpressionFromFallingBackbuildNullExpressionbuildStringExpressionbuildStringExpressionbuildUnknownExpressioncalculatePositionchildrenfindFallBackExpressionFactorygetExpressionFactorygetExpressionRegistrygetGrammargetIdentifierVersiongetJPAVersiongetLengthgetOffsetgetParentgetQueryBNFgetRootgetTexthandleAggregatehandleCollectionisAncestorisIdentifierisNullisParsingCompleteisTolerantisUnknownisVirtualorderedChildrenparseparseUsingExpressionFactorypopulatePositionrebuildActualTextrebuildParsedTextsetParentsetTextshouldParseWithFactoryFirstshouldSkipLiteraltoActualTexttoParsedTexttoString

Field Detail

endsWithDotback to summary
private boolean endsWithDot

Determines whether the path ends with a dot or not.

identificationVariableback to summary
private AbstractExpression identificationVariable

The identification variable that starts the path expression, which can be a sample identification variable, an entry expression, a value expression or a key expression.

pathsback to summary
private List<String> paths

The state field path in a ordered list of string segments.

pathSizeback to summary
private int pathSize

The cached number of segments representing the path expression.

startsWithDotback to summary
private boolean startsWithDot

Determines whether the path starts with a dot or not.

Constructor Detail

AbstractPathExpressionback to summary
protected AbstractPathExpression(AbstractExpression parent, AbstractExpression identificationVariable)

Creates a new AbstractPathExpression.

Parameters
parent:AbstractExpression

The parent of this expression

identificationVariable:AbstractExpression

The identification variable that was already parsed, which means the beginning of the parsing should start with a dot

AbstractPathExpressionback to summary
public AbstractPathExpression(AbstractExpression parent, AbstractExpression identificationVariable, String paths)

Creates a new AbstractPathExpression.

Parameters
parent:AbstractExpression

The parent of this expression

identificationVariable:AbstractExpression

The identification variable that was already parsed, which means the beginning of the parsing should start with a dot

paths:String

The path expression that is following the identification variable

AbstractPathExpressionback to summary
protected AbstractPathExpression(AbstractExpression parent, String paths)

Creates a new AbstractPathExpression.

Parameters
parent:AbstractExpression

The parent of this expression

paths:String

The path expression

Method Detail

acceptChildrenback to summary
public void acceptChildren(ExpressionVisitor visitor)

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.acceptChildren.

Doc from org.eclipse.persistence.jpa.jpql.parser.Expression.acceptChildren.

Visits the children of this Expression. This method can be used to optimize traversing the children since a new list is not created every time children() is called.

This does not traverse the Expression sub-hierarchy, use a subclass of AbstractTraverseChildrenVisitor in order to traverse the entire sub-hierarchy.

Parameters
visitor:ExpressionVisitor

The visitor to visit the children of this object.

Annotations
@Override
addChildrenToback to summary
protected void addChildrenTo(Collection<Expression> children)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addChildrenTo.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addChildrenTo.

Adds the children of this AbstractExpression to the given collection.

Parameters
children:Collection<Expression>

The collection used to store the children

Annotations
@Override
addOrderedChildrenToback to summary
protected final void addOrderedChildrenTo(List<Expression> children)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addOrderedChildrenTo.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addOrderedChildrenTo.

Adds the children of this AbstractExpression to the given list.

Parameters
children:List<Expression>

The list used to store the string representation of this AbstractExpression

Annotations
@Override
checkPathsback to summary
private void checkPaths()
endsWithDotback to summary
public final boolean endsWithDot()

Determines whether the path ends with a dot or not.

Returns:boolean

true if the path ends with a dot; false otherwise

findQueryBNFback to summary
public final JPQLQueryBNF findQueryBNF(Expression expression)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.findQueryBNF.

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.findQueryBNF.

Doc from org.eclipse.persistence.jpa.jpql.parser.Expression.findQueryBNF.

Retrieves the JPQLQueryBNF that represents the fragment of this Expression that was used when parsing the given Expression.

Parameters
expression:Expression

The Expression that is a descendant of this one

Returns:JPQLQueryBNF

The JPQLQueryBNF that was used to parse the given expression

Annotations
@Override
getIdentificationVariableback to summary
public final Expression getIdentificationVariable()

Returns 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:Expression

The root of the path expression

getPathback to summary
public final String getPath(int index)

Returns the specified segment of the state field path.

Parameters
index:int

The 0-based segment index

Returns:String

The specified segment

hasIdentificationVariableback to summary
public final boolean hasIdentificationVariable()

Determines whether the identification variable was parsed.

Returns:boolean

true the identification variable was parsed; false otherwise

hasVirtualIdentificationVariableback to summary
public final boolean hasVirtualIdentificationVariable()

Determines whether the path's identification variable is virtual or not, meaning it's not part of the query but is required for proper navigability.

Returns:boolean

true if this identification variable was virtually created to fully qualify path expression; false if it was parsed

parseback to summary
protected final void parse(WordParser wordParser, boolean tolerant)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.parse.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.parse.

Parses the query by starting at the current position, which is part of the given WordParser.

Parameters
wordParser:WordParser

The text to parse based on the current position of the cursor

tolerant:boolean

Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries

Annotations
@Override
pathsback to summary
public final ListIterable<String> paths()

Returns the segments in the state field path in order.

Returns:ListIterable<String>

An Iterator over the segments of the state field path

pathSizeback to summary
public final int pathSize()

Returns the number of segments in the state field path.

Returns:int

The number of segments

setVirtualIdentificationVariableback to summary
protected final void setVirtualIdentificationVariable(String variableName)

Sets a virtual identification variable because the abstract schema name was parsed without one. This is valid in an UPDATE and DELETE queries.

Parameters
variableName:String

The identification variable that was generated to identify the "root" object

startsWithDotback to summary
public final boolean startsWithDot()

Determines whether the path starts with a dot or not.

Returns:boolean

true if the path starts with a dot; false otherwise

toParsedTextback to summary
public String toParsedText(int startIndex, int stopIndex)

Returns a string representation from the given range.

Parameters
startIndex:int

The beginning of the range to create the string representation

stopIndex:int

When to stop creating the string representation, which is exclusive

Returns:String

The string representation of this path expression contained in the given range

Since
2.4
toParsedTextback to summary
protected final void toParsedText(StringBuilder writer, boolean actual)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.toParsedText.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.toParsedText.

Generates a string representation of this Expression, including its children, if it has any.

Parameters
writer:StringBuilder

The buffer used to append this Expression's string representation

actual:boolean

Determines whether the string representation should represent what was parsed, i.e. include any "virtual" whitespace (such as ending whitespace) and the actual case of the JPQL identifiers

Annotations
@Override