List of usage examples for com.mongodb BasicDBList markAsPartialObject
@Override public void markAsPartialObject()
From source file:org.eclipse.birt.data.oda.mongodb.impl.MDbResultSet.java
License:Open Source License
public String getString(String columnName) throws OdaException { Object columnValue = getFieldValue(columnName); if (columnValue instanceof String) return (String) columnValue; if (columnValue instanceof List && !(columnValue instanceof BasicDBList)) { // convert generic List to JSON-formattable list List<?> fromList = (List<?>) columnValue; if (!fromList.isEmpty()) { BasicDBList fieldValuesList = new BasicDBList(); for (int index = 0; index < fromList.size(); index++) { fieldValuesList.put(index, fromList.get(index)); }//www. j av a2 s .c o m fieldValuesList.markAsPartialObject(); return fieldValuesList.toString(); // return JSON expr format } } if (columnValue instanceof byte[]) return convertToString((byte[]) columnValue); return columnValue != null ? columnValue.toString() : null; }
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 ww . j a v a2s .co 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 }