jason.asSyntax
Class PlanBodyImpl

Package class diagram package PlanBodyImpl
java.lang.Object
  extended by jason.asSyntax.DefaultTerm
      extended by jason.asSyntax.Literal
          extended by jason.asSyntax.Atom
              extended by jason.asSyntax.Structure
                  extended by jason.asSyntax.PlanBodyImpl
All Implemented Interfaces:
LogicalFormula, PlanBody, Term, ToDOM, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<Term>, java.lang.Iterable<PlanBody>
Direct Known Subclasses:
BodyLiteral

public class PlanBodyImpl
extends Structure
implements PlanBody, java.lang.Iterable<PlanBody>

Represents a plan body item (achieve, test, action, ...) and its successors. A plan body like a1; ?t; !g is represented by the following structure (a1, (?t, (!g))).

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface jason.asSyntax.PlanBody
PlanBody.BodyType
 
Field Summary
static java.lang.String BODY_PLAN_FUNCTOR
           
 
Fields inherited from class jason.asSyntax.Structure
emptyTermArray, emptyTermList
 
Fields inherited from class jason.asSyntax.Literal
LFalse, LNeg, LPos, LTrue, predicateIndicatorCache
 
Fields inherited from class jason.asSyntax.DefaultTerm
hashCodeCache, srcInfo
 
Constructor Summary
PlanBodyImpl()
          constructor for empty plan body
PlanBodyImpl(PlanBody.BodyType t, Term b)
           
 
Method Summary
 boolean add(int index, PlanBody bl)
           
 boolean add(PlanBody bl)
          clone the plan body and adds it in the end of this plan
 boolean apply(Unifier u)
          replaces variables by their values in the unifier, returns true if some variable was applied
 int calcHashCode()
           
 PlanBody clone()
          make a deep copy of the terms
 PlanBody clonePB()
          clone the plan body
 boolean equals(java.lang.Object o)
           
 int getArity()
          returns the number of terms of this literal
 org.w3c.dom.Element getAsDOM(org.w3c.dom.Document document)
          get as XML
 PlanBody getBodyNext()
           
 Term getBodyTerm()
           
 PlanBody.BodyType getBodyType()
           
 PlanBody getLastBody()
           
 int getPlanSize()
           
 Term getTerm(int i)
          returns the i-th term (first term is 0)
 boolean isAtom()
           
 boolean isBodyTerm()
           
 boolean isEmptyBody()
           
 boolean isPlanBody()
           
 java.util.Iterator<PlanBody> iterator()
           
 java.util.Iterator<Unifier> logicalConsequence(Agent ag, Unifier un)
          logicalConsequence checks whether one particular predicate is a logical consequence of the belief base.
 Term removeBody(int index)
           
 void setAsBodyTerm(boolean b)
           
 void setBodyNext(PlanBody next)
           
 void setBodyTerm(Term t)
           
 void setBodyType(PlanBody.BodyType bt)
           
 void setTerm(int i, Term t)
           
 java.lang.String toString()
           
 
Methods inherited from class jason.asSyntax.Structure
addTerm, addTerms, addTerms, compareTo, countVars, delTerm, getSingletonVars, getTerms, getTermsSize, hasTerm, hasVar, isGround, isStructure, makeTermsAnnon, makeVarsAnnon, makeVarsAnnon, parse, setTerms, varToReplace
 
Methods inherited from class jason.asSyntax.Atom
getFunctor
 
Methods inherited from class jason.asSyntax.Literal
addAnnot, addAnnots, addAnnots, addSource, canBeAddedInBB, clearAnnots, copy, delAnnot, delAnnots, delSource, delSources, equalsAsStructure, forceFullLiteralImpl, getAnnots, getAnnots, getAsListOfTerms, getPredicateIndicator, getSources, getTermsArray, hasAnnot, hasAnnot, hasSource, hasSource, hasSubsetAnnot, hasSubsetAnnot, importAnnots, isLiteral, negated, newFromListOfTerms, parseLiteral, setAnnots, setNegated
 
