String start, String end) throws PermissionDeniedException {
final IndexScanCallback cb = new IndexScanCallback(docs, contextSet, false);
final Lock lock = dbTokens.getLock();
for (final Iterator<Collection> i = docs.getCollectionIterator(); i.hasNext();) {
final int collectionId = (i.next()).getId();
final IndexQuery query;
if (start == null) {
final Value startRef = new WordRef(collectionId);
query = new IndexQuery(IndexQuery.TRUNC_RIGHT, startRef);
} else if (end == null) {
final Value startRef = new WordRef(collectionId, start.toLowerCase());
query = new IndexQuery(IndexQuery.TRUNC_RIGHT, startRef);
} else {
final Value startRef = new WordRef(collectionId, start.toLowerCase());
final Value endRef = new WordRef(collectionId, end.toLowerCase());
query = new IndexQuery(IndexQuery.BW, startRef, endRef);
}
try {
lock.acquire(Lock.READ_LOCK);
dbTokens.query(query, cb);
} catch (final LockException e) {