亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? engageragent.java

?? JADE(JAVA Agent開發框架)是一個完全由JAVA語言開發的軟件,它簡化了多Agent系統的實現。
?? JAVA
字號:
/*****************************************************************
JADE - Java Agent DEvelopment Framework is a framework to develop
multi-agent systems in compliance with the FIPA specifications.
Copyright (C) 2000 CSELT S.p.A. 

GNU Lesser General Public License

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation, 
version 2.1 of the License. 

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA  02111-1307, USA.
*****************************************************************/

package examples.ontology;

import jade.proto.SimpleAchieveREResponder;

import jade.core.*;
import jade.core.behaviours.*;

import jade.domain.*;

import jade.content.lang.Codec;
import jade.content.*;
import jade.content.abs.*;
import jade.content.onto.*;
import jade.content.onto.basic.*;
import jade.content.lang.sl.*;

import jade.lang.acl.ACLMessage;
import jade.lang.acl.MessageTemplate;

import examples.ontology.employment.*;

import jade.content.onto.basic.*;
import jade.util.leap.*;

/**
	This agent is able to engage people on behalf of company 
	CSELT
	Via Reiss Romoli 274 - Turin
	
	@author Giovanni Caire - CSELT S.p.A
	@version $Date: 2003-02-25 17:01:19 +0100 (mar, 25 feb 2003) $ $Revision: 3689 $
	@see examples.ontology.RequesterAgent
*/
public class EngagerAgent extends Agent {
	
	// AGENT BEHAVIOURS
	/**
		This behaviour handles all queries about people working for a company
		following the FIPA-Query protocol
	*/
	class HandleEnganementQueriesBehaviour extends SimpleAchieveREResponder {
		/**
			Constructor for the <code>HandleEnganementQueriesBehaviour</code>
			class.
			
			@param myAgent The agent owning this behaviour
		*/
		public HandleEnganementQueriesBehaviour(Agent myAgent){
			super(myAgent, MessageTemplate.and(
												MessageTemplate.MatchProtocol(FIPANames.InteractionProtocol.FIPA_QUERY),
												MessageTemplate.MatchOntology(EmploymentOntology.NAME)));
		}
		
		/**
			This method is called when a QUERY-IF or QUERY-REF message is received.
			
			@param msg The received query message
			@return The ACL message to be sent back as reply
			@see jade.proto.FipaQueryResponderBehaviour
		*/
		public ACLMessage prepareResponse(ACLMessage msg){
			
			ACLMessage reply = msg.createReply();
			
			// The QUERY message could be a QUERY-REF. In this case reply 
			// with NOT_UNDERSTOOD
			
			if (msg.getPerformative() != ACLMessage.QUERY_IF){
				reply.setPerformative(ACLMessage.NOT_UNDERSTOOD);
  				String content = "(" + msg.toString() + ")"; 
				reply.setContent(content);
				return(reply);
			}
			
			try {
				// Get the predicate for which the truth is queried	
				Predicate pred = (Predicate)myAgent.getContentManager().extractContent(msg);
				if (!(pred instanceof WorksFor)) {
				// If the predicate for which the truth is queried is not WORKS_FOR
				// reply with NOT_UNDERSTOOD
					reply.setPerformative(ACLMessage.NOT_UNDERSTOOD);
  					String content = "(" + msg.toString() + ")"; 
					reply.setContent(content);
					return(reply);
				}
			
				// Reply 
				reply.setPerformative(ACLMessage.INFORM);
				WorksFor wf = (WorksFor)pred;
				Person p = wf.getPerson();
				Company c = wf.getCompany();
				if (((EngagerAgent) myAgent).isWorking(p, c)) 
					reply.setContent(msg.getContent());
				 else {
					// Create an object representing the fact that the WORKS_FOR 
					// predicate is NOT true.
					Ontology o = getContentManager().lookupOntology(EmploymentOntology.NAME);
					AbsPredicate not = new AbsPredicate(SLVocabulary.NOT);
  					not.set(SLVocabulary.NOT_WHAT, o.fromObject(wf));
		    		myAgent.getContentManager().fillContent(reply, not);
				}
			}
			catch (Codec.CodecException fe) {
				System.err.println(myAgent.getLocalName()+" Fill/extract content unsucceeded. Reason:" + fe.getMessage());
			}
			catch (OntologyException oe){
				System.err.println(myAgent.getLocalName()+" getRoleName() unsucceeded. Reason:" + oe.getMessage());
			}
			
			return (reply);
			
		} // END of handleQueryMessage() method
		
	} // END of HandleEnganementQueriesBehaviour
				
			
	/**
		This behaviour handles a single engagement action that has been  
		requested following the FIPA-Request protocol
	*/
	class HandleEngageBehaviour extends SimpleAchieveREResponder {
  		
