Package nl.rrd.wool.model
Class WoolReply
- java.lang.Object
-
- nl.rrd.wool.model.WoolReply
-
public class WoolReply extends Object
A reply option within aWoolNodeBody. A reply always has a pointer to the next node when the reply is chosen. This might be a pointer to the end node. The reply usually has a statement that is shown in the UI, but a node may have at most one reply without a statement, which is known as an auto-forward reply.The statement may contain a
WoolInputCommand(seeWoolNodeBody).The reply may also have commands that should be performed when the reply is chosen. This can be:
-
-
Constructor Summary
Constructors Constructor Description WoolReply(int replyId, WoolNodePointer nodePointer)Constructs an auto-forward reply without a statement.WoolReply(int replyId, WoolNodeBody statement, WoolNodePointer nodePointer)Constructs a new reply.
-
Method Summary
Modifier and Type Method Description voidaddCommand(WoolCommand command)Adds a command that should be executed when this reply is chosen.WoolReplyexecute(Map<String,Object> variables)Executes the statement in this reply with respect to the specified variable map.List<WoolCommand>getCommands()Returns the commands that should be executed when this reply is chosen.WoolNodePointergetNodePointer()Returns the next node when this reply is chosen.voidgetReadVariableNames(Set<String> varNames)Retrieves all variable names that are read in this reply and adds them to the specified set.intgetReplyId()Returns the reply ID.WoolNodeBodygetStatement()Returns the statement.voidgetWriteVariableNames(Set<String> varNames)Retrieves all variable names that are written in this reply and adds them to the specified set.voidsetCommands(List<WoolCommand> commands)Sets the commands that should be executed when this reply is chosen.voidsetNodePointer(WoolNodePointer nodePointer)Sets the next node when this reply is chosen.voidsetReplyId(int replyId)Sets the reply ID.voidsetStatement(WoolNodeBody statement)Sets the statement.StringtoString()
-
-
-
Constructor Detail
-
WoolReply
public WoolReply(int replyId, WoolNodeBody statement, WoolNodePointer nodePointer)Constructs a new reply.- Parameters:
replyId- the reply IDstatement- the statement or null (auto-forward reply)nodePointer- the next node when the reply is chosen
-
WoolReply
public WoolReply(int replyId, WoolNodePointer nodePointer)Constructs an auto-forward reply without a statement.- Parameters:
replyId- the reply IDnodePointer- the next node when the reply is chosen
-
-
Method Detail
-
getReplyId
public int getReplyId()
Returns the reply ID. The ID is unique within a node.- Returns:
- the reply ID
-
setReplyId
public void setReplyId(int replyId)
Sets the reply ID. The ID is unique within a node.- Parameters:
replyId- the reply ID
-
getStatement
public WoolNodeBody getStatement()
Returns the statement. If this reply is an auto-forward reply, then this method returns null.- Returns:
- the statement or null
-
setStatement
public void setStatement(WoolNodeBody statement)
Sets the statement. If this reply is an auto-forward reply, then the statement can be null.- Parameters:
statement- the statement or null
-
getNodePointer
public WoolNodePointer getNodePointer()
Returns the next node when this reply is chosen. This might be the end node.- Returns:
- the next node when this reply is chosen
-
setNodePointer
public void setNodePointer(WoolNodePointer nodePointer)
Sets the next node when this reply is chosen.- Parameters:
nodePointer- the next node when this reply is chosen
-
getCommands
public List<WoolCommand> getCommands()
Returns the commands that should be executed when this reply is chosen.- Returns:
- the commands that should be executed when this reply is chosen
-
setCommands
public void setCommands(List<WoolCommand> commands)
Sets the commands that should be executed when this reply is chosen.- Parameters:
commands- the commands that should be executed when this reply is chosen
-
addCommand
public void addCommand(WoolCommand command)
Adds a command that should be executed when this reply is chosen.- Parameters:
command- the command that should be executed when this reply is chosen
-
getReadVariableNames
public void getReadVariableNames(Set<String> varNames)
Retrieves all variable names that are read in this reply and adds them to the specified set.- Parameters:
varNames- the set to which the variable names are added
-
getWriteVariableNames
public void getWriteVariableNames(Set<String> varNames)
Retrieves all variable names that are written in this reply and adds them to the specified set.- Parameters:
varNames- the set to which the variable names are added
-
execute
public WoolReply execute(Map<String,Object> variables) throws EvaluationException
Executes the statement in this reply with respect to the specified variable map. It executes commands and resolves variables, so that only content that should be sent to the client, remains in the resulting reply statement. This content can be text or client commands, with all variables resolved.- Parameters:
variables- the variable map- Returns:
- the processed reply
- Throws:
EvaluationException- if an expression cannot be evaluated
-
-