當前位置: 首頁>>代碼示例>>Java>>正文


Java DBCursor.iterator方法代碼示例

本文整理匯總了Java中com.mongodb.DBCursor.iterator方法的典型用法代碼示例。如果您正苦於以下問題:Java DBCursor.iterator方法的具體用法?Java DBCursor.iterator怎麽用?Java DBCursor.iterator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.mongodb.DBCursor的用法示例。


在下文中一共展示了DBCursor.iterator方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: toDumpData

import com.mongodb.DBCursor; //導入方法依賴的package包/類
@Override
public DumpData toDumpData(PageContext pageContext, int maxlevel, DumpProperties dp) {
	DBCursor cursor = coll.find();
	Iterator<DBObject> it = cursor.iterator();
	DumpTable table = new DumpTable("struct","#339933","#8e714e","#000000");
	table.setTitle("DBCollection");

	maxlevel--;
	DBObject obj;
	while(it.hasNext()) {
		obj = it.next();
		table.appendRow(0,
				__toDumpData(toCFML(obj), pageContext,maxlevel,dp)
			);
	}
	return table;
}
 
開發者ID:lucee,項目名稱:extension-mongodb,代碼行數:18,代碼來源:DBCollectionImpl.java

示例2: getCompletionData

import com.mongodb.DBCursor; //導入方法依賴的package包/類
@Override
public List<Map> getCompletionData(){
    DBCursor cursor = rawDataCollection.find();
    Iterator<DBObject> iter = cursor.iterator();
    List<Map> out = new ArrayList<Map>();
    int i = 0;
    while(iter.hasNext()){
        try {
            DBObject temp = iter.next();
            Map map = new HashMap();
            map.put("name", temp.get("name"));
            map.put("schema", temp.get("schema"));
            map.put("id", temp.get("_id").toString());
            if(temp.containsKey("description")) {
                map.put("description", temp.get("description"));
            } else if(temp.containsKey("shortDescription")) {
                map.put("description", temp.get("shortDescription"));
            }
            out.add(map);
        } catch(Exception err) {
            err.printStackTrace();
        }
        i++;
    }
    return out;
}
 
開發者ID:CIDARLAB,項目名稱:clotho3crud,代碼行數:27,代碼來源:JongoConnection.java

示例3: readAttributeValuesFromDbByField

import com.mongodb.DBCursor; //導入方法依賴的package包/類
/**
 * This method is implementing a high performance selection of the values for the given returnField attribute
 * for all objects which match the select filter (filterField, filterValue)  
 * @param object
 *        The request object
 * @param fieldName
 *        The database object field name
 * @param atttibuteName
 *        The query
 * @param values
 *        Request values list	 
 * @return the list of the FfmaDomainObject objects found in database
 * @throws ObjectNotFoundException
 */
public Set<String> readAttributeValuesFromDbByField(
		FfmaDomainObject object, String returnFieldName, String filterFieldName,
		List<String> filterValues, String afterDateFieldName, Long afterDateValue) {
	
	Set<String> res = new HashSet<String>();
	
		DBCollection mongoCollection = db.getCollectionFromString(object
				.getClass().getSimpleName());
		
		BasicDBObject query = new BasicDBObject();
		if (filterFieldName != null)
			query.put(filterFieldName, new BasicDBObject(MongoDbConstants.IN_QUERY, filterValues));
		
		if(afterDateFieldName != null && afterDateValue !=null){
			query.put(afterDateFieldName, new BasicDBObject(MongoDbConstants.GREATER_THAN_QUERY, afterDateValue));
		}
		log.info("Search Query: " + query);
					
		BasicDBObject returnKeys = new BasicDBObject();
		returnKeys.append(returnFieldName, 1);
		log.info("return keys: " + returnKeys);
		DBCursor cur = mongoCollection.find(query, returnKeys);
		
		try {
			//List<BasicDBObject> mongoObjList = getDbObjectsList(mongoCollection, fieldName, atttibuteName, values);
			Iterator<DBObject> iter = cur.iterator();
			while (iter.hasNext()) {
				res.add((String)iter.next().get(returnFieldName));
			}
		} finally {
		    cur.close();
		}		
		return res;		
}
 
開發者ID:ait-ngcms,項目名稱:ffma,代碼行數:49,代碼來源:BaseMongoDbManager.java

示例4: getNumberOfTriples

import com.mongodb.DBCursor; //導入方法依賴的package包/類
/**
 * 
 * @return number of total triples by vocab
 */
public long getNumberOfTriples(Boolean isVocab) {
	long totalTriples = 0;

	try {
		DBCollection collection = DBSuperClass2.getDBInstance().getCollection(DistributionDB.COLLECTION_NAME);

		BasicDBObject query;

		if (isVocab != null)
			query = new BasicDBObject(new BasicDBObject(DistributionDB.IS_VOCABULARY, isVocab));
		else
			query = new BasicDBObject();

		DBCursor instances = collection.find(query);

		Iterator<DBObject> it = instances.iterator();

		while (it.hasNext()) {
			totalTriples = totalTriples + Long.parseLong(it.next().get(DistributionDB.TRIPLES).toString());
		}

	} catch (Exception e) {
		e.printStackTrace();
	}
	return totalTriples;
}
 
開發者ID:AKSW,項目名稱:LODVader,代碼行數:31,代碼來源:DistributionQueries.java


注:本文中的com.mongodb.DBCursor.iterator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。