  	/**
  		Constructor for the <code>HandleEngageBehaviour</code> class.
  		
  		@param myAgent The agent owning this behaviour
  		@param requestMsg The ACL message by means of which the engagement
  		action has been requested
  	*/
  	public HandleEngageBehaviour(Agent myAgent){
			super(myAgent, MessageTemplate.MatchProtocol(FIPANames.InteractionProtocol.FIPA_REQUEST));
  	}
  	
  	/**
	  	This method implements the <code>FipaRequestResponderBehaviour.Factory</code>
  		interface.
  		It will be called within a <code>FipaRequestResponderBehaviour</code> 
  		when an engagement action is requested to instantiate a new 
  		<code>HandleEngageBehaviour</code> handling the requested action
   
  		@param msg The ACL message by means of which the engagement
  		action has been requested
  	*/
    /**
    	This method actually handles the engagement action
     */
     
    public ACLMessage prepareResultNotification(ACLMessage request, ACLMessage response) {
    		// Prepare a dummy ACLMessage used to create the content of all reply messages
   			ACLMessage msg = request.createReply();

			try{
				// Get the requested action
				Action a = (Action)myAgent.getContentManager().extractContent(request);
				Engage e = (Engage) a.getAction();
				Person p = e.getPerson();
				Company c = e.getCompany();
				
				// Check person's age. If < 35 --> AGREE, else REFUSE and exit
				// Perform the engagement action
				int result = ((EngagerAgent) myAgent).doEngage(p, c);
				
				// Reply according to the result
				if (result > 0){
					// OK --> INFORM action done
					Done d = new Done();
					d.setAction(a);
					myAgent.getContentManager().fillContent(msg, d);
					msg.setPerformative(ACLMessage.INFORM);
				}
				else{
					// NOT OK --> FAILURE
					ContentElementList l = new ContentElementList();
					l.add(a);
					l.add(new EngagementError());
					myAgent.getContentManager().fillContent(msg, l);
					msg.setPerformative(ACLMessage.FAILURE);
				}
				
			}
			catch (Exception fe){
				System.out.println(myAgent.getName() + ": Error handling the engagement action.");
				System.out.println(fe.getMessage().toString());
			}
			
			// System.out.println(msg);
			return msg;
		}
		
	     
	public ACLMessage prepareResponse(ACLMessage request) {
			// Prepare a dummy ACLMessage used to create the content of all reply messages
			ACLMessage temp = request.createReply();
						
			try{
				// Get the requested action. 
				Action a = (Action)getContentManager().extractContent(request);
				Engage e = (Engage) a.getAction();
				Person p = e.getPerson();
				Company c = e.getCompany();
			
				// Check person's age. If < 35 --> AGREE, else REFUSE and exit
				if (p.getAge().intValue() < 35){
					// AGREE to accomplish the engagement action without any 
					// special condition.
					ContentElementList l = new ContentElementList();
					l.add(a);
					l.add(new TrueProposition());
					getContentManager().fillContent(temp, l);
					temp.setPerformative(ACLMessage.AGREE);
				}
				else {
					ContentElementList l = new ContentElementList();
					l.add(a);
					l.add(new PersonTooOld());
					getContentManager().fillContent(temp, l);
					temp.setPerformative(ACLMessage.REFUSE);
				}

			} catch (Exception fe){
				fe.printStackTrace();
				System.out.println(getName() + ": Error handling the engagement action.");
				System.out.println(fe.getMessage().toString());
			}
			
			return temp;
		}
	}	
	
	// AGENT LOCAL VARIABLES
	private Company representedCompany; // The company on behalf of which this agent is able to engage people 
	private List employees;	// The people currently working for the company
	
