Package nl.rrd.wool.execution
Class ActiveWoolDialogue
- java.lang.Object
-
- nl.rrd.wool.execution.ActiveWoolDialogue
-
public class ActiveWoolDialogue extends Object
AnActiveWoolDialogueis a wrapper around aWoolDialogue, which contains a static definition of a dialogue (referred to as thedialogueDefinition). TheActiveWoolDialoguealso contains utility functions to keep track of the state during "execution" of the dialogue.
-
-
Constructor Summary
Constructors Constructor Description ActiveWoolDialogue(WoolDialogueDescription dialogueDescription, WoolDialogue dialogueDefinition)
-
Method Summary
Modifier and Type Method Description WoolNodegetCurrentNode()WoolDialoguegetDialogueDefinition()WoolDialogueDescriptiongetDialogueDescription()StringgetDialogueName()Returns the name of thisActiveWoolDialogueas defined in the associatedWoolDialogue.DialogueStategetDialogueState()StringgetUserStatementFromReplyId(int replyId)The user's client returned the givenreplyId- what was the statement that was uttered by the user?WoolVariableStoregetWoolVariableStore()Returns theWoolVariableStoreassociated with thisActiveWoolDialogue.WoolNodePointerprocessReplyAndGetNodePointer(int replyId)Retrieves the pointer to the next node based on the provided reply id.WoolNodeprogressDialogue(WoolNodePointerInternal nodePointer)Takes the next node pointer from the selected reply and determines the next node.voidsetCurrentNode(WoolNode currentNode)voidsetDialogueState(DialogueState dialogueState)voidsetWoolVariableStore(WoolVariableStore woolVariableStore)Sets theWoolVariableStoreused to store/retrieve parameters for thisActiveWoolDialogue.WoolNodestartDialogue()"Starts" thisActiveWoolDialogue, returning the start node and updating its internal state.WoolNodestartDialogue(String nodeId)"Starts" thisActiveWoolDialogueat the providedWoolNode, returning that node and updating the dialogue's internal state.voidstoreReplyInput(Map<String,?> variables)
-
-
-
Constructor Detail
-
ActiveWoolDialogue
public ActiveWoolDialogue(WoolDialogueDescription dialogueDescription, WoolDialogue dialogueDefinition)
-
-
Method Detail
-
getDialogueDescription
public WoolDialogueDescription getDialogueDescription()
-
getDialogueDefinition
public WoolDialogue getDialogueDefinition()
-
getCurrentNode
public WoolNode getCurrentNode()
-
getDialogueState
public DialogueState getDialogueState()
-
getWoolVariableStore
public WoolVariableStore getWoolVariableStore()
Returns theWoolVariableStoreassociated with thisActiveWoolDialogue.- Returns:
- the
WoolVariableStoreassociated with thisActiveWoolDialogue.
-
setCurrentNode
public void setCurrentNode(WoolNode currentNode)
-
setDialogueState
public void setDialogueState(DialogueState dialogueState)
-
setWoolVariableStore
public void setWoolVariableStore(WoolVariableStore woolVariableStore)
Sets theWoolVariableStoreused to store/retrieve parameters for thisActiveWoolDialogue.- Parameters:
woolVariableStore- theWoolVariableStoreused to store/retrieve parameters for thisActiveWoolDialogue.
-
getDialogueName
public String getDialogueName()
Returns the name of thisActiveWoolDialogueas defined in the associatedWoolDialogue.- Returns:
- the name of this
ActiveWoolDialogueas defined in the associatedWoolDialogue.
-
startDialogue
public WoolNode startDialogue() throws WoolException, EvaluationException
"Starts" thisActiveWoolDialogue, returning the start node and updating its internal state.- Returns:
- the initial
WoolNode. - Throws:
WoolException- if the request is invalidEvaluationException- if an expression cannot be evaluated
-
startDialogue
public WoolNode startDialogue(String nodeId) throws WoolException, EvaluationException
"Starts" thisActiveWoolDialogueat the providedWoolNode, returning that node and updating the dialogue's internal state. If you set the nodeId to null, it will return the start node.- Parameters:
nodeId- the node ID or null- Returns:
- the
WoolNode - Throws:
WoolException- if the request is invalidEvaluationException- if an expression cannot be evaluated
-
processReplyAndGetNodePointer
public WoolNodePointer processReplyAndGetNodePointer(int replyId) throws EvaluationException
Retrieves the pointer to the next node based on the provided reply id. This might be a pointer to the end node. This method also performs any "set" actions associated with the reply.- Parameters:
replyId- the reply ID- Returns:
- WoolNodePointer the pointer to the next node
- Throws:
EvaluationException- if an expression cannot be evaluated
-
progressDialogue
public WoolNode progressDialogue(WoolNodePointerInternal nodePointer) throws EvaluationException
Takes the next node pointer from the selected reply and determines the next node. The pointer might point to the end note, which means that there is no next node. If there is no next node, or the next node has no reply options, then the dialogue is considered finished.If there is a next node, then it returns the executed version of that next
WoolNodewhich results from a call to theexecuteWoolNode(WoolNode)function.- Parameters:
nodePointer- the next node pointer from the selected reply- Returns:
- the next
WoolNodethat follows on the selected reply or null - Throws:
EvaluationException- if an expression cannot be evaluated
-
getUserStatementFromReplyId
public String getUserStatementFromReplyId(int replyId) throws WoolException
The user's client returned the givenreplyId- what was the statement that was uttered by the user?- Parameters:
replyId- the reply ID- Returns:
- the statement
- Throws:
WoolException- if no reply with the specified ID is found
-
-