Example usage for com.mongodb BasicDBList isPartialObject

List of usage examples for com.mongodb BasicDBList isPartialObject

Introduction

In this page you can find the example usage for com.mongodb BasicDBList isPartialObject.

Prototype

@Override
    public boolean isPartialObject() 

Source Link

Usage

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  .  j av a2  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
}