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


Java DBCursor.close方法代碼示例

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


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

示例1: loadMongoFactionMembers

import com.mongodb.DBCursor; //導入方法依賴的package包/類
/**
 * (Private Method)
 * <p>
 * Loads MongoFactionMember Objects from the database.
 */
private void loadMongoFactionMembers() {
    println("Loading Faction Member(s)...");
    // Create HashMap.
    mapMongoFactionMembers = new HashMap<>();
    // Initiate collection query.
    DBCursor cursor = collectionFactionMembers.find();
    // Go through each entry.
    while (cursor.hasNext()) {
        // Create an object for each entry.
        MongoFactionMember mongoFactionMember = new MongoFactionMember(collectionFactionMembers, cursor.next());
        // Add to the map with the UUID of the FactionMember.
        mapMongoFactionMembers.put(mongoFactionMember.getPlayerId(), mongoFactionMember);
    }
    // Close the query.
    cursor.close();
    // Report statistics.
    int size = mapMongoFactionMembers.size();
    println("Loaded " + (size == 0 ? "no" : size + "") + " Faction Member" + (size == 1 ? "" : "s") + ".");
}
 
開發者ID:JabJabJab,項目名稱:Sledgehammer,代碼行數:25,代碼來源:ModuleFactions.java

示例2: loadMongoFactionInvites

import com.mongodb.DBCursor; //導入方法依賴的package包/類
/**
 * (Private Method)
 * <p>
 * Loads MongoFactionInvite Objects from the database.
 */
private void loadMongoFactionInvites() {
    println("Loading Faction Invite(s)...");
    // Create HashMap.
    mapMongoFactionInvites = new HashMap<>();
    // Initiate collection query.
    DBCursor cursor = collectionFactionInvites.find();
    // Go through each entry.
    while (cursor.hasNext()) {
        // Create an object for each entry.
        MongoFactionInvite mongoFactionInvite = new MongoFactionInvite(collectionFactionInvites, cursor.next());
        // Add to the map with the UUID of the MongoFactionInvite.
        mapMongoFactionInvites.put(mongoFactionInvite.getUniqueId(), mongoFactionInvite);
    }
    // Close the query.
    cursor.close();
    // Report statistics.
    int size = mapMongoFactionInvites.size();
    println("Loaded " + (size == 0 ? "no" : size + "") + " Faction Invite" + (size == 1 ? "" : "s") + ".");
}
 
開發者ID:JabJabJab,項目名稱:Sledgehammer,代碼行數:25,代碼來源:ModuleFactions.java

示例3: getChatMessages

import com.mongodb.DBCursor; //導入方法依賴的package包/類
/**
 * @param channelId The Unique ID of the channel.
 * @param limit     The Integer limit of ChatMessages to load.
 * @return Returns a List of ChatMessages for the ChatChannel.
 */
private List<ChatMessage> getChatMessages(UUID channelId, int limit) {
    List<ChatMessage> listChatMessages = new LinkedList<>();
    // Grab all the messages with the channel_id set to the one provided.
    DBObject query = new BasicDBObject("channel_id", channelId);
    DBCursor cursor = collectionMessages.find(query);
    // Sort the list by timestamp so that the last messages appear first.
    cursor.sort(new BasicDBObject("timestamp", -1));
    cursor.limit(limit);
    if(cursor.size() > 0) {
        List<DBObject> listObjects = cursor.toArray();
        Collections.reverse(listObjects);
        for(DBObject object : listObjects) {
            // Create the MongoDocument.
            MongoChatMessage mongoChatMessage = new MongoChatMessage(collectionMessages, object);
            // Create the container for the document.
            ChatMessage chatMessage = new ChatMessage(mongoChatMessage);
            // Add this to the list to return.
            listChatMessages.add(chatMessage);
        }
    }
    // Close the cursor to release resources.
    cursor.close();
    // Return the result list of messages for the channel.
    return listChatMessages;
}
 
開發者ID:JabJabJab,項目名稱:Sledgehammer,代碼行數:31,代碼來源:ModuleChat.java

示例4: getMongoPlayer

import com.mongodb.DBCursor; //導入方法依賴的package包/類
public MongoPlayer getMongoPlayer(UUID uniqueId) {
    if (uniqueId == null) {
        throw new IllegalArgumentException("SledgehammerDatabase: uniqueId given is null!");
    }
    MongoPlayer player;
    player = mapPlayersByUUID.get(uniqueId);
    if (player == null) {
        DBCursor cursor = collectionPlayers.find(new BasicDBObject("uuid", uniqueId.toString()));
        if (cursor.hasNext()) {
            player = new MongoPlayer(collectionPlayers, cursor.next());
            registerPlayer(player);
        }
        cursor.close();
    }
    return player;
}
 
