Package jason.asSyntax
Class PlanLibrary
java.lang.Object
jason.asSyntax.PlanLibrary
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 Summary
Fields Modifier and Type Field Description protected org.w3c.dom.Element
eDOMPlans
private PlanLibrary
father
private boolean
hasJagPlans
private boolean
hasMetaEventPlans
private boolean
hasPlansForUpdateEvents
private boolean
hasUserKqmlReceived
static java.lang.String
KQML_PLANS_FILE
private java.lang.String
kqmlReceivedFunctor
private static java.util.concurrent.atomic.AtomicInteger
lastPlanLabel
private java.lang.Object
lockPL
private java.util.Map<java.lang.String,Plan>
planLabels
A map from labels to plansprivate java.util.List<Plan>
plans
All plans as defined in the AS code (maintains the order of the plans)private java.util.Map<PredicateIndicator,java.util.List<Plan>>
relPlans
a MAP from TE to a list of relevant plansprivate static long
serialVersionUID
static Trigger
TE_JAG_AWAKING
static Trigger
TE_JAG_SHUTTING_DOWN
static Trigger
TE_JAG_SLEEPING
private java.util.List<Plan>
varPlans
list of plans that have var as TE -
Constructor Summary
Constructors Constructor Description PlanLibrary()
PlanLibrary(PlanLibrary father)
-
Method Summary
Modifier and Type Method Description Plan
add(Plan p)
Plan
add(Plan p, boolean before)
Adds a plan into the plan library, either before or after all other plans depending on the boolean parameter.Plan
add(Plan p, Term source, boolean before)
Add a new plan in PL.Plan
add(StringTerm stPlan, Term tSource)
Deprecated.parse the plan before (ASSyntax methods) and call add(Plan, ...) methodsPlan
add(StringTerm stPlan, Term tSource, boolean before)
Deprecated.parse the plan before (ASSyntax methods) and call add(Plan, ...) methodsvoid
addAll(PlanLibrary pl)
void
addAll(java.util.List<Plan> plans)
void
clear()
remove all plansPlanLibrary
clone()
Plan
get(Literal label)
return a plan for a labelPlan
get(java.lang.String label)
return a plan for a labeljava.util.List<Plan>
getAllRelevant(Trigger te)
Deprecated.use getCandidatePlans(te) insteadorg.w3c.dom.Element
getAsDOM(org.w3c.dom.Document document)
get as XMLjava.lang.String
getAsTxt(boolean includeKQMLPlans)
get as txtjava.util.List<Plan>
getCandidatePlans(Trigger te)
PlanLibrary
getFather()
java.lang.Object
getLock()
java.util.List<Plan>
getPlans()
private java.lang.String
getStringForLabel(Literal p)
Pred
getUniqueLabel()
add a label to the planboolean
hasCandidatePlan(Trigger te)
boolean
hasJagPlans()
boolean
hasMetaEventPlans()
boolean
hasPlansForUpdateEvents()
boolean
hasUserKqmlReceivedPlans()
boolean
isRelevant(Trigger te)
Deprecated.use hasCandidatePlan(te) insteadboolean
isRoot()
java.util.Iterator<Plan>
iterator()
private void
readObject(java.io.ObjectInputStream inputStream)
Plan
remove(Literal pLabel)
remove the plan with label pLabelboolean
remove(Literal pLabel, Term source)
Remove a plan represented by the label pLabel.void
setFather(PlanLibrary pl)
int
size()
java.lang.String
toString()
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
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
a MAP from TE to a list of relevant plans -
plans
All plans as defined in the AS code (maintains the order of the plans) -
varPlans
list of plans that have var as TE -
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
-
hasPlansForUpdateEvents
private boolean hasPlansForUpdateEvents -
kqmlReceivedFunctor
private final java.lang.String kqmlReceivedFunctor -
TE_JAG_SLEEPING
-
TE_JAG_AWAKING
-
TE_JAG_SHUTTING_DOWN
-
eDOMPlans
protected org.w3c.dom.Element eDOMPlans
-
-
Constructor Details
-
PlanLibrary
public PlanLibrary() -
PlanLibrary
-
-
Method Details
-
isRoot
public boolean isRoot() -
getFather
-
setFather
-
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, JasonExceptionDeprecated.parse the plan before (ASSyntax methods) and call add(Plan, ...) methodsAdd 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, JasonExceptionDeprecated.parse the plan before (ASSyntax methods) and call add(Plan, ...) methodsAdd 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
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
- Throws:
JasonException
-
add
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 librarybefore
- Whether or not to place the new plan before others- Throws:
JasonException
-
addAll
- Throws:
JasonException
-
addAll
- Throws:
JasonException
-
getStringForLabel
-
hasMetaEventPlans
public boolean hasMetaEventPlans() -
hasUserKqmlReceivedPlans
public boolean hasUserKqmlReceivedPlans() -
hasJagPlans
public boolean hasJagPlans() -
getUniqueLabel
add a label to the plan -
get
return a plan for a label -
get
return a plan for a label -
size
public int size() -
getPlans
-
iterator
- Specified by:
iterator
in interfacejava.lang.Iterable<Plan>
-
clear
public void clear()remove all plans -
remove
Remove a plan represented by the label pLabel. In case the plan has many sources, only the plan's source is removed. -
remove
remove the plan with label pLabel -
isRelevant
Deprecated.use hasCandidatePlan(te) instead -
hasCandidatePlan
-
getAllRelevant
Deprecated.use getCandidatePlans(te) instead -
getCandidatePlans
-
clone
- Overrides:
clone
in classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.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
-