⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ontoaid.java

📁 java实现的P2P多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 jade.content;

import jade.core.AID;
import jade.util.leap.Iterator;

/**
 * Utility class that allow using an <code>AID</code> object
 * as an ontological concept.
 * @author Giovanni Caire - TILAB
 */
public class OntoAID extends AID implements Concept {

  /**
   * Constructs an ontological Agent-Identifier whose slot name is 
   * set to an empty string
   * @see AID#AID()
   */
	public OntoAID() {
		super();
	}
	
  /** 
   * Constructor for an ontological Agent-identifier
   * @param name is the value for the slot name for the agent. 
   * @param isGUID indicates if the passed <code>name</code>
   * is already a globally unique identifier or not. Two
   * constants <code>ISGUID</code>, <code>ISLOCALNAME</code>
   * have also been defined for setting a value for this parameter.
   * If the name is a local name, then the HAP (Home Agent Platform)
   * is concatenated to the name, separated by  "@".
   * @see AID#AID(String, boolean)
   */
	public OntoAID(String name, boolean isGUID) {
		super(name, isGUID);
	}
	
	/** 
	 * Create an ontological Agent identifier that wraps an existing 
	 * <code>AID</code>.
	 * @param id the <code>AID</code>to be wrapped. If <code>id</code>
	 * is already an ontological agent identifier no new object is 
	 * created and <code>id</code> is returned with the resolvers 
	 * (if any) properly wrapped.
	 */
	public static OntoAID wrap(AID id) {
		OntoAID wrapper = null;
		if (id != null) {
			if (id instanceof OntoAID) {
				wrapper = (OntoAID) id;
			}
			else {
				wrapper = new OntoAID(id.getName(), ISGUID);
				Iterator it = id.getAllAddresses();
				while (it.hasNext()) {
					wrapper.addAddresses((String) it.next());
				}
				it = id.getAllResolvers();
				while (it.hasNext()) {
					// This automatically performs the wrapping
					wrapper.addResolvers((AID) it.next()); 
				}
			}
		}
		return wrapper; 
	}
	
	/**
	 * This method is redefined so that resolvers AID are automatically
	 * wrapped into OntoAIDs
	 */
	public void addResolvers(AID aid) {
		super.addResolvers(wrap(aid));
	}
	
	// FIXME: clone method should be redefined too	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -