public Element popElement() {
Element answer = super.popElement();
if ((lastElementIndex == matchingElementIndex)
&& (lastElementIndex >= 0)) {
// we are popping the correct level in the tree
// lets check if the path fits
//
// NOTE: this is an inefficient way of doing it - we could
// maintain a history of which parts matched?
if (validElement(answer, lastElementIndex + 1)) {
Element parent = null;
for (int i = 0; i < = lastElementIndex; i++) {
parent = stack[i];
if (!validElement(parent, i)) {
parent = null;
break;
}
}
if (parent != null) {
pathMatches(parent, answer);
}
}
}
return answer;
}
|