DialogStateManager Class
- java.
lang. Object - com.
microsoft. bot. dialogs. memory. DialogStateManager
- com.
Implements
public class DialogStateManager
implements java.util.Map<java.lang.String,java.lang.Object>
The DialogStateManager manages memory scopes and pathresolvers MemoryScopes are named root level Objects, which can exist either in the dialogcontext or off of turn state PathResolvers allow for shortcut behavior for mapping things like $foo to dialog.foo.
Constructor Summary
| Constructor | Description |
|---|---|
| DialogStateManager(DialogContext dc) |
Initializes a new instance of the DialogStateManager class. |
| DialogStateManager(DialogContext dc, DialogStateManagerConfiguration configuration) |
Initializes a new instance of the DialogStateManager class. |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
| T |
<T>getValue(String pathExpression, T defaultValue, Class<T> clsType)
Get the value from memory using path expression (NOTE: This always returns clone of value). |
|
Result |
<TypeT>tryGetValue(String path, Class<TypeT> clsType)
Get the value from memory using path expression (NOTE: This always returns clone of value). |
| void |
add(String key, Object value)
Adds an element to the dialog state manager. |
| void |
add(AbstractMap.SimpleEntry<String,Object> item)
Adds an item to the dialog state manager. |
| java.lang.Boolean |
anyPathChanged(int counter, Iterable<String> paths)
Check to see if any path has changed since watermark. |
| void |
clear()
Removes all items from the dialog state manager. |
| java.lang.Boolean |
contains(AbstractMap.SimpleEntry<String,Object> item)
Determines whether the dialog state manager contains a specific value. |
| final boolean | containsKey(Object key) |
| java.lang.Boolean |
containsKey(String key)
Determines whether the dialog state manager contains an element with the specified key. |
| final boolean | containsValue(Object value) |
| void |
copyTo(AbstractMap.SimpleEntry<String,Object>[] array, int arrayIndex)
Copies the elements of the dialog state manager to an array starting at a particular index. |
| java.util.concurrent.CompletableFuture<java.lang.Void> |
deleteScopesMemory(String name)
Delete the memory for a scope. |
| final java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> | entrySet() |
| final java.lang.Object | get(Object key) |
| java.lang.Boolean |
getBoolValue(String pathExpression, Boolean defaultValue)
Get a boolean value from memory using a path expression. |
|
Dialog |
getConfiguration()
Sets the configured path resolvers and memory scopes for the dialog. |
| java.lang.Object |
getElement(String key)
Gets the elements with the specified key. |
| java.lang.Iterable<java.util.AbstractMap.SimpleEntry<java.lang.String,java.lang.Object>> |
getEnumerator()
Returns an Iterator that iterates through the collection. |
| int |
getIntValue(String pathExpression, int defaultValue)
Get a int value from memory using a path expression. |
| java.lang.Boolean |
getIsReadOnly()
Gets a value indicating whether the dialog state manager is read-only. |
|
Memory |
getMemoryScope(String name)
Get Memory |
| com.fasterxml.jackson.databind.JsonNode |
getMemorySnapshot()
Gets all memoryscopes suitable for logging. |
| java.lang.String |
getStringValue(String pathExpression, String defaultValue)
Get a String value from memory using a path expression. |
| final boolean | isEmpty() |
| final java.util.Set<java.lang.String> | keySet() |
| java.util.concurrent.CompletableFuture<java.lang.Void> |
loadAllScopes()
Load all of the scopes. |
| final java.lang.Object | put(String key, Object value) |
| final void | putAll(Map<? extends String,? extends Object> m) |
| final java.lang.Object | remove(Object key) |
| java.lang.Boolean |
remove(String key)
Removes the element with the specified key from the dialog state manager. |
| boolean |
remove(AbstractMap.SimpleEntry<String,Object> item)
Removes the first occurrence of a specific Object from the dialog state manager. |
| void |
removeValue(String path)
Remove property from memory. |
|
Memory |
resolveMemoryScope(String path, StringBuilder remainingPath)
Resolve |
| java.util.concurrent.CompletableFuture<java.lang.Void> |
saveAllChanges()
Save all changes for all scopes. |
| void |
setConfiguration(DialogStateManagerConfiguration withDialogStateManagerConfiguration)
Sets the configured path resolvers and memory scopes for the dialog. |
| void |
setElement(String key, Object element)
Sets the elements with the specified key. |
| void |
setValue(String path, Object value)
Set memory to value. |
| final int | size() |
| java.util.List<java.lang.String> |
trackPaths(Iterable<String> paths)
Track when specific paths are changed. |
| java.lang.String |
transformPath(String path)
Transform the path using the registered Path |
|
Result |
tryGetValue(String key, Object value)
Gets the value associated with the specified key. |
| final java.util.Collection<java.lang.Object> | values() |
| java.lang.String |
version()
Version help caller to identify the updates and decide cache or not. |
Methods inherited from java.lang.Object
Constructor Details
DialogStateManager
public DialogStateManager(DialogContext dc)
Initializes a new instance of the DialogStateManager class.
Parameters:
DialogStateManager
public DialogStateManager(DialogContext dc, DialogStateManagerConfiguration configuration)
Initializes a new instance of the DialogStateManager class.
Parameters:
Method Details
<T>getValue
public T
Get the value from memory using path expression (NOTE: This always returns clone of value).
Parameters:
Returns:
<TypeT>tryGetValue
public ResultPair
Get the value from memory using path expression (NOTE: This always returns clone of value).
Parameters:
Returns:
add
public void add(String key, Object value)
Adds an element to the dialog state manager.
Parameters:
add
public void add(AbstractMap.SimpleEntry
Adds an item to the dialog state manager.
Parameters:
anyPathChanged
public Boolean anyPathChanged(int counter, Iterable
Check to see if any path has changed since watermark.
Parameters:
Returns:
clear
public void clear()
Removes all items from the dialog state manager.
contains
public Boolean contains(AbstractMap.SimpleEntry
Determines whether the dialog state manager contains a specific value.
Parameters:
Returns:
containsKey
public final boolean containsKey(Object key)
Parameters:
containsKey
public Boolean containsKey(String key)
Determines whether the dialog state manager contains an element with the specified key.
Parameters:
Returns:
containsValue
public final boolean containsValue(Object value)
Parameters:
copyTo
public void copyTo(AbstractMap.SimpleEntry
Copies the elements of the dialog state manager to an array starting at a particular index.
Parameters:
deleteScopesMemory
public CompletableFuture
Delete the memory for a scope.
Parameters:
Returns:
entrySet
public final Set
get
public final Object get(Object key)
Parameters:
getBoolValue
public Boolean getBoolValue(String pathExpression, Boolean defaultValue)
Get a boolean value from memory using a path expression.
Parameters:
Returns:
getConfiguration
public DialogStateManagerConfiguration getConfiguration()
Sets the configured path resolvers and memory scopes for the dialog.
Returns:
getElement
public Object getElement(String key)
Gets the elements with the specified key.
Parameters:
Returns:
getEnumerator
public Iterable
Returns an Iterator that iterates through the collection.
Returns:
getIntValue
public int getIntValue(String pathExpression, int defaultValue)
Get a int value from memory using a path expression.
Parameters:
Returns:
getIsReadOnly
public Boolean getIsReadOnly()
Gets a value indicating whether the dialog state manager is read-only.
Returns:
getMemoryScope
public MemoryScope getMemoryScope(String name)
Get MemoryScope by name.
Parameters:
Returns:
getMemorySnapshot
public JsonNode getMemorySnapshot()
Gets all memoryscopes suitable for logging.
Returns:
getStringValue
public String getStringValue(String pathExpression, String defaultValue)
Get a String value from memory using a path expression.
Parameters:
Returns:
isEmpty
public final boolean isEmpty()
keySet
public final Set
loadAllScopes
public CompletableFuture
Load all of the scopes.
Returns:
put
public final Object put(String key, Object value)
Parameters:
putAll
public final void putAll(Map m)
Parameters:
remove
public final Object remove(Object key)
Parameters:
remove
public Boolean remove(String key)
Removes the element with the specified key from the dialog state manager.
Parameters:
Returns:
remove
public boolean remove(AbstractMap.SimpleEntry
Removes the first occurrence of a specific Object from the dialog state manager.
Parameters:
Returns:
removeValue
public void removeValue(String path)
Remove property from memory.
Parameters:
resolveMemoryScope
public MemoryScope resolveMemoryScope(String path, StringBuilder remainingPath)
ResolveMemoryScope will find the MemoryScope for and return the remaining path.
Parameters:
Returns:
saveAllChanges
public CompletableFuture
Save all changes for all scopes.
Returns:
setConfiguration
public void setConfiguration(DialogStateManagerConfiguration withDialogStateManagerConfiguration)
Sets the configured path resolvers and memory scopes for the dialog.
Parameters:
setElement
public void setElement(String key, Object element)
Sets the elements with the specified key.
Parameters:
setValue
public void setValue(String path, Object value)
Set memory to value.
Parameters:
size
public final int size()
trackPaths
public List
Track when specific paths are changed.
Parameters:
Returns:
transformPath
public String transformPath(String path)
Transform the path using the registered PathTransformers.
Parameters:
Returns:
tryGetValue
public ResultPair