// ones
if (currentSet == null
|| currentDocs == null
|| (!optimized && !(docs == currentDocs || docs
.equalDocs(currentDocs)))) {
final StructuralIndex index = context.getBroker().getStructuralIndex();
if (context.getProfiler().isEnabled())
{context.getProfiler().message(
this,
Profiler.OPTIMIZATIONS,
"OPTIMIZATION",
"Using structural index '" + index.toString()
+ "'");}
currentSet = index.findElementsByTagName(
ElementValue.ELEMENT, docs, test.getName(), null, this);
currentDocs = docs;
registerUpdateListener();
}
switch (axis) {
case Constants.DESCENDANT_SELF_AXIS:
final NodeSet tempSet = currentSet.selectAncestorDescendant(
contextSet, NodeSet.DESCENDANT, true, contextId,
true);
return tempSet;
case Constants.DESCENDANT_AXIS:
return currentSet.selectAncestorDescendant(contextSet,
NodeSet.DESCENDANT, false, contextId, true);
default:
throw new IllegalArgumentException(
"Unsupported axis specified");
}
}
} else {
final DocumentSet docs = contextSet.getDocumentSet();
final StructuralIndex index = context.getBroker().getStructuralIndex();
if (context.getProfiler().isEnabled()) {
context.getProfiler().message(this, Profiler.OPTIMIZATIONS,
"OPTIMIZATION",
"Using structural index '" + index.toString() + "'");
}
if (!contextSet.getProcessInReverseOrder() && (contextSet instanceof VirtualNodeSet || contextSet.getLength() < INDEX_SCAN_THRESHOLD)) {
return index.findDescendantsByTagName(ElementValue.ELEMENT,
test.getName(), axis, docs, contextSet,
contextId, this);
} else {
NodeSelector selector;
switch (axis) {
case Constants.DESCENDANT_SELF_AXIS:
selector = new DescendantOrSelfSelector(contextSet,
contextId);
break;
case Constants.DESCENDANT_AXIS:
selector = new DescendantSelector(contextSet, contextId);
break;
default:
throw new IllegalArgumentException(
"Unsupported axis specified");
}
return index.findElementsByTagName(ElementValue.ELEMENT, docs,
test.getName(), selector, this);
}
}
}