List of usage examples for com.mongodb BasicDBList toMap
@Override @SuppressWarnings("unchecked") public Map toMap()
From source file:org.eclipse.birt.data.oda.mongodb.internal.impl.ResultDataHandler.java
License:Open Source License
private static BasicDBList fetchFieldValuesFromList(String fieldFullName, BasicDBList fromDBList) { if (fromDBList == null || fromDBList.size() == 0) return null; // get the named field value from each element in given array list BasicDBList fieldValuesList = new BasicDBList(); if (fromDBList.isPartialObject()) fieldValuesList.markAsPartialObject(); for (int index = 0; index < fromDBList.size(); index++) { Object listElementObj = fromDBList.get(String.valueOf(index)); if (listElementObj instanceof DBObject) // nested complex object, e.g. document listElementObj = fetchFieldValues(fieldFullName, (DBObject) listElementObj); fieldValuesList.put(index, listElementObj); }//from w w w .ja v a 2 s . c o m // check if at least one field value in list is not null, return the list for (Object elementValue : fieldValuesList.toMap().values()) { if (elementValue != null) return fieldValuesList; } return null; // all values in list is null }