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


Java DBCursor.hasNext方法代碼示例

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


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

示例1: findAll

import com.mongodb.DBCursor; //導入方法依賴的package包/類
public List<AgentConfigurationDatabase> findAll(){
    ArrayList<AgentConfigurationDatabase> agents = null;
    logger.info("Getting all agent cfgs from database...");
       DBCursor cur = getAgentConfigurationTable().find();
       while (cur.hasNext()) {
       	if (agents == null) {
       		agents = new ArrayList<AgentConfigurationDatabase>();
       	}
       	agents.add(this.toAgentCfgDbObject(cur.next()));    	
       }
       if (agents != null){
       	logger.info("Retrieved " + agents.size() + " agent configurations from database");
       }
       else {
       	logger.info("Retrieved " + 0 + " agent configurations from database");
       }
    return agents;
}
 
開發者ID:elastest,項目名稱:elastest-instrumentation-manager,代碼行數:19,代碼來源:AgentConfigurationRepository.java

示例2: getAgentByAgentId

import com.mongodb.DBCursor; //導入方法依賴的package包/類
public AgentFull getAgentByAgentId(String agentId){
    System.out.println("Searching host in DB with agentId = " + agentId);
    logger.info("Searching host in DB with agentId = " + agentId);
    AgentFull agent = null;
    BasicDBObject query = new BasicDBObject();
       query.put("agentId", agentId);

       DBCursor cursor = getAgentTable().find(query);
       if (cursor.hasNext()){
       	agent = new AgentFull();
       	agent.setAgentId((String) cursor.next().get("agentId"));
       	agent.setHost((String) cursor.curr().get("host"));
       	agent.setMonitored((boolean) cursor.curr().get("monitored"));
       	agent.setLogstashIp((String) cursor.curr().get("logstashIp"));
       	agent.setLogstashPort((String) cursor.curr().get("logstashPort"));
       	logger.info("Host finded in DB with agentId = " + agentId + " with ipAddress " + agent.getHost());
       	System.out.println("Host finded in DB with agentId = " + agentId + " with ipAddress " + agent.getHost());
       }
       else {
       	logger.info("Host doesn't exists in DB with agentId = " + agentId);
       	System.out.println("Host doesn't exists in DB with agentId = " + agentId);
       	return null;
       }		
    return agent;
}
 
開發者ID:elastest,項目名稱:elastest-instrumentation-manager,代碼行數:26,代碼來源:AgentRepository.java

示例3: afterCreate

import com.mongodb.DBCursor; //導入方法依賴的package包/類
/** Read the occasions that are stored in the database and schedule them to run. */
@PostConstruct
public void afterCreate() {
  String method = "afterCreate";
  logger.entering(clazz, method);

  orchestrator.setOccasionResource(this);

  DBCollection occasions = getCollection();
  DBCursor cursor = occasions.find();
  while (cursor.hasNext()) {
    DBObject dbOccasion = cursor.next();
    Occasion occasion = new Occasion(dbOccasion);
    try {
      // TODO: There was a comment here about how we should mark the event as
      //       popped in the database, which will have different meaning for
      //       one-time or interval occasions.  Need to re-visit this.
      orchestrator.scheduleOccasion(occasion);
    } catch (Throwable t) {
      logger.log(Level.WARNING, "Could not schedule occasion at startup", t);
    }
  }

  logger.exiting(clazz, method);
}
 
開發者ID:OpenLiberty,項目名稱:sample-acmegifts,代碼行數:26,代碼來源:OccasionResource.java

示例4: existConfiguration

