private static NodePointer doStepNoPredicatesPropertyOwner(
EvalContext context, PropertyOwnerPointer parentPointer,
Step[] steps, int currentStep)
{
Step step = steps[currentStep];
NodePointer childPointer =
createChildPointerForStep(parentPointer, step);
if (!childPointer.isActual()) {
// The property does not exist - create a null pointer.
return createNullPointer(
context,
parentPointer,
steps,
currentStep);
}
else if (currentStep == steps.length - 1) {
// If this is the last step - we are done, we found it
return childPointer;
}
else if (childPointer.isCollection()) {
// Iterate over all values and
// execute remaining steps for each node,
// looking for the best quality match
int bestQuality = 0;
NodePointer bestMatch = null;
int count = childPointer.getLength();
for (int i = 0; i < count; i++) {
childPointer.setIndex(i);
NodePointer pointer =
doStep(context, childPointer, steps, currentStep + 1);
int quality = computeQuality(pointer);
if (quality == PERFECT_MATCH) {
return pointer;
}
else if (quality > bestQuality) {
bestQuality = quality;
bestMatch = (NodePointer) pointer.clone();
}
}
if (bestMatch != null) {
return bestMatch;
}