io.sarl.api.workingmemory
Capacity WorkingMemory
All Superinterfaces:
Capacity
All Known Implementing Classes:
AbstractWorkingMemory, DictionaryWorkingMemory
@org.eclipse.xtext.xbase.lib.XbaseGenerated
capacity WorkingMemory
implements Capacity
Capacity to access to the agent working memory. This working memory enables to have access to a part of the data storage that is exclusively dedicated to the agent.

If the agent does not provide a specific skill for this capacity, the skill to be used is DictionaryWorkingMemory.
Maven Group Identifier:
io.sarl.sdk
Maven Artifact Identifier:
api.workingmemory
Since:
0.15
Property Summary
Modifier and type Property and description
java.lang.Iterable<T> definedNameList
Replies all the defined names stored in the working memory.
java.util.stream.Stream<T> definedNames
Replies all the defined names stored in the working memory.
long memorySize
Replies the number of knowledges that are stored in the working memory.
java.lang.Object workingMemoryLock
Replies a resource that enables to have synchronized access to the working memory.
Action Summary
Modifier and type Action and description
abstract void clearMemory
Remove all knowledge from the working memory.
abstract java.util.stream.Stream<T> getDefinedForName(String)
Replies all the scopes that are known in the working memory and associated to the given knowledge name.
abstract java.util.List<E> getDefinedListForName(String)
Replies all the scopes that are known in the working memory and associated to the given knowledge name.
abstract java.lang.Iterable<T> getDefinedNameList
Replies all the defined names stored in the working memory.
abstract java.util.stream.Stream<T> getDefinedNames
Replies all the defined names stored in the working memory.
abstract java.lang.Object getKnowledge(ScopedDataName)
Replies the knowledge value that is identified by the given id.
abstract T getKnowledge(ScopedDataName,Class<T>)
Replies the data value that is identified by the given id.
abstract long getMemorySize
Replies the number of knowledges that are stored in the working memory.
abstract java.lang.Object getWorkingMemoryLock
Replies a resource that enables to have synchronized access to the working memory.
abstract boolean isDefined(ScopedDataName)
Replies if the given knowledge corresponds to a knowledge that is stored in the working memory.
abstract boolean isMemoryEmpty
Replies if the working memory is empty or not.
abstract boolean isNullAllowedInMemory
Replies if the null value is allowed to be associated to a stored knowledge in the working memory.
abstract java.lang.Object removeKnowledge(ScopedDataName)
Remove the knowledge from the working memory.
abstract void removeNullValuedKnowledges
Remove from the working memory any knowledge that is associated to a null value.
abstract java.lang.Object setKnowledge(ScopedDataName,Object)
Save the knowledge value in the working memory.
abstract void setKnowledgeIfAbsent(ScopedDataName,Object)
Save the knowledge value in the working memory if this memory does not already contain a value for this knowledge.
abstract java.lang.Object setKnowledgeIfPresent(ScopedDataName,Object)
Save the knowledge value in the working memory if this memory already contains a value for this knowledge.
abstract void setNullAllowedInMemory(boolean)
Change the flag indicating if the null value is allowed to be associated to a stored knowledge in the working memory.
Property Details
definedNameList
val definedNameList : java.lang.Iterable<T>
Replies all the defined names stored in the working memory.

This property is an alias for the action: getDefinedNameList

Returns:
the stored knowledge names in an iterable object.
definedNames
val definedNames : java.util.stream.Stream<T>
Replies all the defined names stored in the working memory.

CAUTION: The replied stream must be manually synchronized by the caller of this function.

This property is an alias for the action: getDefinedNames

Returns:
the stored knowledge names in a stream.
memorySize
val memorySize : long
Replies the number of knowledges that are stored in the working memory.

This property is an alias for the action: getMemorySize

Returns:
the number of knowledges.
workingMemoryLock
val workingMemoryLock : java.lang.Object
Replies a resource that enables to have synchronized access to the working memory. This resource could be used in a synchronized block of code:

 synchronized(workingMemory.workingMemoryLock) {
    ...
 }
 

This property is an alias for the action: getWorkingMemoryLock

Returns:
the synchronization resource.
Action Details
clearMemory
def clearMemory
Remove all knowledge from the working memory.
getDefinedForName(String)
def getDefinedForName(String) : java.util.stream.Stream<T>
Replies all the scopes that are known in the working memory and associated to the given knowledge name. Since multiple knowledge may have the same name, the scopes of the knowledges are used to make them unique in the working memory. This function replies all the knowledges with the same name that are stored in the working memory whatever their scopes.

CAUTION: The replied stream must be manually synchronized by the caller of this function.
Parameters:
name - the base name of the knowledge to search for.
Returns:
the scopes of the knowledges with the given name in a stream.
getDefinedListForName(String)
def getDefinedListForName(String) : java.util.List<E>
Replies all the scopes that are known in the working memory and associated to the given knowledge name. Since multiple knowledge may have the same name, the scopes of the knowledges are used to make them unique in the working memory. This function replies all the knowledges with the same name that are stored in the working memory whatever their scopes.
Parameters:
name - the base name of the knowledge to search for.
Returns:
the scopes of the knowledges with the given name in a list.
getDefinedNameList
def getDefinedNameList : java.lang.Iterable<T>
Replies all the defined names stored in the working memory.
Returns:
the stored knowledge names in an iterable object.
getDefinedNames
def getDefinedNames : java.util.stream.Stream<T>
Replies all the defined names stored in the working memory.