開發者ID:JabJabJab,項目名稱:Sledgehammer,代碼行數:17,代碼來源:SledgehammerDatabase.java

示例5: getRecentBuildStatsForProduct

import com.mongodb.DBCursor; //導入方法依賴的package包/類
@GET
@Path("/recent-builds/{product}")
public DBObject getRecentBuildStatsForProduct(@BeanParam final Coordinates coordinates, @QueryParam("limit") final Integer limit) {
	final BasicDBList returns = new BasicDBList();
	final DB db = this.client.getDB("bdd");
	final DBCollection collection = db.getCollection("reportStats");
	final BasicDBObject example = coordinates.getQueryObject(Field.PRODUCT);
	final DBCursor cursor = collection.find(example).sort(Coordinates.getFeatureSortingObject());
	if (limit != null) {
		cursor.limit(limit);
	}
	try {
		while (cursor.hasNext()) {
			final DBObject doc = cursor.next();
			returns.add(doc);
		}
	} finally {
		cursor.close();
	}
	return returns;
}
 
開發者ID:orionhealth,項目名稱:XBDD,代碼行數:22,代碼來源:AutomationStatistics.java

示例6: getDisposalListItems

import com.mongodb.DBCursor; //導入方法依賴的package包/類
public List<DisposalListItem> getDisposalListItems(String organization){
	this.selectCollection(DB_DISPOSAL);
	List<DisposalListItem> disposalListItems = new ArrayList<DisposalListItem>();
    DBCursor cursor = table.find(new BasicDBObject("organization", organization), new BasicDBObject("_id", 0));
    
    if (cursor.size() > 0) {
        while (cursor.hasNext()) {
        	List<Map<String,String>> results = new JSONDeserializer<List<Map<String,String>>>().deserialize(cursor.next().get(ARRAY_DISPOSAL).toString());
         for (int i = 0; i < results.size(); i++) {
         	Map<String, String> item = results.get(i);
         	DisposalListItem disposalItem = new DisposalListItem();
         	
         	disposalItem.setPid(item.get("pid"));
         	disposalItem.setObjectName(item.get("objname"));
         	disposalItem.setObjectType(item.get("objtype"));
         	disposalItem.setDeleter(item.get("username"));
         	disposalItem.setDisposalDateString(item.get("date"));
         	disposalItem.setDisposalDateTimestamp(Long.parseLong(item.get("timestamp")));
         	
	disposalListItems.add(disposalItem);
         }
        }
    }
    cursor.close();
    return disposalListItems;
}
 
開發者ID:mikkeliamk,項目名稱:osa,代碼行數:27,代碼來源:MongoManager.java

示例7: getApprovals

