final NativeArray nativeArray = (NativeArray) result;
final Collection<Document> arrayResult = new ArrayList<Document>((int) nativeArray.getLength());
for (int i = 0; i < (int) nativeArray.getLength(); i++) {
if (nativeArray.get(i, null) instanceof RhinoDocument) {
final RhinoDocument rhinoDocument = (RhinoDocument) nativeArray.get(i, null);
final Document document = rhinoDocument.toDocument(
doc.getId(),
defaults,
database);
arrayResult.add(document);
}