CAUTION: The replied stream must be manually synchronized by the caller of this function.
Returns:
the stored knowledge names in a stream.
getKnowledge(ScopedDataName)
def getKnowledge(ScopedDataName) : java.lang.Object

throws KnowledgeMissingException

Replies the knowledge value that is identified by the given id.
Parameters:
id - the identifier of the knowledge to be extracted from the local state.
Returns:
the knowledge value.
Throws exception:
See:
getKnowledge(ScopedDataName,Class<T>)
getKnowledge(ScopedDataName,Class<T>)
def getKnowledge(ScopedDataName,Class<T>) : T

with T

throws KnowledgeMissingException

Replies the data value that is identified by the given id.
Parameters:
<T> - the expected type of the data.
id - the identifier of the knowledge to be extracted from the local state.
type - the expected type of the data. If this type is not specified, the function replies the value as-is. Otherwise, if the value is not compatible with the given type, a ClassCastException is thrown.
Returns:
the knowledge value.
Throws exception:
See:
getKnowledge(ScopedDataName)
getMemorySize
def getMemorySize : long
Replies the number of knowledges that are stored in the working memory.
Returns:
the number of knowledges.
getWorkingMemoryLock
def getWorkingMemoryLock : java.lang.Object
Replies a resource that enables to have synchronized access to the working memory. This resource could be used in a synchronized block of code:

 synchronized(workingMemory.workingMemoryLock) {
    ...
 }
 
Returns:
the synchronization resource.
isDefined(ScopedDataName)
def isDefined(ScopedDataName) : boolean
Replies if the given knowledge corresponds to a knowledge that is stored in the working memory.

Definition of a knowledge is not related to its value. Therefore, if the value of the stored knowledge is equal to null, the knowledge is defined with a null value.
Parameters:
id - the name to search for.
Returns:
true if a knowledge is stored in the working memory. Otherwise false .
isMemoryEmpty
def isMemoryEmpty : boolean
Replies if the working memory is empty or not. The working memory is empty if there is no stored knowledge inside.
Returns:
true if the working memory is empty.
isNullAllowedInMemory
def isNullAllowedInMemory : boolean
Replies if the null value is allowed to be associated to a stored knowledge in the working memory.

If null value is not allowed in the memory, then each time a null value is put in the memory for a knowledge, this knowledge is removed from the memory. In the case the null value is allowed in the memory, then it is associated to the knowledge.

CAUTION: the support of the null value also depends on the concrete implementation of the working memory. Please refer to the documentation of the working memory's implementation for further details.
Returns:
true if null value is allowed in working memory.
removeKnowledge(ScopedDataName)
def removeKnowledge(ScopedDataName) : java.lang.Object
Remove the knowledge from the working memory.
Parameters:
id - the name to search for.
Returns:
the value that was stored in the working memory.
removeNullValuedKnowledges
def removeNullValuedKnowledges
Remove from the working memory any knowledge that is associated to a null value.
setKnowledge(ScopedDataName,Object)
def setKnowledge(ScopedDataName,Object) : java.lang.Object
Save the knowledge value in the working memory. If a value was already stored in the working memory for this knowledge, then the new value provided as argument will replace the previously stored value.
Parameters:
id - the identifier of the knowledge to be saved in the working memory.
value - the new value of the knowledge.
Returns:
previously stored knowledge value
See:
setKnowledgeIfAbsent(ScopedDataName,Object) , setKnowledgeIfPresent(ScopedDataName,Object)
setKnowledgeIfAbsent(ScopedDataName,Object)
def setKnowledgeIfAbsent(ScopedDataName,Object)
Save the knowledge value in the working memory if this memory does not already contain a value for this knowledge. If the memory contain the given knowledge, this function has no effect.
Parameters:
id - the identifier of the knowledge to be saved in the local state.
value - the new value of the knowledge.
See:
setKnowledge(ScopedDataName,Object) , setKnowledgeIfPresent(ScopedDataName,Object)
setKnowledgeIfPresent(ScopedDataName,Object)
def setKnowledgeIfPresent(ScopedDataName,Object) : java.lang.Object
Save the knowledge value in the working memory if this memory already contains a value for this knowledge. If the memory does not contain the given knowledge, this function has no effect.
Parameters:
id - the identifier of the knowledge to be saved in the local state.
value - the new value of the knowledge.
Returns:
previously stored knowledge value
See:
setKnowledge(ScopedDataName,Object) , setKnowledgeIfAbsent(ScopedDataName,Object)
setNullAllowedInMemory(boolean)
def setNullAllowedInMemory(boolean)
Change the flag indicating if the null value is allowed to be associated to a stored knowledge in the working memory.

If null value is not allowed in the memory, then each time a null value is put in the memory for a knowledge, this knowledge is removed from the memory. In the case the null value is allowed in the memory, then it is associated to the knowledge.

When this function is invoked with false as argument, the content of the working memory is not changed. Therefore, the knowledges that are already stored in the agent memory and associated with a null value are kept in the memory storage. See removeNullValuedKnowledges() for removing null valued knowledges from the working memory.

CAUTION: the support of the null value also depends on the concrete implementation of the working memory. Please refer to the documentation of the working memory's implementation for further details.
Parameters:
enable - is true if null value is allowed in working memory; Otherwise, null value is not allowed.