import com.mongodb.DBCursor; //導入方法依賴的package包/類
@Override
public List<Approval> getApprovals(String userName, String clientId) {
    BasicDBObject query = new BasicDBObject(userIdFieldName, userName).append(clientIdFieldName, clientId);
    DBCursor cursor = null;
    try {
        List<Approval> approvals = new ArrayList<Approval>();
        cursor = getApprovalsCollection().find(query);
        while (cursor.hasNext()) {
            DBObject dbo = cursor.next();
            approvals.add(new Approval((String) dbo.get(userIdFieldName), (String) dbo.get(clientIdFieldName),
                    (String) dbo.get(scopeFieldName), (Date) dbo.get(expiresAtFieldName),
                    Approval.ApprovalStatus.valueOf((String) dbo.get(statusFieldName)),
                    (Date) dbo.get(lastModifiedAtFieldName)));
        }
        return approvals;
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
}
 
開發者ID:cedac-software,項目名稱:spring-security-mongodb,代碼行數:22,代碼來源:MongoApprovalStore.java

示例8: testClear

import com.mongodb.DBCursor; //導入方法依賴的package包/類
protected static void testClear(GridFS gridFS) {
    DBCursor cursor = gridFS.getFileList();
    while (cursor.hasNext()) {
        DBObject dbObject = cursor.next();
        String filename = (String)cursor.next().get("filename");
        System.out.println(filename);
        System.out.println(dbObject.toString());
        gridFS.remove(filename);
    }
    cursor.close();
}
 
開發者ID:javahongxi,項目名稱:whatsmars,代碼行數:12,代碼來源:GridFSClient.java

示例9: findShardSets

import com.mongodb.DBCursor; //導入方法依賴的package包/類
public Map<String, List<MongoClientWrapper>> findShardSets(MongoClient mongoS) {
   // TODO figure out how to do this with the new driver syntax. Does not
   // appear to support sisterDB
   DBCursor find = mongoS.getDB("admin").getSisterDB("config").getCollection("shards").find();
   Map<String, List<MongoClientWrapper>> shardSets = new HashMap<>();
   while (find.hasNext()) {
      DBObject next = find.next();
      String key = (String) next.get("_id");
      shardSets.put(key, getMongoClient(buildServerAddressList(next)));
   }
   find.close();
   return shardSets;
}
 
開發者ID:JaiHirsch,項目名稱:flink-mingo-tail,代碼行數:14,代碼來源:ShardSetFinder.java

示例10: MongoUniqueDocument

import com.mongodb.DBCursor; //導入方法依賴的package包/類
/**
 * New constructor with provided Unique ID.
 *
 * @param collection The MongoCollection storing the MongoDocument.
 * @param uniqueId   The Unique ID being assigned.
 */
public MongoUniqueDocument(MongoCollection collection, UUID uniqueId) {
    super(collection, "id");
    DBObject query = new BasicDBObject("id", uniqueId.toString());
    DBCursor cursor = collection.find(query);
    if (cursor.hasNext()) {
        cursor.close();
        throw new IllegalArgumentException(
                "New Object in collection contains ID that is already in use: \"" + uniqueId.toString() + "\".");
    }
    cursor.close();
    setUniqueId(uniqueId, false);
}
 
開發者ID:JabJabJab,項目名稱:Sledgehammer,代碼行數:19,代碼來源:MongoUniqueDocument.java

示例11: loadMongoChatChannels

import com.mongodb.DBCursor; //導入方法依賴的package包/類
private void loadMongoChatChannels() {
    DBCursor cursor = collectionChannels.find();
    while (cursor.hasNext()) {
        MongoChatChannel mongoChatChannel = new MongoChatChannel(collectionChannels, cursor.next());
        ChatChannel chatChannel = new ChatChannel(mongoChatChannel);
        mapChatChannels.put(chatChannel.getUniqueId(), chatChannel);
        listOrderedChatChannels.add(chatChannel);
    }
    cursor.close();
}
 
開發者ID:JabJabJab,項目名稱:Sledgehammer,代碼行數:11,代碼來源:ModuleChat.java

示例12: MongoPlayer

import com.mongodb.DBCursor; //導入方法依賴的package包/類
public MongoPlayer(MongoCollection collection, UUID uuid) {
    super(collection, uuid);
    reset();
    DBCursor cursor = collection.getDBCollection().find(new BasicDBObject(getFieldId(), getFieldValue()));
    if (cursor.hasNext()) {
        onLoad(cursor.next());
    }
    cursor.close();
}
 
開發者ID:JabJabJab,項目名稱:Sledgehammer,代碼行數:10,代碼來源:MongoPlayer.java

示例13: playerExists

import com.mongodb.DBCursor; //導入方法依賴的package包/類
/**
 * Checks to see if a Player exists.
 *
 * @param username The username of the player.
 * @return Returns true if the Player exists.
 */
public boolean playerExists(String username) {
    if (username == null || username.isEmpty()) {
        throw new IllegalArgumentException("SledgehammerDatabase: Username given is null or empty!");
    }
    boolean returned;
    returned = mapPlayersByUsername.containsKey(username);
    if (!returned) {
        DBCursor cursor = collectionPlayers.find(new BasicDBObject("username", username));
        returned = cursor.hasNext();
        cursor.close();
    }
    return returned;
}
 
開發者ID:JabJabJab,項目名稱:Sledgehammer,代碼行數:20,代碼來源:SledgehammerDatabase.java

示例14: getBan

import com.mongodb.DBCursor; //導入方法依賴的package包/類
public MongoBan getBan(String id) {
    if (id == null || id.isEmpty()) {
        throw new IllegalArgumentException("SledgehammerDatabase: Ban ID is null or empty!");
    }
    MongoBan returned = null;
    DBCursor cursor = collectionBans.find(new BasicDBObject("id", id));
    if (cursor.hasNext()) {
        returned = new MongoBan(collectionBans);
        returned.onLoad(cursor.next());
    }
    cursor.close();
    return returned;
}
 
開發者ID:JabJabJab,項目名稱:Sledgehammer,代碼行數:14,代碼來源:SledgehammerDatabase.java

示例15: getNumberOfAccounts

import com.mongodb.DBCursor; //導入方法依賴的package包/類
/**
 * @param steamID The Steam ID being used to search for accounts.
 * @return The number of accounts registered under the given Steam ID.
 */
public int getNumberOfAccounts(long steamID) {
    if (steamID == -1L) {
        throw new IllegalArgumentException("SledgehammerDatabase: Steam ID is invalid: " + steamID);
    }
    DBCursor cursor = collectionPlayers.find(new BasicDBObject("steamID", "" + steamID));
    int size = cursor.size();
    cursor.close();
    return size;
}
 
開發者ID:JabJabJab,項目名稱:Sledgehammer,代碼行數:14,代碼來源:SledgehammerDatabase.java


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