if (foundItemTypes == null) {
ArrayList nodes = (ArrayList)index.get(getCollationKey(value, itemType, collation, context));
if (nodes==null) {
return EmptyIterator.getInstance();
} else {
return new ListIterator(nodes);
}
} else {
// we need to search the indexes for all possible types, and combine the results.
SequenceIterator result = null;
WeakReference<HashMap<Long, Object>> ref = docIndexes.get(doc);
if (ref != null) {
HashMap<Long, Object> indexList = ref.get();
if (indexList != null) {
for (Iterator<Long> i=indexList.keySet().iterator(); i.hasNext();) {
long key = (i.next()).longValue();
if (((key >> 32)) == keySetNumber) {
int typefp = (int)key;
BuiltInAtomicType type = (BuiltInAtomicType)BuiltInType.getSchemaType(typefp);
Object indexObject2 = getIndex(doc, keySetNumber, type);
if (indexObject2 instanceof String) {
// index is under construction
XPathException de = new XPathException("Key definition is circular");
de.setXPathContext(context);
de.setErrorCode("XTDE0640");
throw de;
}
HashMap index2 = (HashMap)indexObject2;
// NOTE: we've been known to encounter a null index2 here, but it doesn't seem possible
if (!index2.isEmpty()) {
value = soughtValue.convert(type, true, context).asAtomic();
ArrayList nodes = (ArrayList)index2.get(getCollationKey(value, type, collation, context));
if (nodes != null) {
if (result == null) {
result = new ListIterator(nodes);
} else {
result = new UnionEnumeration(result, new ListIterator(nodes), LocalOrderComparer.getInstance());
}
}
}
}
}