当前位置: 首页>>代码示例>>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;未经允许,请勿转载。