本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}