Methods Summary |
---|
public void | applyToQuery(oracle.toplink.essentials.queryframework.ObjectLevelReadQuery theQuery, oracle.toplink.essentials.internal.parsing.GenerationContext context)INTERNAL
Apply this node to the passed query
if (theQuery.isReportQuery()){
ReportQuery reportQuery = (ReportQuery)theQuery;
reportQuery.addAttribute(resolveAttribute(), generateExpression(context));
reportQuery.dontRetrievePrimaryKeys();
}
|
private void | checkNavigation(oracle.toplink.essentials.internal.parsing.Node node, oracle.toplink.essentials.internal.parsing.ParseTreeContext context)INTERNAL
Checks whether the left hand side of this dot node is navigable.
TypeHelper typeHelper = context.getTypeHelper();
// Checks whether the type of the dot node allows a navigation.
Object type = node.getType();
if (!typeHelper.isEntityClass(type) &&
!typeHelper.isEmbeddable(type) &&
!typeHelper.isEnumType(type)) {
throw EJBQLException.invalidNavigation(
context.getQueryInfo(), node.getLine(), node.getColumn(),
this.getAsString(), node.getAsString(),
typeHelper.getTypeName(type));
}
// Special check to disallow collection valued relationships
if (node.isDotNode()) {
Node left = node.getLeft();
AttributeNode right = (AttributeNode)node.getRight();
if (typeHelper.isCollectionValuedRelationship(
left.getType(), right.getAttributeName())) {
throw EJBQLException.invalidCollectionNavigation(
context.getQueryInfo(), right.getLine(), right.getColumn(),
this.getAsString(), right.getAttributeName());
}
}
|
public boolean | endsWithCollectionField(oracle.toplink.essentials.internal.parsing.GenerationContext context)INTERNAL
():
Answer true if the node has a left and right, and the right represents
a collection mapping.
DatabaseMapping mapping = resolveMapping(context);
return (mapping != null) && mapping.isCollectionMapping();
|
public boolean | endsWithDirectToField(oracle.toplink.essentials.internal.parsing.GenerationContext context)INTERNAL
():
Answer true if the SELECTed node has a left and right, and the right represents
a direct-to-field mapping.
DatabaseMapping mapping = resolveMapping(context);
return (mapping != null) && mapping.isDirectToFieldMapping();
|
public oracle.toplink.essentials.expressions.Expression | generateExpression(oracle.toplink.essentials.internal.parsing.GenerationContext context)INTERNAL
Return a TopLink expression by getting the required variables using the
left and right nodes
"emp.address.city" = builder.get("address").get("city")
Node left = getLeft();
Node right = getRight();
if (enumConstant != null) {
// enum literal access
return new ConstantExpression(enumConstant, new ExpressionBuilder());
} else {
// Get the left expression
Expression whereClause = getLeft().generateExpression(context);
// Calculate the mapping and pass it to the right expression
if (right.isAttributeNode()) {
((AttributeNode)right).setMapping(resolveMapping(context));
}
// Or it with whatever the right expression is
whereClause = right.addToExpression(whereClause, context);
// and return the expression...
return whereClause;
}
|
public java.lang.String | getAsString()INTERNAL
Get the string representation of this node.
return left.getAsString() + "." + right.getAsString();
|
private oracle.toplink.essentials.internal.parsing.Node | getLeftMostNode()INTERNAL
Return the left most node of a dot expr, so return 'a' for 'a.b.c'.
return left.isDotNode() ? ((DotNode)left).getLeftMostNode() : left;
|
public java.lang.Class | getTypeOfDirectToField(oracle.toplink.essentials.internal.parsing.GenerationContext context)INTERNAL
Returns the attribute type if the right represents a direct-to-field mapping.
DatabaseMapping mapping = resolveMapping(context);
if ((mapping != null) && mapping.isDirectToFieldMapping()) {
return ((DirectToFieldMapping)mapping).getAttributeClassification();
}
return null;
|
private boolean | isDeclaredVariable(oracle.toplink.essentials.internal.parsing.Node node, oracle.toplink.essentials.internal.parsing.ParseTreeContext context)
if (node.isVariableNode()) {
String name = ((VariableNode)node).getCanonicalVariableName();
return context.isVariable(name);
}
return false;
|
public boolean | isDotNode()INTERNAL
Yes, this is a dot node
return true;
|
public oracle.toplink.essentials.internal.parsing.Node | qualifyAttributeAccess(oracle.toplink.essentials.internal.parsing.ParseTreeContext context)INTERNAL
Check the left child node for an unqualified field access. The method
delegates to the left most expression of multi-navigation path
expression.
if (getLeft() != null) {
setLeft(getLeft().qualifyAttributeAccess(context));
}
return this;
|
public java.lang.String | resolveAttribute()INTERNAL
Answer the name of the attribute which is represented by the receiver's
right node.
return ((AttributeNode)getRight()).getAttributeName();
|
public java.lang.Class | resolveClass(oracle.toplink.essentials.internal.parsing.GenerationContext context)resolveClass: Answer the class which results from traversing the mappings for the receiver's nodes
Class leftClass = getLeft().resolveClass(context);
return getRight().resolveClass(context, leftClass);
|
private java.lang.Object | resolveEnumTypeName(java.lang.String name, oracle.toplink.essentials.internal.parsing.TypeHelper helper)INTERNAL
Returns the type representation for the specified type name. The method
looks for inner classes if it cannot resolve the type name.
Object type = helper.resolveTypeName(name);
if (type == null) {
// check for inner enum type
int index = name.lastIndexOf('.");
if (index != -1) {
name = name.substring(0, index) + '$" + name.substring(index+1);
type = helper.resolveTypeName(name);
}
}
return type;
|
public oracle.toplink.essentials.mappings.DatabaseMapping | resolveMapping(oracle.toplink.essentials.internal.parsing.GenerationContext context)INTERNAL
Answer the mapping resulting from traversing the receiver's nodes
Class leftClass = getLeft().resolveClass(context);
return getRight().resolveMapping(context, leftClass);
|
public void | validate(oracle.toplink.essentials.internal.parsing.ParseTreeContext context)INTERNAL
Validate node and calculate its type.
Check for enum literals.
TypeHelper typeHelper = context.getTypeHelper();
String name = ((AttributeNode)right).getAttributeName();
// check for fully qualified type names
Node leftMost = getLeftMostNode();
if (isDeclaredVariable(leftMost, context)) {
left.validate(context);
checkNavigation(left, context);
Object type = typeHelper.resolveAttribute(left.getType(), name);
if (type == null) {
// could not resolve attribute
throw EJBQLException.unknownAttribute(
context.getQueryInfo(), right.getLine(), right.getColumn(),
name, typeHelper.getTypeName(left.getType()));
}
setType(type);
right.setType(type);
} else {
// Check for enum literal access
String typeName = left.getAsString();
Object type = resolveEnumTypeName(typeName, typeHelper);
if ((type != null) && typeHelper.isEnumType(type)) {
enumConstant = typeHelper.resolveEnumConstant(type, name);
if (enumConstant == null) {
throw EJBQLException.invalidEnumLiteral(context.getQueryInfo(),
right.getLine(), right.getColumn(), typeName, name);
}
} else {
// left most node is not an identification variable and
// dot expression doe not denote an enum literal access =>
// unknown identification variable
throw EJBQLException.aliasResolutionException(
context.getQueryInfo(), leftMost.getLine(),
leftMost.getColumn(), leftMost.getAsString());
}
setType(type);
right.setType(type);
}
|