bdi4jade.core

## Class Intention

- java.lang.Object
- - bdi4jade.core.Intention

-     public class Intention
      extends java.lang.Object

  This class represents the intention abstraction from the BDI model. It represents a goal that the agent is committed to achieve. It has the associated goal and tries to execute plans to achieve it. It keeps a list of the executed plans, and after using all plans unsuccessfully, the goal is considered unachievable. When a plan fails, the BDI-interpreter cycle may invoke the `tryToAchive()` method again, so the intention tries another plan. During its execution, the intention can be set to no longer desired. This occurs during the agent reasoning cycle or when a goal is dropped (`BDIAgent.dropGoal(Goal)`).
  Author:
    Ingrid Nunes

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Intention(Goal goal, AbstractBDIAgent bdiAgent)` Creates a new intention.
    `Intention(Goal goal, AbstractBDIAgent bdiAgent, Capability dispatcher)` Creates a new intention.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addGoalListener(GoalListener goalListener)` Adds a listener to be notified when about goal events.
    `void` | `doWait()` Sets this intention to the `GoalStatus.WAITING` status.
    `Capability` | `getDispatcher()` Returns the capability that dispatched this goal.
    `Goal` | `getGoal()` Returns the goal associated with this intention.
    `java.util.List<GoalListener>` | `getGoalListeners()` Returns all goal listeners.
    `AbstractBDIAgent` | `getMyAgent()` Returns the agent associated with this intention.
    `java.util.Set<Capability>` | `getOwners()` Returns the set of capabilities that own this goal.
    `GoalStatus` | `getStatus()` Returns the current goal status that this capability is committed to achieve.
    `void` | `noLongerDesire()` Sets this intention as no longer desired.
    `void` | `removeGoalListener(GoalListener goalListener)` Removes a goal listener, so it will not be notified about the goal events anymore.
    `void` | `tryToAchive()` Makes this intention starts to try to achieve the goal.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Intention

          public Intention(Goal goal,
                           AbstractBDIAgent bdiAgent)
                    throws java.lang.IllegalAccessException

      Creates a new intention. It is associated with an agent and the goal that it is committed to achieve.
      Parameters:
        `goal` - the goal to be achieved.
        `bdiAgent` - the bdiAgent associated with this intention.
      Throws:
        `java.lang.IllegalAccessException` - if the goal was dispatched by a capability that has no access to the goal to be achieved.

    - #### Intention

          public Intention(Goal goal,
                           AbstractBDIAgent bdiAgent,
                           Capability dispatcher)
                    throws java.lang.IllegalAccessException

      Creates a new intention. It is associated with an agent and the goal that it is committed to achieve. It also receives a `Capability` as parameter indicating the owner of the goal (dispatched the goal).
      Parameters:
        `goal` - the goal to be achieved.
        `bdiAgent` - the bdiAgent associated with this intention.
        `dispatcher` - the Capability that dispatched the goal.
      Throws:
        `java.lang.IllegalAccessException` - if the goal was dispatched by a capability that has no access to the goal to be achieved.

  - ### Method Detail

    - #### addGoalListener

          public void addGoalListener(GoalListener goalListener)

      Adds a listener to be notified when about goal events.
      Parameters:
        `goalListener` - the listener to be notified.

    - #### doWait

          public void doWait()

      Sets this intention to the `GoalStatus.WAITING` status. It may come from the `GoalStatus.PLAN_FAILED` or `GoalStatus.TRYING_TO_ACHIEVE` states.

    - #### getDispatcher

          public Capability getDispatcher()

      Returns the capability that dispatched this goal.
      Returns:
        the dispatcher.

    - #### getGoal

          public Goal getGoal()

      Returns the goal associated with this intention.
      Returns:
        the goal.

    - #### getGoalListeners

          public java.util.List<GoalListener> getGoalListeners()

      Returns all goal listeners.
      Returns:
        the goalListeners.

    - #### getMyAgent

          public AbstractBDIAgent getMyAgent()

      Returns the agent associated with this intention.
      Returns:
        the myAgent.

    - #### getOwners

          public java.util.Set<Capability> getOwners()

      Returns the set of capabilities that own this goal.
      Returns:
        the owners.

    - #### getStatus

          public GoalStatus getStatus()

      Returns the current goal status that this capability is committed to achieve.
      Returns:
        the current goal status.
      See Also:
        `GoalStatus`

    - #### noLongerDesire

          public void noLongerDesire()

      Sets this intention as no longer desired. It stops the current plan execution. It changes the goal status from `GoalStatus.WAITING`, `GoalStatus.PLAN_FAILED` or `GoalStatus.TRYING_TO_ACHIEVE` to `GoalStatus.NO_LONGER_DESIRED`.

    - #### removeGoalListener

          public void removeGoalListener(GoalListener goalListener)

      Removes a goal listener, so it will not be notified about the goal events anymore.
      Parameters:
        `goalListener` - the goal listener to be removed.

    - #### tryToAchive

          public void tryToAchive()

      Makes this intention starts to try to achieve the goal. It changes the goal status from `GoalStatus.WAITING` or `GoalStatus.PLAN_FAILED` to `GoalStatus.TRYING_TO_ACHIEVE`.