Class PlanLibrary

java.lang.Object
jason.asSyntax.PlanLibrary
All Implemented Interfaces:
ToDOM, java.io.Serializable, java.lang.Iterable<Plan>

public class PlanLibrary
extends java.lang.Object
implements java.lang.Iterable<Plan>, java.io.Serializable, ToDOM
Represents a set of plans used by an agent
See Also:
Serialized Form
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
      Constant Field Values
    • KQML_PLANS_FILE

      public static java.lang.String KQML_PLANS_FILE
    • relPlans

      private java.util.Map<PredicateIndicator,​java.util.List<Plan>> relPlans
      a MAP from TE to a list of relevant plans
    • plans

      private java.util.List<Plan> plans
      All plans as defined in the AS code (maintains the order of the plans)
    • varPlans

      private java.util.List<Plan> varPlans
      list of plans that have var as TE
    • planLabels

      private java.util.Map<java.lang.String,​Plan> planLabels
      A map from labels to plans
    • hasMetaEventPlans

      private boolean hasMetaEventPlans
    • hasJagPlans

      private boolean hasJagPlans
    • lastPlanLabel

      private static java.util.concurrent.atomic.AtomicInteger lastPlanLabel
    • hasUserKqmlReceived

      private boolean hasUserKqmlReceived
    • lockPL

      private transient java.lang.Object lockPL
    • father

      private PlanLibrary father
    • hasPlansForUpdateEvents

      private boolean hasPlansForUpdateEvents
    • kqmlReceivedFunctor

      private final java.lang.String kqmlReceivedFunctor
    • TE_JAG_SLEEPING

      public static final Trigger TE_JAG_SLEEPING
    • TE_JAG_AWAKING

      public static final Trigger TE_JAG_AWAKING
    • TE_JAG_SHUTTING_DOWN

      public static final Trigger TE_JAG_SHUTTING_DOWN
    • eDOMPlans

      protected org.w3c.dom.Element eDOMPlans
  • Constructor Details

    • PlanLibrary

      public PlanLibrary()
    • PlanLibrary

      public PlanLibrary​(PlanLibrary father)
  • Method Details

    • isRoot

      public boolean isRoot()
    • getFather

      public PlanLibrary getFather()
    • setFather

      public void setFather​(PlanLibrary pl)
    • hasPlansForUpdateEvents

      public boolean hasPlansForUpdateEvents()
    • getLock

      public java.lang.Object getLock()
    • readObject

      private void readObject​(java.io.ObjectInputStream inputStream) throws java.io.IOException, java.lang.ClassNotFoundException
      Throws:
      java.io.IOException
      java.lang.ClassNotFoundException
    • add

      @Deprecated public Plan add​(StringTerm stPlan, Term tSource) throws jason.asSyntax.parser.ParseException, JasonException
      Deprecated.
      parse the plan before (ASSyntax methods) and call add(Plan, ...) methods
      Add a new plan written as a String. The source normally is "self" or the agent that sent this plan. If the PL already has a plan equals to "stPlan", only a new source is added. The plan is added in the end of the PlanLibrary.
      Throws:
      jason.asSyntax.parser.ParseException
      JasonException
    • add

      @Deprecated public Plan add​(StringTerm stPlan, Term tSource, boolean before) throws jason.asSyntax.parser.ParseException, JasonException
      Deprecated.
      parse the plan before (ASSyntax methods) and call add(Plan, ...) methods
      Add a new plan written as a String. The source normally is "self" or the agent that sent this plan. If the PL already has a plan equals to "stPlan", only a new source is added. If before is true, the plan will be added in the begin of the PlanLibrary; otherwise, it is added in the end.
      Throws:
      jason.asSyntax.parser.ParseException
      JasonException
    • add

      public Plan add​(Plan p, Term source, boolean before) throws JasonException
      Add a new plan in PL. The source normally is "self" or the agent that sent this plan. If the PL already has a plan equals to the parameter p, only a new source is added. If before is true, the plan will be added in the begin of the PlanLibrary; otherwise, it is added in the end.
      Throws:
      JasonException
    • add

      public Plan add​(Plan p) throws JasonException
      Throws:
      JasonException
    • add

      public Plan add​(Plan p, boolean before) throws JasonException
      Adds a plan into the plan library, either before or after all other plans depending on the boolean parameter.
      Parameters:
      p - The plan to be added to the plan library
      before - Whether or not to place the new plan before others
      Throws:
      JasonException
    • addAll

      public void addAll​(PlanLibrary pl) throws JasonException
      Throws:
      JasonException
    • addAll

      public void addAll​(java.util.List<Plan> plans) throws JasonException
      Throws:
      JasonException
    • getStringForLabel

      private java.lang.String getStringForLabel​(Literal p)
    • hasMetaEventPlans

      public boolean hasMetaEventPlans()
    • hasUserKqmlReceivedPlans

      public boolean hasUserKqmlReceivedPlans()
    • hasJagPlans

      public boolean hasJagPlans()
    • getUniqueLabel

      public Pred getUniqueLabel()
      add a label to the plan
    • get

      public Plan get​(java.lang.String label)
      return a plan for a label
    • get

      public Plan get​(Literal label)
      return a plan for a label
    • size

      public int size()
    • getPlans

      public java.util.List<Plan> getPlans()
    • iterator

      public java.util.Iterator<Plan> iterator()
      Specified by:
      iterator in interface java.lang.Iterable<Plan>
    • clear

      public void clear()
      remove all plans
    • remove

      public boolean remove​(Literal pLabel, Term source)
      Remove a plan represented by the label pLabel. In case the plan has many sources, only the plan's source is removed.
    • remove

      public Plan remove​(Literal pLabel)
      remove the plan with label pLabel
    • isRelevant

      @Deprecated public boolean isRelevant​(Trigger te)
      Deprecated.
      use hasCandidatePlan(te) instead
    • hasCandidatePlan

      public boolean hasCandidatePlan​(Trigger te)
    • getAllRelevant

      @Deprecated public java.util.List<Plan> getAllRelevant​(Trigger te)
      Deprecated.
      use getCandidatePlans(te) instead
    • getCandidatePlans

      public java.util.List<Plan> getCandidatePlans​(Trigger te)
    • clone

      public PlanLibrary clone()
      Overrides:
      clone in class java.lang.Object
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • getAsTxt

      public java.lang.String getAsTxt​(boolean includeKQMLPlans)
      get as txt
    • getAsDOM

      public org.w3c.dom.Element getAsDOM​(org.w3c.dom.Document document)
      get as XML
      Specified by:
      getAsDOM in interface ToDOM