CPD Results

The following document contains the results of PMD's CPD 4.2.5.

Duplications

FileProjectLine
org/jage/examples/properties/PropertiesSimpleAgent.javajAgE examples solutions95
org/jage/examples/properties/xml/PropertiesSimpleAgent.javajAgE examples solutions101
		        new Object[] { getAddress(), functionCounter.toString(), functionCounter.countSquareSum() });
		if ((counter + this.hashCode()) % 3 == 0) {
			watch();
		}

		try {
			Thread.sleep(200);
		} catch (InterruptedException e) {
			log.error("Interrupted", e);
		}
	}

	private void watch() {
		Collection<SimpleAgent> answer;
		try {
			AgentEnvironmentQuery<SimpleAgent, SimpleAgent> query = new AgentEnvironmentQuery<SimpleAgent, SimpleAgent>();

			answer = queryEnvironment(query);
			log.info("Agent: {} can see in its environment: {} following agents:", getAddress(), getParentAddress());
			for (SimpleAgent entry : answer) {
				IAgentAddress agentAddress = (IAgentAddress)entry.getProperty("address").getValue();
				if (agentAddress != getAddress()) {
					log.info("    agent: {} with properties:", agentAddress);

					for (Property property : entry.getProperties()) {
						log.info("        {}: {}", property.getMetaProperty().getName(), property.getValue());
					}
				}
			}
		} catch (AgentException e) {
			log.error("Agent exception", e);
		} catch (InvalidPropertyPathException e) {
			log.error("Invalid property", e);
		}

	}

	@Override
	public boolean finish() {
		log.info("Finishing {}", getAddress());
		return true;
	}
FileProjectLine
org/jage/examples/migration/CrawlingSimpleAgent.javajAgE examples solutions88
org/jage/examples/multiworkplace/MultiworkplaceSimpleAgent.javajAgE examples solutions90
		counter++;
		if ((counter + this.hashCode()) % 50 == 0) {
			considerMigration();
		}

		try {
			Thread.sleep(10);
		} catch (InterruptedException e) {
			log.error("Interrupted", e);
		}
	}

	/**
	 * Considers migration and migrates eventually
	 */
	private void considerMigration() {
		Collection<IAgent> answer;
		IAgentAddress target = null;
		try {
			log.info("Queyring parent...");
			AgentEnvironmentQuery<IAgent, IAgent> query = new AgentEnvironmentQuery<IAgent, IAgent>();

			answer = queryParentEnvironment(query);
			if (answer.size() > 1) {
				log.info("Agent: {} can migrate from {} to following environments:", getAddress(), getParentAddress());
				float max = 0;
				for (IAgent entry : answer) {
					IAgentAddress possibleTargetAddress = entry.getAddress();