import com.mongodb.DBCursor; //導入方法依賴的package包/類
public boolean existConfiguration(String agentId){		
    logger.info("Verifying if agent with agentId = " + agentId + " has a configuration stored in DB");
    System.out.println("Verifying if agent with agentId = " + agentId + " has a configuration stored in DB");
       BasicDBObject query = new BasicDBObject();
       query.put("agentId", agentId);

       DBCursor cursor = getAgentConfigurationTable().find(query);
       if (cursor.hasNext()){
       	logger.info("Configuration for agent with agentId = " + agentId + " exists");
       	System.out.println("Configuration for agent with agentId = " + agentId + " exists");
       	return true;
       }
       else {
       	logger.info("Not exists any configuration for an agent with agentId = " + agentId);
       	System.out.println("Not exists any configuration for an agent with agentId = " + agentId);
       	return false;
       }        
}
 
開發者ID:elastest,項目名稱:elastest-instrumentation-manager,代碼行數:19,代碼來源:AgentConfigurationRepository.java

示例5: getAgentConfigurationByAgentId

import com.mongodb.DBCursor; //導入方法依賴的package包/類
public AgentConfigurationDatabase getAgentConfigurationByAgentId(String agentId){
    System.out.println("Searching agent cfg in DB with agentId = " + agentId);
    logger.info("Searching host in DB with agentId = " + agentId);
    BasicDBObject query = new BasicDBObject();
       query.put("agentId", agentId);

       DBCursor cursor = getAgentConfigurationTable().find(query);
       if (cursor.hasNext()){
       	logger.info("Agent cfg exists in DB with agentId = " + agentId);
       	return this.toAgentCfgDbObject(cursor.next());
       }
       else {
       	logger.info("Agent cfg doesn't exists in DB with agentId = " + agentId);
       	System.out.println("Agent cfg doesn't exists in DB with agentId = " + agentId);
       	return null;
       }		
}
 
開發者ID:elastest,項目名稱:elastest-instrumentation-manager,代碼行數:18,代碼來源:AgentConfigurationRepository.java

示例6: existHost

import com.mongodb.DBCursor; //導入方法依賴的package包/類
public boolean existHost(String ipAddress){		
    logger.info("Verifying if host with ipAddress = " + ipAddress + " exists");
    System.out.println("Verifying if host with ipAddress = " + ipAddress + " exists");
       BasicDBObject query = new BasicDBObject();
       query.put("host", ipAddress);

       DBCursor cursor = getAgentTable().find(query);
       if (cursor.hasNext()){
       	logger.info("Host with ipAddress = " + ipAddress + " exists");
       	System.out.println("Host with ipAddress = " + ipAddress + " exists");
       	return true;
       }
       else {
       	logger.info("Not exists any host with ipAddress = " + ipAddress);
       	System.out.println("Not exists any host with ipAddress = " + ipAddress);
       	return false;
       }        
}
 
開發者ID:elastest,項目名稱:elastest-instrumentation-manager,代碼行數:19,代碼來源:AgentRepository.java

示例7: findAll

import com.mongodb.DBCursor; //導入方法依賴的package包/類
public List<AgentFull> findAll(){
    ArrayList<AgentFull> agents = null;
    logger.info("Getting all agents from database...");
       DBCursor cur = getAgentTable().find();
       AgentFull agent = null;
       while (cur.hasNext()) {
       	if (agents == null) {
       		agents = new ArrayList<AgentFull>();
       	}
       	agent = new AgentFull();
       	agent.setAgentId((String) cur.next().get("agentId"));
       	agent.setHost((String) cur.curr().get("host") );
       	agent.setMonitored((boolean) cur.curr().get("monitored"));
       	agents.add(agent);    	
       }
       if (agents != null){
       	logger.info("Retrieved " + agents.size() + " agents from database");
       }
       else {
       	logger.info("Retrieved " + 0 + " agents from database");
       }
    return agents;
}
 
開發者ID:elastest,項目名稱:elastest-instrumentation-manager,代碼行數:24,代碼來源:AgentRepository.java

示例8: findByFirstnameUsingMetaAttributes

import com.mongodb.DBCursor; //導入方法依賴的package包/類
/**
 * This test demonstrates usage of {@code $comment} {@link Meta} usage. One can also enable profiling using
 * {@code --profile=2} when starting {@literal mongod}.
 * <p>
 * <strong>NOTE</strong>: Requires MongoDB v. 2.6.4+
 */