	// AGENT CONSTRUCTOR
	public EngagerAgent(){
		super();
		
		representedCompany = new Company();
		representedCompany.setName("CSELT");
		Address a = new Address();
		a.setStreet("\"Via Reiss Romoli\"");
		a.setNumber(new Long(274));
		a.setCity("Turin");
		representedCompany.setAddress(a);
		
		employees = new ArrayList();
	}
	
	// AGENT SETUP
	protected void setup() {
		System.out.println("This is the EngagerAgent representing the company "+representedCompany.getName());
		
		// Register the codec for the SL0 language
		getContentManager().registerLanguage(new SLCodec(), FIPANames.ContentLanguage.FIPA_SL0);	
		
		// Register the ontology used by this application
		getContentManager().registerOntology(EmploymentOntology.getInstance());
			
		// Create and add the behaviour for handling QUERIES using the employment-ontology
  		addBehaviour(new HandleEnganementQueriesBehaviour(this));
  	
		// Create and add the behaviour for handling REQUESTS using the employment-ontology
		MessageTemplate mt = MessageTemplate.and(
											MessageTemplate.MatchProtocol(FIPANames.InteractionProtocol.FIPA_REQUEST),
											MessageTemplate.MatchOntology(EmploymentOntology.NAME));
  	HandleEnganementQueriesBehaviour b = new HandleEnganementQueriesBehaviour(this);
  	HandleEngageBehaviour c = new HandleEngageBehaviour(this);
  	addBehaviour(b);
  	addBehaviour(c);
	}
	
	// AGENT METHODS
	boolean isWorking(Person p, Company c){
		boolean isAnEmployee = false;	
		Iterator i = employees.iterator();
		while (i.hasNext()){
			Person empl = (Person) i.next();
			if (p.equals(empl))
				isAnEmployee = true;
		}
		
		if (c.equals(representedCompany))
			return isAnEmployee;
		else
			return !isAnEmployee;
	}
	