Methods inherited from class jason.asSyntax.DefaultTerm
getErrorMsg, getSrcInfo, hashCode, isArithExpr, isInternalAction, isList, isNumeric, isPred, isRule, isString, isUnnamedVar, isVar, resetHashCodeCache, setSrcInfo
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jason.asSyntax.Term
countVars, getSrcInfo, hasVar, isArithExpr, isGround, isInternalAction, isList, isLiteral, isNumeric, isPred, isRule, isString, isStructure, isUnnamedVar, isVar, setSrcInfo
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

BODY_PLAN_FUNCTOR

public static final java.lang.String BODY_PLAN_FUNCTOR
See Also:
Constant Field Values
Constructor Detail

PlanBodyImpl

public PlanBodyImpl()
constructor for empty plan body


PlanBodyImpl

public PlanBodyImpl(PlanBody.BodyType t,
                    Term b)
Method Detail

setBodyNext

public void setBodyNext(PlanBody next)
Specified by:
setBodyNext in interface PlanBody

getBodyNext

public PlanBody getBodyNext()
Specified by:
getBodyNext in interface PlanBody

isEmptyBody

public boolean isEmptyBody()
Specified by:
isEmptyBody in interface PlanBody

getBodyType

public PlanBody.BodyType getBodyType()
Specified by:
getBodyType in interface PlanBody

setBodyType

public void setBodyType(PlanBody.BodyType bt)
Specified by:
setBodyType in interface PlanBody

getBodyTerm

public Term getBodyTerm()
Specified by:
getBodyTerm in interface PlanBody

setBodyTerm

public void setBodyTerm(Term t)
Specified by:
setBodyTerm in interface PlanBody

isBodyTerm

public boolean isBodyTerm()
Specified by:
isBodyTerm in interface PlanBody

isAtom

public boolean isAtom()
Specified by:
isAtom in interface Term
Overrides:
isAtom in class Structure

setAsBodyTerm

public void setAsBodyTerm(boolean b)
Specified by:
setAsBodyTerm in interface PlanBody

isPlanBody

public boolean isPlanBody()
Specified by:
isPlanBody in interface Term
Overrides:
isPlanBody in class DefaultTerm

iterator

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

getArity

public int getArity()
Description copied from class: Literal
returns the number of terms of this literal

Overrides:
getArity in class Structure

getTerm

public Term getTerm(int i)
Description copied from class: Literal
returns the i-th term (first term is 0)

Overrides:
getTerm in class Structure

setTerm

public void setTerm(int i,
                    Term t)
Overrides:
setTerm in class Structure

apply

public boolean apply(Unifier u)
Description copied from interface: Term
replaces variables by their values in the unifier, returns true if some variable was applied

Specified by:
apply in interface Term
Overrides:
apply in class Structure

logicalConsequence

public java.util.Iterator<Unifier> logicalConsequence(Agent ag,
                                                      Unifier un)
Description copied from class: Literal
logicalConsequence checks whether one particular predicate is a logical consequence of the belief base. Returns an iterator for all unifiers that are logCons.

Specified by:
logicalConsequence in interface LogicalFormula
Overrides:
logicalConsequence in class Literal

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface Term
Overrides:
equals in class Structure

calcHashCode

public int calcHashCode()
Overrides:
calcHashCode in class Structure

add

public boolean add(PlanBody bl)
clone the plan body and adds it in the end of this plan

Specified by:
add in interface PlanBody

getLastBody

public PlanBody getLastBody()
Specified by:
getLastBody in interface PlanBody

add

public boolean add(int index,
                   PlanBody bl)
Specified by:
add in interface PlanBody

removeBody

public Term removeBody(int index)
Specified by:
removeBody in interface PlanBody

getPlanSize

public int getPlanSize()
Specified by:
getPlanSize in interface PlanBody

clone

public PlanBody clone()
Description copied from class: Structure
make a deep copy of the terms

Specified by:
clone in interface Term
Overrides:
clone in class Structure

clonePB

public PlanBody clonePB()
Description copied from interface: PlanBody
clone the plan body

Specified by:
clonePB in interface PlanBody

toString

public java.lang.String toString()
Overrides:
toString in class Structure

getAsDOM

public org.w3c.dom.Element getAsDOM(org.w3c.dom.Document document)
get as XML

Specified by:
getAsDOM in interface ToDOM
Overrides:
getAsDOM in class Structure