Package nl.rrd.wool.model.command
Class WoolIfCommand
- java.lang.Object
-
- nl.rrd.wool.model.command.WoolCommand
-
- nl.rrd.wool.model.command.WoolExpressionCommand
-
- nl.rrd.wool.model.command.WoolIfCommand
-
- All Implemented Interfaces:
Cloneable
public class WoolIfCommand extends WoolExpressionCommand
This class models the <<if ...>> command in Wool. It can be part of aWoolNodeBody(not inside a reply).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWoolIfCommand.ClauseThis class models a clause of an if statement.-
Nested classes/interfaces inherited from class nl.rrd.wool.model.command.WoolExpressionCommand
WoolExpressionCommand.ParseContentResult, WoolExpressionCommand.ReadContentResult
-
-
Constructor Summary
Constructors Constructor Description WoolIfCommand()WoolIfCommand(WoolIfCommand other)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddIfClause(WoolIfCommand.Clause ifClause)Adds an if clause.WoolIfCommandclone()Returns a deep copy of this command.voidexecuteBodyCommand(Map<String,Object> variables, WoolNodeBody processedBody)This method is called if this command occurs in a statement body.WoolReplyfindReplyById(int replyId)Tries to find a reply with the specified ID within this command.WoolNodeBodygetElseClause()Returns the else clause.List<WoolIfCommand.Clause>getIfClauses()Returns the if clauses.voidgetNodePointers(Set<WoolNodePointer> pointers)Retrieves all node pointers that occur in this command and adds them to the specified list.voidgetReadVariableNames(Set<String> varNames)Retrieves all variable names that are read in this command and adds them to the specified set.voidgetWriteVariableNames(Set<String> varNames)Retrieves all variable names that are written in this command and adds them to the specified set.static WoolIfCommandparse(WoolBodyToken cmdStartToken, CurrentIterator<WoolBodyToken> tokens, WoolNodeState nodeState)voidsetElseClause(WoolNodeBody elseClause)Sets the else clause.voidsetIfClauses(List<WoolIfCommand.Clause> ifClauses)Sets the if clauses.StringtoString()-
Methods inherited from class nl.rrd.wool.model.command.WoolExpressionCommand
parseCommandContent, parseCommandContentExpression, parseCommandContentName, readCommandContent
-
-
-
-
Constructor Detail
-
WoolIfCommand
public WoolIfCommand()
-
WoolIfCommand
public WoolIfCommand(WoolIfCommand other)
-
-
Method Detail
-
getIfClauses
public List<WoolIfCommand.Clause> getIfClauses()
Returns the if clauses. They should be processed from first to last. There should be at least one clause. That is the "if" clause. Any subsequent clauses are "elseif" clauses.- Returns:
- the if clauses
-
setIfClauses
public void setIfClauses(List<WoolIfCommand.Clause> ifClauses)
Sets the if clauses. They should be processed from first to last. There should be at least one clause. That is the "if" clause. Any subsequent clauses are "elseif" clauses.- Parameters:
ifClauses- the if clauses
-
addIfClause
public void addIfClause(WoolIfCommand.Clause ifClause)
Adds an if clause. The clauses should be processed from first to last. There should be at least one clause.That is the "if" clause. Any subsequent clauses are "elseif" clauses.- Parameters:
ifClause- the if clause
-
getElseClause
public WoolNodeBody getElseClause()
Returns the else clause. If there is no else clause, then this method returns null (default).- Returns:
- the else clause or null
-
setElseClause
public void setElseClause(WoolNodeBody elseClause)
Sets the else clause. If there is no else clause, this can be set to null (default).- Parameters:
elseClause- the else clause or null
-
findReplyById
public WoolReply findReplyById(int replyId)
Description copied from class:WoolCommandTries to find a reply with the specified ID within this command. If no such reply is found, this method returns null.- Specified by:
findReplyByIdin classWoolCommand- Parameters:
replyId- the reply ID- Returns:
- the reply or null
-
getReadVariableNames
public void getReadVariableNames(Set<String> varNames)
Description copied from class:WoolCommandRetrieves all variable names that are read in this command and adds them to the specified set.- Specified by:
getReadVariableNamesin classWoolCommand- Parameters:
varNames- the set to which the variable names are added
-
getWriteVariableNames
public void getWriteVariableNames(Set<String> varNames)
Description copied from class:WoolCommandRetrieves all variable names that are written in this command and adds them to the specified set.- Specified by:
getWriteVariableNamesin classWoolCommand- Parameters:
varNames- the set to which the variable names are added
-
getNodePointers
public void getNodePointers(Set<WoolNodePointer> pointers)
Description copied from class:WoolCommandRetrieves all node pointers that occur in this command and adds them to the specified list.- Specified by:
getNodePointersin classWoolCommand- Parameters:
pointers- the list to which the node pointers are added
-
executeBodyCommand
public void executeBodyCommand(Map<String,Object> variables, WoolNodeBody processedBody) throws EvaluationException
Description copied from class:WoolCommandThis method is called if this command occurs in a statement body. It executes the command with respect to the specified variable map. Any body content that should be sent to the client, is added to "processedBody". This content can be text or client commands, with all variables resolved.- Specified by:
executeBodyCommandin classWoolCommand- Parameters:
variables- the variable mapprocessedBody- the processed body- Throws:
EvaluationException- if an expression cannot be evaluated
-
parse
public static WoolIfCommand parse(WoolBodyToken cmdStartToken, CurrentIterator<WoolBodyToken> tokens, WoolNodeState nodeState) throws LineNumberParseException
- Throws:
LineNumberParseException
-
clone
public WoolIfCommand clone()
Description copied from class:WoolCommandReturns a deep copy of this command.- Specified by:
clonein classWoolCommand- Returns:
- a deep copy of this command
-
-