	int doEngage(Person p, Company c){
		if (!c.equals(representedCompany))
			return (-1); // Can engage people on behalf of representedCompany only
		else
			employees.add(p);
		return (1);
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品人人做人人爽人人| 国产精品色一区二区三区| 午夜国产精品一区| 91精品久久久久久久99蜜桃| 日韩中文字幕区一区有砖一区| 欧美日韩的一区二区| 韩国v欧美v亚洲v日本v| 国产人伦精品一区二区| 欧洲一区二区三区在线| 日本视频在线一区| 国产精品国产三级国产普通话蜜臀 | 国产一区二区三区久久悠悠色av| 国产精品久久久久桃色tv| 欧美日韩不卡在线| 成人性视频免费网站| 男男gaygay亚洲| 一区二区三区资源| 国产精品免费人成网站| 欧美日韩高清一区| 欧美在线观看你懂的| 国产xxx精品视频大全| 日韩 欧美一区二区三区| 国产精品久久久久一区| 国产午夜精品一区二区三区视频| 91久久精品一区二区二区| 成人激情av网| 国产成人在线电影| 国产美女精品人人做人人爽| 蜜桃av一区二区三区电影| 亚洲国产综合91精品麻豆| 亚洲黄色录像片| 亚洲综合色噜噜狠狠| 亚洲综合色区另类av| 午夜不卡在线视频| 日韩高清国产一区在线| 精品在线免费观看| 国产一区二区精品久久99| 激情成人综合网| 国产一区二区三区四区五区入口| 国产一区二区三区免费| 丁香天五香天堂综合| 91猫先生在线| 日韩丝袜情趣美女图片| 国产拍揄自揄精品视频麻豆| 18欧美乱大交hd1984| 亚洲成年人影院| 国产麻豆精品视频| 99久久国产综合精品色伊| 精品一区二区成人精品| 99在线视频精品| 久久精品人人做人人综合 | 久久婷婷国产综合精品青草| 色拍拍在线精品视频8848| 亚洲大片在线观看| 久久精品999| 国产v综合v亚洲欧| 日韩国产精品久久久久久亚洲| 中文在线免费一区三区高中清不卡| 在线电影欧美成精品| 欧美日韩在线一区二区| www.亚洲色图.com| 国产区在线观看成人精品| 亚洲.国产.中文慕字在线| 亚洲日本va在线观看| 精品免费视频.| 亚洲精品一区二区三区在线观看 | 三级一区在线视频先锋| 久久久久久久一区| 久久精品人人爽人人爽| 国产欧美1区2区3区| 激情图片小说一区| 欧美日本一区二区| 久久久www成人免费毛片麻豆| 亚洲精品亚洲人成人网在线播放| 麻豆精品视频在线观看| 91麻豆精品国产91久久久| 一区二区不卡在线播放 | 亚洲一本大道在线| 欧美日韩精品二区第二页| 亚洲最色的网站| 欧美色综合网站| 亚洲444eee在线观看| 精品日韩欧美在线| 精品日韩成人av| 日韩片之四级片| 欧美性一二三区| 亚洲欧美中日韩| 91丝袜高跟美女视频| ...xxx性欧美| 欧美日韩成人综合天天影院| 日本三级亚洲精品| 国产欧美日韩在线视频| 国产精品免费aⅴ片在线观看| 26uuu久久综合| 久久机这里只有精品| 91精品国产色综合久久不卡蜜臀 | 成人福利在线看| 国产精品乱码人人做人人爱| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 国产成人一区在线| 亚洲午夜国产一区99re久久| 欧美一区二区精品在线| a级精品国产片在线观看| 亚洲.国产.中文慕字在线| 国产女同互慰高潮91漫画| 欧美精品1区2区3区| av在线播放成人| 久久99日本精品| 亚洲一线二线三线久久久| 国产精品护士白丝一区av| 日韩一级成人av| 日韩欧美在线影院| 91福利视频久久久久| 色综合天天综合网天天看片| 欧美亚洲一区二区在线观看| 不卡在线观看av| 97国产精品videossex| 91一区在线观看| 成人激情视频网站| 成a人片亚洲日本久久| 99久久精品国产毛片| 99久久精品国产麻豆演员表| 色综合久久久久综合| 欧美一a一片一级一片| 欧美三级视频在线播放| 欧美日韩国产一级| 国产精品国产三级国产普通话蜜臀 | 国产欧美一区二区三区网站| 亚洲精品美腿丝袜| 成人看片黄a免费看在线| 精品捆绑美女sm三区| 亚洲一二三四在线观看| 成人免费av网站| 国产成人精品网址| 色999日韩国产欧美一区二区| 欧美亚洲综合色| 国产精品二三区| 麻豆精品视频在线观看视频| 不卡一区在线观看| 欧美一卡二卡在线观看| 自拍偷拍亚洲综合| 免费在线观看成人| 欧日韩精品视频| 国产三级精品三级| 日韩av一区二区三区四区| 粉嫩av一区二区三区在线播放| 欧美精选一区二区| 亚洲永久精品大片| 色悠悠亚洲一区二区| 国产精品久久久久久久久免费丝袜 | 一区二区不卡在线视频 午夜欧美不卡在| 国产麻豆精品theporn| 91精品国产免费| 日本不卡中文字幕| 欧美精选午夜久久久乱码6080| 亚洲精品高清在线| 成人在线视频一区| 国产精品国产三级国产有无不卡| 国产精品亚洲视频| 国产亚洲精品7777| 国产福利电影一区二区三区| 国产日产精品1区| 99麻豆久久久国产精品免费| 欧美高清在线一区| 色婷婷久久久亚洲一区二区三区| 最新日韩在线视频| 欧美日韩高清影院| 国产一区美女在线| 亚洲免费av观看| 欧美年轻男男videosbes| 极品销魂美女一区二区三区| 国产亚洲污的网站| 色婷婷久久久久swag精品| 日韩精品国产精品| 国产精品灌醉下药二区| 欧美亚洲国产一区二区三区| 男人的j进女人的j一区| 久久久久久黄色| 欧美性受极品xxxx喷水| 久久国产三级精品| 亚洲欧美日韩中文字幕一区二区三区| 在线一区二区观看| 国产又粗又猛又爽又黄91精品| 一区二区三区中文字幕精品精品| 日韩欧美亚洲另类制服综合在线| eeuss国产一区二区三区| 人人狠狠综合久久亚洲| 亚洲精品国产成人久久av盗摄| 91精品国产福利| 91成人网在线| 在线观看91视频| 91福利区一区二区三区| 成人av影视在线观看| 九九在线精品视频| 免费在线一区观看| 蜜桃精品视频在线观看| 免费成人av在线播放| 日本女人一区二区三区| 免费精品视频在线| 美女爽到高潮91|