public class FilterKBaseImpl extends KBaseDecorator implements FilterKBase
ArrayListKBaseImpl
by default. The filters of the base are
stored in ArrayList
s.Modifier and Type | Class and Description |
---|---|
(package private) static class |
FilterKBaseImpl.Cache |
Modifier and Type | Field and Description |
---|---|
protected ArrayList |
assertFilterList
List of assertion filters
|
private Formula |
bPattern |
private FilterKBaseImpl.Cache |
cache
Cache
|
private Logger |
logger
Logger
|
protected ArrayList |
queryFilterList
List of query filters
|
decorated
END, FRONT
Constructor and Description |
---|
FilterKBaseImpl(KBase decorated)
Creates a new belief base.
|
FilterKBaseImpl(KBase decorated,
FilterKBaseLoader loader)
Creates a new belief base.
|
Modifier and Type | Method and Description |
---|---|
void |
addFiltersDefinition(FiltersDefinition filtersDefinition)
METHODS TO ADD NEW FILTERS *
|
void |
addKBAssertFilter(KBAssertFilter filter)
Adds an assert filter to the belief base
|
void |
addKBAssertFilter(KBAssertFilter filter,
int index)
Adds an assert filter to the belief base at the specified index.
|
private void |
addKBFilter(KBFilter filter,
int index)
Adds a new
KBFilter . |
void |
addKBQueryFilter(KBQueryFilter filter)
Adds a query filter to the belief base
|
void |
addKBQueryFilter(KBQueryFilter filter,
int index)
Adds a query filter to the belief base at the specified index.
|
void |
addObserver(Observer obs)
Do not forget to initialise observers once added to the KBase
by using
observer.update(null);
Only observers added in the setupKBase method are
automatically initialised. |
void |
assertFormula(Formula formula)
METHODS TO ACCESS KBASE *
|
void |
getObserverTriggerPatterns(Formula formula,
Set result)
Calls the getObserverTriggerPatterns method of each query filters.
|
QueryResult |
query(Formula formula,
ArrayList reasons) |
void |
removeKBAssertFilter(Finder filterIdentifier)
METHODS TO REMOVE FILTERS *
|
void |
removeKBQueryFilter(Finder filterIdentifier)
Removes the query filters that are identified by
the specified finder.
|
ArrayList |
toStrings()
DISPLAY METHODS *
|
private void |
toStrings(ArrayList result,
ArrayList strings) |
void |
viewFilterQuery()
For debugging purpose only
|
addClosedPredicate, eval, getAgentName, getDecorated, getWrappingKBase, isClosed, query, queryRef, queryRef, queryRefSingleTerm, removeClosedPredicate, removeFormula, removeObserver, removeObserver, retractFormula, setAgentName, setWrappingKBase, updateObservers
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addClosedPredicate, eval, getAgentName, getWrappingKBase, isClosed, query, queryRef, queryRef, queryRefSingleTerm, removeClosedPredicate, removeFormula, removeObserver, removeObserver, retractFormula, setAgentName, setWrappingKBase, updateObservers
private final Formula bPattern
protected ArrayList assertFilterList
protected ArrayList queryFilterList
private Logger logger
private FilterKBaseImpl.Cache cache
public FilterKBaseImpl(KBase decorated)
decorated
- the wrapped kbase used to store the facts,
which should not be null.public FilterKBaseImpl(KBase decorated, FilterKBaseLoader loader)
decorated
- the wrapped kbase used to store the facts,
which should not be null.loader
- a particular filters loader.public void assertFormula(Formula formula)
assertFormula
in interface KBase
assertFormula
in class KBaseDecorator
formula
- the formula to assert.public QueryResult query(Formula formula, ArrayList reasons)
query
in interface KBase
query
in class KBaseDecorator
public void addFiltersDefinition(FiltersDefinition filtersDefinition)
addFiltersDefinition
in interface FilterKBase
filtersDefinition
- the list of filtersprivate void addKBFilter(KBFilter filter, int index)
KBFilter
.filter
- a filterindex
- the index to add the filterpublic void addKBAssertFilter(KBAssertFilter filter)
FilterKBase
addKBAssertFilter
in interface FilterKBase
filter
- an assert filterpublic void addKBAssertFilter(KBAssertFilter filter, int index)
FilterKBase
FRONT
or END
constants to put
the filter at the beginning of the lits or at the end of the list.addKBAssertFilter
in interface FilterKBase
filter
- an assert filterindex
- the index in the list of filters to add a new filterpublic void addKBQueryFilter(KBQueryFilter filter)
FilterKBase
addKBQueryFilter
in interface FilterKBase
filter
- a queryFilterpublic void addKBQueryFilter(KBQueryFilter filter, int index)
FilterKBase
FRONT
or END
constants to put
the filter at the beginning of the lits or at the end of the list.addKBQueryFilter
in interface FilterKBase
filter
- a queryFilterindex
- the index in the list of filters to add a new filterpublic void removeKBAssertFilter(Finder filterIdentifier)
removeKBAssertFilter
in interface FilterKBase
filterIdentifier
- a finderpublic void removeKBQueryFilter(Finder filterIdentifier)
FilterKBase
removeKBQueryFilter
in interface FilterKBase
filterIdentifier
- a finderpublic void addObserver(Observer obs)
observer.update(null);
Only observers added in the setupKBase
method are
automatically initialised.addObserver
in interface KBase
addObserver
in class KBaseDecorator
obs
- the observer to addpublic void getObserverTriggerPatterns(Formula formula, Set result)
FilterKBase
getObserverTriggerPatterns
in interface FilterKBase
formula
- an observed formulapublic ArrayList toStrings()
toStrings
in interface KBase
toStrings
in class KBaseDecorator
public void viewFilterQuery()