synchronized (context) {
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()
+ "'");}
// TODO : why a null selector here ? We have one below !
currentSet = index.findElementsByTagName(
ElementValue.ATTRIBUTE, docs, test.getName(), null, this);
currentDocs = docs;
registerUpdateListener();
}
switch (axis) {
case Constants.ATTRIBUTE_AXIS:
return currentSet.matchParentChild(contextSet,
NodeSet.DESCENDANT, contextId);
case Constants.DESCENDANT_ATTRIBUTE_AXIS:
return currentSet.matchAncestorDescendant(contextSet,
NodeSet.DESCENDANT, false, contextId, true);
default:
throw new IllegalArgumentException(
"Unsupported axis specified");
}
}
} else {
final DocumentSet docs = getDocumentSet(contextSet);
final StructuralIndex index = context.getBroker().getStructuralIndex();
if (context.getProfiler().isEnabled())
{context.getProfiler().message(this, Profiler.OPTIMIZATIONS,
"OPTIMIZATION",
"Using structural index '" + index.toString() + "'");}
if (contextSet instanceof ExtNodeSet
&& !contextSet.getProcessInReverseOrder()) {
return index.matchDescendantsByTagName(ElementValue.ATTRIBUTE,
test.getName(), axis, docs, (ExtNodeSet) contextSet,
contextId);
} else {
NodeSelector selector;
switch (axis) {
case Constants.ATTRIBUTE_AXIS:
selector = new ChildSelector(contextSet, contextId);
break;
case Constants.DESCENDANT_ATTRIBUTE_AXIS:
selector = new DescendantSelector(contextSet, contextId);
break;
default:
throw new IllegalArgumentException(
"Unsupported axis specified");
}
return index.matchElementsByTagName(ElementValue.ATTRIBUTE,
docs, test.getName(), selector);
}
}
}