public GetIndexStatistics(XQueryContext context) {
super(context, signature);
}
public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
final IndexStatistics index = (IndexStatistics) context.getBroker().getBrokerPool().
getIndexManager().getIndexById(IndexStatistics.ID);
if (index == null) {
// module may not be enabled
return Sequence.EMPTY_SEQUENCE;
}
final SAXAdapter adapter = new SAXAdapter(context);
try {
adapter.startDocument();
index.toSAX(adapter);
adapter.endDocument();
} catch (final SAXException e) {
throw new XPathException(this, "Error caught while retrieving statistics: " + e.getMessage(), e);
}
final DocumentImpl doc = (DocumentImpl) adapter.getDocument();