}
public List<IndexHit> getTermResults(final CharSequence term, final int limit, final Set<CharSequence> dbids,
final Set<CharSequence> itemNames, final Set<CharSequence> forms) {
List<IndexHit> results = new ArrayList<IndexHit>();
Document doc = getTermDocument(term);
int dbCount = 0;
if (dbids == null || dbids.isEmpty()) {
for (Item item : doc.getItems()) {
String itemName = item.getName();
if (itemName.startsWith(TERM_MAP_PREFIX)) {
dbCount++;
String dbid = itemName.substring(TERM_MAP_PREFIX.length());
Map termMap = doc.getItemValue(itemName, Map.class);
results.addAll(getTermResultsForItemsForms(termMap, itemNames, forms, term, dbid));
if (limit != 0 && results.size() >= limit) {
return results;
}
}
}
} else {
for (CharSequence dbid : dbids) {
String itemName = TERM_MAP_PREFIX + dbid;
if (doc.hasItem(itemName)) {
dbCount++;
Map termMap = doc.getItemValue(itemName, Map.class);
results.addAll(getTermResultsForItemsForms(termMap, itemNames, forms, term, dbid));
if (limit != 0 && results.size() >= limit) {
return results;
}
}
}
}
if (dbCount < 1) {
System.out.println("No databases found that contain term " + term + " in document " + doc.getNoteID() + ": "
+ doc.getAncestorDatabase().getApiPath());
}
return results;
}