br.pucrio.inf.les.bdijade.core
Class PlanLibrary

java.lang.Object
  extended by br.pucrio.inf.les.bdijade.core.PlanLibrary
All Implemented Interfaces:
java.io.Serializable

public class PlanLibrary
extends java.lang.Object
implements java.io.Serializable

This class represents the plan library of a capability. It aggregates the plans that can be used to achieve goals.

Author:
ingrid
See Also:
Serialized Form

Field Summary
private  Capability capability
           
private  java.util.Set<Plan> plans
           
private static long serialVersionUID
           
 
Constructor Summary
PlanLibrary()
          Creates a plan library.
PlanLibrary(java.util.Set<Plan> plans)
          Creates a plan library base associated with a capability and adds the plans in the provided set.
 
Method Summary
 void addPlan(Plan plan)
          Adds a plan to the plan library.
 java.util.Set<Plan> canAchievePlans(Goal goal)
          Returns the set of plans that can achieve the given goal.
 boolean canProcessPlans(jade.lang.acl.ACLMessage message)
          Returns true if there is a plan that can process the given message.
 Capability getCapability()
           
 java.util.Set<Plan> getPlans()
           
 boolean hasPlan(Plan plan)
          Checks if a plan is part of the plan library.
protected  void init()
          Initialize the plan library, adding initial plans.
 boolean removePlan(Plan plan)
          Removes a plan from the plan library.
 void setCapability(Capability capability)
          Sets the capability of this plan library.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

capability

private Capability capability

plans

private final java.util.Set<Plan> plans
Constructor Detail

PlanLibrary

public PlanLibrary()
Creates a plan library.


PlanLibrary

public PlanLibrary(java.util.Set<Plan> plans)
Creates a plan library base associated with a capability and adds the plans in the provided set.

Parameters:
plans - the initial plans
Method Detail

addPlan

public void addPlan(Plan plan)
Adds a plan to the plan library.

Parameters:
plan - the plan to be added.

canAchievePlans

public java.util.Set<Plan> canAchievePlans(Goal goal)
Returns the set of plans that can achieve the given goal.

Parameters:
goal - the goal to be achieved.
Returns:
the set of plans that can achieve the goal.

canProcessPlans

public boolean canProcessPlans(jade.lang.acl.ACLMessage message)
Returns true if there is a plan that can process the given message.

Parameters:
message - the message to be processed.
Returns:
true if a plan can process the message.

getCapability

public Capability getCapability()
Returns:
the capability

getPlans

public java.util.Set<Plan> getPlans()
Returns:
the plans

hasPlan

public boolean hasPlan(Plan plan)
Checks if a plan is part of the plan library.

Parameters:
plan - the plan to be checked
Returns:
true if the plan library contains the plan.

init

protected void init()
Initialize the plan library, adding initial plans.


removePlan

public boolean removePlan(Plan plan)
Removes a plan from the plan library.

Parameters:
plan - the plan to be removed.
Returns:
true if the plan was removed.

setCapability

public void setCapability(Capability capability)
Sets the capability of this plan library. If the capability was already set, it throws a RuntimeException. After setting the capability, the init() method is invoked.

Parameters:
capability - the capability to set