|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.hammurapi.reasoning.impl.InMemoryKnowledgeBase<F>
public class InMemoryKnowledgeBase<F>
Knowledge base which uses in-memory collecitons.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.hammurapi.reasoning.impl.KnowledgeBase |
|---|
KnowledgeBase.PutDerivedResult<F> |
| Constructor Summary | |
|---|---|
InMemoryKnowledgeBase(String name,
String description,
boolean weak)
Creates a new simple knowledge base. |
|
| Method Summary | ||
|---|---|---|
void |
cleanup()
Removes invalid entries. |
|
void |
close()
|
|
boolean |
contains(Handle<F> handle)
|
|
boolean |
contains(Object fact)
|
|
void |
executeRules()
|
|
F |
get(Handle<F> handle)
|
|
Map<Class<F>,Set<Class<F>>> |
getConclusionMap()
|
|
Collection<Derivation<F>> |
getDerivations(F obj)
|
|
Collection<Derivation<F>> |
getDerivations(Handle<F> handle)
|
|
String |
getDescription()
|
|
ExceptionHandler |
getExceptionHandler()
|
|
Executor |
getExecutor()
|
|
Handle<F> |
getHandle(Object fact)
|
|
Collection<Handle<F>> |
getHandles()
|
|
InferenceListener<F> |
getInferenceListener()
|
|
|
getList(String id,
Class<T> elementType)
Lists of handles are array lists, for other element types lists are facades for handle lists. |
|
String |
getName()
|
|
Collection<F> |
getObjects()
|
|
|
getSet(String id,
Class<T> elementType)
Sets of handles are hash sets, for other element types sets are facades for handle sets. |
|
Handle<F> |
put(F fact)
|
|
Handle<F>[] |
putAll(F... facts)
|
|
List<Handle<F>> |
putAll(List<? extends F> facts)
|
|
KnowledgeBase.PutDerivedResult<F> |
putConclusion(F conclusion,
Object rule,
String ruleName,
String ruleDescription,
Method method,
List<Handle<F>> handleList)
|
|
void |
remove(F obj,
boolean strict)
|
|
void |
remove(Handle<F> handle,
boolean strict)
|
|
void |
reset()
|
|
void |
setExceptionHandler(ExceptionHandler handler)
|
|
void |
setExecutor(Executor executor)
|
|
void |
setInferenceListener(InferenceListener<F> listener)
|
|
void |
updateObject(Handle<F> handle,
F fact)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public InMemoryKnowledgeBase(String name,
String description,
boolean weak)
weak - If true, a weak hash map is used for fact storage.
It can be useful for long running sessions with inference listener.
Use of weak hash map ensures that the session will not run out of memory.
When a weak hash map is used, some derivations may become invalid when
source facts of conclusions get garbage collected.| Method Detail |
|---|
public void setExecutor(Executor executor)
executor - Executor for delegation of execution of undo tasks.public Executor getExecutor()
public <T> List<T> getList(String id,
Class<T> elementType)
getList in interface CollectionManager<Object>id - Set id.elementType - Element type.
public <T> Set<? extends T> getSet(String id,
Class<T> elementType)
getSet in interface CollectionManager<Object>id - Set id.elementType - Element type.
public Handle<F> put(F fact)
throws ReasoningException
put in interface ForwardReasoningSession<F>ReasoningException
public Collection<Derivation<F>> getDerivations(F obj)
throws ReasoningException
getDerivations in interface ForwardReasoningSession<F>ReasoningException
public Collection<Derivation<F>> getDerivations(Handle<F> handle)
throws ReasoningException
getDerivations in interface ForwardReasoningSession<F>ReasoningException
public F get(Handle<F> handle)
throws ReasoningException
get in interface ForwardReasoningSession<F>ReasoningException
public Collection<F> getObjects()
throws ReasoningException
getObjects in interface ForwardReasoningSession<F>ReasoningException
public void remove(F obj,
boolean strict)
throws ReasoningException
remove in interface ForwardReasoningSession<F>ReasoningException
public void remove(Handle<F> handle,
boolean strict)
throws ReasoningException
remove in interface ForwardReasoningSession<F>ReasoningExceptionpublic String getDescription()
getDescription in interface ReasoningSessionpublic String getName()
getName in interface ReasoningSession
public void close()
throws ReasoningException
close in interface ReasoningSessionReasoningException
public void reset()
throws ReasoningException
reset in interface ReasoningSessionReasoningException
public void executeRules()
throws ReasoningException
executeRules in interface ForwardReasoningSession<F>ReasoningException
public InferenceListener<F> getInferenceListener()
throws ReasoningException
getInferenceListener in interface ForwardReasoningSession<F>ReasoningException
public void setInferenceListener(InferenceListener<F> listener)
throws ReasoningException
setInferenceListener in interface ForwardReasoningSession<F>ReasoningException
public KnowledgeBase.PutDerivedResult<F> putConclusion(F conclusion,
Object rule,
String ruleName,
String ruleDescription,
Method method,
List<Handle<F>> handleList)
putConclusion in interface KnowledgeBase<F>public Handle<F> getHandle(Object fact)
getHandle in interface ForwardReasoningSession<F>
public void cleanup()
throws ReasoningException
ReasoningException
public boolean contains(Object fact)
throws ReasoningException
contains in interface ForwardReasoningSession<F>ReasoningException
public ExceptionHandler getExceptionHandler()
throws ReasoningException
getExceptionHandler in interface ReasoningSessionReasoningException
public void setExceptionHandler(ExceptionHandler handler)
throws ReasoningException
setExceptionHandler in interface ReasoningSessionReasoningException
public boolean contains(Handle<F> handle)
throws ReasoningException
contains in interface ForwardReasoningSession<F>ReasoningException
public Collection<Handle<F>> getHandles()
throws ReasoningException
getHandles in interface ForwardReasoningSession<F>ReasoningException
public List<Handle<F>> putAll(List<? extends F> facts)
throws ReasoningException
putAll in interface ForwardReasoningSession<F>ReasoningException
public Handle<F>[] putAll(F... facts)
throws ReasoningException
putAll in interface ForwardReasoningSession<F>ReasoningException
public void updateObject(Handle<F> handle,
F fact)
throws ReasoningException
updateObject in interface ForwardReasoningSession<F>ReasoningExceptionpublic Map<Class<F>,Set<Class<F>>> getConclusionMap()
getConclusionMap in interface ForwardReasoningSession<F>
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||