@Test
public void findByFirstnameUsingMetaAttributes() {

    // execute derived finder method just to get the comment in the profile log
    repository.findByFirstname(dave.getFirstname());

    // execute another finder without meta attributes that should not be picked up
    repository.findByLastname(dave.getLastname(), new Sort("firstname"));

    DBCursor cursor = operations.getCollection(ApplicationConfiguration.SYSTEM_PROFILE_DB)
            .find(new BasicDBObject("query.$comment", AdvancedRepository.META_COMMENT));

    while (cursor.hasNext()) {

        DBObject dbo = cursor.next();
        DBObject query = (DBObject) dbo.get("query");

        assertThat(query.containsField("$comment"), is(true));
    }
}
 
開發者ID:Just-Fun,項目名稱:spring-data-examples,代碼行數:27,代碼來源:AdvancedIntegrationTests.java

示例9: remove

import com.mongodb.DBCursor; //導入方法依賴的package包/類
@Override
public int remove(CacheEntryFilter filter) {
    DBCursor cur = qAll();
    int counter = 0;

    while (cur.hasNext()) {
        BasicDBObject obj = (BasicDBObject) cur.next();
        MongoDBCacheEntry entry = new MongoDBCacheEntry(new MongoDBCacheDocument(obj));
        if (filter.accept(entry)) {
            doDelete(obj);
            counter++;
        }
    }

    return counter;
}
 
開發者ID:lucee,項目名稱:extension-mongodb,代碼行數:17,代碼來源:MongoDBCache.java

示例10: values

import com.mongodb.DBCursor; //導入方法依賴的package包/類
@Override
public List<Object> values(CacheKeyFilter filter) {
    DBCursor cur = qAll_Keys_Values();
    List<Object> result = new ArrayList<Object>();

    while (cur.hasNext()) {
        BasicDBObject obj = (BasicDBObject) cur.next();
        MongoDBCacheDocument doc = new MongoDBCacheDocument(obj);

        if (filter.accept(doc.getKey())) {
            try {
                result.add(MongoDBCacheDocument.getValue(obj));
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

    }

    return result;
}
 
開發者ID:lucee,項目名稱:extension-mongodb,代碼行數:22,代碼來源:MongoDBCache.java

示例11: getPlayerID

import com.mongodb.DBCursor; //導入方法依賴的package包/類
public UUID getPlayerID(String username) {
    if (username == null || username.isEmpty()) {
        throw new IllegalArgumentException("SledgehammerDatabase: Username is null or empty!");
    }
    MongoPlayer player = getMongoPlayer(username);
    if (player != null) {
        return player.getUniqueId();
    }
    UUID returned = null;
    DBCursor cursor = collectionPlayers.find(new BasicDBObject("username", username));
    if (cursor.hasNext()) {
        DBObject object = cursor.next();
        returned = UUID.fromString(object.get("uuid").toString());
    }
    cursor.close();
    return returned;
}
 
開發者ID:JabJabJab,項目名稱:Sledgehammer,代碼行數:18,代碼來源:SledgehammerDatabase.java

示例12: 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

示例13: 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

示例14: loadMongoFactions

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

示例15: connection

import com.mongodb.DBCursor; //導入方法依賴的package包/類
public static void connection() {
    try {

        DB db = (new MongoClient("localhost", 27017)).getDB("Questions");

        DBCollection coll = db.getCollection("Questions");

        BasicDBObject query = new BasicDBObject();
        query.put("id", 1001);
        DBCursor cursor = coll.find(query);
        while (cursor.hasNext()) {
            System.out.println(cursor.next());
        }
    } catch (MongoException e) {
        e.printStackTrace();
    }
}
 
開發者ID:Arquisoft,項目名稱:Trivial_i1a,代碼行數:18,代碼來源:Connection.java


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