// see if this is an attribute
Attribute attr = currentEnt.getAttribute(pathComp);
if (attr != null) {
// do a sanity check...
if (toks.hasMoreTokens())
throw new ExpressionException(
"Attribute must be the last component of the path: '"
+ pathComp
+ "'.",
path,
null);
return attr;
}
Relationship rel = currentEnt.getRelationship(pathComp);
if (rel != null) {
currentEnt = rel.getTargetEntity();
if (currentEnt != null || !toks.hasMoreTokens()) { //otherwise an exception will be thrown
return rel;
}
}
// build error message
StringBuilder buf = new StringBuilder();
buf
.append("Can't resolve path component: [")
.append(currentEnt.getName())
.append('.')
.append(pathComp)
.append("].");
throw new ExpressionException(buf.toString(), path, null);
}