|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jason.bb.ChainBBAdapter
public class ChainBBAdapter
This class is to be extended by customised belief bases that may be used in chains (of responsibility). For example, the code
BeliefBase bb = new MyBB1( new MyBB2()); // DefaultBeliefBase is the next of the last element of the chainwill chain 3 BBs: MyBB1, myBB2, and the DefaultBeliefBase. So, for any operation of the BB interface, the operation is firstly called in MyBB1, then in MyBB2 and finally in the DefaultBeliefBase. The code of MyBB1 looks like:
class MyBB1 extends ChainBBAdapter { public MyBB1() { } public MyBB1(BeliefBase next) { super(next); } public boolean add(Literal l) { ... some customisation of add .... return next.add(l); // delegate the operation for the next BB in the chain } ... customisation of other operations ... }
Field Summary | |
---|---|
protected BeliefBase |
nextBB
|
Fields inherited from interface jason.bb.BeliefBase |
---|
APercept, ASelf, TPercept, TSelf |
Constructor Summary | |
---|---|
ChainBBAdapter()
|
|
ChainBBAdapter(BeliefBase bb)
|
Method Summary | |
---|---|
boolean |
abolish(PredicateIndicator pi)
Removes all believes with some functor/arity |
boolean |
add(int index,
Literal l)
Adds a belief in the BB at index position, returns true if succeed |
boolean |
add(Literal l)
Adds a belief in the end of the BB, returns true if succeed. |
BeliefBase |
clone()
|
Literal |
contains(Literal l)
Returns the literal l as it is in BB, this method does not consider annotations in the search. |
java.util.Iterator<Literal> |
getAll()
|
org.w3c.dom.Element |
getAsDOM(org.w3c.dom.Document document)
Gets the BB as XML |
java.util.Iterator<Literal> |
getCandidateBeliefs(Literal l,
Unifier u)
Returns an iterator for all literals relevant for l's predicate indicator, if l is a var, returns all beliefs. The unifier u may contain values for variables in l. |
java.util.Iterator<Literal> |
getCandidateBeliefs(PredicateIndicator pi)
Returns an iterator for all literals in BB that match the functor/arity of the parameter. |
BeliefBase |
getLastBB()
|
ChainBBAdapter |
getNextAdapter()
|
java.util.Iterator<Literal> |
getPercepts()
Returns all beliefs that have "percept" as source |
java.util.Iterator<Literal> |
getRelevant(Literal l)
|
void |
init(Agent ag,
java.lang.String[] args)
Called before the MAS execution with the agent that uses this BB and the args informed in .mas2j project. Example in .mas2j: agent BeliefBaseClass(1,bla); the init args will be ["1", "bla"]. |
java.util.Iterator<Literal> |
iterator()
Returns an iterator for all beliefs. |
boolean |
remove(Literal l)
Removes a literal from BB, returns true if succeed |
void |
setNext(BeliefBase bb)
|
int |
size()
Returns the number of beliefs in BB |
void |
stop()
Called just before the end of MAS execution |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected BeliefBase nextBB
Constructor Detail |
---|
public ChainBBAdapter()
public ChainBBAdapter(BeliefBase bb)
Method Detail |
---|
public void setNext(BeliefBase bb)
public ChainBBAdapter getNextAdapter()
public BeliefBase getLastBB()
public void init(Agent ag, java.lang.String[] args)
BeliefBase
agent BeliefBaseClass(1,bla);
init
in interface BeliefBase
public void stop()
BeliefBase
stop
in interface BeliefBase
public boolean add(Literal l)
BeliefBase
add
in interface BeliefBase
public boolean add(int index, Literal l)
BeliefBase
add
in interface BeliefBase
public Literal contains(Literal l)
BeliefBase
contains(a(10)[d])
returns
a(10)[a,b].
contains
in interface BeliefBase
public java.util.Iterator<Literal> getAll()
getAll
in interface BeliefBase
public java.util.Iterator<Literal> iterator()
BeliefBase
iterator
in interface BeliefBase
iterator
in interface java.lang.Iterable<Literal>
public java.util.Iterator<Literal> getCandidateBeliefs(PredicateIndicator pi)
BeliefBase
getCandidateBeliefs
in interface BeliefBase
public java.util.Iterator<Literal> getCandidateBeliefs(Literal l, Unifier u)
BeliefBase
getCandidateBeliefs(a(5), {})
= {{a(10),a(20)}.getCandidateBeliefs(X)
=
{{a(10),a(20)}. The getCandidateBeliefs(a(X), {X -> 5})
should also return {{a(10),a(20)}.
getCandidateBeliefs
in interface BeliefBase
public java.util.Iterator<Literal> getPercepts()
BeliefBase
getPercepts
in interface BeliefBase
public java.util.Iterator<Literal> getRelevant(Literal l)
getRelevant
in interface BeliefBase
public boolean abolish(PredicateIndicator pi)
BeliefBase
abolish
in interface BeliefBase
public boolean remove(Literal l)
BeliefBase
remove
in interface BeliefBase
public int size()
BeliefBase
size
in interface BeliefBase
public org.w3c.dom.Element getAsDOM(org.w3c.dom.Document document)
BeliefBase
getAsDOM
in interface BeliefBase
public BeliefBase clone()
clone
in interface BeliefBase
clone
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |