Object featureTypeName = getNestedFeatureType(feature);
if (featureTypeName == null || !(featureTypeName instanceof Name)) {
throw new IllegalArgumentException(
"Internal error: Feature type name expected but found " + featureTypeName);
}
DataAccessMappingFeatureIterator featureIterator = instance.featureIterators
.get((Name) featureTypeName);
if (featureIterator == null) {
featureIterator = initSourceFeatures(instance, (Name) featureTypeName, reprojection,
selectedProperties, includeMandatory, 0, null);
}
Expression nestedSourceExpression = instance.nestedSourceExpressions
.get((Name) featureTypeName);
if (nestedSourceExpression == null) {
throw new IllegalArgumentException(
"Internal error: nested source expression expected but found "
+ featureTypeName);
}
ArrayList<Feature> matchingFeatures = new ArrayList<Feature>();
if (featureIterator != null) {
while (featureIterator.hasNext()
&& featureIterator.peekNextValue(nestedSourceExpression).toString()
.equals(foreignKeyValue.toString())
&& featureIterator.checkForeignIdValues(idValues)) {
matchingFeatures.addAll(featureIterator.skip());
}
}
// skip all others
for (Name name : instance.featureIterators.keySet()) {
DataAccessMappingFeatureIterator fIt = instance.featureIterators.get(name);
if (fIt != featureIterator) {
skipFeatures(fIt, instance.nestedSourceExpressions.get(name), foreignKeyValue,
idValues);
}
}