本文整理汇总了Java中eis.exceptions.EntityException类的典型用法代码示例。如果您正苦于以下问题:Java EntityException类的具体用法?Java EntityException怎么用?Java EntityException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityException类属于eis.exceptions包,在下文中一共展示了EntityException类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addEntity
点赞 3
import eis.exceptions.EntityException; //导入依赖的package包/类
/**
* Adds an entity to the environment.
*
* @param entity is the identifier of the entity that is to be added.
* @param type is the type of the entity.
* @throws PlatformException is thrown if the entity already exists.
*/
protected void addEntity(String entity,String type) throws EntityException {
// fail if entity does exist
if( entities.contains(entity) )
throw new EntityException("Entity \"" + entity + "\" does already exist");
// add
entities.add(entity);
// set type
this.setType(entity, type);
// notify
notifyNewEntity(entity);
}
开发者ID:jason-lang,
项目名称:apps,
代码行数:24,
代码来源:EIDefaultImpl.java
示例2: EISHouseEnv
点赞 2
import eis.exceptions.EntityException; //导入依赖的package包/类
public EISHouseEnv() {
jasonEnv = new HouseEnv(); // create the instance of Jason Environment
try {
addEntity("robot");
addEntity("owner");
addEntity("supermarket");
} catch (EntityException e) {
e.printStackTrace();
}
}
开发者ID:jason-lang,
项目名称:apps,
代码行数:11,
代码来源:EISHouseEnv.java
示例3: addEntity
点赞 2
import eis.exceptions.EntityException; //导入依赖的package包/类
/**
* Adds an entity to the environment.
*
* @param entity is the identifier of the entity that is to be added.
* @throws PlatformException is thrown if the entity already exists.
*/
protected void addEntity(String entity) throws EntityException {
// fail if entity does exist
if( entities.contains(entity) )
throw new EntityException("Entity \"" + entity + "\" does already exist");
// add
entities.add(entity);
// notify
notifyNewEntity(entity);
}
开发者ID:jason-lang,
项目名称:apps,
代码行数:20,
代码来源:EIDefaultImpl.java
示例4: getAssociatedAgents
点赞 2
import eis.exceptions.EntityException; //导入依赖的package包/类
public HashSet<String> getAssociatedAgents(String entity) throws EntityException {
if( entities.contains(entity) == false )
throw new EntityException("Entity \"" + entity + "\" has not been registered.");
HashSet<String> ret = new HashSet<String>();
for( Entry<String, HashSet<String>> entry : agentsToEntities.entrySet() ) {
if( entry.getValue().contains(entity) )
ret.add(entry.getKey());
}
return ret;
}
开发者ID:jason-lang,
项目名称:apps,
代码行数:18,
代码来源:EIDefaultImpl.java
示例5: deleteEntity
点赞 2
import eis.exceptions.EntityException; //导入依赖的package包/类
/**
* Deletes an entity, by removing its id from the internal list, and disassociating
* it from the respective agent.
*
* @param entity the id of the entity that is to be removed.
* @throws PlatformException if the agent does not exist.
*/
protected void deleteEntity(String entity) throws EntityException,RelationException {
// check if exists
if( !entities.contains(entity) )
throw new EntityException("Entity \"" + entity + "\" does not exist!");
LinkedList<String> agents = new LinkedList<String>();
// find the association and remove
//boolean associated = false;
for( Entry<String,HashSet<String>> entry : agentsToEntities.entrySet()) {
String agent = entry.getKey();
HashSet<String> ens = entry.getValue();
if( ens.contains(entity) ) {
ens.remove(entity);
agentsToEntities.put(agent, ens);
//associated = true;
if ( agents.contains(agent) == false )
agents.add(agent);
break;
}
}
// fail if entity has not been associated
/*if( associated == false)
try {
throw new RelationException("Entity \"" + entity + "\" has not been associated!");
} catch (RelationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/
// finally delete
entities.remove(entity);
if(this.entitiesToTypes.containsKey(entity))
this.entitiesToTypes.remove(entity);
// notify
notifyDeletedEntity(entity,agents);
}
开发者ID:jason-lang,
项目名称:apps,
代码行数:58,
代码来源:EIDefaultImpl.java