Java Code Examples for com.mongodb.BasicDBList#put()
The following examples show how to use
com.mongodb.BasicDBList#put() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResultDataHandler.java From birt with Eclipse Public License 1.0 | 5 votes |
private static BasicDBList fetchFieldValuesFromList( String fieldFullName, List<Document> documentList ) { if( documentList == null || documentList.size() == 0 ) return null; // get the named field value from each element in given array list BasicDBList fieldValuesList = new BasicDBList(); //if( documentList.isPartialObject() ) // fieldValuesList.markAsPartialObject(); for( int index=0; index < documentList.size(); index++ ) { Object listElementObj = documentList.get( index ); if( listElementObj instanceof Document ) // nested complex object, e.g. document listElementObj = fetchFieldValues( fieldFullName, (Document)listElementObj ); fieldValuesList.put( index, listElementObj ); } // 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 }
Example 2
Source File: MDbResultSet.java From birt with Eclipse Public License 1.0 | 5 votes |
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) ); } fieldValuesList.markAsPartialObject(); return fieldValuesList.toString(); // return JSON expr format } } if( columnValue instanceof byte[] ) return convertToString( (byte[])columnValue ); return columnValue != null ? columnValue.toString() : null; }